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

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

Issue 2235533002: Revert "Changed NavigationController access to through tab in Java code" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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_sources.gni ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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.navigation.NavigationHandler;
15 import org.chromium.chrome.browser.profiles.Profile; 14 import org.chromium.chrome.browser.profiles.Profile;
16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; 15 import org.chromium.chrome.test.ChromeActivityTestCaseBase;
17 import org.chromium.content.browser.test.util.Criteria; 16 import org.chromium.content.browser.test.util.Criteria;
18 import org.chromium.content.browser.test.util.CriteriaHelper; 17 import org.chromium.content.browser.test.util.CriteriaHelper;
19 import org.chromium.content_public.browser.LoadUrlParams; 18 import org.chromium.content_public.browser.LoadUrlParams;
19 import org.chromium.content_public.browser.NavigationController;
20 import org.chromium.content_public.browser.NavigationEntry; 20 import org.chromium.content_public.browser.NavigationEntry;
21 import org.chromium.content_public.browser.NavigationHistory; 21 import org.chromium.content_public.browser.NavigationHistory;
22 22
23 /** 23 /**
24 * Tests for the navigation popup. 24 * Tests for the navigation popup.
25 */ 25 */
26 public class NavigationPopupTest extends ChromeActivityTestCaseBase<ChromeActivi ty> { 26 public class NavigationPopupTest extends ChromeActivityTestCaseBase<ChromeActivi ty> {
27 27
28 private static final int INVALID_NAVIGATION_INDEX = -1; 28 private static final int INVALID_NAVIGATION_INDEX = -1;
29 29
(...skipping 28 matching lines...) Expand all
58 } 58 }
59 59
60 // Exists solely to expose protected methods to this test. 60 // Exists solely to expose protected methods to this test.
61 private static class TestNavigationEntry extends NavigationEntry { 61 private static class TestNavigationEntry extends NavigationEntry {
62 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl, 62 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl,
63 String title, Bitmap favicon, int transition) { 63 String title, Bitmap favicon, int transition) {
64 super(index, url, virtualUrl, originalUrl, title, favicon, transitio n); 64 super(index, url, virtualUrl, originalUrl, title, favicon, transitio n);
65 } 65 }
66 } 66 }
67 67
68 private static class TestNavigationHandler implements NavigationHandler { 68 private static class TestNavigationController implements NavigationControlle r {
69 private final TestNavigationHistory mHistory; 69 private final TestNavigationHistory mHistory;
70 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX; 70 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX;
71 71
72 public TestNavigationHandler() { 72 public TestNavigationController() {
73 mHistory = new TestNavigationHistory(); 73 mHistory = new TestNavigationHistory();
74 mHistory.addEntry(new TestNavigationEntry( 74 mHistory.addEntry(new TestNavigationEntry(
75 1, "about:blank", null, null, "About Blank", null, 0)); 75 1, "about:blank", null, null, "About Blank", null, 0));
76 mHistory.addEntry(new TestNavigationEntry( 76 mHistory.addEntry(new TestNavigationEntry(
77 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null, 0)); 77 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null, 0));
78 } 78 }
79 79
80 @Override 80 @Override
81 public boolean canGoBack() { 81 public boolean canGoBack() {
82 return false; 82 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 @Override 140 @Override
141 public void continuePendingReload() { 141 public void continuePendingReload() {
142 } 142 }
143 143
144 @Override 144 @Override
145 public void loadUrl(LoadUrlParams params) { 145 public void loadUrl(LoadUrlParams params) {
146 } 146 }
147 147
148 @Override 148 @Override
149 public void clearHistory() {
150 }
151
152 @Override
153 public NavigationHistory getNavigationHistory() {
154 return null;
155 }
156
157 @Override
149 public String getOriginalUrlForVisibleNavigationEntry() { 158 public String getOriginalUrlForVisibleNavigationEntry() {
150 return null; 159 return null;
151 } 160 }
152 161
153 @Override 162 @Override
154 public void clearSslPreferences() { 163 public void clearSslPreferences() {
155 } 164 }
156 165
157 @Override 166 @Override
158 public boolean getUseDesktopUserAgent() { 167 public boolean getUseDesktopUserAgent() {
159 return false; 168 return false;
160 } 169 }
161 170
162 @Override 171 @Override
163 public void setUseDesktopUserAgent(boolean override, boolean reloadOnCha nge) { 172 public void setUseDesktopUserAgent(boolean override, boolean reloadOnCha nge) {
164 } 173 }
165 174
166 @Override 175 @Override
167 public NavigationEntry getEntryAtIndex(int index) { 176 public NavigationEntry getEntryAtIndex(int index) {
168 return null; 177 return null;
169 } 178 }
170 179
171 @Override 180 @Override
181 public NavigationEntry getPendingEntry() {
182 return null;
183 }
184
185 @Override
172 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { 186 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
173 return mHistory; 187 return mHistory;
174 } 188 }
175 189
176 @Override 190 @Override
177 public void goToNavigationIndex(int index) { 191 public void goToNavigationIndex(int index) {
178 mNavigatedIndex = index; 192 mNavigatedIndex = index;
179 } 193 }
180 194
181 @Override 195 @Override
182 public int getLastCommittedEntryIndex() { 196 public int getLastCommittedEntryIndex() {
183 return -1; 197 return -1;
184 } 198 }
185 199
186 @Override 200 @Override
187 public boolean removeEntryAtIndex(int index) { 201 public boolean removeEntryAtIndex(int index) {
188 return false; 202 return false;
189 } 203 }
204
205 @Override
206 public boolean canCopyStateOver() {
207 return false;
208 }
209
210 @Override
211 public boolean canPruneAllButLastCommitted() {
212 return false;
213 }
214
215 @Override
216 public void copyStateFrom(NavigationController source) {
217 }
218
219 @Override
220 public void copyStateFromAndPrune(NavigationController source, boolean r eplaceEntry) {
221 }
190 } 222 }
191 223
192 @MediumTest 224 @MediumTest
193 @Feature({"Navigation"}) 225 @Feature({"Navigation"})
194 public void testFaviconFetching() throws InterruptedException { 226 public void testFaviconFetching() throws InterruptedException {
195 final TestNavigationHandler controller = new TestNavigationHandler(); 227 final TestNavigationController controller = new TestNavigationController ();
196 final NavigationPopup popup = new NavigationPopup( 228 final NavigationPopup popup = new NavigationPopup(
197 mProfile, getActivity(), controller, true); 229 mProfile, getActivity(), controller, true);
198 popup.setWidth(300); 230 popup.setWidth(300);
199 popup.setHeight(300); 231 popup.setHeight(300);
200 popup.setAnchorView(getActivity().getCurrentContentViewCore().getContain erView()); 232 popup.setAnchorView(getActivity().getCurrentContentViewCore().getContain erView());
201 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 233 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
202 @Override 234 @Override
203 public void run() { 235 public void run() {
204 popup.show(); 236 popup.show();
205 } 237 }
(...skipping 16 matching lines...) Expand all
222 @Override 254 @Override
223 public void run() { 255 public void run() {
224 popup.dismiss(); 256 popup.dismiss();
225 } 257 }
226 }); 258 });
227 } 259 }
228 260
229 @SmallTest 261 @SmallTest
230 @Feature({"Navigation"}) 262 @Feature({"Navigation"})
231 public void testItemSelection() { 263 public void testItemSelection() {
232 final TestNavigationHandler controller = new TestNavigationHandler(); 264 final TestNavigationController controller = new TestNavigationController ();
233 final NavigationPopup popup = 265 final NavigationPopup popup =
234 new NavigationPopup(mProfile, getActivity(), controller, true); 266 new NavigationPopup(mProfile, getActivity(), controller, true);
235 popup.setWidth(300); 267 popup.setWidth(300);
236 popup.setHeight(300); 268 popup.setHeight(300);
237 popup.setAnchorView(getActivity().getCurrentContentViewCore().getContain erView()); 269 popup.setAnchorView(getActivity().getCurrentContentViewCore().getContain erView());
238 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 270 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
239 @Override 271 @Override
240 public void run() { 272 public void run() {
241 popup.show(); 273 popup.show();
242 } 274 }
243 }); 275 });
244 276
245 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 277 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
246 @Override 278 @Override
247 public void run() { 279 public void run() {
248 popup.performItemClick(1); 280 popup.performItemClick(1);
249 } 281 }
250 }); 282 });
251 283
252 assertFalse("Popup did not hide as expected.", popup.isShowing()); 284 assertFalse("Popup did not hide as expected.", popup.isShowing());
253 assertEquals("Popup attempted to navigate to the wrong index", 5, 285 assertEquals("Popup attempted to navigate to the wrong index", 5,
254 controller.mNavigatedIndex); 286 controller.mNavigatedIndex);
255 } 287 }
256 288
257 } 289 }
OLDNEW
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698