Chromium Code Reviews| 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/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_app_list_view_presenter_impl.h" | 12 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.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" | 18 #include "ui/app_list/app_list_switches.h" |
| 19 #include "ui/app_list/views/app_list_main_view.h" | 19 #include "ui/app_list/views/app_list_main_view.h" |
| 20 #include "ui/app_list/views/app_list_view.h" | 20 #include "ui/app_list/views/app_list_view.h" |
| 21 #include "ui/app_list/views/search_box_view.h" | |
| 21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/display/display.h" | 24 #include "ui/display/display.h" |
| 24 #include "ui/display/screen.h" | 25 #include "ui/display/screen.h" |
| 25 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
| 27 #include "ui/views/controls/textfield/textfield.h" | |
| 26 | 28 |
| 27 namespace ash { | 29 namespace ash { |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 int64_t GetPrimaryDisplayId() { | 32 int64_t GetPrimaryDisplayId() { |
| 31 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 33 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 class AppListPresenterDelegateTest : public test::AshTestBase, | 38 class AppListPresenterDelegateTest : public test::AshTestBase, |
| 37 public testing::WithParamInterface<bool> { | 39 public testing::WithParamInterface<bool> { |
| 38 public: | 40 public: |
| 39 AppListPresenterDelegateTest() {} | 41 AppListPresenterDelegateTest() {} |
| 40 ~AppListPresenterDelegateTest() override {} | 42 ~AppListPresenterDelegateTest() override {} |
| 41 | 43 |
| 42 app_list::AppListPresenterImpl* app_list_presenter_impl() { | 44 app_list::AppListPresenterImpl* app_list_presenter_impl() { |
| 43 return &app_list_presenter_impl_; | 45 return &app_list_presenter_impl_; |
| 44 } | 46 } |
| 45 | 47 |
| 46 // testing::Test: | 48 // testing::Test: |
| 47 void SetUp() override { | 49 void SetUp() override { |
| 48 AshTestBase::SetUp(); | 50 AshTestBase::SetUp(); |
| 49 | 51 |
| 50 // If the current test is parameterized. | 52 if (testing::UnitTest::GetInstance()->current_test_info()->value_param() && |
| 51 if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) { | 53 GetParam()) { |
| 52 test_with_fullscreen_ = GetParam(); | 54 EnableFullscreenAppList(); |
| 53 if (test_with_fullscreen_) | |
| 54 EnableFullscreenAppList(); | |
| 55 } | 55 } |
| 56 | |
| 56 // Make the display big enough to hold the app list. | 57 // Make the display big enough to hold the app list. |
| 57 UpdateDisplay("1024x768"); | 58 UpdateDisplay("1024x768"); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void EnableFullscreenAppList() { | 61 void EnableFullscreenAppList() { |
| 61 scoped_feature_list_.InitAndEnableFeature( | 62 scoped_feature_list_.InitAndEnableFeature( |
| 62 app_list::features::kEnableFullscreenAppList); | 63 app_list::features::kEnableFullscreenAppList); |
| 63 } | 64 } |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 test::TestAppListViewPresenterImpl app_list_presenter_impl_; | 67 test::TestAppListViewPresenterImpl app_list_presenter_impl_; |
| 67 bool test_with_fullscreen_; | |
| 68 base::test::ScopedFeatureList scoped_feature_list_; | 68 base::test::ScopedFeatureList scoped_feature_list_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); | 70 DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class FullscreenAppListPresenterDelegateTest | |
|
khmel
2017/07/10 15:52:22
nit: not sure, but looks like we might merge to on
newcomer
2017/07/10 16:38:20
Discussed offline:
We are using two classes becaus
| |
| 74 : public test::AshTestBase, | |
|
khmel
2017/07/10 15:52:22
nit: It would be nice to add comment what param me
newcomer
2017/07/10 16:38:20
There is a comment on the Initializer for this par
| |
| 75 public testing::WithParamInterface<bool> { | |
| 76 public: | |
| 77 FullscreenAppListPresenterDelegateTest() {} | |
| 78 ~FullscreenAppListPresenterDelegateTest() override {} | |
| 79 | |
| 80 app_list::AppListPresenterImpl* app_list_presenter_impl() { | |
| 81 return &app_list_presenter_impl_; | |
| 82 } | |
| 83 | |
| 84 // testing::Test: | |
| 85 void SetUp() override { | |
| 86 AshTestBase::SetUp(); | |
| 87 | |
| 88 scoped_feature_list_.InitAndEnableFeature( | |
| 89 app_list::features::kEnableFullscreenAppList); | |
| 90 | |
| 91 // Make the display big enough to hold the app list. | |
| 92 UpdateDisplay("1024x768"); | |
| 93 } | |
| 94 | |
| 95 int GetPointOutsideSearchbox(bool outside) { | |
| 96 gfx::Point searchbox_point = app_list_presenter_impl_.GetView() | |
| 97 ->search_box_view() | |
| 98 ->GetBoundsInScreen(); | |
| 99 | |
| 100 searchbox_point.Offset(0, outside ? -1 : 0); | |
| 101 | |
| 102 return searchbox_point; | |
| 103 } | |
| 104 | |
| 105 private: | |
| 106 test::TestAppListViewPresenterImpl app_list_presenter_impl_; | |
| 107 base::test::ScopedFeatureList scoped_feature_list_; | |
| 108 | |
| 109 DISALLOW_COPY_AND_ASSIGN(FullscreenAppListPresenterDelegateTest); | |
| 110 }; | |
| 111 | |
| 73 // Instantiate the Boolean which is used to toggle the Fullscreen app list in | 112 // Instantiate the Boolean which is used to toggle the Fullscreen app list in |
| 74 // the parameterized tests. | 113 // the parameterized tests. |
| 75 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool()); | 114 INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool()); |
| 76 | 115 |
| 116 // Instantiate the Boolean which is used to toggle mouse and touch events in | |
| 117 // the parameterized tests. | |
| 118 INSTANTIATE_TEST_CASE_P(, | |
| 119 FullscreenAppListPresenterDelegateTest, | |
| 120 testing::Bool()); | |
| 121 | |
| 77 // Tests that app list hides when focus moves to a normal window. | 122 // Tests that app list hides when focus moves to a normal window. |
| 78 TEST_P(AppListPresenterDelegateTest, HideOnFocusOut) { | 123 TEST_P(AppListPresenterDelegateTest, HideOnFocusOut) { |
| 79 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 124 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 80 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 125 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 81 | 126 |
| 82 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 127 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
| 83 wm::ActivateWindow(window.get()); | 128 wm::ActivateWindow(window.get()); |
| 84 | 129 |
| 85 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 130 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 86 } | 131 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 115 // Click outside the bubble. This should close it. | 160 // Click outside the bubble. This should close it. |
| 116 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 161 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
| 117 gfx::Point point_outside = | 162 gfx::Point point_outside = |
| 118 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 163 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
| 119 gfx::Vector2d(10, 0); | 164 gfx::Vector2d(10, 0); |
| 120 generator.MoveMouseToInHost(point_outside); | 165 generator.MoveMouseToInHost(point_outside); |
| 121 generator.ClickLeftButton(); | 166 generator.ClickLeftButton(); |
| 122 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 167 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 123 } | 168 } |
| 124 | 169 |
| 125 // Tests that clicking outside the app-list bubble closes it. | 170 // Tests that tapping outside the app-list bubble closes it. |
| 126 TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) { | 171 TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) { |
| 127 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 172 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 128 | 173 |
| 129 aura::Window* app_window = app_list_presenter_impl()->GetWindow(); | 174 aura::Window* app_window = app_list_presenter_impl()->GetWindow(); |
| 130 ASSERT_TRUE(app_window); | 175 ASSERT_TRUE(app_window); |
| 131 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); | 176 gfx::Rect app_window_bounds = app_window->GetBoundsInRootWindow(); |
| 132 | 177 |
| 133 ui::test::EventGenerator& generator = GetEventGenerator(); | 178 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 134 // Click on the bubble itself. The bubble should remain visible. | 179 // Click on the bubble itself. The bubble should remain visible. |
| 135 generator.GestureTapAt(app_window_bounds.CenterPoint()); | 180 generator.GestureTapAt(app_window_bounds.CenterPoint()); |
| 136 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 181 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 137 | 182 |
| 138 // Click outside the bubble. This should close it. | 183 // Tap outside the bubble. This should close it. |
| 139 gfx::Point point_outside = | 184 gfx::Point point_outside = |
| 140 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + | 185 gfx::Point(app_window_bounds.right(), app_window_bounds.y()) + |
| 141 gfx::Vector2d(10, 0); | 186 gfx::Vector2d(10, 0); |
| 142 generator.GestureTapAt(point_outside); | 187 generator.GestureTapAt(point_outside); |
| 143 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 188 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 144 } | 189 } |
| 145 | 190 |
| 146 // Tests opening the app list on a non-primary display, then deleting the | 191 // Tests opening the app list on a non-primary display, then deleting the |
| 147 // display. | 192 // display. |
| 148 TEST_P(AppListPresenterDelegateTest, NonPrimaryDisplay) { | 193 TEST_P(AppListPresenterDelegateTest, NonPrimaryDisplay) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 // which is much bigger than the actual app list size). | 227 // which is much bigger than the actual app list size). |
| 183 | 228 |
| 184 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | 229 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); |
| 185 int app_list_view_top = | 230 int app_list_view_top = |
| 186 app_list->anchor_rect().y() - app_list->bounds().height() / 2; | 231 app_list->anchor_rect().y() - app_list->bounds().height() / 2; |
| 187 const int kMinimalAppListMargin = 10; | 232 const int kMinimalAppListMargin = 10; |
| 188 | 233 |
| 189 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); | 234 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); |
| 190 } | 235 } |
| 191 | 236 |
| 192 // Tests that the peeking app list closes if the user taps outside its | 237 // Tests that the peeking app list closes if the user taps or clicks outside |
| 193 // bounds. | 238 // its bounds. |
| 194 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { | 239 TEST_P(FullscreenAppListPresenterDelegateTest, |
| 195 EnableFullscreenAppList(); | 240 TapAndClickOutsideClosesPeekingAppList) { |
| 196 | 241 bool test_mouse_event = GetParam(); |
| 197 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 242 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 198 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 243 EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(), |
| 244 app_list::AppListView::PEEKING); | |
| 199 ui::test::EventGenerator& generator = GetEventGenerator(); | 245 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 200 | 246 |
| 201 // Grab the bounds of the search box, | |
| 202 // which is guaranteed to be inside the app list. | |
| 203 gfx::Point tap_point = app_list_presenter_impl() | |
| 204 ->GetView() | |
| 205 ->search_box_widget() | |
| 206 ->GetContentsView() | |
| 207 ->GetBoundsInScreen() | |
| 208 .CenterPoint(); | |
| 209 | |
| 210 // Tapping inside the bounds doesn't close the app list. | 247 // Tapping inside the bounds doesn't close the app list. |
| 211 generator.GestureTapAt(tap_point); | 248 gfx::Point tap_point = GetPointOutsideSearchbox(false); |
| 212 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 249 if (test_mouse_event) { |
| 213 | 250 generator.MoveMouseTo(tap_point); |
| 214 // Clicking inside the bounds doesn't close the app list. | 251 generator.ClickLeftButton(); |
| 215 generator.MoveMouseTo(tap_point); | 252 generator.ReleaseLeftButton(); |
| 216 generator.ClickLeftButton(); | 253 } else { |
| 217 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 254 generator.GestureTapAt(tap_point); |
| 255 } | |
| 256 EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(), | |
| 257 app_list::AppListView::PEEKING); | |
| 218 | 258 |
| 219 // Tapping outside the bounds closes the app list. | 259 // Tapping outside the bounds closes the app list. |
| 220 tap_point.set_x(tap_point.x() + 750); | 260 tap_point.offset(0, 750); |
| 221 generator.GestureTapAt(tap_point); | 261 if (test_mouse_event) { |
| 222 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 262 generator.MoveMouseTo(tap_point); |
| 263 generator.ClickLeftButton(); | |
| 264 generator.ReleaseLeftButton(); | |
| 265 } else { | |
| 266 generator.GestureTapAt(tap_point); | |
| 267 } | |
| 268 EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(), | |
| 269 app_list::AppListView::CLOSED); | |
| 270 } | |
| 223 | 271 |
| 272 // Tests that a keypress activates the searchbox and that clearing the searchbox | |
| 273 // deactivates the searchbox. | |
| 274 TEST_F(FullscreenAppListPresenterDelegateTest, KeyPressEnablesSearchBox) { | |
| 224 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 275 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 225 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 276 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 277 app_list::SearchBoxView* search_box_view = | |
| 278 app_list_presenter_impl()->GetView()->search_box_view(); | |
| 279 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 226 | 280 |
| 227 // Clicking outside the bounds closes the app list. | 281 // Press any key, the search box should be active. |
| 228 generator.MoveMouseTo(tap_point); | 282 generator.PressKey(ui::VKEY_0, 0); |
| 229 generator.ClickLeftButton(); | 283 EXPECT_TRUE(search_box_view->is_search_box_active()); |
| 230 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 284 |
| 285 // Delete the text, the search box should be inactive. | |
| 286 search_box_view->ClearSearch(); | |
| 287 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 288 } | |
| 289 | |
| 290 // Tests that a tap/click on the AppListView from half launcher returns the | |
| 291 // AppListView to Peeking, and that a tap/click on the AppListView from Peeking | |
| 292 // closes the app list. | |
| 293 TEST_P(FullscreenAppListPresenterDelegateTest, | |
| 294 StateTransitionsByTapAndClickingAppListBodyFromHalf) { | |
| 295 bool test_mouse_event = GetParam(); | |
|
khmel
2017/07/10 15:52:22
nit: const bool test_mouse_event = ...
I would al
newcomer
2017/07/10 16:38:20
Done!
| |
| 296 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 297 app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView(); | |
| 298 app_list::SearchBoxView* search_box_view = app_list_view->search_box_view(); | |
| 299 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 300 EXPECT_EQ(app_list_view->app_list_state(), | |
| 301 app_list::AppListView::AppListState::PEEKING); | |
| 302 | |
| 303 // Press a key, the AppListView should transition to half. | |
| 304 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 305 EXPECT_EQ(app_list_view->app_list_state(), | |
| 306 app_list::AppListView::AppListState::HALF); | |
| 307 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 308 | |
| 309 // Tap outside the search box, the AppListView should transition to Peeking | |
| 310 // and the search box should be inactive. | |
| 311 if (test_mouse_event) { | |
| 312 generator.MoveMouseTo(GetPointOutsideSearchBox()); | |
| 313 generator.ClickLeftButton(); | |
| 314 } else { | |
| 315 generator.GestureTapDownAndUp(GetPointOutsideSearchBox()); | |
| 316 } | |
| 317 EXPECT_EQ(app_list_view->app_list_state(), | |
| 318 app_list::AppListView::AppListState::PEEKING); | |
| 319 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 320 | |
| 321 // Tap outside the search box again, the AppListView should hide. | |
| 322 if (test_mouse_event) { | |
| 323 generator.MoveMouseTo(GetPointOutsideSearchBox()); | |
| 324 generator.ClickLeftButton(); | |
| 325 } else { | |
| 326 generator.GestureTapDownAndUp(GetPointOutsideSearchBox()); | |
| 327 } | |
| 328 EXPECT_EQ(app_list_view->app_list_state(), | |
| 329 app_list::AppListView::AppListState::CLOSED); | |
| 330 } | |
| 331 | |
| 332 // Tests that a tap/click on the AppListView from Fullscreen search returns the | |
| 333 // AppListView to fullscreen all apps, and that a tap/click on the AppListView | |
| 334 // from fullscreen all apps closes the app list. | |
| 335 TEST_P(FullscreenAppListPresenterDelegateTest, | |
| 336 StateTransitionsByTappingAppListBodyFromFullscreen) { | |
| 337 bool test_mouse_event = GetParam(); | |
| 338 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 339 app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView(); | |
| 340 app_list::SearchBoxView* search_box_view = app_list_view->search_box_view(); | |
| 341 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 342 | |
| 343 // Execute a long upwards drag, this should transition the app list to | |
| 344 // fullscreen. | |
| 345 int top_of_app_list = | |
|
khmel
2017/07/10 15:52:22
nit: const int ...
newcomer
2017/07/10 16:38:20
Done.
| |
| 346 app_list_view->GetWidget()->GetWindowBoundsInScreen().y(); | |
| 347 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 348 gfx::Point(10, 10), | |
| 349 base::TimeDelta::FromMilliseconds(100), 10); | |
| 350 EXPECT_EQ(app_list_view->app_list_state(), | |
| 351 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 352 | |
| 353 // Press a key, this should activate the searchbox and transition to | |
| 354 // fullscreen search. | |
| 355 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 356 EXPECT_EQ(app_list_view->app_list_state(), | |
| 357 app_list::AppListView::AppListState::FULLSCREEN_SEARCH); | |
| 358 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 359 | |
| 360 // Tap outside the searchbox, this should deactivate the searchbox and the | |
| 361 // applistview should return to fullscreen all apps. | |
| 362 if (test_mouse_event) { | |
| 363 generator.MoveMouseTo(GetPointOutsideSearchBox()); | |
| 364 generator.ClickLeftButton(); | |
| 365 } else { | |
| 366 generator.GestureTapDownAndUp(GetPointOutsideSearchBox()); | |
| 367 } | |
| 368 EXPECT_EQ(app_list_view->app_list_state(), | |
| 369 app_list::AppListView::AppListState::FULLSCREEN_ALL_APPS); | |
| 370 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 371 | |
| 372 // Tap outside the searchbox again, this should close the applistview. | |
| 373 if (test_mouse_event) { | |
| 374 generator.MoveMouseTo(outside_search_box); | |
| 375 generator.ClickLeftButton(); | |
| 376 } else { | |
| 377 generator.GestureTapDownAndUp(outside_search_box); | |
| 378 } | |
| 379 EXPECT_EQ(app_list_view->app_list_state(), | |
| 380 app_list::AppListView::AppListState::CLOSED); | |
| 381 } | |
| 382 | |
| 383 // Tests that the searchbox activates when it is tapped and that the widget is | |
| 384 // closed after tapping outside the searchbox. | |
| 385 TEST_P(FullscreenAppListPresenterDelegateTest, TapAndClickEnablesSearchBox) { | |
| 386 bool test_mouse_event = GetParam(); | |
| 387 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 388 app_list::SearchBoxView* search_box_view = | |
| 389 app_list_presenter_impl()->GetView()->search_box_view(); | |
| 390 | |
| 391 // Tap/Click the search box, it should activate. | |
| 392 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 393 if (test_mouse_event) { | |
| 394 generator.MoveMouseTo(GetPointOutsideSearchbox(false);); | |
| 395 generator.PressLeftButton(); | |
| 396 generator.ReleaseLeftButton(); | |
| 397 } else { | |
| 398 generator.GestureTapAt(GetPointOutsideSearchbox(false);); | |
| 399 } | |
| 400 | |
| 401 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 402 | |
| 403 // Tap on the body of the app list, the search box should deactivate. | |
| 404 if (test_mouse_event) { | |
| 405 generator.MoveMouseTo(GetPointOutsideSearchBox(true)); | |
| 406 generator.PressLeftButton(); | |
| 407 generator.ReleaseLeftButton(); | |
| 408 } else { | |
| 409 generator.GestureTapAt(GetPointOutsideSearchBox(true)); | |
| 410 } | |
| 411 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 412 EXPECT_TRUE(app_list_presenter_impl()->IsVisible()); | |
| 413 | |
| 414 // Tap on the body of the app list again, the app list should hide. | |
| 415 if (test_mouse_event) { | |
| 416 generator.PressLeftButton(); | |
| 417 generator.ReleaseLeftButton(); | |
| 418 } else { | |
| 419 generator.GestureTapAt(GetPointOutsideSearchbox(true)); | |
| 420 } | |
| 421 EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(), | |
| 422 app_list::AppListView::AppListState::CLOSED); | |
| 231 } | 423 } |
| 232 | 424 |
| 233 } // namespace ash | 425 } // namespace ash |
| OLD | NEW |