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/aura/test/event_generator.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 | 17 |
17 namespace ash { | 18 namespace ash { |
18 | 19 |
20 namespace { | |
21 | |
22 const int kMinimalCenteredAppListMargin = 10; | |
23 | |
24 } | |
25 | |
19 // 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. |
20 // (The test name ends in "/0" for normal, "/1" for centered.) | 27 // (The test name ends in "/0" for normal, "/1" for centered.) |
21 class AppListControllerTest : public test::AshTestBase, | 28 class AppListControllerTest : public test::AshTestBase, |
22 public ::testing::WithParamInterface<bool> { | 29 public ::testing::WithParamInterface<bool> { |
23 public: | 30 public: |
24 AppListControllerTest(); | 31 AppListControllerTest(); |
25 virtual ~AppListControllerTest(); | 32 virtual ~AppListControllerTest(); |
26 virtual void SetUp() OVERRIDE; | 33 virtual void SetUp() OVERRIDE; |
27 }; | 34 }; |
28 | 35 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 Shell::GetInstance()->ToggleAppList(secondary_window); | 137 Shell::GetInstance()->ToggleAppList(secondary_window); |
131 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 138 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
132 | 139 |
133 // Remove the secondary display. Shouldn't crash (http://crbug.com/368990). | 140 // Remove the secondary display. Shouldn't crash (http://crbug.com/368990). |
134 UpdateDisplay("800x600"); | 141 UpdateDisplay("800x600"); |
135 | 142 |
136 // Updating the displays should close the app list. | 143 // Updating the displays should close the app list. |
137 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 144 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
138 } | 145 } |
139 | 146 |
147 // Tests opening the app launcher on a tiny display that is too small to contain | |
148 // it. | |
149 TEST_P(AppListControllerTest, TinyDisplay) { | |
Matt Giuca
2014/05/12 06:34:23
Note: This test fails without CL 283443003 because
varkha
2014/05/13 03:25:31
(Should this test and maybe other tests be disable
Matt Giuca
2014/05/13 04:02:12
Why? This test doesn't use window resizing, it jus
varkha
2014/05/13 04:40:11
Unfortunately this call is a NOP on platforms that
Matt Giuca
2014/05/13 05:31:58
Fair enough. Done.
| |
150 // Don't test this for the non-centered app list case; it isn't designed for | |
151 // small displays. The most common case of a small display --- when the | |
152 // virtual keyboard is open --- switches into the centered app list mode, so | |
153 // we just want to run this test in that case. | |
154 if (!GetParam()) | |
varkha
2014/05/13 03:25:31
Can we wrap this in a self-descriptive method (boo
Matt Giuca
2014/05/13 04:02:12
Done.
| |
155 return; | |
156 | |
157 // Set up a screen with a tiny display (height smaller than the app list). | |
158 UpdateDisplay("400x300"); | |
159 | |
160 Shell::GetInstance()->ToggleAppList(NULL); | |
161 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | |
162 | |
163 // The top of the app list should be on-screen (even if the bottom is not). | |
164 // We need to manually calculate the Y coordinate of the top of the app list | |
165 // from the anchor (center) and height. There isn't a bounds rect that gives | |
166 // the actual app list position (the widget bounds include the bubble border | |
167 // which is much bigger than the actual app list size). | |
168 app_list::AppListView* app_list = Shell::GetInstance()->GetAppListView(); | |
169 int app_list_view_top = | |
170 app_list->anchor_rect().y() - app_list->bounds().height() / 2; | |
171 EXPECT_GE(app_list_view_top, kMinimalCenteredAppListMargin); | |
172 } | |
173 | |
140 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, | 174 INSTANTIATE_TEST_CASE_P(AppListControllerTestInstance, |
141 AppListControllerTest, | 175 AppListControllerTest, |
142 ::testing::Bool()); | 176 ::testing::Bool()); |
143 | 177 |
144 } // namespace ash | 178 } // namespace ash |
OLD | NEW |