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

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

Issue 2662293002: 📰 Handle optional item in group dismissal (Closed)
Patch Set: Created 3 years, 11 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/SuggestionsSectionTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java
index 273dd949bb9734f81a2054470e09f78614087271..198e424eff679497d1bc0862fb25483b6dbcb1b8 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSectionTest.java
@@ -4,11 +4,14 @@
package org.chromium.chrome.browser.ntp.cards;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -721,6 +724,36 @@ public void testCardIsNotifiedWhenBecomingSoleCard() {
@Test
@Feature({"Ntp"})
+ @EnableFeatures(ChromeFeatureList.NTP_SUGGESTIONS_SECTION_DISMISSAL)
+ public void testGetItemDismissalGroupWithSuggestions() {
+ List<SnippetArticle> suggestions = createDummySuggestions(5, TEST_CATEGORY_ID);
+ SuggestionsSection section = createSectionWithReloadAction(false);
+ section.setSuggestions(suggestions, CategoryStatus.AVAILABLE, /* replaceExisting = */ true);
+
+ assertThat(section.getItemDismissalGroup(1).size(), is(1));
+ assertThat(section.getItemDismissalGroup(1), contains(1));
+ }
+
+ @Test
+ @Feature({"Ntp"})
+ @EnableFeatures(ChromeFeatureList.NTP_SUGGESTIONS_SECTION_DISMISSAL)
+ public void testGetItemDismissalGroupWithActionItem() {
+ SuggestionsSection section = createSectionWithReloadAction(true);
+ assertThat(section.getItemDismissalGroup(1).size(), is(2));
+ assertThat(section.getItemDismissalGroup(1), contains(1, 2));
+ }
+
+ @Test
+ @Feature({"Ntp"})
+ @EnableFeatures(ChromeFeatureList.NTP_SUGGESTIONS_SECTION_DISMISSAL)
+ public void testGetItemDismissalGroupWithoutActionItem() {
+ SuggestionsSection section = createSectionWithReloadAction(false);
+ assertThat(section.getItemDismissalGroup(1).size(), is(1));
+ assertThat(section.getItemDismissalGroup(1), contains(1));
+ }
+
+ @Test
+ @Feature({"Ntp"})
public void testCardIsNotifiedWhenNotTheLastAnymore() {
List<SnippetArticle> suggestions = createDummySuggestions(5, /* categoryId = */ 42);
SuggestionsSection section = createSectionWithReloadAction(false);

Powered by Google App Engine
This is Rietveld 408576698