| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.support.test.filters.SmallTest; | 7 import android.support.test.filters.SmallTest; |
| 8 | 8 |
| 9 import org.chromium.android_webview.AwContents; | 9 import org.chromium.android_webview.AwContents; |
| 10 import org.chromium.android_webview.AwRenderProcessGoneDetail; | 10 import org.chromium.android_webview.AwRenderProcessGoneDetail; |
| 11 import org.chromium.android_webview.AwSwitches; | 11 import org.chromium.android_webview.AwSwitches; |
| 12 import org.chromium.android_webview.renderer_priority.RendererPriority; | 12 import org.chromium.android_webview.renderer_priority.RendererPriority; |
| 13 import org.chromium.base.test.util.CallbackHelper; | 13 import org.chromium.base.test.util.CallbackHelper; |
| 14 import org.chromium.base.test.util.CommandLineFlags; | 14 import org.chromium.base.test.util.CommandLineFlags; |
| 15 import org.chromium.base.test.util.Feature; | 15 import org.chromium.base.test.util.Feature; |
| 16 import org.chromium.base.test.util.parameter.ParameterizedTest; | 16 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 17 | 17 |
| 18 import java.util.concurrent.TimeUnit; |
| 19 |
| 18 /** | 20 /** |
| 19 * Tests for AwContentsClient.onRenderProcessGone callback. | 21 * Tests for AwContentsClient.onRenderProcessGone callback. |
| 20 */ | 22 */ |
| 21 public class AwContentsClientOnRenderProcessGoneTest extends AwTestBase { | 23 public class AwContentsClientOnRenderProcessGoneTest extends AwTestBase { |
| 24 private static final String TAG = "AwRendererGone"; |
| 22 private static class GetRenderProcessGoneHelper extends CallbackHelper { | 25 private static class GetRenderProcessGoneHelper extends CallbackHelper { |
| 23 private AwRenderProcessGoneDetail mDetail; | 26 private AwRenderProcessGoneDetail mDetail; |
| 24 | 27 |
| 25 public AwRenderProcessGoneDetail getAwRenderProcessGoneDetail() { | 28 public AwRenderProcessGoneDetail getAwRenderProcessGoneDetail() { |
| 26 assert getCallCount() > 0; | 29 assert getCallCount() > 0; |
| 27 return mDetail; | 30 return mDetail; |
| 28 } | 31 } |
| 29 | 32 |
| 30 public void notifyCalled(AwRenderProcessGoneDetail detail) { | 33 public void notifyCalled(AwRenderProcessGoneDetail detail) { |
| 31 mDetail = detail; | 34 mDetail = detail; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 .Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER) | 61 .Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER) |
| 59 @ParameterizedTest.Set | 62 @ParameterizedTest.Set |
| 60 public void testOnRenderProcessCrash() throws Throwable { | 63 public void testOnRenderProcessCrash() throws Throwable { |
| 61 RenderProcessGoneTestAwContentsClient contentsClient = | 64 RenderProcessGoneTestAwContentsClient contentsClient = |
| 62 new RenderProcessGoneTestAwContentsClient(); | 65 new RenderProcessGoneTestAwContentsClient(); |
| 63 AwTestContainerView testView = createAwTestContainerViewOnMainSync(conte
ntsClient); | 66 AwTestContainerView testView = createAwTestContainerViewOnMainSync(conte
ntsClient); |
| 64 AwContents awContents = testView.getAwContents(); | 67 AwContents awContents = testView.getAwContents(); |
| 65 GetRenderProcessGoneHelper helper = contentsClient.getGetRenderProcessGo
neHelper(); | 68 GetRenderProcessGoneHelper helper = contentsClient.getGetRenderProcessGo
neHelper(); |
| 66 loadUrlAsync(awContents, "chrome://crash"); | 69 loadUrlAsync(awContents, "chrome://crash"); |
| 67 int callCount = helper.getCallCount(); | 70 int callCount = helper.getCallCount(); |
| 68 helper.waitForCallback(callCount); | 71 helper.waitForCallback(callCount, 1, CallbackHelper.WAIT_TIMEOUT_SECONDS
* 5, |
| 69 | 72 TimeUnit.SECONDS); |
| 70 assertEquals(callCount + 1, helper.getCallCount()); | 73 assertEquals(callCount + 1, helper.getCallCount()); |
| 71 assertTrue(helper.getAwRenderProcessGoneDetail().didCrash()); | 74 assertTrue(helper.getAwRenderProcessGoneDetail().didCrash()); |
| 72 assertEquals(RendererPriority.HIGH, | 75 assertEquals(RendererPriority.HIGH, |
| 73 helper.getAwRenderProcessGoneDetail().rendererPriority()); | 76 helper.getAwRenderProcessGoneDetail().rendererPriority()); |
| 74 } | 77 } |
| 75 | 78 |
| 76 @Feature({"AndroidWebView"}) | 79 @Feature({"AndroidWebView"}) |
| 77 @SmallTest | 80 @SmallTest |
| 78 @CommandLineFlags | 81 @CommandLineFlags |
| 79 .Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER) | 82 .Add(AwSwitches.WEBVIEW_SANDBOXED_RENDERER) |
| 80 @ParameterizedTest.Set | 83 @ParameterizedTest.Set |
| 81 public void testOnRenderProcessKill() throws Throwable { | 84 public void testOnRenderProcessKill() throws Throwable { |
| 82 RenderProcessGoneTestAwContentsClient contentsClient = | 85 RenderProcessGoneTestAwContentsClient contentsClient = |
| 83 new RenderProcessGoneTestAwContentsClient(); | 86 new RenderProcessGoneTestAwContentsClient(); |
| 84 AwTestContainerView testView = createAwTestContainerViewOnMainSync(conte
ntsClient); | 87 AwTestContainerView testView = createAwTestContainerViewOnMainSync(conte
ntsClient); |
| 85 AwContents awContents = testView.getAwContents(); | 88 AwContents awContents = testView.getAwContents(); |
| 86 GetRenderProcessGoneHelper helper = contentsClient.getGetRenderProcessGo
neHelper(); | 89 GetRenderProcessGoneHelper helper = contentsClient.getGetRenderProcessGo
neHelper(); |
| 87 loadUrlAsync(awContents, "chrome://kill"); | 90 loadUrlAsync(awContents, "chrome://kill"); |
| 88 int callCount = helper.getCallCount(); | 91 int callCount = helper.getCallCount(); |
| 89 helper.waitForCallback(callCount); | 92 helper.waitForCallback(callCount); |
| 90 | 93 |
| 91 assertEquals(callCount + 1, helper.getCallCount()); | 94 assertEquals(callCount + 1, helper.getCallCount()); |
| 92 assertFalse(helper.getAwRenderProcessGoneDetail().didCrash()); | 95 assertFalse(helper.getAwRenderProcessGoneDetail().didCrash()); |
| 93 assertEquals(RendererPriority.HIGH, | 96 assertEquals(RendererPriority.HIGH, |
| 94 helper.getAwRenderProcessGoneDetail().rendererPriority()); | 97 helper.getAwRenderProcessGoneDetail().rendererPriority()); |
| 95 } | 98 } |
| 96 } | 99 } |
| OLD | NEW |