Index: android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java |
index 7b06c16a10cea29e9a710bed631e6ab0b0476acb..a20ddb5f79f5cd14367042c38f9a22a2c0bfb6bc 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java |
@@ -18,6 +18,7 @@ |
import java.util.concurrent.CountDownLatch; |
import java.util.concurrent.TimeUnit; |
+import java.util.concurrent.atomic.AtomicReference; |
/** |
* Visual state related tests. |
@@ -25,8 +26,6 @@ |
public class VisualStateTest extends AwTestBase { |
private TestAwContentsClient mContentsClient = new TestAwContentsClient(); |
- private long mExpectedFlushRequestId = -1; |
- private AwContents mAwContents; |
@Feature({"AndroidWebView"}) |
@SmallTest |
@@ -40,19 +39,17 @@ |
runTestOnUiThread(new Runnable() { |
@Override |
public void run() { |
- mExpectedFlushRequestId = |
- awContents.flushVisualState(new AwContents.VisualStateFlushCallback() { |
- @Override |
- public void onComplete(long requestId) { |
- assertEquals(mExpectedFlushRequestId, requestId); |
- ch.notifyCalled(); |
- } |
+ awContents.flushVisualState(new AwContents.VisualStateFlushCallback() { |
+ @Override |
+ public void onComplete() { |
+ ch.notifyCalled(); |
+ } |
- @Override |
- public void onFailure(long requestId) { |
- fail("onFailure received"); |
- } |
- }); |
+ @Override |
+ public void onFailure() { |
+ fail("onFailure received"); |
+ } |
+ }); |
} |
}); |
ch.waitForCallback(chCount); |
@@ -68,44 +65,44 @@ |
final LoadUrlParams bluePageUrl = createTestPageUrl("blue"); |
final CountDownLatch testFinishedSignal = new CountDownLatch(1); |
+ final AtomicReference<AwContents> awContentsRef = new AtomicReference<>(); |
final AwTestContainerView testView = |
createAwTestContainerViewOnMainSync(new TestAwContentsClient() { |
@Override |
public void onPageFinished(String url) { |
if (bluePageUrl.getUrl().equals(url)) { |
- mExpectedFlushRequestId = |
- mAwContents.flushVisualState(new VisualStateFlushCallback() { |
- @Override |
- public void onFailure(long requestId) { |
- fail("onFailure received"); |
- } |
+ awContentsRef.get().flushVisualState(new VisualStateFlushCallback() { |
+ @Override |
+ public void onFailure() { |
+ fail("onFailure received"); |
+ } |
- @Override |
- public void onComplete(long requestId) { |
- assertEquals(mExpectedFlushRequestId, requestId); |
- Bitmap blueScreenshot = |
- GraphicsTestUtils.drawAwContents( |
- mAwContents, 1, 1); |
- assertEquals(Color.BLUE, blueScreenshot.getPixel(0, 0)); |
- testFinishedSignal.countDown(); |
- } |
- }); |
+ @Override |
+ public void onComplete() { |
+ Bitmap blueScreenshot = GraphicsTestUtils.drawAwContents( |
+ awContentsRef.get(), 1, 1); |
+ assertEquals(Color.BLUE, blueScreenshot.getPixel(0, 0)); |
+ testFinishedSignal.countDown(); |
+ } |
+ }); |
} |
} |
}); |
- mAwContents = testView.getAwContents(); |
+ final AwContents awContents = testView.getAwContents(); |
+ awContentsRef.set(awContents); |
runTestOnUiThread(new Runnable() { |
@Override |
public void run() { |
- mAwContents.setBackgroundColor(Color.RED); |
- mAwContents.loadUrl(bluePageUrl); |
+ awContents.setBackgroundColor(Color.RED); |
+ awContents.loadUrl(bluePageUrl); |
// We have just loaded the blue page, but the graphics pipeline is asynchronous |
// so at this point the WebView still draws red, ie. the View background color. |
// Only when the flush callback is received will we know for certain that the |
// blue page contents are on screen. |
- Bitmap redScreenshot = GraphicsTestUtils.drawAwContents(mAwContents, 1, 1); |
+ Bitmap redScreenshot = GraphicsTestUtils.drawAwContents( |
+ awContentsRef.get(), 1, 1); |
assertEquals(Color.RED, redScreenshot.getPixel(0, 0)); |
} |
}); |