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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java

Issue 2928053002: [TTS] Robustness for VR: show with null selection. (Closed)
Patch Set: Check that we have a selection in the long-press case too. Cleanup and better document the test. 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
index 6f910e67d2f78b1794d29855c13033aa143c4329..0b23f5bda0cf3fdaabd187123fa0e4930145cd26 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTapEventTest.java
@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.contextualsearch;
import android.content.Context;
-import android.net.Uri;
import android.support.test.filters.SmallTest;
import android.widget.LinearLayout;
@@ -35,8 +34,6 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
import org.chromium.ui.touch_selection.SelectionEventType;
-import javax.annotation.Nullable;
-
/**
* Mock touch events with Contextual Search to test behavior of its panel and manager.
*/
@@ -55,21 +52,6 @@ public class ContextualSearchTapEventTest {
private OverlayPanelManagerWrapper mPanelManager;
private SelectionClient mContextualSearchClient;
- /**
- * A ContextualSearchRequest that foregoes URI template lookup.
- */
- private static class MockContextualSearchRequest extends ContextualSearchRequest {
- public MockContextualSearchRequest(String term, String altTerm, boolean prefetch) {
- super(term, altTerm, "", prefetch);
- }
-
- @Override
- protected Uri getUriTemplate(
- String query, @Nullable String alternateTerm, String mid, boolean shouldPrefetch) {
- return Uri.parse("");
- }
- }
-
// --------------------------------------------------------------------------------------------
/**
@@ -118,12 +100,6 @@ public class ContextualSearchTapEventTest {
QuickActionCategory.NONE);
}
- @Override
- protected ContextualSearchRequest createContextualSearchRequest(
- String query, String altTerm, String mid, boolean shouldPrefetch) {
- return new MockContextualSearchRequest(query, altTerm, shouldPrefetch);
- }
-
@Override
protected void nativeGatherSurroundingText(long nativeContextualSearchManager,
ContextualSearchContext contextualSearchContext, WebContents baseWebContents) {}
@@ -349,4 +325,31 @@ public class ContextualSearchTapEventTest {
Assert.assertEquals(mPanelManager.getRequestPanelShowCount(), 1);
Assert.assertEquals(mPanelManager.getPanelHideCount(), 0);
}
+
+ /**
+ * Tests that a Tap gesture processing is robust even when the selection somehow gets cleared
+ * during that process. This tests a failure-case found in crbug.com/728644.
+ */
+ @Test
+ @SmallTest
+ @Feature({"ContextualSearch"})
+ @Restriction(Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+ public void testTapProcessIsRobustWhenSelectionGetsCleared() throws InterruptedException {
+ Assert.assertEquals(mPanelManager.getRequestPanelShowCount(), 0);
+
+ // Fake a Tap event.
+ mockTapText("text");
+ // Generate the surrounding-text-available callback.
+ generateTextSurroundingSelectionAvailable();
+
+ // Now clear the selection!
+ mContextualSearchManager.getSelectionController().clearSelection();
+
+ // Continue processing the Tap by acknowledging the SelectWordAroundCaret has selected the
+ // word. However we just simulated a condition that clears the selection above, so we're
+ // testing for robustness in completion of the processing even when there's no selection.
+ generateSelectWordAroundCaretAck();
+ Assert.assertEquals(mPanelManager.getRequestPanelShowCount(), 0);
+ Assert.assertEquals(mPanelManager.getPanelHideCount(), 0);
+ }
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698