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 a3f36740f56e0e4e22b91349c427635d945ced5a..679322db627c7144afac10ede4832c991f1b2259 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 |
@@ -277,10 +277,9 @@ public class NewTabPageAdapterTest { |
mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.AVAILABLE); |
assertItemsFor(section(4)); |
- // When the category is disabled, the suggestions are cleared and we should go back to |
- // the situation with the status card. |
- mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.SIGNED_OUT); |
- assertItemsFor(sectionWithStatusCard()); |
+ // When the category is disabled, the section should go away completely. |
+ mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.CATEGORY_EXPLICITLY_DISABLED); |
+ assertItemsFor(); |
// The adapter should now be waiting for new suggestions. |
suggestions = createDummySuggestions(6, TEST_CATEGORY); |
@@ -306,11 +305,6 @@ public class NewTabPageAdapterTest { |
suggestions.add(new SnippetArticle(TEST_CATEGORY, "https://site.com/url1", "title1", "pub1", |
"txt1", "https://site.com/url1", 0, 0, 0)); |
- // When suggestion are disabled, we should not be able to load them. |
- mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.SIGNED_OUT); |
- mSource.setSuggestionsForCategory(TEST_CATEGORY, suggestions); |
- assertItemsFor(sectionWithStatusCard()); |
- |
// INITIALIZING lets us load suggestion still. |
mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.INITIALIZING); |
mSource.setSuggestionsForCategory(TEST_CATEGORY, suggestions); |
@@ -320,6 +314,11 @@ public class NewTabPageAdapterTest { |
mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.AVAILABLE); |
mSource.setSuggestionsForCategory(TEST_CATEGORY, suggestions); |
assertItemsFor(section(4)); |
+ |
+ // When the category gets disabled, the section should go away and not load any suggestions. |
Marc Treib
2017/03/10 13:02:21
Moved due to the same reason as above.
dgn
2017/03/10 13:51:30
Does it work keeping the same order as before but
Marc Treib
2017/03/10 14:37:20
Yup, that works! (with slightly different expectat
|
+ mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.CATEGORY_EXPLICITLY_DISABLED); |
+ mSource.setSuggestionsForCategory(TEST_CATEGORY, suggestions); |
+ assertItemsFor(); |
} |
/** |
@@ -341,8 +340,10 @@ public class NewTabPageAdapterTest { |
mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.AVAILABLE_LOADING); |
assertTrue(progress.isVisible()); |
- mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.SIGNED_OUT); |
- assertFalse(progress.isVisible()); |
+ // After the section gets disabled, it should gone completely, so checking the progress |
+ // indicator doesn't make sense anymore. |
+ mSource.setStatusForCategory(TEST_CATEGORY, CategoryStatus.CATEGORY_EXPLICITLY_DISABLED); |
+ assertEquals(mAdapter.getSectionListForTesting().getSectionForTesting(TEST_CATEGORY), null); |
} |
/** |
@@ -733,11 +734,10 @@ public class NewTabPageAdapterTest { |
suggestionsSource.setSuggestionsForCategory( |
TEST_CATEGORY, createDummySuggestions(0, TEST_CATEGORY)); |
mAdapter.getSectionListForTesting().onCategoryStatusChanged( |
- TEST_CATEGORY, CategoryStatus.SIGNED_OUT); |
- verify(dataObserver).onItemRangeRemoved(2, newSuggestionCount); |
- verify(dataObserver).onItemRangeChanged(4, 1, null); // Spacer refresh |
- verify(dataObserver).onItemRangeInserted(2, 1); // Status card added |
- verify(dataObserver).onItemRangeChanged(5, 1, null); // Spacer refresh |
+ TEST_CATEGORY, CategoryStatus.CATEGORY_EXPLICITLY_DISABLED); |
+ // All suggestions as well as the header and the action should be gone. |
+ verify(dataObserver).onItemRangeRemoved(1, newSuggestionCount + 2); |
+ verify(dataObserver, times(2)).onItemRangeChanged(2, 1, null); // Spacer refresh |
Marc Treib
2017/03/10 13:02:21
Why does this happen twice? Bug, expected, or unex
dgn
2017/03/10 13:51:30
it's refreshed once when we remove the section, th
Marc Treib
2017/03/10 14:37:20
Thanks! Added a comment.
|
} |
@Test |