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

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

Issue 2848663002: 📰 Correctly remove content while resetting suggestions (Closed)
Patch Set: Created 3 years, 8 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/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.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/SectionListTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SectionListTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SectionListTest.java
index e7ee137d8521d29c3bfe4512bc53df40ec3d9cb1..61bb60627cb3f77dd8c1f0fdf8b74f0ef95e4d0b 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SectionListTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SectionListTest.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.ntp.cards;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -350,17 +351,24 @@ public void testSynchroniseWithSourceWithNoChange() {
@Test
@Features(@Features.Register(ChromeFeatureList.CHROME_HOME))
public void testSynchroniseWithSourceWithStaleSection() {
+ final int initialSectionSize = 2;
+ final int updatedSectionSize = 5;
registerCategory(mSuggestionSource, CATEGORY1, 1);
- registerCategory(mSuggestionSource, CATEGORY2, 2);
+ registerCategory(mSuggestionSource, CATEGORY2, initialSectionSize);
when(mUiDelegate.isVisible()).thenReturn(true); // Prevent updates on new suggestions.
SectionList sectionList = spy(new SectionList(mUiDelegate, mOfflinePageBridge));
sectionList.refreshSuggestions();
+ assertThat(sectionList.getSectionForTesting(CATEGORY2).getSuggestionsCount(),
+ is(initialSectionSize));
+
// New suggestions are added, which will make CATEGORY2 stale.
bindViewHolders(sectionList);
- mSuggestionSource.setSuggestionsForCategory(CATEGORY2,
- createDummySuggestions(CATEGORY2, 5));
+ mSuggestionSource.setSuggestionsForCategory(
+ CATEGORY2, createDummySuggestions(updatedSectionSize, CATEGORY2));
assertTrue(sectionList.getSectionForTesting(CATEGORY2).isDataStale());
+ assertThat(sectionList.getSectionForTesting(CATEGORY2).getSuggestionsCount(),
+ is(initialSectionSize));
clearInvocations(mSuggestionSource);
sectionList.synchroniseWithSource();
@@ -370,6 +378,8 @@ public void testSynchroniseWithSourceWithStaleSection() {
inOrder.verify(mSuggestionSource).getSuggestionsForCategory(CATEGORY2);
// CATEGORY1 doesn't need to be refreshed.
inOrder.verify(mSuggestionSource, never()).getSuggestionsForCategory(CATEGORY1);
+ assertThat(sectionList.getSectionForTesting(CATEGORY2).getSuggestionsCount(),
+ is(updatedSectionSize));
}
@Test
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698