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/shelf/shelf.h" | |
| 11 #include "ash/shelf/shelf_layout_manager.h" | |
| 10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_port.h" | |
| 11 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_app_list_view_presenter_impl.h" | 15 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | |
| 13 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 14 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 15 #include "base/macros.h" | 19 #include "base/macros.h" |
| 16 #include "base/test/scoped_feature_list.h" | 20 #include "base/test/scoped_feature_list.h" |
| 17 #include "ui/app_list/app_list_features.h" | 21 #include "ui/app_list/app_list_features.h" |
| 18 #include "ui/app_list/app_list_switches.h" | 22 #include "ui/app_list/app_list_switches.h" |
| 19 #include "ui/app_list/views/app_list_main_view.h" | 23 #include "ui/app_list/views/app_list_main_view.h" |
| 20 #include "ui/app_list/views/app_list_view.h" | 24 #include "ui/app_list/views/app_list_view.h" |
| 21 #include "ui/aura/test/test_windows.h" | 25 #include "ui/aura/test/test_windows.h" |
| 22 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 23 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 24 #include "ui/display/screen.h" | 28 #include "ui/display/screen.h" |
| 25 #include "ui/events/test/event_generator.h" | 29 #include "ui/events/test/event_generator.h" |
| 26 | 30 |
| 27 namespace ash { | 31 namespace ash { |
| 28 namespace { | 32 namespace { |
| 29 | 33 |
| 30 int64_t GetPrimaryDisplayId() { | 34 int64_t GetPrimaryDisplayId() { |
| 31 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 35 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 32 } | 36 } |
| 33 | 37 |
| 38 void SetShelfAlignment(ShelfAlignment alignment) { | |
| 39 Shelf::ForWindow( | |
| 40 ShellPort::Get()->GetRootWindowForDisplayId(GetPrimaryDisplayId())) | |
| 41 ->SetAlignment(alignment); | |
| 42 } | |
| 43 | |
| 44 void EnableMaximizeMode(bool enable) { | |
| 45 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 46 enable); | |
| 47 } | |
| 48 | |
| 34 } // namespace | 49 } // namespace |
| 35 | 50 |
| 36 class AppListPresenterDelegateTest : public test::AshTestBase, | 51 class AppListPresenterDelegateTest : public test::AshTestBase, |
| 37 public testing::WithParamInterface<bool> { | 52 public testing::WithParamInterface<bool> { |
| 38 public: | 53 public: |
| 39 AppListPresenterDelegateTest() {} | 54 AppListPresenterDelegateTest() {} |
| 40 ~AppListPresenterDelegateTest() override {} | 55 ~AppListPresenterDelegateTest() override {} |
| 41 | 56 |
| 42 app_list::AppListPresenterImpl* app_list_presenter_impl() { | 57 app_list::AppListPresenterImpl* app_list_presenter_impl() { |
| 43 return &app_list_presenter_impl_; | 58 return &app_list_presenter_impl_; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 // which is much bigger than the actual app list size). | 197 // which is much bigger than the actual app list size). |
| 183 | 198 |
| 184 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | 199 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); |
| 185 int app_list_view_top = | 200 int app_list_view_top = |
| 186 app_list->anchor_rect().y() - app_list->bounds().height() / 2; | 201 app_list->anchor_rect().y() - app_list->bounds().height() / 2; |
| 187 const int kMinimalAppListMargin = 10; | 202 const int kMinimalAppListMargin = 10; |
| 188 | 203 |
| 189 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); | 204 EXPECT_GE(app_list_view_top, kMinimalAppListMargin); |
| 190 } | 205 } |
| 191 | 206 |
| 207 // Tests that the app list initializes in fullscreen with side shelf alignment | |
| 208 // and that the state transitions via text input act properly. | |
| 209 TEST_F(AppListPresenterDelegateTest, SideShelfAlignmentTextStateTransitions) { | |
| 210 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 211 if (Shell::GetAshConfig() == Config::MASH) | |
| 212 return; | |
| 213 | |
| 214 EnableFullscreenAppList(); | |
| 215 SetShelfAlignment(ShelfAlignment::SHELF_ALIGNMENT_LEFT); | |
|
vadimt
2017/06/21 00:05:59
Will this alignment stick and influence other test
newcomer
2017/06/21 16:34:47
I just tested this, it does not influence other te
| |
| 216 | |
| 217 // Open the app list with side shelf alignment, then check that it is in | |
| 218 // fullscreen mode. | |
| 219 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 220 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 221 EXPECT_TRUE(app_list->is_fullscreen()); | |
| 222 EXPECT_EQ(app_list->app_list_state(), | |
| 223 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 224 | |
| 225 // Enter text in the searchbox, the app list should transition to fullscreen | |
| 226 // search. | |
| 227 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 228 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 229 EXPECT_EQ(app_list->app_list_state(), | |
| 230 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 231 | |
| 232 // Delete the text in the searchbox, the app list should transition to | |
| 233 // fullscreen all apps. | |
| 234 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 235 EXPECT_EQ(app_list->app_list_state(), | |
| 236 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 237 } | |
| 238 | |
| 239 // Tests that the app list initializes in peeking with bottom shelf alignment | |
| 240 // and that the state transitions via text input act properly. | |
| 241 TEST_F(AppListPresenterDelegateTest, BottomShelfAlignmentTextStateTransitions) { | |
| 242 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 243 if (Shell::GetAshConfig() == Config::MASH) | |
| 244 return; | |
|
vadimt
2017/06/21 00:05:59
Empty line below.
newcomer
2017/06/21 16:34:47
Done.
| |
| 245 EnableFullscreenAppList(); | |
| 246 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 247 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 248 EXPECT_FALSE(app_list->is_fullscreen()); | |
| 249 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 250 | |
| 251 // Enter text in the searchbox, this should transition the app list to half | |
| 252 // state. | |
| 253 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 254 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 255 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 256 | |
| 257 // Empty the searchbox, this should transition the app list to it's previous | |
| 258 // state. | |
| 259 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 260 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 261 } | |
| 262 | |
| 263 // Tests that the app list initializes in fullscreen with maximize mode active | |
| 264 // and that the state transitions via text input act properly. | |
| 265 TEST_F(AppListPresenterDelegateTest, MaximizeModeTextStateTransitions) { | |
| 266 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 267 if (Shell::GetAshConfig() == Config::MASH) | |
| 268 return; | |
| 269 EnableFullscreenAppList(); | |
| 270 EnableMaximizeMode(true); | |
| 271 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 272 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 273 EXPECT_EQ(app_list->app_list_state(), | |
| 274 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 275 | |
| 276 // Enter text in the searchbox, the app list should transition to fullscreen | |
| 277 // search. | |
| 278 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 279 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 280 EXPECT_EQ(app_list->app_list_state(), | |
| 281 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 282 | |
| 283 // Delete the text in the searchbox, the app list should transition to | |
| 284 // fullscreen all apps. generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 285 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 286 EXPECT_EQ(app_list->app_list_state(), | |
| 287 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 288 } | |
| 289 | |
| 290 // Tests that the app list state responds correctly to maximize mode being | |
| 291 // enabled while the app list is being shown. | |
| 292 TEST_F(AppListPresenterDelegateTest, | |
| 293 PeekingToFullscreenWhenMaximizeModeIsActive) { | |
| 294 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 295 if (Shell::GetAshConfig() == Config::MASH) | |
| 296 return; | |
| 297 | |
| 298 EnableFullscreenAppList(); | |
| 299 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 300 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 301 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 302 // Enable maximize mode, this should force the app list to switch to the | |
| 303 // fullscreen equivalent of the current state. | |
| 304 EnableMaximizeMode(true); | |
| 305 EXPECT_EQ(app_list->app_list_state(), | |
| 306 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 307 // Disable maximize mode, the state of the app list should not change. | |
| 308 EnableMaximizeMode(false); | |
| 309 EXPECT_EQ(app_list->app_list_state(), | |
| 310 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 311 // Enter text in the searchbox, the app list should transition to fullscreen | |
| 312 // search. | |
| 313 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 314 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 315 EXPECT_EQ(app_list->app_list_state(), | |
| 316 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 317 | |
| 318 // Delete the text in the searchbox, the app list should transition to | |
| 319 // fullscreen all apps. generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 320 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 321 EXPECT_EQ(app_list->app_list_state(), | |
| 322 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 323 } | |
| 324 | |
| 325 // Tests that the app list state responds correctly to maximize mode being | |
| 326 // enabled while the app list is being shown with half launcher. | |
| 327 TEST_F(AppListPresenterDelegateTest, HalfToFullscreenWhenMaximizeModeIsActive) { | |
| 328 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 329 if (Shell::GetAshConfig() == Config::MASH) | |
| 330 return; | |
| 331 EnableFullscreenAppList(); | |
| 332 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 333 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 334 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 335 | |
| 336 // Enter text in the search box to transition to half app list. | |
| 337 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 338 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 339 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 340 | |
| 341 // Enable maximize mode and force the app list to transition to the fullscreen | |
| 342 // equivalent of the current state. | |
| 343 EnableMaximizeMode(true); | |
| 344 EXPECT_EQ(app_list->app_list_state(), | |
| 345 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 346 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 347 EXPECT_EQ(app_list->app_list_state(), | |
| 348 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 349 } | |
| 350 | |
| 351 // Tests that the app list view handles drag properly in laptop mode. | |
| 352 TEST_F(AppListPresenterDelegateTest, AppListViewDragHandler) { | |
| 353 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 354 if (Shell::GetAshConfig() == Config::MASH) | |
| 355 return; | |
| 356 | |
| 357 EnableFullscreenAppList(); | |
| 358 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 359 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 360 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 361 | |
| 362 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 363 // Execute a slow short upwards drag this should fail to transition the app | |
| 364 // list. | |
| 365 int top_of_app_list = app_list_presenter_impl() | |
| 366 ->GetView() | |
| 367 ->GetWidget() | |
| 368 ->GetWindowBoundsInScreen() | |
| 369 .y(); | |
| 370 generator.GestureScrollSequence(gfx::Point(0, top_of_app_list + 20), | |
| 371 gfx::Point(0, top_of_app_list - 20), | |
| 372 base::TimeDelta::FromMilliseconds(500), 50); | |
| 373 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 374 | |
| 375 // Execute a long upwards drag, this should transition the app list. | |
| 376 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 377 gfx::Point(10, 10), | |
| 378 base::TimeDelta::FromMilliseconds(100), 10); | |
| 379 EXPECT_EQ(app_list->app_list_state(), | |
| 380 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 381 | |
| 382 // Execute a short downward drag, this should fail to transition the app list. | |
| 383 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 100), | |
| 384 base::TimeDelta::FromMilliseconds(100), 10); | |
| 385 EXPECT_EQ(app_list->app_list_state(), | |
| 386 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 387 | |
| 388 // Execute a long downward drag, this should transition the app list. | |
| 389 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 900), | |
| 390 base::TimeDelta::FromMilliseconds(100), 10); | |
| 391 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 392 | |
| 393 // Transition to fullscreen. | |
| 394 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 395 gfx::Point(10, 10), | |
| 396 base::TimeDelta::FromMilliseconds(100), 10); | |
| 397 EXPECT_EQ(app_list->app_list_state(), | |
| 398 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 399 | |
| 400 // Enter text to transition to |FULLSCREEN_SEARCH|. | |
| 401 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 402 EXPECT_EQ(app_list->app_list_state(), | |
| 403 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 404 | |
| 405 // Execute a short downward drag, this should fail to close the app list. | |
| 406 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 100), | |
| 407 base::TimeDelta::FromMilliseconds(100), 10); | |
| 408 EXPECT_EQ(app_list->app_list_state(), | |
| 409 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 410 | |
| 411 // Execute a long downward drag, this should close the app list. | |
| 412 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 900), | |
| 413 base::TimeDelta::FromMilliseconds(100), 10); | |
| 414 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 415 } | |
| 416 | |
| 417 // Tests that the app list view handles drag properly in maximize mode. | |
| 418 TEST_F(AppListPresenterDelegateTest, | |
| 419 AppListViewDragHandlerMaximizeModeFromAllApps) { | |
| 420 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 421 if (Shell::GetAshConfig() == Config::MASH) | |
| 422 return; | |
| 423 EnableFullscreenAppList(); | |
| 424 EnableMaximizeMode(true); | |
| 425 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 426 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 427 EXPECT_EQ(app_list->app_list_state(), | |
| 428 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 429 | |
| 430 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 431 // Drag down. | |
| 432 generator.GestureScrollSequence(gfx::Point(0, 0), gfx::Point(0, 720), | |
| 433 base::TimeDelta::FromMilliseconds(100), 10); | |
| 434 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 435 } | |
| 436 | |
| 437 // Tests that the state of the app list changes properly with drag input from | |
| 438 // fullscreen search. | |
| 439 TEST_F(AppListPresenterDelegateTest, | |
| 440 AppListViewDragHandlerMaximizeModeFromSearch) { | |
| 441 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 442 if (Shell::GetAshConfig() == Config::MASH) | |
| 443 return; | |
| 444 | |
| 445 // Reset the app list. | |
| 446 EnableFullscreenAppList(); | |
| 447 EnableMaximizeMode(true); | |
| 448 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 449 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 450 EXPECT_EQ(app_list->app_list_state(), | |
| 451 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 452 // Type in the search box to transition to |FULLSCREEN_SEARCH|. | |
| 453 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 454 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 455 EXPECT_EQ(app_list->app_list_state(), | |
| 456 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 457 // Drag down, this should close the app list. | |
| 458 generator.GestureScrollSequence(gfx::Point(0, 0), gfx::Point(0, 720), | |
| 459 base::TimeDelta::FromMilliseconds(100), 10); | |
| 460 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 461 } | |
| 462 | |
| 463 // Tests that the bottom shelf background is hidden when the app list is shown | |
| 464 // in laptop mode. | |
| 465 TEST_F(AppListPresenterDelegateTest, | |
| 466 ShelfBackgroundIsHiddenWhenAppListIsShown) { | |
| 467 EnableFullscreenAppList(); | |
| 468 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 469 ShelfLayoutManager* shelf_layout_manager = | |
| 470 Shelf::ForWindow( | |
| 471 ShellPort::Get()->GetRootWindowForDisplayId(GetPrimaryDisplayId())) | |
| 472 ->shelf_layout_manager(); | |
| 473 EXPECT_TRUE(shelf_layout_manager->GetShelfBackgroundType() == | |
| 474 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT); | |
| 475 } | |
| 476 | |
| 192 // Tests that the peeking app list closes if the user taps outside its | 477 // Tests that the peeking app list closes if the user taps outside its |
| 193 // bounds. | 478 // bounds. |
| 194 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { | 479 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { |
| 195 EnableFullscreenAppList(); | 480 // Todo(Newcomer): Investigate mash failures crbug.com/726838 |
| 196 | 481 if (Shell::GetAshConfig() == Config::MASH) |
| 482 return; | |
| 483 | |
| 484 EnableFullscreenAppList(); | |
| 197 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 485 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 198 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 486 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 199 ui::test::EventGenerator& generator = GetEventGenerator(); | 487 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 200 | 488 |
| 201 // Grab the bounds of the search box, | 489 // Grab the bounds of the search box, |
| 202 // which is guaranteed to be inside the app list. | 490 // which is guaranteed to be inside the app list. |
| 203 gfx::Point tap_point = app_list_presenter_impl() | 491 gfx::Point tap_point = app_list_presenter_impl() |
| 204 ->GetView() | 492 ->GetView() |
| 205 ->search_box_widget() | 493 ->search_box_widget() |
| 206 ->GetContentsView() | 494 ->GetContentsView() |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 223 | 511 |
| 224 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 512 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 225 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 513 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 226 | 514 |
| 227 // Clicking outside the bounds closes the app list. | 515 // Clicking outside the bounds closes the app list. |
| 228 generator.MoveMouseTo(tap_point); | 516 generator.MoveMouseTo(tap_point); |
| 229 generator.ClickLeftButton(); | 517 generator.ClickLeftButton(); |
| 230 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 518 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 231 } | 519 } |
| 232 | 520 |
| 521 // Tests that the half app list closes if the user taps outside its bounds. | |
| 522 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesHalfAppList) { | |
| 523 // Todo(Newcomer): Investigate mash failures crbug.com/726838 | |
| 524 if (Shell::GetAshConfig() == Config::MASH) | |
| 525 return; | |
| 526 | |
| 527 EnableFullscreenAppList(); | |
| 528 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 529 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 530 | |
| 531 // Transition to half app list by entering text. | |
| 532 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 533 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 534 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 535 | |
| 536 // Grab the bounds of the search box, | |
| 537 // which is guaranteed to be inside the app list. | |
| 538 gfx::Point tap_point = app_list_presenter_impl() | |
| 539 ->GetView() | |
| 540 ->search_box_widget() | |
| 541 ->GetContentsView() | |
| 542 ->GetBoundsInScreen() | |
| 543 .CenterPoint(); | |
| 544 | |
| 545 // Tapping inside the bounds doesn't close the app list. | |
| 546 generator.GestureTapAt(tap_point); | |
| 547 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | |
| 548 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 549 | |
| 550 // Clicking inside the bounds doesn't close the app list. | |
| 551 generator.MoveMouseTo(tap_point); | |
| 552 generator.ClickLeftButton(); | |
| 553 EXPECT_TRUE(app_list_presenter_impl()->IsVisible()); | |
| 554 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 555 | |
| 556 // Tapping outside the bounds closes the app list. | |
| 557 generator.GestureTapAt(gfx::Point(10, 10)); | |
| 558 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 559 | |
| 560 // Reset the app list to half state. | |
| 561 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 562 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 563 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 564 | |
| 565 // Clicking outside the bounds closes the app list. | |
| 566 generator.MoveMouseTo(gfx::Point(10, 10)); | |
| 567 generator.ClickLeftButton(); | |
| 568 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 569 } | |
| 570 | |
| 233 } // namespace ash | 571 } // namespace ash |
| OLD | NEW |