| 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/shelf_types.h" | 9 #include "ash/public/cpp/shelf_types.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/test_app_list_view_presenter_impl.h" | 16 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 17 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 17 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/test/scoped_feature_list.h" | 21 #include "base/test/scoped_feature_list.h" |
| 22 #include "ui/app_list/app_list_features.h" | 22 #include "ui/app_list/app_list_features.h" |
| 23 #include "ui/app_list/app_list_switches.h" | 23 #include "ui/app_list/app_list_switches.h" |
| 24 #include "ui/app_list/views/app_list_main_view.h" | 24 #include "ui/app_list/views/app_list_main_view.h" |
| 25 #include "ui/app_list/views/app_list_view.h" | 25 #include "ui/app_list/views/app_list_view.h" |
| 26 #include "ui/app_list/views/search_box_view.h" |
| 26 #include "ui/aura/test/test_windows.h" | 27 #include "ui/aura/test/test_windows.h" |
| 27 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/display/screen.h" | 30 #include "ui/display/screen.h" |
| 30 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
| 31 | 32 |
| 32 namespace ash { | 33 namespace ash { |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 int64_t GetPrimaryDisplayId() { | 36 int64_t GetPrimaryDisplayId() { |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 generator.MoveMouseTo(tap_point); | 492 generator.MoveMouseTo(tap_point); |
| 492 generator.ClickLeftButton(); | 493 generator.ClickLeftButton(); |
| 493 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 494 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 494 } | 495 } |
| 495 | 496 |
| 496 // Tests that the shelf background displays/hides with bottom shelf | 497 // Tests that the shelf background displays/hides with bottom shelf |
| 497 // alignment. | 498 // alignment. |
| 498 TEST_F(AppListPresenterDelegateTest, | 499 TEST_F(AppListPresenterDelegateTest, |
| 499 ShelfBackgroundRespondsToAppListBeingShown) { | 500 ShelfBackgroundRespondsToAppListBeingShown) { |
| 500 // TODO(newcomer): Investigate mash failures crbug.com/726838 | 501 // TODO(newcomer): Investigate mash failures crbug.com/726838 |
| 501 if (Shell::GetAshConfig() == Config::MASH) | 502 if (Shell::GetAshConfig() == Config::MASH) |
| 502 return; | 503 return; |
| 503 EnableFullscreenAppList(); | 504 EnableFullscreenAppList(); |
| 504 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 505 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 505 | 506 |
| 506 // Show the app list, the shelf background should be transparent. | 507 // Show the app list, the shelf background should be transparent. |
| 507 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 508 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 508 ShelfLayoutManager* shelf_layout_manager = | 509 ShelfLayoutManager* shelf_layout_manager = |
| 509 GetPrimaryShelf()->shelf_layout_manager(); | 510 GetPrimaryShelf()->shelf_layout_manager(); |
| 510 EXPECT_EQ(shelf_layout_manager->GetShelfBackgroundType(), | 511 EXPECT_EQ(shelf_layout_manager->GetShelfBackgroundType(), |
| 511 SHELF_BACKGROUND_DEFAULT); | 512 SHELF_BACKGROUND_DEFAULT); |
| 512 app_list_presenter_impl()->Dismiss(); | 513 app_list_presenter_impl()->Dismiss(); |
| 513 | 514 |
| 514 // Set the alignment to the side and show the app list. The background should | 515 // Set the alignment to the side and show the app list. The background should |
| 515 // show. | 516 // show. |
| 516 GetPrimaryShelf()->SetAlignment(ShelfAlignment::SHELF_ALIGNMENT_LEFT); | 517 GetPrimaryShelf()->SetAlignment(ShelfAlignment::SHELF_ALIGNMENT_LEFT); |
| 517 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 518 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 518 EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled()); | 519 EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled()); |
| 519 EXPECT_FALSE(GetPrimaryShelf()->IsHorizontalAlignment()); | 520 EXPECT_FALSE(GetPrimaryShelf()->IsHorizontalAlignment()); |
| 520 EXPECT_EQ(GetPrimaryShelf()->shelf_layout_manager()-> | 521 EXPECT_EQ(GetPrimaryShelf()->shelf_layout_manager()->GetShelfBackgroundType(), |
| 521 GetShelfBackgroundType(), | |
| 522 SHELF_BACKGROUND_DEFAULT); | 522 SHELF_BACKGROUND_DEFAULT); |
| 523 } | 523 } |
| 524 | 524 |
| 525 // Tests that the half app list closes if the user taps outside its bounds. | 525 // Tests that the half app list closes if the user taps outside its bounds. |
| 526 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesHalfAppList) { | 526 TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesHalfAppList) { |
| 527 // TODO(newcomer): Investigate mash failures crbug.com/726838 | 527 // TODO(newcomer): Investigate mash failures crbug.com/726838 |
| 528 EnableFullscreenAppList(); | 528 EnableFullscreenAppList(); |
| 529 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 529 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 530 ui::test::EventGenerator& generator = GetEventGenerator(); | 530 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 531 | 531 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 562 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 562 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 563 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | 563 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); |
| 564 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); | 564 EXPECT_EQ(app_list->app_list_state(), app_list::AppListView::HALF); |
| 565 | 565 |
| 566 // Clicking outside the bounds closes the app list. | 566 // Clicking outside the bounds closes the app list. |
| 567 generator.MoveMouseTo(gfx::Point(10, 10)); | 567 generator.MoveMouseTo(gfx::Point(10, 10)); |
| 568 generator.ClickLeftButton(); | 568 generator.ClickLeftButton(); |
| 569 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); | 569 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 // Tests that the app list transitions on mousewheel and gesture scroll events. |
| 573 TEST_P(AppListPresenterDelegateTest, MouseWheelAndGestureScrollTransition) { |
| 574 if (!GetParam()) |
| 575 EnableFullscreenAppList(); // TODO FOR THIS CL: on rebase, change this to |
| 576 // class FullscreenAppListPresenterDelegateTest |
| 577 |
| 578 bool test_mouse_event = GetParam(); |
| 579 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 580 app_list::AppListView* view = app_list_presenter_impl()->GetView(); |
| 581 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 582 gfx::Point inside_search_box = view->app_list_main_view() |
| 583 ->search_box_view() |
| 584 ->GetBoundsInScreen() |
| 585 .origin(); |
| 586 EXPECT_EQ(view->app_list_state(), app_list::AppListView::PEEKING); |
| 587 |
| 588 // Move mouse to over the searchbox, mousewheel scroll up. |
| 589 generator.MoveMouseTo(inside_search_box); |
| 590 if (test_mouse_event) { |
| 591 generator.MoveMouseWheel(0, -30); |
| 592 } else { |
| 593 generator.ScrollSequence( |
| 594 inside_search_box, base::TimeDelta::FromMilliseconds(5), 0, -300, 2, 2); |
| 595 } |
| 596 EXPECT_EQ(view->app_list_state(), app_list::AppListView::FULLSCREEN_ALL_APPS); |
| 597 |
| 598 // swipe down, the app list should return to peeking mode. |
| 599 gfx::Point start = gfx::Point(0, 0); |
| 600 generator.GestureScrollSequence(start, gfx::Point(0, 720), |
| 601 base::TimeDelta::FromMilliseconds(100), 10); |
| 602 EXPECT_EQ(view->app_list_state(), app_list::AppListView::PEEKING); |
| 603 |
| 604 // Move mouse away from the searchbox, mousewheel scroll up. |
| 605 gfx::Point outside_search_box = view->GetBoundsInScreen().origin(); |
| 606 generator.MoveMouseTo(outside_search_box); |
| 607 if (test_mouse_event) { |
| 608 generator.MoveMouseWheel(0, -30); |
| 609 } else { |
| 610 generator.ScrollSequence(outside_search_box, |
| 611 base::TimeDelta::FromMilliseconds(5), 0, -300, 2, |
| 612 2); |
| 613 } |
| 614 EXPECT_EQ(view->app_list_state(), app_list::AppListView::FULLSCREEN_ALL_APPS); |
| 615 } |
| 616 |
| 572 } // namespace ash | 617 } // namespace ash |
| OLD | NEW |