Commit 332c7720 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

chromecast: Destroy WindowAndroid

WindowAndroid needs to be explicitly destroyed. Caught this while trying
to add LifetimeAssert to WindowAndroid to enforce this.

Bug: 1081250
Change-Id: I2e888b8875f856946abb83fb91fd32d60845304b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212793Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771212}
parent e25f396f
...@@ -102,7 +102,12 @@ class CastWebContentsScopes { ...@@ -102,7 +102,12 @@ class CastWebContentsScopes {
// WebContents can be destroyed by the app before CastWebContentsComponent // WebContents can be destroyed by the app before CastWebContentsComponent
// unbinds, which is why we need this check. // unbinds, which is why we need this check.
webContents.onHide(); webContents.onHide();
if (webContents.getTopLevelNativeWindow() == window) {
webContents.setTopLevelNativeWindow(null);
} }
}
window.destroy();
}; };
}; };
} }
......
...@@ -21,6 +21,7 @@ import android.content.IntentFilter; ...@@ -21,6 +21,7 @@ import android.content.IntentFilter;
import android.net.Uri; import android.net.Uri;
import android.os.PatternMatcher; import android.os.PatternMatcher;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -92,6 +93,12 @@ public class CastWebContentsServiceTest { ...@@ -92,6 +93,12 @@ public class CastWebContentsServiceTest {
mShadowService = Shadows.shadowOf(mService); mShadowService = Shadows.shadowOf(mService);
} }
@After
public void tearDown() {
mServiceLifecycle.unbind();
mServiceLifecycle.destroy();
}
@Test @Test
public void testForegroundedAfterBind() { public void testForegroundedAfterBind() {
mServiceLifecycle.bind(); mServiceLifecycle.bind();
......
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