| // Copyright 2019 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "ash/app_list/app_list_controller_impl.h" |
| |
| #include "ash/app_list/home_launcher_gesture_handler.h" |
| #include "ash/app_list/views/app_list_main_view.h" |
| #include "ash/app_list/views/app_list_view.h" |
| #include "ash/app_list/views/contents_view.h" |
| #include "ash/app_list/views/expand_arrow_view.h" |
| #include "ash/shell.h" |
| #include "ash/test/ash_test_base.h" |
| #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| #include "ash/wm/window_state.h" |
| #include "ash/wm/window_util.h" |
| |
| namespace ash { |
| |
| namespace { |
| |
| bool IsTabletMode() { |
| return Shell::Get() |
| ->tablet_mode_controller() |
| ->IsTabletModeWindowManagerEnabled(); |
| } |
| |
| bool GetExpandArrowViewVisibility() { |
| return Shell::Get() |
| ->app_list_controller() |
| ->presenter() |
| ->GetView() |
| ->app_list_main_view() |
| ->contents_view() |
| ->expand_arrow_view() |
| ->visible(); |
| } |
| |
| } // namespace |
| |
| class AppListControllerImplTest : public AshTestBase { |
| public: |
| AppListControllerImplTest() = default; |
| ~AppListControllerImplTest() override = default; |
| |
| std::unique_ptr<aura::Window> CreateTestWindow() { |
| return AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400)); |
| } |
| |
| private: |
| DISALLOW_COPY_AND_ASSIGN(AppListControllerImplTest); |
| }; |
| |
| // Hide the expand arrow view in tablet mode when there is no activatable window |
| // (see https://crbug.com/923089). |
| TEST_F(AppListControllerImplTest, UpdateExpandArrowViewVisibility) { |
| // Turn on the tablet mode. |
| Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); |
| EXPECT_TRUE(IsTabletMode()); |
| |
| // No activatable windows. So hide the expand arrow view. |
| EXPECT_FALSE(GetExpandArrowViewVisibility()); |
| |
| std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| std::unique_ptr<aura::Window> w2(CreateTestWindow()); |
| |
| // Activate w1 then press home launcher button. Expand arrow view should show |
| // because w1 still exists. |
| wm::ActivateWindow(w1.get()); |
| Shell::Get() |
| ->app_list_controller() |
| ->home_launcher_gesture_handler() |
| ->ShowHomeLauncher(display::Screen::GetScreen()->GetPrimaryDisplay()); |
| EXPECT_EQ(mojom::WindowStateType::MINIMIZED, |
| wm::GetWindowState(w1.get())->GetStateType()); |
| EXPECT_TRUE(GetExpandArrowViewVisibility()); |
| |
| // Activate w2 then close w1. w2 still exists so expand arrow view shows. |
| wm::ActivateWindow(w2.get()); |
| w1.reset(); |
| EXPECT_TRUE(GetExpandArrowViewVisibility()); |
| |
| // No activatable windows. Hide the expand arrow view. |
| w2.reset(); |
| EXPECT_FALSE(GetExpandArrowViewVisibility()); |
| } |
| |
| } // namespace ash |