| 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 99ac7d092a6dc73e077d4781baa5647a915fd9b6..4721044ada51609be0bfb79ab9bcf5a8b71e451c 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
|
| @@ -65,6 +65,16 @@ public class NewTabPageAdapterTest {
|
| mCategoryInfo.put(category, info);
|
| }
|
|
|
| + public void fireSuggestionInvalidated(@CategoryInt int category, String suggestionId) {
|
| + for (SnippetArticleListItem 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);
|
| @@ -415,6 +425,9 @@ public class NewTabPageAdapterTest {
|
| assertItemsFor();
|
| }
|
|
|
| + /**
|
| + * Tests that the more button is shown for sections that declare it.
|
| + */
|
| @Test
|
| @Feature({"Ntp"})
|
| public void testMoreButton() {
|
| @@ -432,6 +445,23 @@ public class NewTabPageAdapterTest {
|
| assertItemsFor(sectionWithMoreButton(10), section(3));
|
| }
|
|
|
| + /**
|
| + * Tests that invalidated suggestions are immediately removed.
|
| + */
|
| + @Test
|
| + @Feature({"Ntp"})
|
| + public void testSuggestionInvalidated() {
|
| + List<SnippetArticleListItem> articles = createDummySnippets(3);
|
| + mSnippetsSource.setStatusForCategory(KnownCategories.ARTICLES, CategoryStatus.AVAILABLE);
|
| + mSnippetsSource.setSuggestionsForCategory(KnownCategories.ARTICLES, articles);
|
| + assertItemsFor(section(3));
|
| + assertEquals(articles, mNtpAdapter.getItems().subList(2, 5));
|
| +
|
| + SnippetArticleListItem removed = articles.remove(1);
|
| + mSnippetsSource.fireSuggestionInvalidated(KnownCategories.ARTICLES, removed.mId);
|
| + assertEquals(articles, mNtpAdapter.getItems().subList(2, 4));
|
| + }
|
| +
|
| private List<SnippetArticleListItem> createDummySnippets(int count) {
|
| List<SnippetArticleListItem> snippets = new ArrayList<>();
|
| for (int index = 0; index < count; index++) {
|
|
|