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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/VisualStateTest.java

Issue 900303002: [WebView] Add unique visual state request ids. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 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
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 a20ddb5f79f5cd14367042c38f9a22a2c0bfb6bc..7b06c16a10cea29e9a710bed631e6ab0b0476acb 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,7 +18,6 @@ import org.chromium.content_public.browser.LoadUrlParams;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Visual state related tests.
@@ -26,6 +25,8 @@ import java.util.concurrent.atomic.AtomicReference;
public class VisualStateTest extends AwTestBase {
private TestAwContentsClient mContentsClient = new TestAwContentsClient();
+ private long mExpectedFlushRequestId = -1;
+ private AwContents mAwContents;
@Feature({"AndroidWebView"})
@SmallTest
@@ -39,17 +40,19 @@ public class VisualStateTest extends AwTestBase {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
- awContents.flushVisualState(new AwContents.VisualStateFlushCallback() {
- @Override
- public void onComplete() {
- ch.notifyCalled();
- }
+ mExpectedFlushRequestId =
+ awContents.flushVisualState(new AwContents.VisualStateFlushCallback() {
+ @Override
+ public void onComplete(long requestId) {
+ assertEquals(mExpectedFlushRequestId, requestId);
+ ch.notifyCalled();
+ }
- @Override
- public void onFailure() {
- fail("onFailure received");
- }
- });
+ @Override
+ public void onFailure(long requestId) {
+ fail("onFailure received");
+ }
+ });
}
});
ch.waitForCallback(chCount);
@@ -65,44 +68,44 @@ public class VisualStateTest extends AwTestBase {
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)) {
- awContentsRef.get().flushVisualState(new VisualStateFlushCallback() {
- @Override
- public void onFailure() {
- fail("onFailure received");
- }
+ mExpectedFlushRequestId =
+ mAwContents.flushVisualState(new VisualStateFlushCallback() {
+ @Override
+ public void onFailure(long requestId) {
+ fail("onFailure received");
+ }
- @Override
- public void onComplete() {
- Bitmap blueScreenshot = GraphicsTestUtils.drawAwContents(
- awContentsRef.get(), 1, 1);
- assertEquals(Color.BLUE, blueScreenshot.getPixel(0, 0));
- testFinishedSignal.countDown();
- }
- });
+ @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();
+ }
+ });
}
}
});
- final AwContents awContents = testView.getAwContents();
- awContentsRef.set(awContents);
+ mAwContents = testView.getAwContents();
runTestOnUiThread(new Runnable() {
@Override
public void run() {
- awContents.setBackgroundColor(Color.RED);
- awContents.loadUrl(bluePageUrl);
+ mAwContents.setBackgroundColor(Color.RED);
+ mAwContents.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(
- awContentsRef.get(), 1, 1);
+ Bitmap redScreenshot = GraphicsTestUtils.drawAwContents(mAwContents, 1, 1);
assertEquals(Color.RED, redScreenshot.getPixel(0, 0));
}
});
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContents.java ('k') | android_webview/native/aw_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698