OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/shelf/app_list_button.h" | 8 #include "ash/shelf/app_list_button.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shelf/wm_shelf.h" | 10 #include "ash/shelf/wm_shelf.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "ui/app_list/presenter/app_list.h" | 16 #include "ui/app_list/presenter/app_list.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/events/test/event_generator.h" | 18 #include "ui/events/test/event_generator.h" |
19 | 19 |
20 using AppListTest = InProcessBrowserTest; | 20 using AppListTest = InProcessBrowserTest; |
21 | 21 |
22 // An integration test to toggle the app list by pressing the shelf button. | 22 // An integration test to toggle the app list by pressing the shelf button. |
23 IN_PROC_BROWSER_TEST_F(AppListTest, PressAppListButtonToShowAndDismiss) { | 23 IN_PROC_BROWSER_TEST_F(AppListTest, PressAppListButtonToShowAndDismiss) { |
24 ash::WmShelf* shelf = | 24 ash::WmShelf* shelf = ash::WmShelf::ForWindow(ash::wm::GetActiveWindow()); |
25 ash::WmShelf::ForWindow(ash::WmWindow::Get(ash::wm::GetActiveWindow())); | |
26 ash::ShelfWidget* shelf_widget = shelf->shelf_widget(); | 25 ash::ShelfWidget* shelf_widget = shelf->shelf_widget(); |
27 ash::AppListButton* app_list_button = shelf_widget->GetAppListButton(); | 26 ash::AppListButton* app_list_button = shelf_widget->GetAppListButton(); |
28 | 27 |
29 aura::Window* root_window = ash::wm::GetActiveWindow()->GetRootWindow(); | 28 aura::Window* root_window = ash::wm::GetActiveWindow()->GetRootWindow(); |
30 aura::Window* app_list_container = | 29 aura::Window* app_list_container = |
31 root_window->GetChildById(ash::kShellWindowId_AppListContainer); | 30 root_window->GetChildById(ash::kShellWindowId_AppListContainer); |
32 ui::test::EventGenerator generator(shelf_widget->GetNativeWindow()); | 31 ui::test::EventGenerator generator(shelf_widget->GetNativeWindow()); |
33 | 32 |
34 // Click the app list button to show the app list. | 33 // Click the app list button to show the app list. |
35 ash::Shell* shell = ash::Shell::Get(); | 34 ash::Shell* shell = ash::Shell::Get(); |
36 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); | 35 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); |
37 EXPECT_EQ(0u, app_list_container->children().size()); | 36 EXPECT_EQ(0u, app_list_container->children().size()); |
38 EXPECT_FALSE(app_list_button->is_showing_app_list()); | 37 EXPECT_FALSE(app_list_button->is_showing_app_list()); |
39 generator.set_current_location( | 38 generator.set_current_location( |
40 app_list_button->GetBoundsInScreen().CenterPoint()); | 39 app_list_button->GetBoundsInScreen().CenterPoint()); |
41 generator.ClickLeftButton(); | 40 generator.ClickLeftButton(); |
42 base::RunLoop().RunUntilIdle(); | 41 base::RunLoop().RunUntilIdle(); |
43 EXPECT_TRUE(shell->app_list()->GetTargetVisibility()); | 42 EXPECT_TRUE(shell->app_list()->GetTargetVisibility()); |
44 EXPECT_EQ(1u, app_list_container->children().size()); | 43 EXPECT_EQ(1u, app_list_container->children().size()); |
45 EXPECT_TRUE(app_list_button->is_showing_app_list()); | 44 EXPECT_TRUE(app_list_button->is_showing_app_list()); |
46 | 45 |
47 // Click the button again to dismiss the app list; the window animates closed. | 46 // Click the button again to dismiss the app list; the window animates closed. |
48 generator.ClickLeftButton(); | 47 generator.ClickLeftButton(); |
49 base::RunLoop().RunUntilIdle(); | 48 base::RunLoop().RunUntilIdle(); |
50 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); | 49 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); |
51 EXPECT_EQ(1u, app_list_container->children().size()); | 50 EXPECT_EQ(1u, app_list_container->children().size()); |
52 EXPECT_FALSE(app_list_button->is_showing_app_list()); | 51 EXPECT_FALSE(app_list_button->is_showing_app_list()); |
53 } | 52 } |
OLD | NEW |