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

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: Created 3 years, 7 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/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_app_list_view_presenter_impl.h" 11 #include "ash/test/test_app_list_view_presenter_impl.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/command_line.h" 14 #include "base/command_line.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/test/scoped_feature_list.h" 16 #include "base/test/scoped_feature_list.h"
17 #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"
18 #include "ui/app_list/views/app_list_view.h" 20 #include "ui/app_list/views/app_list_view.h"
19 #include "ui/aura/test/test_windows.h" 21 #include "ui/aura/test/test_windows.h"
20 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
21 #include "ui/display/display.h" 23 #include "ui/display/display.h"
22 #include "ui/display/screen.h" 24 #include "ui/display/screen.h"
23 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
24 26
25 namespace ash { 27 namespace ash {
26 namespace { 28 namespace {
27 29
(...skipping 20 matching lines...) Expand all
48 // If the current test is parameterized. 50 // If the current test is parameterized.
49 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) { 51 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
50 test_with_fullscreen_ = GetParam(); 52 test_with_fullscreen_ = GetParam();
51 if (test_with_fullscreen_) 53 if (test_with_fullscreen_)
52 EnableFullscreenAppList(); 54 EnableFullscreenAppList();
53 } 55 }
54 // Make the display big enough to hold the app list. 56 // Make the display big enough to hold the app list.
55 UpdateDisplay("1024x768"); 57 UpdateDisplay("1024x768");
56 } 58 }
57 59
58 private:
59 void EnableFullscreenAppList() { 60 void EnableFullscreenAppList() {
60 scoped_feature_list_.InitAndEnableFeature( 61 scoped_feature_list_.InitAndEnableFeature(
61 app_list::features::kEnableFullscreenAppList); 62 app_list::features::kEnableFullscreenAppList);
62 } 63 }
63 64
65 private:
64 test::TestAppListViewPresenterImpl app_list_presenter_impl_; 66 test::TestAppListViewPresenterImpl app_list_presenter_impl_;
65 bool test_with_fullscreen_; 67 bool test_with_fullscreen_;
66 base::test::ScopedFeatureList scoped_feature_list_; 68 base::test::ScopedFeatureList scoped_feature_list_;
67 69
68 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); 70 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
69 }; 71 };
70 72
71 // 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
72 // the parameterized tests. 74 // the parameterized tests.
73 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
180 // which is much bigger than the actual app list size). 182 // which is much bigger than the actual app list size).
181 183
182 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); 184 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
183 int app_list_view_top = 185 int app_list_view_top =
184 app_list->anchor_rect().y() - app_list->bounds().height() / 2; 186 app_list->anchor_rect().y() - app_list->bounds().height() / 2;
185 const int kMinimalAppListMargin = 10; 187 const int kMinimalAppListMargin = 10;
186 188
187 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); 189 EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
188 } 190 }
189 191
192 // Tests that the peeking launcher is enlarged to fullscreen after the user
193 // types in the search box.
194 TEST_P(AppListPresenterDelegateTest, SnapToFullscreenAfterSearchboxInput) {
195 if(!app_list::features::IsFullscreenAppListEnabled())
xiyuan 2017/05/24 18:28:17 If the test case does not run for non-fullscreen,
newcomer 2017/05/25 23:10:50 Done! I was experimenting with tests and left that
196 return;
197 //EnableFullscreenAppList();
vadimt 2017/05/22 23:36:56 Remove/uncomment?
newcomer 2017/05/25 23:10:50 Done.
198 UpdateDisplay("1024x768");
199 EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled());
200 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
201 app_list::AppListView* app_list = app_list_presenter_impl()->GetView();
202 // check that it is in peeking mode
203 EXPECT_FALSE(app_list->IsFullscreen());
204
205 // dummy key event to search box
206 ui::test::EventGenerator& generator = GetEventGenerator();
207 generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
208 // check that it is in fullscreen mode
209 EXPECT_TRUE(app_list->IsFullscreen());
210 }
211
212 // Tests that the peeking launcher closes if the user taps outside it's
213 // bounds.
214 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingLauncher) {
215 EnableFullscreenAppList();
216
217 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
218 ui::test::EventGenerator& generator = GetEventGenerator();
219 // Grab the bounds of the search box,
xiyuan 2017/05/24 18:28:17 nit: insert an empty line before
newcomer 2017/05/25 23:10:50 Done.
220 // which is guarunteed to be inside the launcher.
xiyuan 2017/05/24 18:28:17 nit: guarunteed -> guaranteed
newcomer 2017/05/25 23:10:50 Done.
221 gfx::Rect search_box_bounds = app_list_presenter_impl()
222 ->GetView()
223 ->search_box_widget()
224 ->GetContentsView()
225 ->GetBoundsInScreen();
226 gfx::Point tap_point = search_box_bounds.CenterPoint();
227 // Tapping inside the bounds doesn't close the launcher.
xiyuan 2017/05/24 18:28:17 nit: insert an empty line before.
newcomer 2017/05/25 23:10:50 Done.
228 generator.GestureTapAt(tap_point);
229 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
230 // Clicking inside the bounds doesn't close the launcher.
xiyuan 2017/05/24 18:28:17 nit: insert an empty line before.
newcomer 2017/05/25 23:10:50 Done.
231 generator.MoveMouseTo(tap_point);
232 generator.ClickLeftButton();
233 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
234
235 // Tapping outside the bounds closes the launcher.
236 tap_point.set_x(tap_point.x() + 750);
237 generator.GestureTapAt(tap_point);
238 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
239
240 app_list_presenter_impl()->Show(GetPrimaryDisplayId());
241 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
242
243 // Clicking outside the bounds closes the launcher.
244 generator.MoveMouseTo(tap_point);
245 generator.ClickLeftButton();
246 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
247 }
248
190 } // namespace ash 249 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698