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

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, 6 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..f0a330ff7366a0ea73ff1f01e6e97cc789b0ba87 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 {
@@ -230,4 +232,184 @@ 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(AppListPresenterDelegateTest, KeyPressEnablesSearchBox) {
+ EnableFullscreenAppList();
+
+ 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 the searchbox activates when it is clicked and that the searchbox
+// is inactive after clicking the app list body.
+TEST_F(AppListPresenterDelegateTest, ClickEnablesSearchBox) {
+ EnableFullscreenAppList();
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ app_list::SearchBoxView* search_box_view =
+ app_list_presenter_impl()->GetView()->search_box_view();
+
+ // Click the searchbox, the search box should be active.
+ gfx::Point search_box_point =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ generator.MoveMouseTo(search_box_point);
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+ EXPECT_TRUE(app_list_presenter_impl()->GetView()->app_list_state() ==
+ app_list::AppListView::AppListState::PEEKING);
+
+ // Click outside the search box, the searchbox should be disabled.
+ search_box_point.set_x(20);
+ generator.MoveMouseTo(search_box_point);
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ 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(AppListPresenterDelegateTest,
+ StateTransitionsByTapAndClickingAppListBodyFromHalf) {
+ if (!GetParam())
+ EnableFullscreenAppList();
oshima 2017/07/05 19:11:59 If you enable it anyway, why this has to be parame
newcomer 2017/07/05 22:03:57 I couldn't find a way to create multiple parameter
oshima 2017/07/06 16:04:12 You should create a separate base class, which alw
+
+ 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() ==
+ 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() ==
+ 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);
+ if (GetParam()) {
+ 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);
+ 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 (GetParam()) {
+ 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::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(AppListPresenterDelegateTest,
+ StateTransitionsByTappingAppListBodyFromFullscreen) {
+ if (!GetParam())
+ EnableFullscreenAppList();
+
+ 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);
+ 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);
+ if (GetParam()) {
+ 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 (GetParam()) {
+ 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::CLOSED);
+}
+
+// Tests that the searchbox activates when it is tapped and that the widget is
+// closed after tapping outside the searchbox.
+TEST_F(AppListPresenterDelegateTest, TapEnablesSearchBox) {
+ EnableFullscreenAppList();
+ app_list_presenter_impl()->Show(GetPrimaryDisplayId());
+ app_list::SearchBoxView* search_box_view =
+ app_list_presenter_impl()->GetView()->search_box_view();
+
+ // Tap the search box, it should activate.
+ gfx::Point search_box_point =
+ search_box_view->search_box()->GetBoundsInScreen().CenterPoint();
+ ui::test::EventGenerator& generator = GetEventGenerator();
+ generator.GestureTapAt(search_box_point);
+ 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);
+ generator.GestureTapAt(search_box_point);
+ 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.
+ generator.GestureTapAt(search_box_point);
+ 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/app_list_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698