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

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

Issue 1036893002: Make GC test catch strong ref from client objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: findbugs Created 5 years, 9 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
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index 85db017737cce0778a75c286914a82bedb275109..0478a00938e1ab4060b6d023b687440829a14963 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -139,6 +139,14 @@ public class AwContentsTest extends AwTestBase {
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU));
}
+ @SuppressFBWarnings("URF_UNREAD_FIELD")
+ private static class StrongRefTestAwContentsClient extends TestAwContentsClient {
+ private AwContents mAwContentsStrongRef;
+ public void setAwContentsStrongRef(AwContents awContents) {
+ mAwContentsStrongRef = awContents;
+ }
+ }
+
@DisableHardwareAccelerationForTest
@LargeTest
@Feature({"AndroidWebView"})
@@ -159,7 +167,13 @@ public class AwContentsTest extends AwTestBase {
});
for (int i = 0; i < repetitions; ++i) {
for (int j = 0; j < concurrentInstances; ++j) {
- AwTestContainerView view = createAwTestContainerViewOnMainSync(mContentsClient);
+ final StrongRefTestAwContentsClient client = new StrongRefTestAwContentsClient();
+ AwTestContainerView view = createAwTestContainerViewOnMainSync(client);
+ // Embedding app can hold onto a strong ref to the WebView from either WebViewClient
+ // or WebChromeClient. That should not prevent WebView from gc-ed. We simulate that
+ // behavior by making the equivalent change here, have AwContentsClient hold a
+ // strong ref to the AwContents object.
+ client.setAwContentsStrongRef(view.getAwContents());
loadUrlAsync(view.getAwContents(), "about:blank");
}
assertTrue(AwContents.getNativeInstanceCount() >= concurrentInstances);
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698