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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java

Issue 2504113003: Add NewTabPageRecyclerViewTest. (Closed)
Patch Set: Address review comment from bauerb. Created 4 years, 1 month 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/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
index 84872fcf4ec01b9a661a400814bad22e4f7178b5..84760a1c2d5a3a04e30a1ad0c3729c198c831949 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/FakeSuggestionsSource.java
@@ -28,6 +28,12 @@ public class FakeSuggestionsSource implements SuggestionsSource {
private final Map<Integer, SuggestionsCategoryInfo> mCategoryInfo = new HashMap<>();
private final Map<String, Bitmap> mThumbnails = new HashMap<>();
+ private final List<Integer> mDismissedCategories = new ArrayList<>();
+ private final Map<Integer, List<SnippetArticle>> mDismissedCategorySuggestions =
+ new HashMap<>();
+ private final Map<Integer, Integer> mDismissedCategoryStatus = new LinkedHashMap<>();
+ private final Map<Integer, SuggestionsCategoryInfo> mDismissedCategoryInfo = new HashMap<>();
+
/**
* Sets the status to be returned for a given category.
*/
@@ -60,7 +66,7 @@ public class FakeSuggestionsSource implements SuggestionsSource {
}
/**
- * Set's the bitmap to be returned when the Thumbnail is requested for a snippet with that id.
+ * Sets the bitmap to be returned when the thumbnail is requested for a snippet with that id.
*/
public void setThumbnailForId(String id, Bitmap bitmap) {
mThumbnails.put(id, bitmap);
@@ -92,17 +98,29 @@ public class FakeSuggestionsSource implements SuggestionsSource {
@Override
public void dismissSuggestion(SnippetArticle suggestion) {
- throw new UnsupportedOperationException();
+ for (List<SnippetArticle> suggestions : mSuggestions.values()) {
+ suggestions.remove(suggestion);
+ }
}
@Override
public void dismissCategory(@CategoryInt int category) {
+ mDismissedCategorySuggestions.put(category, mSuggestions.get(category));
+ mDismissedCategoryStatus.put(category, mCategoryStatus.get(category));
+ mDismissedCategoryInfo.put(category, mCategoryInfo.get(category));
+ mDismissedCategories.add(category);
silentlyRemoveCategory(category);
}
@Override
public void restoreDismissedCategories() {
- throw new UnsupportedOperationException();
+ for (int category : mDismissedCategories) {
+ mSuggestions.put(category, mDismissedCategorySuggestions.remove(category));
+ mCategoryStatus.put(category, mDismissedCategoryStatus.remove(category));
+ mCategoryInfo.put(category, mDismissedCategoryInfo.remove(category));
+ mCategories.add(category);
+ }
+ mDismissedCategories.clear();
}
@Override
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698