Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Unified Diff: ash/app_list/app_list_presenter_delegate_unittest.cc

Issue 2952763002: SearchBoxView now enables/disables cursor based on user interaction. (Closed)
Patch Set: Removed filters that are going to dissapear anyways after rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 42eaa1309f31e61eaa4f1b3f6c3277d04d1b6c8e..d5c88d15e9f13a8a0d3cf07b575fb645bdca5933 100644
--- a/ash/app_list/app_list_presenter_delegate_unittest.cc
+++ b/ash/app_list/app_list_presenter_delegate_unittest.cc
@@ -18,11 +18,13 @@
#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/app_list/views/search_box_view.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/test/event_generator.h"
+#include "ui/views/controls/textfield/textfield.h"
namespace ash {
namespace {
@@ -47,12 +49,11 @@ class AppListPresenterDelegateTest : public test::AshTestBase,
void SetUp() override {
AshTestBase::SetUp();
- // If the current test is parameterized.
- if (testing::UnitTest::GetInstance()->current_test_info()->value_param()) {
- test_with_fullscreen_ = GetParam();
- if (test_with_fullscreen_)
- EnableFullscreenAppList();
+ if (testing::UnitTest::GetInstance()->current_test_info()->value_param() &&
+ GetParam()) {
+ EnableFullscreenAppList();
}
+
// Make the display big enough to hold the app list.
UpdateDisplay("1024x768");
}
@@ -64,16 +65,60 @@ class AppListPresenterDelegateTest : public test::AshTestBase,
private:
test::TestAppListViewPresenterImpl app_list_presenter_impl_;
- bool test_with_fullscreen_;
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(AppListPresenterDelegateTest);
};
+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
+ : 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
+ public testing::WithParamInterface<bool> {
+ public:
+ FullscreenAppListPresenterDelegateTest() {}
+ ~FullscreenAppListPresenterDelegateTest() override {}
+
+ app_list::AppListPresenterImpl* app_list_presenter_impl() {
+ return &app_list_presenter_impl_;
+ }
+
+ // testing::Test:
+ void SetUp() override {
+ AshTestBase::SetUp();
+
+ scoped_feature_list_.InitAndEnableFeature(
+ app_list::features::kEnableFullscreenAppList);
+
+ // Make the display big enough to hold the app list.
+ UpdateDisplay("1024x768");
+ }
+
+ int GetPointOutsideSearchbox(bool outside) {
+ gfx::Point searchbox_point = app_list_presenter_impl_.GetView()
+ ->search_box_view()
+ ->GetBoundsInScreen();
+
+ searchbox_point.Offset(0, outside ? -1 : 0);
+
+ return searchbox_point;
+ }
+
+ private:
+ test::TestAppListViewPresenterImpl app_list_presenter_impl_;
+ base::test::ScopedFeatureList scoped_feature_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(FullscreenAppListPresenterDelegateTest);
+};
+
// Instantiate the Boolean which is used to toggle the Fullscreen app list in
// the parameterized tests.
INSTANTIATE_TEST_CASE_P(, AppListPresenterDelegateTest, testing::Bool());
+// Instantiate the Boolean which is used to toggle mouse and touch events in
+// the parameterized tests.
+INSTANTIATE_TEST_CASE_P(,
+ FullscreenAppListPresenterDelegateTest,
+ testing::Bool());
+
// Tests that app list hides when focus moves to a normal window.
TEST_P(AppListPresenterDelegateTest, HideOnFocusOut) {
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
@@ -122,7 +167,7 @@ TEST_F(AppListPresenterDelegateTest, ClickOutsideBubbleClosesBubble) {
EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
}
-// Tests that clicking outside the app-list bubble closes it.
+// Tests that tapping outside the app-list bubble closes it.
TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) {
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
@@ -135,7 +180,7 @@ TEST_F(AppListPresenterDelegateTest, TapOutsideBubbleClosesBubble) {
generator.GestureTapAt(app_window_bounds.CenterPoint());
EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
- // Click outside the bubble. This should close it.
+ // Tap outside the bubble. This should close it.
gfx::Point point_outside =
gfx::Point(app_window_bounds.right(), app_window_bounds.y()) +
gfx::Vector2d(10, 0);
@@ -189,45 +234,192 @@ TEST_F(AppListPresenterDelegateTest, TinyDisplay) {
EXPECT_GE(app_list_view_top, kMinimalAppListMargin);
}
-// Tests that the peeking app list closes if the user taps outside its
-// bounds.
-TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) {
- EnableFullscreenAppList();
+// Tests that the peeking app list closes if the user taps or clicks outside
+// its bounds.
+TEST_P(FullscreenAppListPresenterDelegateTest,
+ TapAndClickOutsideClosesPeekingAppList) {
+ bool test_mouse_event = GetParam();
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(),
+ app_list::AppListView::PEEKING);
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ // Tapping inside the bounds doesn't close the app list.
+ gfx::Point tap_point = GetPointOutsideSearchbox(false);
+ if (test_mouse_event) {
+ generator.MoveMouseTo(tap_point);
+ generator.ClickLeftButton();
+ generator.ReleaseLeftButton();
+ } else {
+ generator.GestureTapAt(tap_point);
+ }
+ EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(),
+ app_list::AppListView::PEEKING);
+
+ // Tapping outside the bounds closes the app list.
+ tap_point.offset(0, 750);
+ if (test_mouse_event) {
+ generator.MoveMouseTo(tap_point);
+ generator.ClickLeftButton();
+ generator.ReleaseLeftButton();
+ } else {
+ generator.GestureTapAt(tap_point);
+ }
+ EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(),
+ app_list::AppListView::CLOSED);
+}
+
+// Tests that a keypress activates the searchbox and that clearing the searchbox
+// deactivates the searchbox.
+TEST_F(FullscreenAppListPresenterDelegateTest, KeyPressEnablesSearchBox) {
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
- EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
ui::test::EventGenerator& generator = GetEventGenerator();
+ app_list::SearchBoxView* search_box_view =
+ app_list_presenter_impl()->GetView()->search_box_view();
+ EXPECT_FALSE(search_box_view->is_search_box_active());
- // Grab the bounds of the search box,
- // which is guaranteed to be inside the app list.
- gfx::Point tap_point = app_list_presenter_impl()
- ->GetView()
- ->search_box_widget()
- ->GetContentsView()
- ->GetBoundsInScreen()
- .CenterPoint();
+ // Press any key, the search box should be active.
+ generator.PressKey(ui::VKEY_0, 0);
+ EXPECT_TRUE(search_box_view->is_search_box_active());
- // Tapping inside the bounds doesn't close the app list.
- generator.GestureTapAt(tap_point);
- EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
+ // Delete the text, the search box should be inactive.
+ search_box_view->ClearSearch();
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+}
- // Clicking inside the bounds doesn't close the app list.
- generator.MoveMouseTo(tap_point);
- generator.ClickLeftButton();
- EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
+// Tests that a tap/click on the AppListView from half launcher returns the
+// AppListView to Peeking, and that a tap/click on the AppListView from Peeking
+// closes the app list.
+TEST_P(FullscreenAppListPresenterDelegateTest,
+ StateTransitionsByTapAndClickingAppListBodyFromHalf) {
+ 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!
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView();
+ app_list::SearchBoxView* search_box_view = app_list_view->search_box_view();
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::PEEKING);
+
+ // Press a key, the AppListView should transition to half.
+ generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::HALF);
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Tap outside the search box, the AppListView should transition to Peeking
+ // and the search box should be inactive.
+ if (test_mouse_event) {
+ generator.MoveMouseTo(GetPointOutsideSearchBox());
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(GetPointOutsideSearchBox());
+ }
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::PEEKING);
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+
+ // Tap outside the search box again, the AppListView should hide.
+ if (test_mouse_event) {
+ generator.MoveMouseTo(GetPointOutsideSearchBox());
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(GetPointOutsideSearchBox());
+ }
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::CLOSED);
+}
- // Tapping outside the bounds closes the app list.
- tap_point.set_x(tap_point.x() + 750);
- generator.GestureTapAt(tap_point);
- EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
+// Tests that a tap/click on the AppListView from Fullscreen search returns the
+// AppListView to fullscreen all apps, and that a tap/click on the AppListView
+// from fullscreen all apps closes the app list.
+TEST_P(FullscreenAppListPresenterDelegateTest,
+ StateTransitionsByTappingAppListBodyFromFullscreen) {
+ bool test_mouse_event = GetParam();
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView();
+ app_list::SearchBoxView* search_box_view = app_list_view->search_box_view();
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ // Execute a long upwards drag, this should transition the app list to
+ // fullscreen.
+ int top_of_app_list =
khmel 2017/07/10 15:52:22 nit: const int ...
newcomer 2017/07/10 16:38:20 Done.
+ app_list_view->GetWidget()->GetWindowBoundsInScreen().y();
+ generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20),
+ gfx::Point(10, 10),
+ base::TimeDelta::FromMilliseconds(100), 10);
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::FULLSCREEN_ALL_APPS);
+
+ // Press a key, this should activate the searchbox and transition to
+ // fullscreen search.
+ generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::FULLSCREEN_SEARCH);
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Tap outside the searchbox, this should deactivate the searchbox and the
+ // applistview should return to fullscreen all apps.
+ if (test_mouse_event) {
+ generator.MoveMouseTo(GetPointOutsideSearchBox());
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(GetPointOutsideSearchBox());
+ }
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::FULLSCREEN_ALL_APPS);
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+
+ // Tap outside the searchbox again, this should close the applistview.
+ if (test_mouse_event) {
+ generator.MoveMouseTo(outside_search_box);
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(outside_search_box);
+ }
+ EXPECT_EQ(app_list_view->app_list_state(),
+ app_list::AppListView::AppListState::CLOSED);
+}
+
+// Tests that the searchbox activates when it is tapped and that the widget is
+// closed after tapping outside the searchbox.
+TEST_P(FullscreenAppListPresenterDelegateTest, TapAndClickEnablesSearchBox) {
+ bool test_mouse_event = GetParam();
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
- EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
+ app_list::SearchBoxView* search_box_view =
+ app_list_presenter_impl()->GetView()->search_box_view();
- // Clicking outside the bounds closes the app list.
- generator.MoveMouseTo(tap_point);
- generator.ClickLeftButton();
- EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
+ // Tap/Click the search box, it should activate.
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ if (test_mouse_event) {
+ generator.MoveMouseTo(GetPointOutsideSearchbox(false););
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ } else {
+ generator.GestureTapAt(GetPointOutsideSearchbox(false););
+ }
+
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Tap on the body of the app list, the search box should deactivate.
+ if (test_mouse_event) {
+ generator.MoveMouseTo(GetPointOutsideSearchBox(true));
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ } else {
+ generator.GestureTapAt(GetPointOutsideSearchBox(true));
+ }
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+ EXPECT_TRUE(app_list_presenter_impl()->IsVisible());
+
+ // Tap on the body of the app list again, the app list should hide.
+ if (test_mouse_event) {
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ } else {
+ generator.GestureTapAt(GetPointOutsideSearchbox(true));
+ }
+ EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(),
+ app_list::AppListView::AppListState::CLOSED);
}
} // namespace ash
« no previous file with comments | « no previous file | testing/buildbot/filters/ash_unittests_mash.filter » ('j') | ui/app_list/views/search_box_view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698