Chromium Code Reviews| 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/events/test/event_generator.h" | 18 #include "ui/events/test/event_generator.h" |
| 18 | 19 |
| 19 using AppListTest = InProcessBrowserTest; | 20 using AppListTest = InProcessBrowserTest; |
| 20 | 21 |
| 21 // 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. |
| 22 IN_PROC_BROWSER_TEST_F(AppListTest, PressAppListButtonToShowAndDismiss) { | 23 IN_PROC_BROWSER_TEST_F(AppListTest, PressAppListButtonToShowAndDismiss) { |
| 23 ash::WmShelf* shelf = | 24 ash::WmShelf* shelf = |
| 24 ash::WmShelf::ForWindow(ash::WmWindow::Get(ash::wm::GetActiveWindow())); | 25 ash::WmShelf::ForWindow(ash::WmWindow::Get(ash::wm::GetActiveWindow())); |
| 25 ash::ShelfWidget* shelf_widget = shelf->shelf_widget(); | 26 ash::ShelfWidget* shelf_widget = shelf->shelf_widget(); |
| 26 ash::AppListButton* app_list_button = shelf_widget->GetAppListButton(); | 27 ash::AppListButton* app_list_button = shelf_widget->GetAppListButton(); |
| 27 | 28 |
| 28 ash::WmWindow* root_window = | 29 aura::Window* root_window = ash::WmWindow::Get(ash::wm::GetActiveWindow()) |
|
msw
2017/04/12 22:12:50
nit: avoid WmWindow roundabout here?
sky
2017/04/12 22:35:04
Done.
| |
| 29 ash::WmWindow::Get(ash::wm::GetActiveWindow())->GetRootWindow(); | 30 ->GetRootWindow() |
| 30 ash::WmWindow* app_list_container = root_window->GetChildByShellWindowId( | 31 ->aura_window(); |
| 31 ash::kShellWindowId_AppListContainer); | 32 aura::Window* app_list_container = |
| 33 root_window->GetChildById(ash::kShellWindowId_AppListContainer); | |
| 32 ui::test::EventGenerator generator(shelf_widget->GetNativeWindow()); | 34 ui::test::EventGenerator generator(shelf_widget->GetNativeWindow()); |
| 33 | 35 |
| 34 // Click the app list button to show the app list. | 36 // Click the app list button to show the app list. |
| 35 ash::Shell* shell = ash::Shell::Get(); | 37 ash::Shell* shell = ash::Shell::Get(); |
| 36 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); | 38 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); |
| 37 EXPECT_EQ(0u, app_list_container->GetChildren().size()); | 39 EXPECT_EQ(0u, app_list_container->children().size()); |
| 38 EXPECT_FALSE(app_list_button->is_showing_app_list()); | 40 EXPECT_FALSE(app_list_button->is_showing_app_list()); |
| 39 generator.set_current_location( | 41 generator.set_current_location( |
| 40 app_list_button->GetBoundsInScreen().CenterPoint()); | 42 app_list_button->GetBoundsInScreen().CenterPoint()); |
| 41 generator.ClickLeftButton(); | 43 generator.ClickLeftButton(); |
| 42 base::RunLoop().RunUntilIdle(); | 44 base::RunLoop().RunUntilIdle(); |
| 43 EXPECT_TRUE(shell->app_list()->GetTargetVisibility()); | 45 EXPECT_TRUE(shell->app_list()->GetTargetVisibility()); |
| 44 EXPECT_EQ(1u, app_list_container->GetChildren().size()); | 46 EXPECT_EQ(1u, app_list_container->children().size()); |
| 45 EXPECT_TRUE(app_list_button->is_showing_app_list()); | 47 EXPECT_TRUE(app_list_button->is_showing_app_list()); |
| 46 | 48 |
| 47 // Click the button again to dismiss the app list; the window animates closed. | 49 // Click the button again to dismiss the app list; the window animates closed. |
| 48 generator.ClickLeftButton(); | 50 generator.ClickLeftButton(); |
| 49 base::RunLoop().RunUntilIdle(); | 51 base::RunLoop().RunUntilIdle(); |
| 50 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); | 52 EXPECT_FALSE(shell->app_list()->GetTargetVisibility()); |
| 51 EXPECT_EQ(1u, app_list_container->GetChildren().size()); | 53 EXPECT_EQ(1u, app_list_container->children().size()); |
| 52 EXPECT_FALSE(app_list_button->is_showing_app_list()); | 54 EXPECT_FALSE(app_list_button->is_showing_app_list()); |
| 53 } | 55 } |
| OLD | NEW |