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

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

Issue 2340333002: 📰 Make status cards swipable (Closed)
Patch Set: fix nit Created 4 years, 3 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 810795772eecc28cc11a2db9090373fdabaa584c..377424dbb3c2b865de3652ab181c8326b1198047 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
@@ -6,6 +6,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -655,6 +657,46 @@ public void testCategoryOrder() {
assertEquals(KnownCategories.DOWNLOADS, getCategory(groups.get(3)));
}
+ @Test
+ @Feature({"Ntp"})
+ public void testDismissSibling() {
+ List<SnippetArticle> snippets = createDummySuggestions(3);
+ SuggestionsSection section;
+
+ // Part 1: ShowMoreButton = true
+ section = new SuggestionsSection(42,
+ new SuggestionsCategoryInfo("", ContentSuggestionsCardLayout.FULL_CARD, true, true),
+ null);
+ section.setStatus(CategoryStatus.AVAILABLE);
+ assertNotNull(section.getActionItem());
+
+ // 1.1: Without snippets
+ assertEquals(-1, section.getDismissSiblingPosDelta(section.getActionItem()));
+ assertEquals(1, section.getDismissSiblingPosDelta(section.getStatusItem()));
+
+ // 1.2: With snippets
+ section.setSuggestions(snippets, CategoryStatus.AVAILABLE);
+ assertEquals(0, section.getDismissSiblingPosDelta(section.getActionItem()));
+ assertEquals(0, section.getDismissSiblingPosDelta(section.getStatusItem()));
+ assertEquals(0, section.getDismissSiblingPosDelta(snippets.get(0)));
+
+ // Part 2: ShowMoreButton = false
+ section = new SuggestionsSection(42,
+ new SuggestionsCategoryInfo("", ContentSuggestionsCardLayout.FULL_CARD, false,
+ true),
+ null);
+ section.setStatus(CategoryStatus.AVAILABLE);
+ assertNull(section.getActionItem());
+
+ // 2.1: Without snippets
+ assertEquals(0, section.getDismissSiblingPosDelta(section.getStatusItem()));
+
+ // 2.2: With snippets
+ section.setSuggestions(snippets, CategoryStatus.AVAILABLE);
+ assertEquals(0, section.getDismissSiblingPosDelta(section.getStatusItem()));
+ assertEquals(0, section.getDismissSiblingPosDelta(snippets.get(0)));
+ }
+
private List<SnippetArticle> createDummySuggestions(int count) {
List<SnippetArticle> suggestions = new ArrayList<>();
for (int index = 0; index < count; index++) {

Powered by Google App Engine
This is Rietveld 408576698