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 |