Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / shell / android / javatests / src / org / chromium / content_shell_apk / ContentShellShellManagementTest.java
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.
4
5 package org.chromium.content_shell_apk;
6
7 import android.test.suitebuilder.annotation.SmallTest;
8
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;
13
14 /**
15  * Test suite to verify the behavior of the shell management logic.
16  */
17 public class ContentShellShellManagementTest extends ContentShellTestBase {
18
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>");
23
24     @SmallTest
25     @Feature({"Main"})
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());
30
31         Shell previousActiveShell = activity.getActiveShell();
32         assertFalse(previousActiveShell.isDestroyed());
33
34         ThreadUtils.runOnUiThreadBlocking(new Runnable() {
35             @Override
36             public void run() {
37                 activity.getShellManager().launchShell(TEST_PAGE_2);
38             }
39         });
40         waitForActiveShellToBeDoneLoading();
41         assertEquals(TEST_PAGE_2, activity.getActiveShell().getContentViewCore()
42                 .getWebContents().getUrl());
43
44         assertNotSame(previousActiveShell, activity.getActiveShell());
45         assertTrue(previousActiveShell.isDestroyed());
46         assertFalse(previousActiveShell.getContentViewCore().isAlive());
47     }
48
49 }