Commit 7ed41e75 authored by tdresser@chromium.org's avatar tdresser@chromium.org

Make tap gesture ignore its ack disposition.

BUG=302852,275611
TEST=ImmediateInputRouterTest.GestureTypesIgnoringAck

Review URL: https://codereview.chromium.org/84653006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243713 0039d316-1c4b-4281-b951-d872f2087c98
parent 1ee6a6d0
...@@ -8,6 +8,7 @@ import android.test.suitebuilder.annotation.MediumTest; ...@@ -8,6 +8,7 @@ import android.test.suitebuilder.annotation.MediumTest;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -98,7 +99,12 @@ public class AutofillPopupTest extends ChromiumTestShellTestBase { ...@@ -98,7 +99,12 @@ public class AutofillPopupTest extends ChromiumTestShellTestBase {
waitForKeyboardShowRequest(immw, 1); waitForKeyboardShowRequest(immw, 1);
view.getContentViewCore().getInputConnectionForTest().setComposingText("J", 1); ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
view.getContentViewCore().getInputConnectionForTest().setComposingText("J", 1);
}
});
waitForAnchorViewAdd(view); waitForAnchorViewAdd(view);
View anchorView = view.findViewById(R.id.autofill_popup_window); View anchorView = view.findViewById(R.id.autofill_popup_window);
......
...@@ -880,32 +880,41 @@ TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) { ...@@ -880,32 +880,41 @@ TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) {
// Test that GestureShowPress events don't get out of order due to // Test that GestureShowPress events don't get out of order due to
// ignoring their acks. // ignoring their acks.
TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) {
SimulateGestureEvent(WebInputEvent::GestureTap, // GesturePinchBegin ignores its ack.
SimulateGestureEvent(WebInputEvent::GesturePinchBegin,
WebGestureEvent::Touchscreen); WebGestureEvent::Touchscreen);
EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
// GesturePinchBegin waits for an ack.
SimulateGestureEvent(WebInputEvent::GesturePinchUpdate,
WebGestureEvent::Touchscreen);
EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
SimulateGestureEvent(WebInputEvent::GestureShowPress, SimulateGestureEvent(WebInputEvent::GestureShowPress,
WebGestureEvent::Touchscreen); WebGestureEvent::Touchscreen);
EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
// The ShowPress, though it ignores ack, is still stuck in the queue // The ShowPress, though it ignores ack, is still stuck in the queue
// behind the Tap which requires an ack. // behind the PinchUpdate which requires an ack.
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
SimulateGestureEvent(WebInputEvent::GestureShowPress, SimulateGestureEvent(WebInputEvent::GestureShowPress,
WebGestureEvent::Touchscreen); WebGestureEvent::Touchscreen);
EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
// ShowPress has entered the queue. // ShowPress has entered the queue.
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
SendInputEventACK(WebInputEvent::GestureTap, // This ack is ignored.
SendInputEventACK(WebInputEvent::GesturePinchBegin,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED); INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
SendInputEventACK(WebInputEvent::GesturePinchUpdate,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
// Now that the Tap has been ACKed, the ShowPress events should receive // Now that the Tap has been ACKed, the ShowPress events should receive
// synthetics acks, and fire immediately. // synthetic acks, and fire immediately.
EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount());
} }
......
...@@ -328,10 +328,9 @@ class TouchEditableImplAuraTest : public ContentBrowserTest { ...@@ -328,10 +328,9 @@ class TouchEditableImplAuraTest : public ContentBrowserTest {
// Tap textfield // Tap textfield
touch_editable->Reset(); touch_editable->Reset();
generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40));
// Tap Down and Tap acks are sent synchronously.
touch_editable->WaitForSelectionChangeCallback(); touch_editable->WaitForSelectionChangeCallback();
// No Tap Down Ack is coming, it's async.
touch_editable->Reset(); touch_editable->Reset();
touch_editable->WaitForGestureAck(); // Wait for Tap Ack.
// Check if cursor handle is showing. // Check if cursor handle is showing.
ui::TouchSelectionController* controller = ui::TouchSelectionController* controller =
......
...@@ -289,6 +289,7 @@ bool WebInputEventTraits::IgnoresAckDisposition( ...@@ -289,6 +289,7 @@ bool WebInputEventTraits::IgnoresAckDisposition(
case WebInputEvent::GestureTapDown: case WebInputEvent::GestureTapDown:
case WebInputEvent::GestureShowPress: case WebInputEvent::GestureShowPress:
case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTap:
case WebInputEvent::GesturePinchBegin: case WebInputEvent::GesturePinchBegin:
case WebInputEvent::GesturePinchEnd: case WebInputEvent::GesturePinchEnd:
case WebInputEvent::GestureScrollBegin: case WebInputEvent::GestureScrollBegin:
......
...@@ -83,7 +83,7 @@ public class ImeTest extends ContentShellTestBase { ...@@ -83,7 +83,7 @@ public class ImeTest extends ContentShellTestBase {
@MediumTest @MediumTest
@Feature({"TextInput", "Main"}) @Feature({"TextInput", "Main"})
public void testKeyboardDismissedAfterClickingGo() throws Throwable { public void testKeyboardDismissedAfterClickingGo() throws Throwable {
mConnection.setComposingText("hello", 1); setComposingText(mConnection, "hello", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5);
performGo(getAdapterInputConnection(), mCallbackContainer); performGo(getAdapterInputConnection(), mCallbackContainer);
...@@ -95,19 +95,19 @@ public class ImeTest extends ContentShellTestBase { ...@@ -95,19 +95,19 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest @SmallTest
@Feature({"TextInput", "Main"}) @Feature({"TextInput", "Main"})
public void testGetTextUpdatesAfterEnteringText() throws Throwable { public void testGetTextUpdatesAfterEnteringText() throws Throwable {
mConnection.setComposingText("h", 1); setComposingText(mConnection, "h", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "h", 1, 1, 0, 1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "h", 1, 1, 0, 1);
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter());
mConnection.setComposingText("he", 1); setComposingText(mConnection, "he", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "he", 2, 2, 0, 2); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "he", 2, 2, 0, 2);
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter());
mConnection.setComposingText("hel", 1); setComposingText(mConnection, "hel", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hel", 3, 3, 0, 3); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hel", 3, 3, 0, 3);
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter());
mConnection.commitText("hel", 1); commitText(mConnection, "hel", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hel", 3, 3, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hel", 3, 3, -1, -1);
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter());
} }
...@@ -115,10 +115,10 @@ public class ImeTest extends ContentShellTestBase { ...@@ -115,10 +115,10 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest @SmallTest
@Feature({"TextInput"}) @Feature({"TextInput"})
public void testImeCopy() throws Exception { public void testImeCopy() throws Exception {
mConnection.commitText("hello", 1); commitText(mConnection, "hello", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1);
mConnection.setSelection(2, 5); setSelection(mConnection, 2, 5);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 2, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 2, 5, -1, -1);
mImeAdapter.copy(); mImeAdapter.copy();
...@@ -128,7 +128,7 @@ public class ImeTest extends ContentShellTestBase { ...@@ -128,7 +128,7 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest @SmallTest
@Feature({"TextInput"}) @Feature({"TextInput"})
public void testEnterTextAndRefocus() throws Exception { public void testEnterTextAndRefocus() throws Exception {
mConnection.commitText("hello", 1); commitText(mConnection, "hello", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1);
DOMUtils.clickNode(this, mContentView, mCallbackContainer, "input_radio"); DOMUtils.clickNode(this, mContentView, mCallbackContainer, "input_radio");
...@@ -143,10 +143,10 @@ public class ImeTest extends ContentShellTestBase { ...@@ -143,10 +143,10 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest @SmallTest
@Feature({"TextInput"}) @Feature({"TextInput"})
public void testImeCut() throws Exception { public void testImeCut() throws Exception {
mConnection.commitText("snarful", 1); commitText(mConnection, "snarful", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1);
mConnection.setSelection(1, 5); setSelection(mConnection, 1, 5);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1);
mImeAdapter.cut(); mImeAdapter.cut();
...@@ -171,7 +171,7 @@ public class ImeTest extends ContentShellTestBase { ...@@ -171,7 +171,7 @@ public class ImeTest extends ContentShellTestBase {
mImeAdapter.paste(); mImeAdapter.paste();
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "blarg", 5, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "blarg", 5, 5, -1, -1);
mConnection.setSelection(3, 5); setSelection(mConnection, 3, 5);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "blarg", 3, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "blarg", 3, 5, -1, -1);
mImeAdapter.paste(); mImeAdapter.paste();
...@@ -187,7 +187,7 @@ public class ImeTest extends ContentShellTestBase { ...@@ -187,7 +187,7 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest @SmallTest
@Feature({"TextInput"}) @Feature({"TextInput"})
public void testImeSelectAndUnSelectAll() throws Exception { public void testImeSelectAndUnSelectAll() throws Exception {
mConnection.commitText("hello", 1); commitText(mConnection, "hello", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1);
mImeAdapter.selectAll(); mImeAdapter.selectAll();
...@@ -229,22 +229,22 @@ public class ImeTest extends ContentShellTestBase { ...@@ -229,22 +229,22 @@ public class ImeTest extends ContentShellTestBase {
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1);
mConnection.commitText("hllo", 1); commitText(mConnection, "hllo", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hllo", 4, 4, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hllo", 4, 4, -1, -1);
mConnection.commitText(" ", 1); commitText(mConnection, " ", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hllo ", 5, 5, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hllo ", 5, 5, -1, -1);
mConnection.setSelection(1, 1); setSelection(mConnection, 1, 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hllo ", 1, 1, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hllo ", 1, 1, -1, -1);
mConnection.setComposingRegion(0, 4); setComposingRegion(mConnection, 0, 4);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hllo ", 1, 1, 0, 4); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hllo ", 1, 1, 0, 4);
mConnection.finishComposingText(); finishComposingText(mConnection);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 5, "hllo ", 1, 1, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 5, "hllo ", 1, 1, -1, -1);
mConnection.commitText("\n", 1); commitText(mConnection, "\n", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 6, "h\nllo ", 2, 2, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 6, "h\nllo ", 2, 2, -1, -1);
} }
...@@ -262,7 +262,7 @@ public class ImeTest extends ContentShellTestBase { ...@@ -262,7 +262,7 @@ public class ImeTest extends ContentShellTestBase {
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1);
mConnection.setComposingText("hello", 1); setComposingText(mConnection, "hello", 1);
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5);
getInstrumentation().runOnMainSync(new Runnable() { getInstrumentation().runOnMainSync(new Runnable() {
...@@ -353,6 +353,55 @@ public class ImeTest extends ContentShellTestBase { ...@@ -353,6 +353,55 @@ public class ImeTest extends ContentShellTestBase {
return getContentViewCore().getInputConnectionForTest(); return getContentViewCore().getInputConnectionForTest();
} }
private void commitText(final AdapterInputConnection connection, final CharSequence text,
final int newCursorPosition) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
connection.commitText(text, newCursorPosition);
}
});
}
private void setSelection(final AdapterInputConnection connection, final int start,
final int end) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
connection.setSelection(start, end);
}
});
}
private void setComposingRegion(final AdapterInputConnection connection, final int start,
final int end) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
connection.setComposingRegion(start, end);
}
});
}
private void setComposingText(final AdapterInputConnection connection, final CharSequence text,
final int newCursorPosition) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
connection.setComposingText(text, newCursorPosition);
}
});
}
private void finishComposingText(final AdapterInputConnection connection) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
connection.finishComposingText();
}
});
}
private static class TestAdapterInputConnectionFactory extends private static class TestAdapterInputConnectionFactory extends
ImeAdapter.AdapterInputConnectionFactory { ImeAdapter.AdapterInputConnectionFactory {
@Override @Override
......
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