OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "ash/test/test_shell_delegate.h" | 8 #include "ash/test/test_shell_delegate.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "ui/app_list/app_list_switches.h" | 12 #include "ui/app_list/app_list_switches.h" |
13 #include "ui/app_list/views/app_list_view.h" | 13 #include "ui/app_list/views/app_list_view.h" |
14 #include "ui/aura/test/event_generator.h" | |
15 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/events/test/event_generator.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const int kMinimalCenteredAppListMargin = 10; | 22 const int kMinimalCenteredAppListMargin = 10; |
23 | 23 |
24 } | 24 } |
25 | 25 |
26 // The parameter is true to test the centered app list, false for normal. | 26 // The parameter is true to test the centered app list, false for normal. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 79 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
80 } | 80 } |
81 | 81 |
82 // Tests that clicking outside the app-list bubble closes it. | 82 // Tests that clicking outside the app-list bubble closes it. |
83 TEST_P(AppListControllerTest, ClickOutsideBubbleClosesBubble) { | 83 TEST_P(AppListControllerTest, ClickOutsideBubbleClosesBubble) { |
84 Shell* shell = Shell::GetInstance(); | 84 Shell* shell = Shell::GetInstance(); |
85 shell->ToggleAppList(NULL); | 85 shell->ToggleAppList(NULL); |
86 | 86 |
87 aura::Window* app_window = shell->GetAppListWindow(); | 87 aura::Window* app_window = shell->GetAppListWindow(); |
88 ASSERT_TRUE(app_window); | 88 ASSERT_TRUE(app_window); |
89 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow(), | 89 ui::test::EventGenerator generator(shell->GetPrimaryRootWindow(), app_window); |
90 app_window); | |
91 // Click on the bubble itself. The bubble should remain visible. | 90 // Click on the bubble itself. The bubble should remain visible. |
92 generator.ClickLeftButton(); | 91 generator.ClickLeftButton(); |
93 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 92 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
94 | 93 |
95 // Click outside the bubble. This should close it. | 94 // Click outside the bubble. This should close it. |
96 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 95 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
97 gfx::Point point_outside = | 96 gfx::Point point_outside = |
98 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 97 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
99 gfx::Vector2d(10, 0); | 98 gfx::Vector2d(10, 0); |
100 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); | 99 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); |
101 generator.MoveMouseToInHost(point_outside); | 100 generator.MoveMouseToInHost(point_outside); |
102 generator.ClickLeftButton(); | 101 generator.ClickLeftButton(); |
103 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 102 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
104 } | 103 } |
105 | 104 |
106 // Tests that clicking outside the app-list bubble closes it. | 105 // Tests that clicking outside the app-list bubble closes it. |
107 TEST_P(AppListControllerTest, TapOutsideBubbleClosesBubble) { | 106 TEST_P(AppListControllerTest, TapOutsideBubbleClosesBubble) { |
108 Shell* shell = Shell::GetInstance(); | 107 Shell* shell = Shell::GetInstance(); |
109 shell->ToggleAppList(NULL); | 108 shell->ToggleAppList(NULL); |
110 | 109 |
111 aura::Window* app_window = shell->GetAppListWindow(); | 110 aura::Window* app_window = shell->GetAppListWindow(); |
112 ASSERT_TRUE(app_window); | 111 ASSERT_TRUE(app_window); |
113 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 112 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
114 | 113 |
115 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow()); | 114 ui::test::EventGenerator generator(shell->GetPrimaryRootWindow()); |
116 // Click on the bubble itself. The bubble should remain visible. | 115 // Click on the bubble itself. The bubble should remain visible. |
117 generator.GestureTapAt(app_window_bounds.CenterPoint()); | 116 generator.GestureTapAt(app_window_bounds.CenterPoint()); |
118 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 117 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
119 | 118 |
120 // Click outside the bubble. This should close it. | 119 // Click outside the bubble. This should close it. |
121 gfx::Point point_outside = | 120 gfx::Point point_outside = |
122 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 121 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
123 gfx::Vector2d(10, 0); | 122 gfx::Vector2d(10, 0); |
124 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); | 123 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); |
125 generator.GestureTapAt(point_outside); | 124 generator.GestureTapAt(point_outside); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 int app_list_view_top = | 178 int app_list_view_top = |
180 app_list->anchor_rect().y() - app_list->bounds().height() / 2; | 179 app_list->anchor_rect().y() - app_list->bounds().height() / 2; |
181 EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); | 180 EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); |
182 } | 181 } |
183 | 182 |
184 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, | 183 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, |
185 AppListControllerTest, | 184 AppListControllerTest, |
186 ::testing::Bool()); | 185 ::testing::Bool()); |
187 | 186 |
188 } // namespace ash | 187 } // namespace ash |
OLD | NEW |