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" |
14 #include "ui/aura/test/test_windows.h" | 15 #include "ui/aura/test/test_windows.h" |
15 #include "ui/aura/window.h" | 16 #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 ui::test::EventGenerator generator(shell->GetPrimaryRootWindow(), app_window); | 89 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow(), |
| 90 app_window); |
90 // Click on the bubble itself. The bubble should remain visible. | 91 // Click on the bubble itself. The bubble should remain visible. |
91 generator.ClickLeftButton(); | 92 generator.ClickLeftButton(); |
92 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 93 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
93 | 94 |
94 // Click outside the bubble. This should close it. | 95 // Click outside the bubble. This should close it. |
95 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 96 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
96 gfx::Point point_outside = | 97 gfx::Point point_outside = |
97 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 98 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
98 gfx::Vector2d(10, 0); | 99 gfx::Vector2d(10, 0); |
99 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); | 100 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); |
100 generator.MoveMouseToInHost(point_outside); | 101 generator.MoveMouseToInHost(point_outside); |
101 generator.ClickLeftButton(); | 102 generator.ClickLeftButton(); |
102 EXPECT_FALSE(shell->GetAppListTargetVisibility()); | 103 EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
103 } | 104 } |
104 | 105 |
105 // Tests that clicking outside the app-list bubble closes it. | 106 // Tests that clicking outside the app-list bubble closes it. |
106 TEST_P(AppListControllerTest, TapOutsideBubbleClosesBubble) { | 107 TEST_P(AppListControllerTest, TapOutsideBubbleClosesBubble) { |
107 Shell* shell = Shell::GetInstance(); | 108 Shell* shell = Shell::GetInstance(); |
108 shell->ToggleAppList(NULL); | 109 shell->ToggleAppList(NULL); |
109 | 110 |
110 aura::Window* app_window = shell->GetAppListWindow(); | 111 aura::Window* app_window = shell->GetAppListWindow(); |
111 ASSERT_TRUE(app_window); | 112 ASSERT_TRUE(app_window); |
112 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 113 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
113 | 114 |
114 ui::test::EventGenerator generator(shell->GetPrimaryRootWindow()); | 115 aura::test::EventGenerator generator(shell->GetPrimaryRootWindow()); |
115 // Click on the bubble itself. The bubble should remain visible. | 116 // Click on the bubble itself. The bubble should remain visible. |
116 generator.GestureTapAt(app_window_bounds.CenterPoint()); | 117 generator.GestureTapAt(app_window_bounds.CenterPoint()); |
117 EXPECT_TRUE(shell->GetAppListTargetVisibility()); | 118 EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
118 | 119 |
119 // Click outside the bubble. This should close it. | 120 // Click outside the bubble. This should close it. |
120 gfx::Point point_outside = | 121 gfx::Point point_outside = |
121 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 122 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
122 gfx::Vector2d(10, 0); | 123 gfx::Vector2d(10, 0); |
123 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); | 124 EXPECT_TRUE(shell->GetPrimaryRootWindow()->bounds().Contains(point_outside)); |
124 generator.GestureTapAt(point_outside); | 125 generator.GestureTapAt(point_outside); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 int app_list_view_top = | 179 int app_list_view_top = |
179 app_list->anchor_rect().y() - app_list->bounds().height() / 2; | 180 app_list->anchor_rect().y() - app_list->bounds().height() / 2; |
180 EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); | 181 EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); |
181 } | 182 } |
182 | 183 |
183 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, | 184 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, |
184 AppListControllerTest, | 185 AppListControllerTest, |
185 ::testing::Bool()); | 186 ::testing::Bool()); |
186 | 187 |
187 } // namespace ash | 188 } // namespace ash |
OLD | NEW |