| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
| 6 | 6 |
| 7 import android.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
| 8 import android.graphics.Color; | 8 import android.graphics.Color; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 import android.view.View; | 10 import android.view.View; |
| 11 | 11 |
| 12 import org.chromium.android_webview.AwContents; | 12 import org.chromium.android_webview.AwContents; |
| 13 import org.chromium.android_webview.AwContents.VisualStateCallback; | 13 import org.chromium.android_webview.AwContents.VisualStateCallback; |
| 14 import org.chromium.android_webview.test.util.GraphicsTestUtils; | 14 import org.chromium.android_webview.test.util.GraphicsTestUtils; |
| 15 import org.chromium.base.ThreadUtils; | 15 import org.chromium.base.ThreadUtils; |
| 16 import org.chromium.base.test.util.DisabledTest; | |
| 17 import org.chromium.base.test.util.Feature; | 16 import org.chromium.base.test.util.Feature; |
| 17 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 18 | 18 |
| 19 import java.util.concurrent.CountDownLatch; | 19 import java.util.concurrent.CountDownLatch; |
| 20 import java.util.concurrent.TimeUnit; | 20 import java.util.concurrent.TimeUnit; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * AwContents rendering / pixel tests. | 23 * AwContents rendering / pixel tests. |
| 24 */ | 24 */ |
| 25 public class AwContentsRenderTest extends AwTestBase { | 25 public class AwContentsRenderTest extends AwTestBase { |
| 26 | 26 |
| 27 private TestAwContentsClient mContentsClient; | 27 private TestAwContentsClient mContentsClient; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 }); | 86 }); |
| 87 | 87 |
| 88 int pictureCount = mContentsClient.getPictureListenerHelper().getCallCou
nt(); | 88 int pictureCount = mContentsClient.getPictureListenerHelper().getCallCou
nt(); |
| 89 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), "abo
ut:blank"); | 89 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), "abo
ut:blank"); |
| 90 mContentsClient.getPictureListenerHelper().waitForCallback(pictureCount,
1); | 90 mContentsClient.getPictureListenerHelper().waitForCallback(pictureCount,
1); |
| 91 // Invalidation only, so picture should be null. | 91 // Invalidation only, so picture should be null. |
| 92 assertNull(mContentsClient.getPictureListenerHelper().getPicture()); | 92 assertNull(mContentsClient.getPictureListenerHelper().getPicture()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // @SmallTest | 95 @SmallTest |
| 96 // @Feature({"AndroidWebView"}) | 96 @Feature({"AndroidWebView"}) |
| 97 @DisabledTest | 97 @ParameterizedTest.Set |
| 98 public void testForceDrawWhenInvisible() throws Throwable { | 98 public void testForceDrawWhenInvisible() throws Throwable { |
| 99 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), | 99 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), |
| 100 "data:text/html,<html><head><style>body {background-color:#22778
8}</style></head>" | 100 "data:text/html,<html><head><style>body {background-color:#22778
8}</style></head>" |
| 101 + "<body>Hello world!</body></html>"); | 101 + "<body>Hello world!</body></html>"); |
| 102 | 102 |
| 103 Bitmap visibleBitmap = null; | 103 Bitmap visibleBitmap = null; |
| 104 Bitmap invisibleBitmap = null; | 104 Bitmap invisibleBitmap = null; |
| 105 final CountDownLatch latch = new CountDownLatch(1); | 105 final CountDownLatch latch = new CountDownLatch(1); |
| 106 runTestOnUiThread(new Runnable() { | 106 runTestOnUiThread(new Runnable() { |
| 107 @Override | 107 @Override |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 // VisualStateCallback#onComplete won't be called when WebView is | 148 // VisualStateCallback#onComplete won't be called when WebView is |
| 149 // invisible. So there is no reliable way to tell if View#setVisibility | 149 // invisible. So there is no reliable way to tell if View#setVisibility |
| 150 // has taken effect. Just sleep the test thread for 500ms. | 150 // has taken effect. Just sleep the test thread for 500ms. |
| 151 Thread.sleep(500); | 151 Thread.sleep(500); |
| 152 invisibleBitmap = GraphicsTestUtils.drawAwContentsOnUiThread(mAwContents
, width, height); | 152 invisibleBitmap = GraphicsTestUtils.drawAwContentsOnUiThread(mAwContents
, width, height); |
| 153 assertNotNull(invisibleBitmap); | 153 assertNotNull(invisibleBitmap); |
| 154 assertTrue(invisibleBitmap.sameAs(visibleBitmap)); | 154 assertTrue(invisibleBitmap.sameAs(visibleBitmap)); |
| 155 } | 155 } |
| 156 } | 156 } |
| OLD | NEW |