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

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

Issue 1685763003: [Contextual Search] Re-landing the CL: https://codereview.chromium.org/1669983003/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flaky_test
Patch Set: Sync Created 4 years, 10 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 | « no previous file | 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/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 00512bd2e073ecbeaaa087bcb1ba531f7272d7fc..9da48f099fdcb4340870c62f22711f2a4dfc4f7e 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
@@ -25,7 +25,6 @@ import android.view.ViewConfiguration;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
-import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R;
@@ -201,6 +200,21 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
}
/**
+ * Waits for the requested search term to match, and asserts.
+ * @param searchTerm A given search term.
+ */
+ public void waitForSearchTermToMatch(
+ final String searchTerm) throws InterruptedException {
+ CriteriaHelper.pollForCriteria(new Criteria("Search term never matched.") {
+ @Override
+ public boolean isSatisfied() {
+ String url = mFakeServer.getLoadedUrl();
+ return !TextUtils.isEmpty(url) && url.contains("q=" + searchTerm);
+ }
+ }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
+ }
+
+ /**
* Runs the given Runnable in the main thread.
* @param runnable The Runnable.
*/
@@ -242,7 +256,7 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
private void simulateTapSearch(String nodeId) throws InterruptedException, TimeoutException {
ContextualSearchFakeServer.FakeTapSearch search = mFakeServer.getFakeTapSearch(nodeId);
search.simulate();
- assertLoadedSearchTermMatches(search.getSearchTerm());
+ waitForSearchTermToMatch(search.getSearchTerm());
waitForPanelToPeek();
}
@@ -483,7 +497,8 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
boolean doesMatch = false;
String message = "but there was no loaded URL!";
if (mFakeServer != null) {
- doesMatch = mFakeServer.getLoadedUrl().contains("q=" + searchTerm);
+ String url = mFakeServer.getLoadedUrl();
+ doesMatch = !TextUtils.isEmpty(url) && url.contains("q=" + searchTerm);
message = "in URL: " + mFakeServer.getLoadedUrl();
}
assertTrue("Expected to find searchTerm " + searchTerm + ", " + message, doesMatch);
@@ -2287,7 +2302,6 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
/**
* Tests that chained searches load correctly.
*/
- @DisabledTest // https://crbug.com/551711
@SmallTest
@Feature({"ContextualSearch"})
@Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698