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

COVERAGE SUMMARY FOR SOURCE FILE [NavigationPopupTest.java]

nameclass, %method, %block, %line, %
NavigationPopupTest.java60%  (6/10)60%  (15/25)55%  (146/266)61%  (31.7/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NavigationPopupTest$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/3)
NavigationPopupTest$1 (NavigationPopupTest, NavigationPopup): void 0%   (0/1)0%   (0/9)0%   (0/1)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class NavigationPopupTest$20%   (0/1)0%   (0/2)0%   (0/20)0%   (0/4)
NavigationPopupTest$2 (NavigationPopupTest, NavigationPopupTest$TestNavigatio... 0%   (0/1)0%   (0/9)0%   (0/1)
isSatisfied (): boolean 0%   (0/1)0%   (0/11)0%   (0/3)
     
class NavigationPopupTest$2$10%   (0/1)0%   (0/2)0%   (0/30)0%   (0/5)
NavigationPopupTest$2$1 (NavigationPopupTest$2): void 0%   (0/1)0%   (0/6)0%   (0/1)
call (): Boolean 0%   (0/1)0%   (0/24)0%   (0/4)
     
class NavigationPopupTest$30%   (0/1)0%   (0/2)0%   (0/13)0%   (0/3)
NavigationPopupTest$3 (NavigationPopupTest, NavigationPopup): void 0%   (0/1)0%   (0/9)0%   (0/1)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class NavigationPopupTest100% (1/1)75%  (3/4)56%  (52/93)64%  (14/22)
testFaviconFetching (): void 0%   (0/1)0%   (0/41)0%   (0/8)
NavigationPopupTest (): void 100% (1/1)100% (3/3)100% (2/2)
setUp (): void 100% (1/1)100% (7/7)100% (3/3)
testItemSelection (): void 100% (1/1)100% (42/42)100% (9/9)
     
class NavigationPopupTest$TestNavigationClient100% (1/1)80%  (4/5)94%  (47/50)95%  (9.5/10)
access$100 (NavigationPopupTest$TestNavigationClient): NavigationPopupTest$Te... 0%   (0/1)0%   (0/3)0%   (0/1)
NavigationPopupTest$TestNavigationClient (): void 100% (1/1)100% (37/37)100% (6/6)
access$200 (NavigationPopupTest$TestNavigationClient): int 100% (1/1)100% (3/3)100% (1/1)
getDirectedNavigationHistory (boolean, int): NavigationHistory 100% (1/1)100% (3/3)100% (1/1)
goToNavigationIndex (int): void 100% (1/1)100% (4/4)100% (2/2)
     
class NavigationPopupTest$4100% (1/1)100% (2/2)100% (13/13)100% (3/3)
NavigationPopupTest$4 (NavigationPopupTest, NavigationPopup): void 100% (1/1)100% (9/9)100% (1/1)
run (): void 100% (1/1)100% (4/4)100% (2/2)
     
class NavigationPopupTest$5100% (1/1)100% (2/2)100% (15/15)100% (3/3)
NavigationPopupTest$5 (NavigationPopupTest, NavigationPopup): void 100% (1/1)100% (9/9)100% (1/1)
run (): void 100% (1/1)100% (6/6)100% (2/2)
     
class NavigationPopupTest$TestNavigationEntry100% (1/1)100% (1/1)100% (9/9)100% (2/2)
NavigationPopupTest$TestNavigationEntry (int, String, String, String, String,... 100% (1/1)100% (9/9)100% (2/2)
     
class NavigationPopupTest$TestNavigationHistory100% (1/1)100% (3/3)100% (10/10)100% (3/3)
NavigationPopupTest$TestNavigationHistory (): void 100% (1/1)100% (3/3)100% (1/1)
NavigationPopupTest$TestNavigationHistory (NavigationPopupTest$1): void 100% (1/1)100% (3/3)100% (1/1)
addEntry (NavigationEntry): void 100% (1/1)100% (4/4)100% (2/2)

1// Copyright (c) 2013 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.browser;
6 
7import android.graphics.Bitmap;
8import android.test.suitebuilder.annotation.MediumTest;
9import android.test.suitebuilder.annotation.SmallTest;
10 
11import org.chromium.base.ThreadUtils;
12import org.chromium.base.test.util.Feature;
13import org.chromium.base.test.util.UrlUtils;
14import org.chromium.chrome.testshell.ChromiumTestShellActivity;
15import org.chromium.chrome.testshell.ChromiumTestShellTestBase;
16import org.chromium.content.browser.NavigationClient;
17import org.chromium.content.browser.NavigationEntry;
18import org.chromium.content.browser.NavigationHistory;
19import org.chromium.content.browser.test.util.Criteria;
20import org.chromium.content.browser.test.util.CriteriaHelper;
21 
22import java.util.concurrent.Callable;
23import java.util.concurrent.ExecutionException;
24 
25/**
26 * Tests for the navigation popup.
27 */
28public class NavigationPopupTest extends ChromiumTestShellTestBase {
29 
30    private static final int INVALID_NAVIGATION_INDEX = -1;
31 
32    private ChromiumTestShellActivity mActivity;
33 
34    @Override
35    public void setUp() throws Exception {
36        super.setUp();
37 
38        mActivity = launchChromiumTestShellWithBlankPage();
39    }
40 
41    // Exists solely to expose protected methods to this test.
42    private static class TestNavigationHistory extends NavigationHistory {
43        @Override
44        protected void addEntry(NavigationEntry entry) {
45            super.addEntry(entry);
46        }
47    }
48 
49    // Exists solely to expose protected methods to this test.
50    private static class TestNavigationEntry extends NavigationEntry {
51        public TestNavigationEntry(int index, String url, String virtualUrl, String originalUrl,
52                String title, Bitmap favicon) {
53            super(index, url, virtualUrl, originalUrl, title, favicon);
54        }
55    }
56 
57    private static class TestNavigationClient implements NavigationClient {
58        private TestNavigationHistory mHistory;
59        private int mNavigatedIndex = INVALID_NAVIGATION_INDEX;
60 
61        public TestNavigationClient() {
62            mHistory = new TestNavigationHistory();
63            mHistory.addEntry(new TestNavigationEntry(
64                    1, "about:blank", null, null, "About Blank", null));
65            mHistory.addEntry(new TestNavigationEntry(
66                    5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null));
67        }
68 
69        @Override
70        public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
71            return mHistory;
72        }
73 
74        @Override
75        public void goToNavigationIndex(int index) {
76            mNavigatedIndex = index;
77        }
78    }
79 
80    @MediumTest
81    @Feature({"Navigation"})
82    public void testFaviconFetching() throws InterruptedException {
83        final TestNavigationClient client = new TestNavigationClient();
84        final NavigationPopup popup = new NavigationPopup(
85                mActivity, client, true);
86        popup.setWidth(300);
87        popup.setAnchorView(mActivity.getActiveContentView());
88        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
89            @Override
90            public void run() {
91                popup.show();
92            }
93        });
94 
95        assertTrue("All favicons did not get updated.",
96                CriteriaHelper.pollForCriteria(new Criteria() {
97            @Override
98            public boolean isSatisfied() {
99                try {
100                    return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
101                        @Override
102                        public Boolean call() throws Exception {
103                            NavigationHistory history = client.mHistory;
104                            for (int i = 0; i < history.getEntryCount(); i++) {
105                                if (history.getEntryAtIndex(i).getFavicon() == null) return false;
106                            }
107                            return true;
108                        }
109                    });
110                } catch (ExecutionException e) {
111                    return false;
112                }
113            }
114        }));
115 
116        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
117            @Override
118            public void run() {
119                popup.dismiss();
120            }
121        });
122    }
123 
124    @SmallTest
125    @Feature({"Navigation"})
126    public void testItemSelection() {
127        final TestNavigationClient client = new TestNavigationClient();
128        final NavigationPopup popup = new NavigationPopup(
129                mActivity, client, true);
130        popup.setWidth(300);
131        popup.setAnchorView(mActivity.getActiveContentView());
132        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
133            @Override
134            public void run() {
135                popup.show();
136            }
137        });
138 
139        ThreadUtils.runOnUiThreadBlocking(new Runnable() {
140            @Override
141            public void run() {
142                popup.performItemClick(1);
143            }
144        });
145 
146        assertFalse("Popup did not hide as expected.", popup.isShowing());
147        assertEquals("Popup attempted to navigate to the wrong index", 5, client.mNavigatedIndex);
148    }
149 
150}

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