Commit 3433bc09 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Commit Bot

webview: deflake more detached view tests.

I accidentally shadowed a variable in testDisconnectedViewLoadsContent
leading to the test still flaking. Fix that, and also apply the same
change to VisualStateTest which also uses a detached view and thus can
be vulnerable to the same issue.

Bug: 949391
Bug: 1058304
Change-Id: Ifc1d8305dca265368c1fa2dc7d8c1cc9bb487e79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145754
Commit-Queue: Richard Coles <torne@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Auto-Submit: Richard Coles <torne@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758215}
parent 56c5ebd9
......@@ -202,8 +202,7 @@ public class AndroidViewIntegrationTest {
@Feature({"AndroidWebView"})
public void testDisconnectedViewLoadsContent() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView mTestContainerView =
createDetachedTestContainerViewOnMainSync(contentsClient);
mTestContainerView = createDetachedTestContainerViewOnMainSync(contentsClient);
assertZeroHeight(mTestContainerView);
final int contentSizeChangeCallCount = mOnContentSizeChangedHelper.getCallCount();
......
......@@ -64,6 +64,7 @@ public class VisualStateTest {
private static final String ENTER_FULLSCREEN_CONTROL_ID = "enterFullscreenControl";
private TestAwContentsClient mContentsClient = new TestAwContentsClient();
private AwTestContainerView mTestView;
private static class DelayedInputStream extends FilterInputStream {
private CountDownLatch mLatch = new CountDownLatch(1);
......@@ -120,9 +121,8 @@ public class VisualStateTest {
@Feature({"AndroidWebView"})
@SmallTest
public void testVisualStateCallbackIsReceived() throws Throwable {
AwTestContainerView testContainer =
mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient);
final AwContents awContents = testContainer.getAwContents();
mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient);
final AwContents awContents = mTestView.getAwContents();
mActivityTestRule.loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(),
CommonResources.ABOUT_HTML, "text/html", false);
final CallbackHelper ch = new CallbackHelper();
......@@ -153,7 +153,7 @@ public class VisualStateTest {
final CountDownLatch testFinishedSignal = new CountDownLatch(1);
final AtomicReference<AwContents> awContentsRef = new AtomicReference<>();
final AwTestContainerView testView =
mTestView =
mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() {
@Override
public void onPageFinished(String url) {
......@@ -175,7 +175,7 @@ public class VisualStateTest {
}
}
});
final AwContents awContents = testView.getAwContents();
final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
......@@ -207,7 +207,7 @@ public class VisualStateTest {
final CountDownLatch pageCommitCallbackOccurred = new CountDownLatch(1);
final AtomicReference<AwContents> awContentsRef = new AtomicReference<>();
final AwTestContainerView testView =
mTestView =
mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() {
@Override
public void onPageCommitVisible(String url) {
......@@ -246,7 +246,7 @@ public class VisualStateTest {
}
});
final AwContents awContents = testView.getAwContents();
final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
......@@ -297,11 +297,10 @@ public class VisualStateTest {
});
}
};
final AwTestContainerView testView =
mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = testView.getAwContents();
mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents);
final WebContents webContents = testView.getWebContents();
final WebContents webContents = mTestView.getWebContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
// JS will notify this observer once it has changed the background color of the page.
......@@ -364,11 +363,10 @@ public class VisualStateTest {
});
}
};
final AwTestContainerView testView =
mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = testView.getAwContents();
mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents);
final WebContents webContents = testView.getWebContents();
final WebContents webContents = mTestView.getWebContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
awContents.getSettings().setFullscreenSupported(true);
......@@ -421,9 +419,8 @@ public class VisualStateTest {
final CountDownLatch testFinishedSignal = new CountDownLatch(1);
final TestAwContentsClient awContentsClient = new TestAwContentsClient();
final AwTestContainerView testView =
createDetachedTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = testView.getAwContents();
mTestView = createDetachedTestContainerViewOnMainSync(awContentsClient);
final AwContents awContents = mTestView.getAwContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
......
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