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

Unified Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 103293004: No touch handles when Views textfield cannot get focused (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated after r288781 Created 6 years, 4 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
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index f29c0a40e0265b10c448fe43af905b8efb76c564..bd4c76be88d2c3fb56fa78e0289af08083ed25e0 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -327,6 +327,29 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
textfield_->OnMouseReleased(release);
}
+ // Simulates a complete tap.
+ void Tap(const gfx::Point& point) {
+ GestureEventForTest begin(
+ ui::ET_GESTURE_BEGIN, point.x(), point.y(), 0.0f, 0.0f);
+ textfield_->OnGestureEvent(&begin);
+
+ GestureEventForTest tap_down(
+ ui::ET_GESTURE_TAP_DOWN, point.x(), point.y(), 0.0f, 0.0f);
+ textfield_->OnGestureEvent(&tap_down);
+
+ GestureEventForTest show_press(
+ ui::ET_GESTURE_SHOW_PRESS, point.x(), point.y(), 0.0f, 0.0f);
+ textfield_->OnGestureEvent(&show_press);
+
+ GestureEventForTest tap(
+ ui::ET_GESTURE_TAP, point.x(), point.y(), 1.0f, 0.0f);
+ textfield_->OnGestureEvent(&tap);
+
+ GestureEventForTest end(
+ ui::ET_GESTURE_END, point.x(), point.y(), 0.0f, 0.0f);
+ textfield_->OnGestureEvent(&end);
+ }
+
void VerifyTextfieldContextMenuContents(bool textfield_has_selection,
bool can_undo,
ui::MenuModel* menu) {
@@ -1973,6 +1996,29 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
}
#endif
+TEST_F(TextfieldTest, TouchSelectionInUnfocusableTextfield) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
+
+ InitTextfield();
+ textfield_->SetText(ASCIIToUTF16("hello world"));
+ gfx::Point touch_point(GetCursorPositionX(2), 0);
+
+ // Disable textfield and tap on it. Touch text selection should not get
+ // activated.
+ textfield_->SetEnabled(false);
+ Tap(touch_point);
+ EXPECT_FALSE(test_api_->touch_selection_controller());
+ textfield_->SetEnabled(true);
+
+ // Make textfield unfocusable and tap on it. Touch text selection should not
+ // get activated.
+ textfield_->SetFocusable(false);
+ Tap(touch_point);
+ EXPECT_FALSE(textfield_->HasFocus());
+ EXPECT_FALSE(test_api_->touch_selection_controller());
+ textfield_->SetFocusable(true);
+}
+
// Long_Press gesture in Textfield can initiate a drag and drop now.
TEST_F(TextfieldTest, TestLongPressInitiatesDragDrop) {
InitTextfield();
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698