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

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

Issue 2651743002: 📰 Fix card style when a neighbour is added or removed (Closed)
Patch Set: Revert to previous implementation 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
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7b13c4a398ede405a78cf98533b4f263118acbad..f07229dc9d8f174a2d972216458101518daa08b1 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
@@ -42,6 +42,7 @@
import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
import org.chromium.chrome.browser.ntp.snippets.SuggestionsSource;
import org.chromium.chrome.browser.offlinepages.OfflinePageItem;
+import org.chromium.chrome.browser.suggestions.PartialUpdateId;
import org.chromium.chrome.browser.suggestions.SuggestionsMetricsReporter;
import org.chromium.chrome.browser.suggestions.SuggestionsNavigationDelegate;
import org.chromium.chrome.browser.suggestions.SuggestionsRanker;
@@ -185,7 +186,6 @@ public void testSetStatusNotification() {
section.setStatus(CategoryStatus.AVAILABLE);
verify(mParent).onItemRangeRemoved(section, 2, 1);
- verifyNoMoreInteractions(mParent);
}
@Test
@@ -674,6 +674,59 @@ public void testSectionDoesNotUpdateOnNewSuggestionsWhenAppended() {
verifySnippets(section, snippets);
}
+ @Test
+ @Feature({"Ntp"})
+ public void testCardIsNotifiedWhenBecomingFirst() {
+ List<SnippetArticle> suggestions = createDummySuggestions(5, /* categoryId = */ 42);
+ SuggestionsSection section = createSectionWithReloadAction(false);
+ section.setSuggestions(suggestions, CategoryStatus.AVAILABLE, /* replaceExisting = */ true);
+ reset(mParent);
+
+ // Remove the first card. The second one should get the update.
+ section.removeSuggestionById(suggestions.get(0).mIdWithinCategory);
+ verify(mParent).onItemRangeChanged(section, 1, 1, PartialUpdateId.CARD_BACKGROUND);
+ }
+
+ @Test
+ @Feature({"Ntp"})
+ public void testCardIsNotifiedWhenBecomingLast() {
+ List<SnippetArticle> suggestions = createDummySuggestions(5, /* categoryId = */ 42);
+ SuggestionsSection section = createSectionWithReloadAction(false);
+ section.setSuggestions(suggestions, CategoryStatus.AVAILABLE, /* replaceExisting = */ true);
+ reset(mParent);
+
+ // Remove the last card. The penultimate one should get the update.
+ section.removeSuggestionById(suggestions.get(4).mIdWithinCategory);
+ verify(mParent).onItemRangeChanged(section, 4, 1, PartialUpdateId.CARD_BACKGROUND);
+ }
+
+ @Test
+ @Feature({"Ntp"})
+ public void testCardIsNotifiedWhenBecomingSoleCard() {
+ List<SnippetArticle> suggestions = createDummySuggestions(2, /* categoryId = */ 42);
+ SuggestionsSection section = createSectionWithReloadAction(false);
+ section.setSuggestions(suggestions, CategoryStatus.AVAILABLE, /* replaceExisting = */ true);
+ reset(mParent);
+
+ // Remove the last card. The penultimate one should get the update.
+ section.removeSuggestionById(suggestions.get(1).mIdWithinCategory);
+ verify(mParent).onItemRangeChanged(section, 1, 1, PartialUpdateId.CARD_BACKGROUND);
+ }
+
+ @Test
+ @Feature({"Ntp"})
+ public void testCardIsNotifiedWhenNotTheLastAnymore() {
+ List<SnippetArticle> suggestions = createDummySuggestions(5, /* categoryId = */ 42);
+ SuggestionsSection section = createSectionWithReloadAction(false);
+
+ section.setSuggestions(suggestions, CategoryStatus.AVAILABLE, /* replaceExisting = */ true);
+ reset(mParent);
+
+ section.setSuggestions(createDummySuggestions(2, /* categoryId = */ 42, "new"),
+ CategoryStatus.AVAILABLE, /* replaceExisting = */ false);
+ verify(mParent).onItemRangeChanged(section, 5, 1, PartialUpdateId.CARD_BACKGROUND);
+ }
+
private SuggestionsSection createSectionWithSuggestions(List<SnippetArticle> snippets) {
SuggestionsSection section = createSectionWithReloadAction(true);
section.setStatus(CategoryStatus.AVAILABLE);
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698