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

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: SearchBoxView now enables/disables cursor based on user interaction. 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..b494dbeb339191d804e763ba0fe6377c442cb300 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,10 @@ 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();
oshima 2017/07/06 21:05:51 nit: you need {} in this case
newcomer 2017/07/10 15:24:06 Done.
+
// Make the display big enough to hold the app list.
UpdateDisplay("1024x768");
}
@@ -64,16 +64,50 @@ 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
+ : public test::AshTestBase,
+ 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");
+ }
+
+ 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 +156,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());
@@ -191,9 +225,8 @@ TEST_F(AppListPresenterDelegateTest, TinyDisplay) {
// Tests that the peeking app list closes if the user taps outside its
// bounds.
-TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) {
- EnableFullscreenAppList();
-
+TEST_F(FullscreenAppListPresenterDelegateTest,
+ TapAndClickOutsideClosesPeekingAppList) {
app_list_presenter_impl()->Show(GetPrimaryDisplayId());
EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility());
ui::test::EventGenerator& generator = GetEventGenerator();
@@ -230,4 +263,169 @@ TEST_F(AppListPresenterDelegateTest, TapAndClickOutsideClosesPeekingAppList) {
EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility());
}
+// 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());
+ 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());
+
+ // Press any key, the search box should be active.
+ generator.PressKey(ui::VKEY_0, 0);
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Delete the text, the search box should be inactive.
+ search_box_view->ClearSearch();
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+}
+
+// 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 tap_or_click = GetParam();
oshima 2017/07/06 21:05:51 test_mouse_event (a_or_b sounds like it's true for
newcomer 2017/07/10 15:24:07 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_TRUE(app_list_view->app_list_state() ==
oshima 2017/07/06 21:05:51 nit: EXPECT_EQ
newcomer 2017/07/10 15:24:06 Done.
+ app_list::AppListView::AppListState::PEEKING);
+
+ // Press a key, the AppListView should transition to half.
+ generator.PressKey(ui::KeyboardCode::VKEY_0, 0);
+ EXPECT_TRUE(app_list_view->app_list_state() ==
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:04 Done.
+ 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.
+ gfx::Point outside_search_box =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ outside_search_box.set_x(20);
oshima 2017/07/06 21:05:51 how about BoundsInScreen().top_right() Offset(0,
newcomer 2017/07/10 15:24:08 Done.
+ if (tap_or_click) {
+ generator.MoveMouseTo(outside_search_box);
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(outside_search_box);
+ }
+ EXPECT_TRUE(app_list_view->app_list_state() ==
+ app_list::AppListView::AppListState::PEEKING);
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:04 Done.
+ EXPECT_FALSE(search_box_view->is_search_box_active());
+
+ // Tap outside the search box again, the AppListView should hide.
+ outside_search_box =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ outside_search_box.set_x(20);
+ if (tap_or_click) {
+ generator.MoveMouseTo(outside_search_box);
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(outside_search_box);
+ }
+ EXPECT_TRUE(app_list_view->app_list_state() ==
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:04 Done.
+ app_list::AppListView::AppListState::CLOSED);
+}
+
+// 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 tap_or_click = 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 =
+ 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_TRUE(app_list_view->app_list_state() ==
+ app_list::AppListView::AppListState::FULLSCREEN_SEARCH);
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:04 Done.
+ 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.
+ gfx::Point outside_search_box =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ outside_search_box.set_x(20);
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:06 Done.
+ if (tap_or_click) {
+ generator.MoveMouseTo(outside_search_box);
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(outside_search_box);
+ }
+ EXPECT_TRUE(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 (tap_or_click) {
+ generator.MoveMouseTo(outside_search_box);
+ generator.ClickLeftButton();
+ } else {
+ generator.GestureTapDownAndUp(outside_search_box);
+ }
+ EXPECT_TRUE(app_list_view->app_list_state() ==
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:07 Done.
+ 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, TapOrClickEnablesSearchBox) {
+ bool tap_or_click = GetParam();
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ app_list::SearchBoxView* search_box_view =
+ app_list_presenter_impl()->GetView()->search_box_view();
+
+ // Tap/Click the search box, it should activate.
+ gfx::Point search_box_point =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ if (tap_or_click) {
+ generator.GestureTapAt(search_box_point);
+ } else {
+ generator.MoveMouseTo(search_box_point);
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ }
+
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Tap on the body of the app list, the search box should deactivate.
+ search_box_point.set_x(20);
oshima 2017/07/06 21:05:51 ditto
newcomer 2017/07/10 15:24:04 Done.
+ if (tap_or_click) {
+ generator.GestureTapAt(search_box_point);
+ } else {
+ generator.MoveMouseTo(search_box_point);
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ }
+ 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 (tap_or_click) {
+ generator.GestureTapAt(search_box_point);
+ } else {
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ }
+ EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(),
+ app_list::AppListView::AppListState::CLOSED);
+}
+
} // namespace ash
« no previous file with comments | « ash/app_list/app_list_delegate_impl.cc ('k') | ash/app_list/app_list_presenter_delegate_unittest.cc.autosave » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698