| 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 <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 Loading... |
| 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 Loading... |
| 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_F(AppListPresenterDelegateTest, SnapToFullscreenAfterSearchboxInput) { |
| 195 EnableFullscreenAppList(); |
| 196 UpdateDisplay("1024x768"); |
| 197 EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled()); |
| 198 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 199 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); |
| 200 // check that it is in peeking mode |
| 201 EXPECT_FALSE(app_list->IsFullscreen()); |
| 202 |
| 203 // dummy key event to search box |
| 204 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 205 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); |
| 206 // check that it is in fullscreen mode |
| 207 EXPECT_TRUE(app_list->IsFullscreen()); |
| 208 } |
| 209 |
| 210 // Tests that the peeking launcher closes if the user taps outside it's |
| 211 // bounds. |
| 212 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingLauncher) { |
| 213 EnableFullscreenAppList(); |
| 214 |
| 215 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 216 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 217 |
| 218 // Grab the bounds of the search box, |
| 219 // which is guaranteed to be inside the launcher. |
| 220 gfx::Rect search_box_bounds = app_list_presenter_impl() |
| 221 ->GetView() |
| 222 ->search_box_widget() |
| 223 ->GetContentsView() |
| 224 ->GetBoundsInScreen(); |
| 225 gfx::Point tap_point = search_box_bounds.CenterPoint(); |
| 226 |
| 227 // Tapping inside the bounds doesn't close the launcher. |
| 228 generator.GestureTapAt(tap_point); |
| 229 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 230 |
| 231 // Clicking inside the bounds doesn't close the launcher. |
| 232 generator.MoveMouseTo(tap_point); |
| 233 generator.ClickLeftButton(); |
| 234 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 235 |
| 236 // Tapping outside the bounds closes the launcher. |
| 237 tap_point.set_x(tap_point.x() + 750); |
| 238 generator.GestureTapAt(tap_point); |
| 239 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 240 |
| 241 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 242 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 243 |
| 244 // Clicking outside the bounds closes the launcher. |
| 245 generator.MoveMouseTo(tap_point); |
| 246 generator.ClickLeftButton(); |
| 247 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 248 } |
| 249 |
| 190 } // namespace ash | 250 } // namespace ash |
| OLD | NEW |