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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java

Issue 2244793002: Remove deleted offline page suggestions from opened NTPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust MockContentSuggestionsProvider 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java
index ab3819fd442079e81c93ac2eb4e363e953f78639..294ba16bed9d99c037e1acd703ed07860ff6ad6b 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java
@@ -66,6 +66,16 @@ public class NewTabPageAdapterTest {
mCategoryInfo.put(category, info);
}
+ public void fireSuggestionInvalidated(@CategoryInt int category, String suggestionId) {
+ for (SnippetArticle suggestion : mSuggestions.get(category)) {
+ if (suggestion.mId.equals(suggestionId)) {
+ mSuggestions.get(category).remove(suggestion);
+ break;
+ }
+ }
+ mObserver.onSuggestionInvalidated(category, suggestionId);
+ }
+
public void silentlyRemoveCategory(int category) {
mSuggestions.remove(category);
mCategoryStatus.remove(category);
@@ -417,6 +427,9 @@ public class NewTabPageAdapterTest {
assertItemsFor();
}
+ /**
+ * Tests that the more button is shown for sections that declare it.
+ */
@Test
@Feature({"Ntp"})
public void testMoreButton() {
@@ -434,6 +447,23 @@ public class NewTabPageAdapterTest {
assertItemsFor(sectionWithMoreButton(10), section(3));
}
+ /**
+ * Tests that invalidated suggestions are immediately removed.
+ */
+ @Test
+ @Feature({"Ntp"})
+ public void testSuggestionInvalidated() {
+ List<SnippetArticle> articles = createDummySnippets(3);
+ mSnippetsSource.setStatusForCategory(KnownCategories.ARTICLES, CategoryStatus.AVAILABLE);
+ mSnippetsSource.setSuggestionsForCategory(KnownCategories.ARTICLES, articles);
+ assertItemsFor(section(3));
+ assertEquals(articles, mNtpAdapter.getItems().subList(2, 5));
+
+ SnippetArticle removed = articles.remove(1);
+ mSnippetsSource.fireSuggestionInvalidated(KnownCategories.ARTICLES, removed.mId);
+ assertEquals(articles, mNtpAdapter.getItems().subList(2, 4));
+ }
+
private List<SnippetArticle> createDummySnippets(int count) {
List<SnippetArticle> snippets = new ArrayList<>();
for (int index = 0; index < count; index++) {

Powered by Google App Engine
This is Rietveld 408576698