Commit a84bbd13 authored by mohsen@chromium.org's avatar mohsen@chromium.org

Re-enable TouchCursorInTextfieldTest with some fixes and logs

Re-enabled TouchEditableImplAuraTest.TouchCursorInTextfieldTest with two
fixes:
 - Changed focus_textfield() in touch_seleciton.html to collapse
   selection after focus, since nothing should be selected after
   focusing the textfield.
 - Added a wait between dragging the handle and getting the cursor
   position in the test to be sure that the cursor position is updated
   completely.
Also, added some logs in the test so that if it failed again, more data
is available for investigation.

BUG=235991

Review URL: https://chromiumcodereview.appspot.com/23823004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221596 0039d316-1c4b-4281-b951-d872f2087c98
parent 2f87d88d
......@@ -294,6 +294,7 @@ class TouchEditableImplAuraTest : public ContentBrowserTest {
EXPECT_TRUE(touch_editable->touch_selection_controller_.get());
}
// TODO(mohsen): Remove logs if the test showed no flakiness anymore.
void TestTouchCursorInTextfield() {
ASSERT_NO_FATAL_FAILURE(
StartTestWithPage("files/touch_selection.html"));
......@@ -311,21 +312,28 @@ class TouchEditableImplAuraTest : public ContentBrowserTest {
aura::test::EventGenerator generator(content->GetRootWindow(), content);
gfx::Rect bounds = content->GetBoundsInRootWindow();
EXPECT_EQ(touch_editable->rwhva_, rwhva);
LOG(INFO) << "Focus the textfield.";
ExecuteSyncJSFunction(view_host, "focus_textfield()");
// Tap textfield
touch_editable->Reset();
LOG(INFO) << "Tap in the textfield.";
generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40));
LOG(INFO) << "Wait for tap-down ACK.";
touch_editable->WaitForGestureAck(); // Wait for Tap Down Ack
touch_editable->Reset();
LOG(INFO) << "Wait for tap ACK.";
touch_editable->WaitForGestureAck(); // Wait for Tap Ack.
LOG(INFO) << "Test the touch selection handle.";
// Check if cursor handle is showing.
ui::TouchSelectionController* controller =
touch_editable->touch_selection_controller_.get();
EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, touch_editable->text_input_type_);
EXPECT_TRUE(controller);
LOG(INFO) << "Test cursor position.";
scoped_ptr<base::Value> value =
content::ExecuteScriptAndGetValue(view_host, "get_cursor_position()");
int cursor_pos = -1;
......@@ -333,14 +341,18 @@ class TouchEditableImplAuraTest : public ContentBrowserTest {
EXPECT_NE(-1, cursor_pos);
// Move the cursor handle.
LOG(INFO) << "Drag the touch selection handle to change its position.";
generator.GestureScrollSequence(
gfx::Point(50, 59),
gfx::Point(10, 59),
base::TimeDelta::FromMilliseconds(20),
1);
LOG(INFO) << "Wait for cursor position to change.";
touch_editable->WaitForSelectionChangeCallback();
LOG(INFO) << "Check cursor position is changed.";
EXPECT_TRUE(touch_editable->touch_selection_controller_.get());
value = content::ExecuteScriptAndGetValue(
view_host, "get_cursor_position()");
value = content::ExecuteScriptAndGetValue(view_host,
"get_cursor_position()");
int new_cursor_pos = -1;
value->GetAsInteger(&new_cursor_pos);
EXPECT_NE(-1, new_cursor_pos);
......@@ -367,9 +379,8 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
TestTouchSelectionOnLongPress();
}
// TODO(miu): Disabled test due to flakiness. http://crbug.com/235991
IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
DISABLED_TouchCursorInTextfieldTest) {
TouchCursorInTextfieldTest) {
TestTouchCursorInTextfield();
}
......
......@@ -18,6 +18,8 @@ function get_selection() {
function focus_textfield() {
document.getElementById("textfield").focus();
// Focusing the textfiled selects its text. Collapse selection to a cursor.
window.getSelection().collapseToStart();
}
function get_cursor_position() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment