| 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 36f0bf7f1c99a68eedb9fcd50b7fa06d392dc531..f8d0e7f9e3f2084f5affd8bd3aae88d3f636cf66 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
|
| @@ -53,8 +53,8 @@
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ChromeFeatureList;
|
| import org.chromium.chrome.browser.EnableFeatures;
|
| +import org.chromium.chrome.browser.ntp.ContextMenuManager;
|
| import org.chromium.chrome.browser.ntp.NewTabPage.DestructionObserver;
|
| -import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
|
| import org.chromium.chrome.browser.ntp.cards.ContentSuggestionsTestUtils.CategoryInfoBuilder;
|
| import org.chromium.chrome.browser.ntp.cards.SignInPromo.SigninObserver;
|
| import org.chromium.chrome.browser.ntp.snippets.CategoryInt;
|
| @@ -67,6 +67,7 @@
|
| import org.chromium.chrome.browser.signin.SigninManager;
|
| import org.chromium.chrome.browser.signin.SigninManager.SignInAllowedObserver;
|
| import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver;
|
| +import org.chromium.chrome.browser.suggestions.ContentSuggestionsManager;
|
| import org.chromium.testing.local.LocalRobolectricTestRunner;
|
|
|
| import java.util.ArrayList;
|
| @@ -91,7 +92,7 @@
|
| @Mock
|
| private OfflinePageBridge mOfflinePageBridge;
|
| @Mock
|
| - private NewTabPageManager mNewTabPageManager;
|
| + private ContentSuggestionsManager mContentSuggestionsManager;
|
|
|
| /**
|
| * Stores information about a section that should be present in the adapter.
|
| @@ -191,8 +192,7 @@ public void setUp() {
|
| mSource.setInfoForCategory(category,
|
| new CategoryInfoBuilder(category).showIfEmpty().build());
|
|
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(mSource);
|
| - when(mNewTabPageManager.isCurrentPage()).thenReturn(true);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(mSource);
|
|
|
| reloadNtp();
|
| }
|
| @@ -409,7 +409,7 @@ public void testSectionVisibleIfEmpty() {
|
| new CategoryInfoBuilder(category).showIfEmpty().build());
|
|
|
| // 1.1 - Initial state
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| reloadNtp();
|
| assertItemsFor(sectionWithStatusCard().withProgress());
|
|
|
| @@ -434,7 +434,7 @@ public void testSectionVisibleIfEmpty() {
|
| suggestionsSource.setInfoForCategory(category, new CategoryInfoBuilder(category).build());
|
|
|
| // 2.1 - Initial state
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| reloadNtp();
|
| assertItemsFor();
|
|
|
| @@ -464,7 +464,7 @@ public void testMoreButton() {
|
| .build());
|
|
|
| // 1.1 - Initial state.
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| reloadNtp();
|
| assertItemsFor(sectionWithStatusCard().withActionButton().withProgress());
|
|
|
| @@ -490,7 +490,7 @@ public void testMoreButton() {
|
| new CategoryInfoBuilder(category).showIfEmpty().build());
|
|
|
| // 2.1 - Initial state.
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| reloadNtp();
|
| assertItemsFor(sectionWithStatusCard().withProgress());
|
|
|
| @@ -564,7 +564,7 @@ public void testDynamicCategories() {
|
| @Feature({"Ntp"})
|
| public void testCategoryOrder() {
|
| FakeSuggestionsSource suggestionsSource = new FakeSuggestionsSource();
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| registerCategory(suggestionsSource, KnownCategories.ARTICLES, 0);
|
| registerCategory(suggestionsSource, KnownCategories.BOOKMARKS, 0);
|
| registerCategory(suggestionsSource, KnownCategories.PHYSICAL_WEB_PAGES, 0);
|
| @@ -584,7 +584,7 @@ public void testCategoryOrder() {
|
|
|
| // With a different order.
|
| suggestionsSource = new FakeSuggestionsSource();
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| registerCategory(suggestionsSource, KnownCategories.ARTICLES, 0);
|
| registerCategory(suggestionsSource, KnownCategories.PHYSICAL_WEB_PAGES, 0);
|
| registerCategory(suggestionsSource, KnownCategories.DOWNLOADS, 0);
|
| @@ -604,7 +604,7 @@ public void testCategoryOrder() {
|
|
|
| // With unknown categories.
|
| suggestionsSource = new FakeSuggestionsSource();
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| registerCategory(suggestionsSource, KnownCategories.ARTICLES, 0);
|
| registerCategory(suggestionsSource, KnownCategories.PHYSICAL_WEB_PAGES, 0);
|
| registerCategory(suggestionsSource, KnownCategories.DOWNLOADS, 0);
|
| @@ -629,7 +629,7 @@ public void testCategoryOrder() {
|
| public void testChangeNotifications() {
|
| FakeSuggestionsSource suggestionsSource = spy(new FakeSuggestionsSource());
|
| registerCategory(suggestionsSource, KnownCategories.ARTICLES, 3);
|
| - when(mNewTabPageManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
| + when(mContentSuggestionsManager.getSuggestionsSource()).thenReturn(suggestionsSource);
|
|
|
| @SuppressWarnings("unchecked")
|
| Callback<String> itemDismissedCallback = mock(Callback.class);
|
| @@ -726,7 +726,7 @@ public void testSigninPromo() {
|
| ArgumentCaptor<DestructionObserver> observers =
|
| ArgumentCaptor.forClass(DestructionObserver.class);
|
|
|
| - doNothing().when(mNewTabPageManager).addDestructionObserver(observers.capture());
|
| + doNothing().when(mContentSuggestionsManager).addDestructionObserver(observers.capture());
|
|
|
| reloadNtp();
|
| assertTrue(isSignInPromoVisible());
|
| @@ -795,7 +795,8 @@ public void testAllDismissedVisibility() {
|
| ArgumentCaptor<DestructionObserver> observers =
|
| ArgumentCaptor.forClass(DestructionObserver.class);
|
|
|
| - verify(mNewTabPageManager, atLeastOnce()).addDestructionObserver(observers.capture());
|
| + verify(mContentSuggestionsManager, atLeastOnce())
|
| + .addDestructionObserver(observers.capture());
|
|
|
| SigninObserver signinObserver = null;
|
| for (DestructionObserver observer : observers.getAllValues()) {
|
| @@ -972,8 +973,8 @@ private SectionDescriptor sectionWithStatusCard() {
|
| }
|
|
|
| private void reloadNtp() {
|
| - mAdapter = new NewTabPageAdapter(mNewTabPageManager, mock(View.class), null,
|
| - mOfflinePageBridge);
|
| + mAdapter = new NewTabPageAdapter(mContentSuggestionsManager, mock(View.class), null,
|
| + mOfflinePageBridge, mock(ContextMenuManager.class));
|
| }
|
|
|
| private void assertArticlesEqual(List<SnippetArticle> articles, int start, int end) {
|
|
|