Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Side by Side Diff: ash/app_list/app_list_presenter_delegate_unittest.cc

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Addressed comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/public/cpp/config.h"
8 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_app_list_view_presenter_impl.h" 12 #include "ash/test/test_app_list_view_presenter_impl.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/test/scoped_feature_list.h" 16 #include "base/test/scoped_feature_list.h"
16 #include "ui/app_list/app_list_features.h" 17 #include "ui/app_list/app_list_features.h"
18 #include "ui/app_list/app_list_switches.h"
19 #include "ui/app_list/views/app_list_main_view.h"
17 #include "ui/app_list/views/app_list_view.h" 20 #include "ui/app_list/views/app_list_view.h"
18 #include "ui/aura/test/test_windows.h" 21 #include "ui/aura/test/test_windows.h"
19 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
20 #include "ui/display/display.h" 23 #include "ui/display/display.h"
21 #include "ui/display/screen.h" 24 #include "ui/display/screen.h"
22 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
23 26
24 namespace ash { 27 namespace ash {
25 namespace { 28 namespace {
26 29
(...skipping 20 matching lines...) Expand all
47 // If the current test is parameterized. 50 // If the current test is parameterized.
48 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) { 51 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
49 test_with_fullscreen_ = GetParam(); 52 test_with_fullscreen_ = GetParam();
50 if (test_with_fullscreen_) 53 if (test_with_fullscreen_)
51 EnableFullscreenAppList(); 54 EnableFullscreenAppList();
52 } 55 }
53 // Make the display big enough to hold the app list. 56 // Make the display big enough to hold the app list.
54 UpdateDisplay("1024x768"); 57 UpdateDisplay("1024x768");
55 } 58 }
56 59
57 private:
58 void EnableFullscreenAppList() { 60 void EnableFullscreenAppList() {
59 scoped_feature_list_.InitAndEnableFeature( 61 scoped_feature_list_.InitAndEnableFeature(
60 app_list::features::kEnableFullscreenAppList); 62 app_list::features::kEnableFullscreenAppList);
61 } 63 }
62 64
65 private:
63 test::TestAppListViewPresenterImpl app_list_presenter_impl_; 66 test::TestAppListViewPresenterImpl app_list_presenter_impl_;
64 bool test_with_fullscreen_; 67 bool test_with_fullscreen_;
65 base::test::ScopedFeatureList scoped_feature_list_; 68 base::test::ScopedFeatureList scoped_feature_list_;
66 69
67 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); 70 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
68 }; 71 };
69 72
70 // Instantiate the Boolean which is used to toggle the Fullscreen app list in 73 // Instantiate the Boolean which is used to toggle the Fullscreen app list in
71 // the parameterized tests. 74 // the parameterized tests.
72 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool()); 75 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // which is much bigger than the actual app list size). 182 // which is much bigger than the actual app list size).
180 183
181 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); 184 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
182 int app_list_view_top = 185 int app_list_view_top =
183 app_list->anchor_rect().y() - app_list->bounds().height() / 2; 186 app_list->anchor_rect().y() - app_list->bounds().height() / 2;
184 const int kMinimalAppListMargin = 10; 187 const int kMinimalAppListMargin = 10;
185 188
186 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); 189 EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
187 } 190 }
188 191
192 // Tests that the peeking launcher is enlarged to fullscreen after the user
193 // types in the search box.
194 TEST_F(AppListPresenterDelegateTest, SnapToFullscreenAfterSearchboxInput) {
195 // TODO(newcomer): investigate failure in mash. http://crbug.com/726838.
196 if (Shell::GetAshConfig() == Config::MASH)
197 return;
198
199 EnableFullscreenAppList();
200 UpdateDisplay("1024x768");
201 EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled());
202 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
203 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
204 // Check that it is in peeking mode.
205 EXPECT_FALSE(app_list->IsFullscreen());
206
207 // Dummy key event to search box.
208 ui::test::EventGenerator& generator = GetEventGenerator();
209 generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
210 // Check that it is in fullscreen mode.
211 EXPECT_TRUE(app_list->IsFullscreen());
212 }
213
214 // Tests that the peeking launcher closes if the user taps outside it's
msw 2017/06/06 17:56:31 nit: its (no apostrophe)
newcomer 2017/06/06 23:26:27 Done.
215 // bounds.
216 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingLauncher) {
217 EnableFullscreenAppList();
218
219 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
msw 2017/06/06 17:56:31 nit: EXPECT_TRUE(app_list_presenter_impl()->GetTar
newcomer 2017/06/06 23:26:27 Done.
220 ui::test::EventGenerator& generator = GetEventGenerator();
221
222 // Grab the bounds of the search box,
223 // which is guaranteed to be inside the launcher.
224 gfx::Rect search_box_bounds = app_list_presenter_impl()
msw 2017/06/06 17:56:31 optional nit: inline this in the |tap_point| assig
newcomer 2017/06/06 23:26:27 Done.
225 ->GetView()
226 ->search_box_widget()
227 ->GetContentsView()
228 ->GetBoundsInScreen();
229 gfx::Point tap_point = search_box_bounds.CenterPoint();
230
231 // Tapping inside the bounds doesn't close the launcher.
232 generator.GestureTapAt(tap_point);
233 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
234
235 // Clicking inside the bounds doesn't close the launcher.
236 generator.MoveMouseTo(tap_point);
237 generator.ClickLeftButton();
238 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
239
240 // Tapping outside the bounds closes the launcher.
241 tap_point.set_x(tap_point.x() + 750);
242 generator.GestureTapAt(tap_point);
243 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
244
245 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
246 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
247
248 // Clicking outside the bounds closes the launcher.
249 generator.MoveMouseTo(tap_point);
250 generator.ClickLeftButton();
251 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
252 }
253
189 } // namespace ash 254 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698