Chromium Code Reviews| Index: ash/app_list/app_list_presenter_delegate_unittest.cc |
| diff --git a/ash/app_list/app_list_presenter_delegate_unittest.cc b/ash/app_list/app_list_presenter_delegate_unittest.cc |
| index ab85c9417b322aec873a96006c57338988087765..f258d47f51cc50080cbbc479a86c4818f99adc76 100644 |
| --- a/ash/app_list/app_list_presenter_delegate_unittest.cc |
| +++ b/ash/app_list/app_list_presenter_delegate_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include <memory> |
| #include "ash/ash_switches.h" |
| +#include "ash/public/cpp/config.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| #include "ash/shell.h" |
| #include "ash/test/ash_test_base.h" |
| @@ -14,6 +15,8 @@ |
| #include "base/macros.h" |
| #include "base/test/scoped_feature_list.h" |
| #include "ui/app_list/app_list_features.h" |
| +#include "ui/app_list/app_list_switches.h" |
| +#include "ui/app_list/views/app_list_main_view.h" |
| #include "ui/app_list/views/app_list_view.h" |
| #include "ui/aura/test/test_windows.h" |
| #include "ui/aura/window.h" |
| @@ -54,12 +57,12 @@ class AppListPresenterDelegateTest : public test::AshTestBase, |
| UpdateDisplay("1024x768"); |
| } |
| - private: |
| void EnableFullscreenAppList() { |
| scoped_feature_list_.InitAndEnableFeature( |
| app_list::features::kEnableFullscreenAppList); |
| } |
| + private: |
| test::TestAppListViewPresenterImpl app_list_presenter_impl_; |
| bool test_with_fullscreen_; |
| base::test::ScopedFeatureList scoped_feature_list_; |
| @@ -186,4 +189,66 @@ TEST_F(AppListPresenterDelegateTest, TinyDisplay) { |
| EXPECT_GE(app_list_view_top, kMinimalAppListMargin); |
| } |
| +// Tests that the peeking launcher is enlarged to fullscreen after the user |
| +// types in the search box. |
| +TEST_F(AppListPresenterDelegateTest, SnapToFullscreenAfterSearchboxInput) { |
| + // TODO(newcomer): investigate failure in mash. http://crbug.com/726838. |
| + if (Shell::GetAshConfig() == Config::MASH) |
| + return; |
| + |
| + EnableFullscreenAppList(); |
| + UpdateDisplay("1024x768"); |
| + EXPECT_TRUE(app_list::features::IsFullscreenAppListEnabled()); |
| + app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| + app_list::AppListView* app_list = app_list_presenter_impl()->GetView(); |
| + // Check that it is in peeking mode. |
| + EXPECT_FALSE(app_list->IsFullscreen()); |
| + |
| + // Dummy key event to search box. |
| + ui::test::EventGenerator& generator = GetEventGenerator(); |
| + generator.PressKey(ui::KeyboardCode::VKEY_0, 0); |
| + // Check that it is in fullscreen mode. |
| + EXPECT_TRUE(app_list->IsFullscreen()); |
| +} |
| + |
| +// Tests that the peeking launcher closes if the user taps outside it's |
|
msw
2017/06/06 17:56:31
nit: its (no apostrophe)
newcomer
2017/06/06 23:26:27
Done.
|
| +// bounds. |
| +TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingLauncher) { |
| + EnableFullscreenAppList(); |
| + |
| + app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
|
msw
2017/06/06 17:56:31
nit: EXPECT_TRUE(app_list_presenter_impl()->GetTar
newcomer
2017/06/06 23:26:27
Done.
|
| + ui::test::EventGenerator& generator = GetEventGenerator(); |
| + |
| + // Grab the bounds of the search box, |
| + // which is guaranteed to be inside the launcher. |
| + gfx::Rect search_box_bounds = app_list_presenter_impl() |
|
msw
2017/06/06 17:56:31
optional nit: inline this in the |tap_point| assig
newcomer
2017/06/06 23:26:27
Done.
|
| + ->GetView() |
| + ->search_box_widget() |
| + ->GetContentsView() |
| + ->GetBoundsInScreen(); |
| + gfx::Point tap_point = search_box_bounds.CenterPoint(); |
| + |
| + // Tapping inside the bounds doesn't close the launcher. |
| + generator.GestureTapAt(tap_point); |
| + EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| + |
| + // Clicking inside the bounds doesn't close the launcher. |
| + generator.MoveMouseTo(tap_point); |
| + generator.ClickLeftButton(); |
| + EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| + |
| + // Tapping outside the bounds closes the launcher. |
| + tap_point.set_x(tap_point.x() + 750); |
| + generator.GestureTapAt(tap_point); |
| + EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| + |
| + app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| + EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| + |
| + // Clicking outside the bounds closes the launcher. |
| + generator.MoveMouseTo(tap_point); |
| + generator.ClickLeftButton(); |
| + EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| +} |
| + |
| } // namespace ash |