OLD | NEW |
---|---|
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.shell.ChromeShellActivity; | 14 import org.chromium.chrome.shell.ChromeShellActivity; |
15 import org.chromium.chrome.shell.ChromeShellTestBase; | 15 import org.chromium.chrome.shell.ChromeShellTestBase; |
16 import org.chromium.content.browser.NavigationClient; | |
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; |
18 import org.chromium.content_public.browser.LoadUrlParams; | |
19 import org.chromium.content_public.browser.NavigationController; | |
19 import org.chromium.content_public.browser.NavigationEntry; | 20 import org.chromium.content_public.browser.NavigationEntry; |
20 import org.chromium.content_public.browser.NavigationHistory; | 21 import org.chromium.content_public.browser.NavigationHistory; |
21 | 22 |
22 import java.util.concurrent.Callable; | 23 import java.util.concurrent.Callable; |
23 import java.util.concurrent.ExecutionException; | 24 import java.util.concurrent.ExecutionException; |
24 | 25 |
25 /** | 26 /** |
26 * Tests for the navigation popup. | 27 * Tests for the navigation popup. |
27 */ | 28 */ |
28 public class NavigationPopupTest extends ChromeShellTestBase { | 29 public class NavigationPopupTest extends ChromeShellTestBase { |
(...skipping 18 matching lines...) Expand all Loading... | |
47 } | 48 } |
48 | 49 |
49 // Exists solely to expose protected methods to this test. | 50 // Exists solely to expose protected methods to this test. |
50 private static class TestNavigationEntry extends NavigationEntry { | 51 private static class TestNavigationEntry extends NavigationEntry { |
51 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl, | 52 public TestNavigationEntry(int index, String url, String virtualUrl, Str ing originalUrl, |
52 String title, Bitmap favicon) { | 53 String title, Bitmap favicon) { |
53 super(index, url, virtualUrl, originalUrl, title, favicon); | 54 super(index, url, virtualUrl, originalUrl, title, favicon); |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 private static class TestNavigationClient implements NavigationClient { | 58 private static class TestNavigationClient implements NavigationController { |
Ted C
2014/10/22 17:41:34
TestNavigationController now
AKVT
2014/10/23 13:34:27
Done.
| |
58 private TestNavigationHistory mHistory; | 59 private TestNavigationHistory mHistory; |
59 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX; | 60 private int mNavigatedIndex = INVALID_NAVIGATION_INDEX; |
60 | 61 |
61 public TestNavigationClient() { | 62 public TestNavigationClient() { |
62 mHistory = new TestNavigationHistory(); | 63 mHistory = new TestNavigationHistory(); |
63 mHistory.addEntry(new TestNavigationEntry( | 64 mHistory.addEntry(new TestNavigationEntry( |
64 1, "about:blank", null, null, "About Blank", null)); | 65 1, "about:blank", null, null, "About Blank", null)); |
65 mHistory.addEntry(new TestNavigationEntry( | 66 mHistory.addEntry(new TestNavigationEntry( |
66 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null)); | 67 5, UrlUtils.encodeHtmlDataUri("<html>1</html>"), null, null, null, null)); |
67 } | 68 } |
68 | 69 |
69 @Override | 70 @Override |
71 public boolean canGoBack() { | |
72 return false; | |
73 } | |
74 | |
75 @Override | |
76 public boolean canGoForward() { | |
77 return false; | |
78 } | |
79 | |
80 @Override | |
81 public boolean canGoToOffset(int offset) { | |
82 return false; | |
83 } | |
84 | |
85 @Override | |
86 public void goToOffset(int offset) { | |
87 } | |
88 | |
89 @Override | |
90 public void goBack() { | |
91 } | |
92 | |
93 @Override | |
94 public void goForward() { | |
95 } | |
96 | |
97 @Override | |
98 public void loadIfNecessary() { | |
99 } | |
100 | |
101 @Override | |
102 public void requestRestoreLoad() { | |
103 } | |
104 | |
105 @Override | |
106 public void reload(boolean checkForRepost) { | |
107 } | |
108 | |
109 @Override | |
110 public void reloadIgnoringCache(boolean checkForRepost) { | |
111 } | |
112 | |
113 @Override | |
114 public void cancelPendingReload() { | |
115 } | |
116 | |
117 @Override | |
118 public void continuePendingReload() { | |
119 } | |
120 | |
121 @Override | |
122 public void loadUrl(LoadUrlParams params) { | |
123 } | |
124 | |
125 @Override | |
126 public void clearHistory() { | |
127 } | |
128 | |
129 @Override | |
130 public NavigationHistory getNavigationHistory() { | |
131 return null; | |
132 } | |
133 | |
134 | |
135 @Override | |
136 public String getOriginalUrlForVisibleNavigationEntry() { | |
137 return null; | |
138 } | |
139 | |
140 @Override | |
141 public void clearSslPreferences() { | |
142 } | |
143 | |
144 @Override | |
145 public boolean getUseDesktopUserAgent() { | |
146 return false; | |
147 } | |
148 | |
149 @Override | |
150 public void setUseDesktopUserAgent(boolean override, boolean reloadOnCha nge) { | |
151 } | |
152 | |
153 @Override | |
154 public NavigationEntry getPendingEntry() { | |
155 return null; | |
156 } | |
157 | |
158 @Override | |
70 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { | 159 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) { |
71 return mHistory; | 160 return mHistory; |
72 } | 161 } |
73 | 162 |
74 @Override | 163 @Override |
75 public void goToNavigationIndex(int index) { | 164 public void goToNavigationIndex(int index) { |
76 mNavigatedIndex = index; | 165 mNavigatedIndex = index; |
77 } | 166 } |
78 } | 167 } |
79 | 168 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 public void run() { | 232 public void run() { |
144 popup.performItemClick(1); | 233 popup.performItemClick(1); |
145 } | 234 } |
146 }); | 235 }); |
147 | 236 |
148 assertFalse("Popup did not hide as expected.", popup.isShowing()); | 237 assertFalse("Popup did not hide as expected.", popup.isShowing()); |
149 assertEquals("Popup attempted to navigate to the wrong index", 5, client .mNavigatedIndex); | 238 assertEquals("Popup attempted to navigate to the wrong index", 5, client .mNavigatedIndex); |
150 } | 239 } |
151 | 240 |
152 } | 241 } |
OLD | NEW |