1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.content_shell_apk;
7 import android.test.suitebuilder.annotation.SmallTest;
9 import org.chromium.base.ThreadUtils;
10 import org.chromium.base.test.util.Feature;
11 import org.chromium.base.test.util.UrlUtils;
12 import org.chromium.content_shell.Shell;
15 * Test suite to verify the behavior of the shell management logic.
17 public class ContentShellShellManagementTest extends ContentShellTestBase {
19 private static final String TEST_PAGE_1 = UrlUtils.encodeHtmlDataUri(
20 "<html><body style='background: red;'></body></html>");
21 private static final String TEST_PAGE_2 = UrlUtils.encodeHtmlDataUri(
22 "<html><body style='background: green;'></body></html>");
26 public void testMultipleShellsLaunched() throws InterruptedException {
27 final ContentShellActivity activity = launchContentShellWithUrl(TEST_PAGE_1);
28 assertEquals(TEST_PAGE_1, activity.getActiveShell().getContentViewCore()
29 .getWebContents().getUrl());
31 Shell previousActiveShell = activity.getActiveShell();
32 assertFalse(previousActiveShell.isDestroyed());
34 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
37 activity.getShellManager().launchShell(TEST_PAGE_2);
40 waitForActiveShellToBeDoneLoading();
41 assertEquals(TEST_PAGE_2, activity.getActiveShell().getContentViewCore()
42 .getWebContents().getUrl());
44 assertNotSame(previousActiveShell, activity.getActiveShell());
45 assertTrue(previousActiveShell.isDestroyed());
46 assertFalse(previousActiveShell.getContentViewCore().isAlive());