EMMA Coverage Report (generated Tue Aug 20 10:07:21 PDT 2013)
[all classes][org.chromium.chrome.testshell]

COVERAGE SUMMARY FOR SOURCE FILE [ChromiumTestShellUrlTest.java]

nameclass, %method, %block, %line, %
ChromiumTestShellUrlTest.java100% (4/4)100% (10/10)96%  (234/244)95%  (41/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ChromiumTestShellUrlTest100% (1/1)100% (4/4)93%  (137/147)94%  (29/31)
testCompositorInit (): void 100% (1/1)62%  (16/26)71%  (5/7)
ChromiumTestShellUrlTest (): void 100% (1/1)100% (3/3)100% (1/1)
testBaseStartup (): void 100% (1/1)100% (10/10)100% (4/4)
testChromeWelcomePageLoads (): void 100% (1/1)100% (108/108)100% (19/19)
     
class ChromiumTestShellUrlTest$1100% (1/1)100% (2/2)100% (31/31)100% (6/6)
ChromiumTestShellUrlTest$1 (ChromiumTestShellUrlTest, ChromiumTestShellActivi... 100% (1/1)100% (15/15)100% (1/1)
run (): void 100% (1/1)100% (16/16)100% (5/5)
     
class ChromiumTestShellUrlTest$2100% (1/1)100% (2/2)100% (43/43)100% (5/5)
ChromiumTestShellUrlTest$2 (ChromiumTestShellUrlTest, AtomicBoolean, AtomicRe... 100% (1/1)100% (18/18)100% (1/1)
run (): void 100% (1/1)100% (25/25)100% (4/4)
     
class ChromiumTestShellUrlTest$3100% (1/1)100% (2/2)100% (23/23)100% (4/4)
ChromiumTestShellUrlTest$3 (ChromiumTestShellUrlTest, ChromiumTestShellActivi... 100% (1/1)100% (9/9)100% (1/1)
run (): void 100% (1/1)100% (14/14)100% (3/3)

1// Copyright (c) 2012 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 
5package org.chromium.chrome.testshell;
6 
7import android.test.suitebuilder.annotation.SmallTest;
8 
9import org.chromium.base.ThreadUtils;
10import org.chromium.base.test.util.Feature;
11import org.chromium.content.browser.ContentView;
12import org.chromium.content.browser.ContentViewCore;
13import org.chromium.content.browser.ContentViewRenderView;
14 
15import java.util.concurrent.atomic.AtomicBoolean;
16import java.util.concurrent.atomic.AtomicReference;
17 
18public class ChromiumTestShellUrlTest extends ChromiumTestShellTestBase {
19    // URL used for base tests.
20    private static final String URL = "data:text";
21 
22    @SmallTest
23    @Feature({"Main"})
24    public void testBaseStartup() throws InterruptedException {
25        ChromiumTestShellActivity activity = launchChromiumTestShellWithUrl(URL);
26        waitForActiveShellToBeDoneLoading();
27 
28        // Make sure the activity was created as expected.
29        assertNotNull(activity);
30    }
31 
32    @SmallTest
33    @Feature({"Main"})
34    public void testChromeWelcomePageLoads() throws InterruptedException {
35        String welcomeUrl = "chrome://welcome/";
36        final ChromiumTestShellActivity activity = launchChromiumTestShellWithUrl(welcomeUrl);
37        waitForActiveShellToBeDoneLoading();
38 
39        // Make sure the activity was created as expected.
40        assertNotNull(activity);
41 
42        // Ensure we have a ContentView and ContentViewCore.
43        final AtomicReference<ContentView> contentView = new AtomicReference<ContentView>();
44        final AtomicReference<ContentViewCore> contentViewCore =
45                new AtomicReference<ContentViewCore>();
46        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
47            @Override
48            public void run() {
49                ContentView activeContentView = activity.getActiveContentView();
50                contentView.set(activeContentView);
51                if (activeContentView != null) {
52                    contentViewCore.set(activeContentView.getContentViewCore());
53                }
54            }
55        });
56        assertNotNull(contentView.get());
57        assertNotNull(contentViewCore.get());
58 
59        // Ensure the correct page has been loaded, ie. not interstitial, and title/url should
60        // be sane. Note, a typical correct title is: "Welcome to Chromium", whereas a wrong one
61        // would be on the form "chrome://welcome/ is not available".
62        final AtomicBoolean isShowingInterstitialPage = new AtomicBoolean();
63        final AtomicReference<String> url = new AtomicReference<String>();
64        final AtomicReference<String> title = new AtomicReference<String>();
65        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
66            @Override
67            public void run() {
68                isShowingInterstitialPage.set(contentViewCore.get().isShowingInterstitialPage());
69                url.set(contentViewCore.get().getUrl());
70                title.set(contentViewCore.get().getTitle());
71            }
72        });
73        assertFalse("Showed interstitial page instead of welcome page",
74                isShowingInterstitialPage.get());
75        assertNotNull("URL was null", url.get());
76        assertTrue("URL did not contain: " + welcomeUrl + ". Was: " + url.get(),
77                url.get().contains(welcomeUrl));
78        assertNotNull("Title was null", title.get());
79        assertFalse("Title should not contain: " + welcomeUrl + ". Was: " + title.get(),
80                title.get().toLowerCase().contains(welcomeUrl));
81    }
82 
83    /**
84     * Tests that creating an extra ContentViewRenderView does not cause an assert because we would
85     * initialize the compositor twice http://crbug.com/162312
86     */
87    @SmallTest
88    @Feature({"Main"})
89    public void testCompositorInit() throws InterruptedException {
90        // Start the ChromiumTestShell, this loads the native library and create an instance of
91        // ContentViewRenderView.
92        final ChromiumTestShellActivity activity = launchChromiumTestShellWithUrl(URL);
93        waitForActiveShellToBeDoneLoading();
94 
95        // Now create a new ContentViewRenderView, it should not assert.
96        try {
97            runTestOnUiThread(new Runnable() {
98                @Override
99                public void run() {
100                    ContentViewRenderView contentViewRenderView =
101                            new ContentViewRenderView(getInstrumentation().getTargetContext());
102                    contentViewRenderView.setCurrentContentView(activity.getActiveContentView());
103                }
104            });
105        } catch (Throwable e) {
106            fail("Could not create a ContentViewRenderView: " + e);
107        }
108    }
109}

[all classes][org.chromium.chrome.testshell]
EMMA 2.0.5312 (C) Vladimir Roubtsov