aw: Avoid leaking WindowAndroid in tests
Overall goal here is to ensure WindowAndroid instances are destroyed at the end of instrumentation tests, but there is change in behavior for production code. Eager destroy WindowAndroid in AwContents. When the destroy runnable for all AwContents that uses a WindowAndroid runs. Need to ensure at this time that the WindowAndroid is removed from the global map as well. This works because WindowAndroid lifetime and destroy runnable lifetime are essentially the same. Then in AwActivityTestRule, keep track of all AwContents created in instrumentation tests in a list of weak references, and destroy at the end of the test. Calling AwContents.destroy multiple is ok, so this should be safe. Need specific handling for AwUncaughtExceptionTest because it renders the UI thread useless at the end of the test. Instead synchronously destroy the AwContents in the test body itself. Bug: 1081250 Change-Id: Ic07e52c7b21bf1300942e8b0a7cf178b8e3858b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2205879 Commit-Queue: Bo <boliu@chromium.org> Reviewed-by:Richard Coles <torne@chromium.org> Cr-Commit-Position: refs/heads/master@{#771078}
Showing
Please register or sign in to comment