Commit 5bd2e471 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Test if tap flakiness is based on the thread

Adds another ContextualSearchManagerTest similar to an existing test
that is currently somewhat flaky to see if the flakiness is due to
polling on the UI thread vs the Instrumentation thread.

BUG=818897

Change-Id: Icb40f34db4de4b1d26a4dc555a3bbf0d01b1090d
Reviewed-on: https://chromium-review.googlesource.com/963288Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543739}
parent 13557353
......@@ -171,6 +171,7 @@ public class ContextualSearchManagerTest {
private ContextualSearchPolicy mPolicy;
private ContextualSearchSelectionController mSelectionController;
private EmbeddedTestServer mTestServer;
private boolean mPollInstrumentationThread;
private float mDpToPx;
......@@ -801,10 +802,11 @@ public class ContextualSearchManagerTest {
/**
* Waits for the Search Panel to enter the given {@code PanelState} and assert.
* Waits on the UI thread unless mPollInstrumentationThread is set.
* @param state The {@link PanelState} to wait for.
*/
private void waitForPanelToEnterState(final PanelState state) {
CriteriaHelper.pollUiThread(new Criteria() {
final Criteria panelStateCriteria = new Criteria() {
@Override
public boolean isSatisfied() {
if (mPanel == null) return false;
......@@ -812,7 +814,12 @@ public class ContextualSearchManagerTest {
+ "Instead, the current state is " + mPanel.getPanelState() + ".");
return mPanel.getPanelState() == state && !mPanel.isHeightAnimationRunning();
}
}, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
};
if (mPollInstrumentationThread) {
CriteriaHelper.pollInstrumentationThread(panelStateCriteria);
} else {
CriteriaHelper.pollUiThread(panelStateCriteria);
}
}
/**
......@@ -854,18 +861,24 @@ public class ContextualSearchManagerTest {
/**
* Waits for the selection to be empty.
* Waits on the UI thread unless mPollInstrumentationThread is set.
* Use this method any time a test repeatedly establishes and dissolves a selection to ensure
* that the selection has been completely dissolved before simulating the next selection event.
* 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 it has been dissolved.
*/
private void waitForSelectionEmpty() {
CriteriaHelper.pollUiThread(new Criteria("Selection never empty.") {
final Criteria selectionEmptyCriteria = new Criteria("Selection never empty.") {
@Override
public boolean isSatisfied() {
return mSelectionController.isSelectionEmpty();
}
}, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
};
if (mPollInstrumentationThread) {
CriteriaHelper.pollInstrumentationThread(selectionEmptyCriteria);
} else {
CriteriaHelper.pollUiThread(selectionEmptyCriteria);
}
}
/**
......@@ -1031,7 +1044,6 @@ public class ContextualSearchManagerTest {
private void clickToTriggerPrefetch() throws InterruptedException, TimeoutException {
mFakeServer.reset();
simulateTapSearch("search");
waitForPanelToPeek();
closePanel();
waitForPanelToCloseAndSelectionEmpty();
}
......@@ -2195,6 +2207,19 @@ public class ContextualSearchManagerTest {
}
}
/**
* Tests a bunch of taps in a row, with the variation that we wait on the instrumentation
* thread instead of the UI thread for some wait sequences.
*/
@Test
@LargeTest
@Feature({"ContextualSearch"})
@DisableIf.Build(sdk_is_less_than = Build.VERSION_CODES.LOLLIPOP, message = "crbug.com/818897")
public void testTapALotInstrumentation() throws InterruptedException, TimeoutException {
mPollInstrumentationThread = true;
testTapALot();
}
/**
* Tests ContextualSearchManager#shouldInterceptNavigation for a case that an external
* navigation has a user gesture.
......
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