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

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: Addressed Comments, refactored. 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..874931a85999fa692edc59d8ecf9c9b74f04c16a 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,79 @@ 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 cursor should enable and the placeholder text
+ // should be aligned left
+ generator.PressKey(ui::VKEY_0, 0);
+ EXPECT_TRUE(search_box_view->is_search_box_active());
+
+ // Delete the text, the cursor should return to its previous state with the
+ // placeholder text back in place.
+ 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 widget is
+// closed after clicking outside the searchbox.
+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());
+
+ // Click outside the search box, the widget should close.
+ gfx::Point app_list_point = app_list_presenter_impl()
+ ->GetView()
+ ->GetWidget()
+ ->GetWindowBoundsInScreen()
+ .CenterPoint();
+ generator.MoveMouseTo(app_list_point);
+ generator.PressLeftButton();
+ generator.ReleaseLeftButton();
+ EXPECT_FALSE(app_list_presenter_impl()->IsVisible());
+}
+
+// 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 app list should hide.
+ gfx::Point app_list_point = app_list_presenter_impl()
+ ->GetView()
+ ->GetWidget()
+ ->GetWindowBoundsInScreen()
+ .CenterPoint();
+ generator.GestureTapAt(app_list_point);
+ EXPECT_FALSE(app_list_presenter_impl()->IsVisible());
+}
} // 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.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698