Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java

Issue 12578027: Removed 'show full history' from navigation popup. Cleaned up associated dead code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-show-full-history-from-menu-222282
Patch Set: Removed broken test (checking click on show full history which we removed) Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/NavigationPopup.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.graphics.Bitmap; 7 import android.graphics.Bitmap;
8 import android.test.suitebuilder.annotation.MediumTest; 8 import android.test.suitebuilder.annotation.MediumTest;
9 import android.test.suitebuilder.annotation.SmallTest; 9 import android.test.suitebuilder.annotation.SmallTest;
10 10
11 import org.chromium.base.ThreadUtils; 11 import org.chromium.base.ThreadUtils;
12 import org.chromium.base.test.util.Feature; 12 import org.chromium.base.test.util.Feature;
13 import org.chromium.base.test.util.UrlUtils; 13 import org.chromium.base.test.util.UrlUtils;
14 import org.chromium.chrome.browser.NavigationPopup.NavigationPopupDelegate;
15 import org.chromium.chrome.testshell.ChromiumTestShellActivity; 14 import org.chromium.chrome.testshell.ChromiumTestShellActivity;
16 import org.chromium.chrome.testshell.ChromiumTestShellTestBase; 15 import org.chromium.chrome.testshell.ChromiumTestShellTestBase;
17 import org.chromium.content.browser.NavigationClient; 16 import org.chromium.content.browser.NavigationClient;
18 import org.chromium.content.browser.NavigationEntry; 17 import org.chromium.content.browser.NavigationEntry;
19 import org.chromium.content.browser.NavigationHistory; 18 import org.chromium.content.browser.NavigationHistory;
20 import org.chromium.content.browser.test.util.Criteria; 19 import org.chromium.content.browser.test.util.Criteria;
21 import org.chromium.content.browser.test.util.CriteriaHelper; 20 import org.chromium.content.browser.test.util.CriteriaHelper;
22 21
23 import java.util.concurrent.Callable; 22 import java.util.concurrent.Callable;
24 import java.util.concurrent.ExecutionException; 23 import java.util.concurrent.ExecutionException;
(...skipping 23 matching lines...) Expand all
48 } 47 }
49 48
50 // Exists solely to expose protected methods to this test. 49 // Exists solely to expose protected methods to this test.
51 private static class TestNavigationEntry extends NavigationEntry { 50 private static class TestNavigationEntry extends NavigationEntry {
52 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl, 51 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl,
53 String title, Bitmap favicon) { 52 String title, Bitmap favicon) {
54 super(index, url, virtualUrl, originalUrl, title, favicon); 53 super(index, url, virtualUrl, originalUrl, title, favicon);
55 } 54 }
56 } 55 }
57 56
58 private static class TestNavigationPopupDelegate implements NavigationPopupD elegate {
59 private boolean mHistoryRequested;
60
61 @Override
62 public void openHistory() {
63 mHistoryRequested = true;
64 }
65 }
66
67 private static class TestNavigationClient implements NavigationClient { 57 private static class TestNavigationClient implements NavigationClient {
68 private TestNavigationHistory mHistory; 58 private TestNavigationHistory mHistory;
69 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX; 59 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX;
70 60
71 public TestNavigationClient() { 61 public TestNavigationClient() {
72 mHistory = new TestNavigationHistory(); 62 mHistory = new TestNavigationHistory();
73 mHistory.addEntry(new TestNavigationEntry( 63 mHistory.addEntry(new TestNavigationEntry(
74 1, "about:blank", null, null, "About Blank", null)); 64 1, "about:blank", null, null, "About Blank", null));
75 mHistory.addEntry(new TestNavigationEntry( 65 mHistory.addEntry(new TestNavigationEntry(
76 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null)); 66 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null));
77 } 67 }
78 68
79 @Override 69 @Override
80 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { 70 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
81 return mHistory; 71 return mHistory;
82 } 72 }
83 73
84 @Override 74 @Override
85 public void goToNavigationIndex(int index) { 75 public void goToNavigationIndex(int index) {
86 mNavigatedIndex = index; 76 mNavigatedIndex = index;
87 } 77 }
88 } 78 }
89 79
90 @MediumTest 80 @MediumTest
91 @Feature({"Navigation"}) 81 @Feature({"Navigation"})
92 public void testFaviconFetching() throws InterruptedException { 82 public void testFaviconFetching() throws InterruptedException {
93 final TestNavigationClient client = new TestNavigationClient(); 83 final TestNavigationClient client = new TestNavigationClient();
94 final NavigationPopup popup = new NavigationPopup( 84 final NavigationPopup popup = new NavigationPopup(
95 mActivity, new TestNavigationPopupDelegate(), client, true); 85 mActivity, client, true);
96 popup.setWidth(300); 86 popup.setWidth(300);
97 popup.setAnchorView(mActivity.getActiveContentView()); 87 popup.setAnchorView(mActivity.getActiveContentView());
98 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 88 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
99 @Override 89 @Override
100 public void run() { 90 public void run() {
101 popup.show(); 91 popup.show();
102 } 92 }
103 }); 93 });
104 94
105 assertTrue("All favicons did not get updated.", 95 assertTrue("All favicons did not get updated.",
(...skipping 23 matching lines...) Expand all
129 popup.dismiss(); 119 popup.dismiss();
130 } 120 }
131 }); 121 });
132 } 122 }
133 123
134 @SmallTest 124 @SmallTest
135 @Feature({"Navigation"}) 125 @Feature({"Navigation"})
136 public void testItemSelection() { 126 public void testItemSelection() {
137 final TestNavigationClient client = new TestNavigationClient(); 127 final TestNavigationClient client = new TestNavigationClient();
138 final NavigationPopup popup = new NavigationPopup( 128 final NavigationPopup popup = new NavigationPopup(
139 mActivity, new TestNavigationPopupDelegate(), client, true); 129 mActivity, client, true);
140 popup.setWidth(300); 130 popup.setWidth(300);
141 popup.setAnchorView(mActivity.getActiveContentView()); 131 popup.setAnchorView(mActivity.getActiveContentView());
142 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 132 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
143 @Override 133 @Override
144 public void run() { 134 public void run() {
145 popup.show(); 135 popup.show();
146 } 136 }
147 }); 137 });
148 138
149 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 139 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
150 @Override 140 @Override
151 public void run() { 141 public void run() {
152 popup.performItemClick(1); 142 popup.performItemClick(1);
153 } 143 }
154 }); 144 });
155 145
156 assertFalse("Popup did not hide as expected.", popup.isShowing()); 146 assertFalse("Popup did not hide as expected.", popup.isShowing());
157 assertEquals("Popup attempted to navigate to the wrong index", 5, client .mNavigatedIndex); 147 assertEquals("Popup attempted to navigate to the wrong index", 5, client .mNavigatedIndex);
158 } 148 }
159 149
160 @SmallTest
161 @Feature({"Navigation"})
162 public void testShowHistorySelection() {
163 final TestNavigationClient client = new TestNavigationClient();
164 TestNavigationPopupDelegate delegate = new TestNavigationPopupDelegate() ;
165 final NavigationPopup popup = new NavigationPopup(mActivity, delegate, c lient, true);
166 popup.setWidth(300);
167 popup.setAnchorView(mActivity.getActiveContentView());
168 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
169 @Override
170 public void run() {
171 popup.show();
172 }
173 });
174
175 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
176 @Override
177 public void run() {
178 popup.performItemClick(2);
179 }
180 });
181
182 assertFalse("Popup did not hide as expected.", popup.isShowing());
183 assertTrue("Popup did not correctly request history.", delegate.mHistory Requested);
184 assertEquals("Popup attempted to navigate instead of showing history",
185 INVALID_NAVIGATION_INDEX, client.mNavigatedIndex);
186 }
187
188 } 150 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/NavigationPopup.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698