Index: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java |
index 4c9bd963185374f319246dffdad67c4effab5969..f8381713bd35dbc7c7b83ea977d7b80aba13fa88 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java |
@@ -391,6 +391,21 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro |
} |
/** |
+ * Waits for the selection bounds to resolve. |
+ * This is needed because the renderer's notification of a selection going away is async, |
+ * and a subsequent tap may think there's a current selection until the bounds have dissolved. |
+ */ |
+ private void waitForSelectionBoundsDissolved() throws InterruptedException { |
+ assertTrue("Selection never cleared.", |
+ CriteriaHelper.pollForCriteria(new Criteria() { |
+ @Override |
+ public boolean isSatisfied() { |
+ return mSelectionController.isSelectionBoundsDissolved(); |
+ } |
+ }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL)); |
+ } |
+ |
+ /** |
* A ContentViewCore that has some methods stubbed out for testing. |
*/ |
private static final class StubbedContentViewCore extends ContentViewCore { |
@@ -1791,4 +1806,23 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro |
longPressNode("states-far"); |
waitForPanelToPeekAndAssert(); |
} |
+ |
+ /** |
+ * Tests a bunch of taps in a row. |
+ * We've had reliability problems with simple taps due to async clearing |
+ * of selection bounds, so this helps prevent a regression with that. |
+ */ |
+ @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
+ @CommandLineFlags.Add({ |
+ ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_DECIDED + "=200", |
+ ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_UNDECIDED + "=200", |
+ ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=200", |
+ ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_UNDECIDED + "=200"}) |
+ public void testTapALot() throws InterruptedException, TimeoutException { |
+ for (int i = 0; i < 50; i++) { |
+ clickToTriggerSearchTermResolution(); |
+ waitForSelectionBoundsDissolved(); |
+ assertSearchTermRequested(); |
+ } |
+ } |
} |