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 { ...@@ -202,8 +202,7 @@ public class AndroidViewIntegrationTest {
@Feature({"AndroidWebView"}) @Feature({"AndroidWebView"})
public void testDisconnectedViewLoadsContent() throws Throwable { public void testDisconnectedViewLoadsContent() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient(); final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView mTestContainerView = mTestContainerView = createDetachedTestContainerViewOnMainSync(contentsClient);
createDetachedTestContainerViewOnMainSync(contentsClient);
assertZeroHeight(mTestContainerView); assertZeroHeight(mTestContainerView);
final int contentSizeChangeCallCount = mOnContentSizeChangedHelper.getCallCount(); final int contentSizeChangeCallCount = mOnContentSizeChangedHelper.getCallCount();
......
...@@ -64,6 +64,7 @@ public class VisualStateTest { ...@@ -64,6 +64,7 @@ public class VisualStateTest {
private static final String ENTER_FULLSCREEN_CONTROL_ID = "enterFullscreenControl"; private static final String ENTER_FULLSCREEN_CONTROL_ID = "enterFullscreenControl";
private TestAwContentsClient mContentsClient = new TestAwContentsClient(); private TestAwContentsClient mContentsClient = new TestAwContentsClient();
private AwTestContainerView mTestView;
private static class DelayedInputStream extends FilterInputStream { private static class DelayedInputStream extends FilterInputStream {
private CountDownLatch mLatch = new CountDownLatch(1); private CountDownLatch mLatch = new CountDownLatch(1);
...@@ -120,9 +121,8 @@ public class VisualStateTest { ...@@ -120,9 +121,8 @@ public class VisualStateTest {
@Feature({"AndroidWebView"}) @Feature({"AndroidWebView"})
@SmallTest @SmallTest
public void testVisualStateCallbackIsReceived() throws Throwable { public void testVisualStateCallbackIsReceived() throws Throwable {
AwTestContainerView testContainer = mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient);
mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient); final AwContents awContents = mTestView.getAwContents();
final AwContents awContents = testContainer.getAwContents();
mActivityTestRule.loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(), mActivityTestRule.loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(),
CommonResources.ABOUT_HTML, "text/html", false); CommonResources.ABOUT_HTML, "text/html", false);
final CallbackHelper ch = new CallbackHelper(); final CallbackHelper ch = new CallbackHelper();
...@@ -153,7 +153,7 @@ public class VisualStateTest { ...@@ -153,7 +153,7 @@ public class VisualStateTest {
final CountDownLatch testFinishedSignal = new CountDownLatch(1); final CountDownLatch testFinishedSignal = new CountDownLatch(1);
final AtomicReference<AwContents> awContentsRef = new AtomicReference<>(); final AtomicReference<AwContents> awContentsRef = new AtomicReference<>();
final AwTestContainerView testView = mTestView =
mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() { mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() {
@Override @Override
public void onPageFinished(String url) { public void onPageFinished(String url) {
...@@ -175,7 +175,7 @@ public class VisualStateTest { ...@@ -175,7 +175,7 @@ public class VisualStateTest {
} }
} }
}); });
final AwContents awContents = testView.getAwContents(); final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents); awContentsRef.set(awContents);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
...@@ -207,7 +207,7 @@ public class VisualStateTest { ...@@ -207,7 +207,7 @@ public class VisualStateTest {
final CountDownLatch pageCommitCallbackOccurred = new CountDownLatch(1); final CountDownLatch pageCommitCallbackOccurred = new CountDownLatch(1);
final AtomicReference<AwContents> awContentsRef = new AtomicReference<>(); final AtomicReference<AwContents> awContentsRef = new AtomicReference<>();
final AwTestContainerView testView = mTestView =
mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() { mActivityTestRule.createAwTestContainerViewOnMainSync(new TestAwContentsClient() {
@Override @Override
public void onPageCommitVisible(String url) { public void onPageCommitVisible(String url) {
...@@ -246,7 +246,7 @@ public class VisualStateTest { ...@@ -246,7 +246,7 @@ public class VisualStateTest {
} }
}); });
final AwContents awContents = testView.getAwContents(); final AwContents awContents = mTestView.getAwContents();
awContentsRef.set(awContents); awContentsRef.set(awContents);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
...@@ -297,11 +297,10 @@ public class VisualStateTest { ...@@ -297,11 +297,10 @@ public class VisualStateTest {
}); });
} }
}; };
final AwTestContainerView testView = mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient); final AwContents awContents = mTestView.getAwContents();
final AwContents awContents = testView.getAwContents();
awContentsRef.set(awContents); awContentsRef.set(awContents);
final WebContents webContents = testView.getWebContents(); final WebContents webContents = mTestView.getWebContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents); AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
// JS will notify this observer once it has changed the background color of the page. // JS will notify this observer once it has changed the background color of the page.
...@@ -364,11 +363,10 @@ public class VisualStateTest { ...@@ -364,11 +363,10 @@ public class VisualStateTest {
}); });
} }
}; };
final AwTestContainerView testView = mTestView = mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient);
mActivityTestRule.createAwTestContainerViewOnMainSync(awContentsClient); final AwContents awContents = mTestView.getAwContents();
final AwContents awContents = testView.getAwContents();
awContentsRef.set(awContents); awContentsRef.set(awContents);
final WebContents webContents = testView.getWebContents(); final WebContents webContents = mTestView.getWebContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents); AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
awContents.getSettings().setFullscreenSupported(true); awContents.getSettings().setFullscreenSupported(true);
...@@ -421,9 +419,8 @@ public class VisualStateTest { ...@@ -421,9 +419,8 @@ public class VisualStateTest {
final CountDownLatch testFinishedSignal = new CountDownLatch(1); final CountDownLatch testFinishedSignal = new CountDownLatch(1);
final TestAwContentsClient awContentsClient = new TestAwContentsClient(); final TestAwContentsClient awContentsClient = new TestAwContentsClient();
final AwTestContainerView testView = mTestView = createDetachedTestContainerViewOnMainSync(awContentsClient);
createDetachedTestContainerViewOnMainSync(awContentsClient); final AwContents awContents = mTestView.getAwContents();
final AwContents awContents = testView.getAwContents();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents); 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