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 Shell::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; | |
|
oshima
2017/06/22 00:06:25
can you use filter instead? mustash team prefer th
newcomer
2017/06/22 17:17:24
Done.
| |
| 213 | |
| 214 EnableFullscreenAppList(); | |
| 215 SetShelfAlignment(ShelfAlignment::SHELF_ALIGNMENT_LEFT); | |
| 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; | |
| 245 | |
| 246 EnableFullscreenAppList(); | |
| 247 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 248 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 249 EXPECT_FALSE(app_list->is_fullscreen()); | |
| 250 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 251 | |
| 252 // Enter text in the searchbox, this should transition the app list to half | |
| 253 // state. | |
| 254 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 255 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 256 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 257 | |
| 258 // Empty the searchbox, this should transition the app list to it's previous | |
| 259 // state. | |
| 260 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 261 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 262 } | |
| 263 | |
| 264 // Tests that the app list initializes in fullscreen with maximize mode active | |
| 265 // and that the state transitions via text input act properly. | |
| 266 TEST_F(AppListPresenterDelegateTest, MaximizeModeTextStateTransitions) { | |
| 267 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 268 if (Shell::GetAshConfig() == Config::MASH) | |
| 269 return; | |
| 270 | |
| 271 EnableFullscreenAppList(); | |
| 272 EnableMaximizeMode(true); | |
| 273 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 274 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 275 EXPECT_EQ(app_list->app_list_state(), | |
| 276 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 277 | |
| 278 // Enter text in the searchbox, the app list should transition to fullscreen | |
| 279 // search. | |
| 280 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 281 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 282 EXPECT_EQ(app_list->app_list_state(), | |
| 283 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 284 | |
| 285 // Delete the text in the searchbox, the app list should transition to | |
| 286 // fullscreen all apps. generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 287 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 288 EXPECT_EQ(app_list->app_list_state(), | |
| 289 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 290 } | |
| 291 | |
| 292 // Tests that the app list state responds correctly to maximize mode being | |
| 293 // enabled while the app list is being shown. | |
| 294 TEST_F(AppListPresenterDelegateTest, | |
| 295 PeekingToFullscreenWhenMaximizeModeIsActive) { | |
| 296 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 297 if (Shell::GetAshConfig() == Config::MASH) | |
| 298 return; | |
| 299 | |
| 300 EnableFullscreenAppList(); | |
| 301 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 302 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 303 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 304 // Enable maximize mode, this should force the app list to switch to the | |
| 305 // fullscreen equivalent of the current state. | |
| 306 EnableMaximizeMode(true); | |
| 307 EXPECT_EQ(app_list->app_list_state(), | |
| 308 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 309 // Disable maximize mode, the state of the app list should not change. | |
| 310 EnableMaximizeMode(false); | |
| 311 EXPECT_EQ(app_list->app_list_state(), | |
| 312 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 313 // Enter text in the searchbox, the app list should transition to fullscreen | |
| 314 // search. | |
| 315 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 316 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 317 EXPECT_EQ(app_list->app_list_state(), | |
| 318 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 319 | |
| 320 // Delete the text in the searchbox, the app list should transition to | |
| 321 // fullscreen all apps. generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 322 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 323 EXPECT_EQ(app_list->app_list_state(), | |
| 324 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 325 } | |
| 326 | |
| 327 // Tests that the app list state responds correctly to maximize mode being | |
| 328 // enabled while the app list is being shown with half launcher. | |
| 329 TEST_F(AppListPresenterDelegateTest, HalfToFullscreenWhenMaximizeModeIsActive) { | |
| 330 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 331 if (Shell::GetAshConfig() == Config::MASH) | |
| 332 return; | |
| 333 | |
| 334 EnableFullscreenAppList(); | |
| 335 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 336 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 337 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 338 | |
| 339 // Enter text in the search box to transition to half app list. | |
| 340 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 341 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 342 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 343 | |
| 344 // Enable maximize mode and force the app list to transition to the fullscreen | |
| 345 // equivalent of the current state. | |
| 346 EnableMaximizeMode(true); | |
| 347 EXPECT_EQ(app_list->app_list_state(), | |
| 348 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 349 generator.PressKey(ui::KeyboardCode::VKEY_BACK, 0); | |
| 350 EXPECT_EQ(app_list->app_list_state(), | |
| 351 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 352 } | |
| 353 | |
| 354 // Tests that the app list view handles drag properly in laptop mode. | |
| 355 TEST_F(AppListPresenterDelegateTest, AppListViewDragHandler) { | |
| 356 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 357 if (Shell::GetAshConfig() == Config::MASH) | |
| 358 return; | |
| 359 | |
| 360 EnableFullscreenAppList(); | |
| 361 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 362 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 363 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 364 | |
| 365 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 366 // Execute a slow short upwards drag this should fail to transition the app | |
| 367 // list. | |
| 368 int top_of_app_list = app_list_presenter_impl() | |
| 369 ->GetView() | |
| 370 ->GetWidget() | |
| 371 ->GetWindowBoundsInScreen() | |
| 372 .y(); | |
| 373 generator.GestureScrollSequence(gfx::Point(0, top_of_app_list + 20), | |
| 374 gfx::Point(0, top_of_app_list - 20), | |
| 375 base::TimeDelta::FromMilliseconds(500), 50); | |
| 376 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 377 | |
| 378 // Execute a long upwards drag, this should transition the app list. | |
| 379 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 380 gfx::Point(10, 10), | |
| 381 base::TimeDelta::FromMilliseconds(100), 10); | |
| 382 EXPECT_EQ(app_list->app_list_state(), | |
| 383 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 384 | |
| 385 // Execute a short downward drag, this should fail to transition the app list. | |
| 386 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 100), | |
| 387 base::TimeDelta::FromMilliseconds(100), 10); | |
| 388 EXPECT_EQ(app_list->app_list_state(), | |
| 389 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 390 | |
| 391 // Execute a long downward drag, this should transition the app list. | |
| 392 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 900), | |
| 393 base::TimeDelta::FromMilliseconds(100), 10); | |
| 394 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::PEEKING); | |
| 395 | |
| 396 // Transition to fullscreen. | |
| 397 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 398 gfx::Point(10, 10), | |
| 399 base::TimeDelta::FromMilliseconds(100), 10); | |
| 400 EXPECT_EQ(app_list->app_list_state(), | |
| 401 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 402 | |
| 403 // Enter text to transition to |FULLSCREEN_SEARCH|. | |
| 404 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 405 EXPECT_EQ(app_list->app_list_state(), | |
| 406 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 407 | |
| 408 // Execute a short downward drag, this should fail to close the app list. | |
| 409 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 100), | |
| 410 base::TimeDelta::FromMilliseconds(100), 10); | |
| 411 EXPECT_EQ(app_list->app_list_state(), | |
| 412 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 413 | |
| 414 // Execute a long downward drag, this should close the app list. | |
| 415 generator.GestureScrollSequence(gfx::Point(10, 10), gfx::Point(10, 900), | |
| 416 base::TimeDelta::FromMilliseconds(100), 10); | |
| 417 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::CLOSED); | |
| 418 } | |
| 419 | |
| 420 // Tests that the app list view handles drag properly in maximize mode. | |
| 421 TEST_F(AppListPresenterDelegateTest, | |
| 422 AppListViewDragHandlerMaximizeModeFromAllApps) { | |
| 423 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 424 if (Shell::GetAshConfig() == Config::MASH) | |
| 425 return; | |
| 426 | |
| 427 EnableFullscreenAppList(); | |
| 428 EnableMaximizeMode(true); | |
| 429 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 430 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 431 EXPECT_EQ(app_list->app_list_state(), | |
| 432 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 433 | |
| 434 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 435 // Drag down. | |
| 436 generator.GestureScrollSequence(gfx::Point(0, 0), gfx::Point(0, 720), | |
| 437 base::TimeDelta::FromMilliseconds(100), 10); | |
| 438 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::CLOSED); | |
| 439 } | |
| 440 | |
| 441 // Tests that the state of the app list changes properly with drag input from | |
| 442 // fullscreen search. | |
| 443 TEST_F(AppListPresenterDelegateTest, | |
| 444 AppListViewDragHandlerMaximizeModeFromSearch) { | |
| 445 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 446 if (Shell::GetAshConfig() == Config::MASH) | |
| 447 return; | |
| 448 | |
| 449 // Reset the app list. | |
| 450 EnableFullscreenAppList(); | |
| 451 EnableMaximizeMode(true); | |
| 452 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 453 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 454 EXPECT_EQ(app_list->app_list_state(), | |
| 455 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 456 // Type in the search box to transition to |FULLSCREEN_SEARCH|. | |
| 457 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 458 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 459 EXPECT_EQ(app_list->app_list_state(), | |
| 460 app_list::AppListView::FULLSCREEN_SEARCH); | |
| 461 // Drag down, this should close the app list. | |
| 462 generator.GestureScrollSequence(gfx::Point(0, 0), gfx::Point(0, 720), | |
| 463 base::TimeDelta::FromMilliseconds(100), 10); | |
| 464 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::CLOSED); | |
| 465 } | |
| 466 | |
| 467 // Tests that the bottom shelf background is hidden when the app list is shown | |
| 468 // in laptop mode. | |
| 469 TEST_F(AppListPresenterDelegateTest, | |
| 470 ShelfBackgroundIsHiddenWhenAppListIsShown) { | |
| 471 EnableFullscreenAppList(); | |
| 472 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 473 ShelfLayoutManager* shelf_layout_manager = | |
| 474 Shelf::ForWindow( | |
| 475 Shell::GetRootWindowForDisplayId(GetPrimaryDisplayId())) | |
| 476 ->shelf_layout_manager(); | |
| 477 EXPECT_TRUE(shelf_layout_manager->GetShelfBackgroundType() == | |
| 478 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT); | |
| 479 } | |
| 480 | |
| 192 // Tests that the peeking app list closes if the user taps outside its | 481 // Tests that the peeking app list closes if the user taps outside its |
| 193 // bounds. | 482 // bounds. |
| 194 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { | 483 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) { |
| 195 EnableFullscreenAppList(); | 484 // TODO(newcomer): Investigate mash failures crbug.com/726838 |
| 196 | 485 if (Shell::GetAshConfig() == Config::MASH) |
| 486 return; | |
| 487 | |
| 488 EnableFullscreenAppList(); | |
| 197 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 489 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 198 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 490 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 199 ui::test::EventGenerator& generator = GetEventGenerator(); | 491 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 200 | 492 |
| 201 // Grab the bounds of the search box, | 493 // Grab the bounds of the search box, |
| 202 // which is guaranteed to be inside the app list. | 494 // which is guaranteed to be inside the app list. |
| 203 gfx::Point tap_point = app_list_presenter_impl() | 495 gfx::Point tap_point = app_list_presenter_impl() |
| 204 ->GetView() | 496 ->GetView() |
| 205 ->search_box_widget() | 497 ->search_box_widget() |
| 206 ->GetContentsView() | 498 ->GetContentsView() |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 223 | 515 |
| 224 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 516 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 225 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 517 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 226 | 518 |
| 227 // Clicking outside the bounds closes the app list. | 519 // Clicking outside the bounds closes the app list. |
| 228 generator.MoveMouseTo(tap_point); | 520 generator.MoveMouseTo(tap_point); |
| 229 generator.ClickLeftButton(); | 521 generator.ClickLeftButton(); |
| 230 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 522 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 231 } | 523 } |
| 232 | 524 |
| 525 // Tests that the half app list closes if the user taps outside its bounds. | |
| 526 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesHalfAppList) { | |
| 527 // TODO(newcomer): Investigate mash failures crbug.com/726838 | |
| 528 if (Shell::GetAshConfig() == Config::MASH) | |
| 529 return; | |
| 530 | |
| 531 EnableFullscreenAppList(); | |
| 532 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 533 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 534 | |
| 535 // Transition to half app list by entering text. | |
| 536 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 537 app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); | |
| 538 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 539 | |
| 540 // Grab the bounds of the search box, | |
| 541 // which is guaranteed to be inside the app list. | |
| 542 gfx::Point tap_point = app_list_presenter_impl() | |
| 543 ->GetView() | |
| 544 ->search_box_widget() | |
| 545 ->GetContentsView() | |
| 546 ->GetBoundsInScreen() | |
| 547 .CenterPoint(); | |
| 548 | |
| 549 // Tapping inside the bounds doesn't close the app list. | |
| 550 generator.GestureTapAt(tap_point); | |
| 551 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | |
| 552 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 553 | |
| 554 // Clicking inside the bounds doesn't close the app list. | |
| 555 generator.MoveMouseTo(tap_point); | |
| 556 generator.ClickLeftButton(); | |
| 557 EXPECT_TRUE(app_list_presenter_impl()->IsVisible()); | |
| 558 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 559 | |
| 560 // Tapping outside the bounds closes the app list. | |
| 561 generator.GestureTapAt(gfx::Point(10, 10)); | |
| 562 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 563 | |
| 564 // Reset the app list to half state. | |
| 565 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 566 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 567 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | |
| 568 | |
| 569 // Clicking outside the bounds closes the app list. | |
| 570 generator.MoveMouseTo(gfx::Point(10, 10)); | |
| 571 generator.ClickLeftButton(); | |
| 572 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | |
| 573 } | |
| 574 | |
| 233 } // namespace ash | 575 } // namespace ash |
| OLD | NEW |