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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java

Issue 2754203004: 📰 Add tests for context menu usage (Closed)
Patch Set: y Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java b/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java
index b411748dd34ebb35da14a73170f8ab20dc456f1d..c782fd98b47c9f9b29f0e35e457fe072c99b925f 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/FakeMostVisitedSites.java
@@ -5,15 +5,16 @@
package org.chromium.chrome.browser.suggestions;
import org.chromium.base.ThreadUtils;
-import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.ntp.NTPTileSource;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
* A fake implementation of MostVisitedSites that returns a fixed list of most visited sites.
*/
-public class FakeMostVisitedSites extends MostVisitedSites {
+public class FakeMostVisitedSites implements MostVisitedSites {
private final List<String> mBlacklistedUrls = new ArrayList<>();
private String[] mTitles = new String[] {};
@@ -22,13 +23,8 @@
private int[] mSources = new int[] {};
private Observer mObserver;
- /**
- * @param profile The profile for which to fetch site suggestions.
- */
- public FakeMostVisitedSites(Profile profile) {
- // TODO(mvanouwerkerk): Do not let the fake inherit from the real implementation.
- super(profile);
- }
+ @Override
+ public void destroy() {}
@Override
public void setObserver(Observer observer, int numResults) {
@@ -81,6 +77,23 @@ public void setTileSuggestions(
notifyTileSuggestionsAvailable();
}
+ /**
+ * Sets new tile suggestion data, generating dummy data for the missing properties.
+ * If there is an observer it is notified.
+ *
+ * @param urls The URLs of the site suggestions.
+ * @see #setTileSuggestions(String[], String[], String[], int[])
+ */
+ public void setTileSuggestions(String... urls) {
+ String[] whitelistIconPaths = new String[urls.length];
+ Arrays.fill(whitelistIconPaths, "");
+
+ int[] sources = new int[urls.length];
+ Arrays.fill(sources, NTPTileSource.TOP_SITES);
+
+ setTileSuggestions(urls, urls.clone(), whitelistIconPaths, sources);
+ }
+
private void notifyTileSuggestionsAvailable() {
if (mObserver == null) return;
ThreadUtils.runOnUiThreadBlocking(new Runnable() {

Powered by Google App Engine
This is Rietveld 408576698