OLD | NEW |
1 // Copyright 2014 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.content_shell_apk; | 5 package org.chromium.content_shell_apk; |
6 | 6 |
7 import android.support.test.filters.SmallTest; | 7 import android.support.test.filters.SmallTest; |
8 | 8 |
| 9 import org.junit.Assert; |
| 10 import org.junit.Rule; |
| 11 import org.junit.Test; |
| 12 import org.junit.runner.RunWith; |
| 13 |
| 14 import org.chromium.base.test.BaseJUnit4ClassRunner; |
9 import org.chromium.base.test.util.Feature; | 15 import org.chromium.base.test.util.Feature; |
10 import org.chromium.base.test.util.RetryOnFailure; | 16 import org.chromium.base.test.util.RetryOnFailure; |
11 import org.chromium.base.test.util.UrlUtils; | 17 import org.chromium.base.test.util.UrlUtils; |
12 import org.chromium.content_shell.Shell; | 18 import org.chromium.content_shell.Shell; |
13 | 19 |
14 import java.util.concurrent.ExecutionException; | 20 import java.util.concurrent.ExecutionException; |
15 | 21 |
16 /** | 22 /** |
17 * Test suite to verify the behavior of the shell management logic. | 23 * Test suite to verify the behavior of the shell management logic. |
18 */ | 24 */ |
19 public class ContentShellShellManagementTest extends ContentShellTestBase { | 25 @RunWith(BaseJUnit4ClassRunner.class) |
| 26 public class ContentShellShellManagementTest { |
| 27 @Rule |
| 28 public ContentShellActivityTestRule mActivityTestRule = new ContentShellActi
vityTestRule(); |
20 | 29 |
21 private static final String TEST_PAGE_1 = UrlUtils.encodeHtmlDataUri( | 30 private static final String TEST_PAGE_1 = UrlUtils.encodeHtmlDataUri( |
22 "<html><body style='background: red;'></body></html>"); | 31 "<html><body style='background: red;'></body></html>"); |
23 private static final String TEST_PAGE_2 = UrlUtils.encodeHtmlDataUri( | 32 private static final String TEST_PAGE_2 = UrlUtils.encodeHtmlDataUri( |
24 "<html><body style='background: green;'></body></html>"); | 33 "<html><body style='background: green;'></body></html>"); |
25 | 34 |
| 35 @Test |
26 @SmallTest | 36 @SmallTest |
27 @Feature({"Main"}) | 37 @Feature({"Main"}) |
28 @RetryOnFailure | 38 @RetryOnFailure |
29 public void testMultipleShellsLaunched() throws InterruptedException, Execut
ionException { | 39 public void testMultipleShellsLaunched() throws InterruptedException, Execut
ionException { |
30 final ContentShellActivity activity = launchContentShellWithUrl(TEST_PAG
E_1); | 40 final ContentShellActivity activity = |
31 assertEquals(TEST_PAGE_1, activity.getActiveShell().getContentViewCore() | 41 mActivityTestRule.launchContentShellWithUrl(TEST_PAGE_1); |
32 .getWebContents().getUrl()); | 42 Assert.assertEquals(TEST_PAGE_1, |
| 43 activity.getActiveShell().getContentViewCore().getWebContents().
getUrl()); |
33 | 44 |
34 Shell previousActiveShell = activity.getActiveShell(); | 45 Shell previousActiveShell = activity.getActiveShell(); |
35 assertFalse(previousActiveShell.isDestroyed()); | 46 Assert.assertFalse(previousActiveShell.isDestroyed()); |
36 | 47 |
37 loadNewShell(TEST_PAGE_2); | 48 mActivityTestRule.loadNewShell(TEST_PAGE_2); |
38 assertEquals(TEST_PAGE_2, activity.getActiveShell().getContentViewCore() | 49 Assert.assertEquals(TEST_PAGE_2, |
39 .getWebContents().getUrl()); | 50 activity.getActiveShell().getContentViewCore().getWebContents().
getUrl()); |
40 | 51 |
41 assertNotSame(previousActiveShell, activity.getActiveShell()); | 52 Assert.assertNotSame(previousActiveShell, activity.getActiveShell()); |
42 assertTrue(previousActiveShell.isDestroyed()); | 53 Assert.assertTrue(previousActiveShell.isDestroyed()); |
43 assertFalse(previousActiveShell.getContentViewCore().isAlive()); | 54 Assert.assertFalse(previousActiveShell.getContentViewCore().isAlive()); |
44 } | 55 } |
45 | 56 |
46 } | 57 } |
OLD | NEW |