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

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

Issue 2513453004: [Android NTP] Move suggestion sections into a separate node. (Closed)
Patch Set: sync Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.ntp.cards; 5 package org.chromium.chrome.browser.ntp.cards;
6 6
7 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertFalse; 8 import static org.junit.Assert.assertFalse;
9 import static org.junit.Assert.assertNotNull; 9 import static org.junit.Assert.assertNotNull;
10 import static org.junit.Assert.assertNull; 10 import static org.junit.Assert.assertNull;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 assertFalse(section.getProgressItemForTesting().isVisible()); 340 assertFalse(section.getProgressItemForTesting().isVisible());
341 } 341 }
342 342
343 private SuggestionsSection createSectionWithReloadAction(boolean hasReloadAc tion) { 343 private SuggestionsSection createSectionWithReloadAction(boolean hasReloadAc tion) {
344 CategoryInfoBuilder builder = new CategoryInfoBuilder(42).showIfEmpty(); 344 CategoryInfoBuilder builder = new CategoryInfoBuilder(42).showIfEmpty();
345 if (hasReloadAction) builder.withReloadAction(); 345 if (hasReloadAction) builder.withReloadAction();
346 return createSection(builder.build()); 346 return createSection(builder.build());
347 } 347 }
348 348
349 private SuggestionsSection createSection(SuggestionsCategoryInfo info) { 349 private SuggestionsSection createSection(SuggestionsCategoryInfo info) {
350 return new SuggestionsSection(mParent, info, mManager, mBridge); 350 SuggestionsSection section = new SuggestionsSection(mParent, mManager, m Bridge, info);
351 section.init();
352 return section;
351 } 353 }
352 354
353 private OfflinePageItem createOfflinePageItem(String url, long offlineId) { 355 private OfflinePageItem createOfflinePageItem(String url, long offlineId) {
354 return new OfflinePageItem(url, offlineId, "", "", "", 0, 0, 0, 0); 356 return new OfflinePageItem(url, offlineId, "", "", "", 0, 0, 0, 0);
355 } 357 }
356 358
357 private static void verifyAction(SuggestionsSection section, @ActionItem.Act ion int action) { 359 private static void verifyAction(SuggestionsSection section, @ActionItem.Act ion int action) {
358 SuggestionsSource suggestionsSource = mock(SuggestionsSource.class); 360 SuggestionsSource suggestionsSource = mock(SuggestionsSource.class);
359 NewTabPageManager manager = mock(NewTabPageManager.class); 361 NewTabPageManager manager = mock(NewTabPageManager.class);
360 when(manager.getSuggestionsSource()).thenReturn(suggestionsSource); 362 when(manager.getSuggestionsSource()).thenReturn(suggestionsSource);
361 363
362 if (action != ActionItem.ACTION_NONE) { 364 if (action != ActionItem.ACTION_NONE) {
363 section.getActionItem().performAction(manager); 365 section.getActionItem().performAction(manager);
364 } 366 }
365 367
366 verify(section.getCategoryInfo(), 368 verify(section.getCategoryInfo(),
367 (action == ActionItem.ACTION_VIEW_ALL ? times(1) : never())) 369 (action == ActionItem.ACTION_VIEW_ALL ? times(1) : never()))
368 .performViewAllAction(manager); 370 .performViewAllAction(manager);
369 verify(suggestionsSource, 371 verify(suggestionsSource,
370 action == ActionItem.ACTION_RELOAD || action == ActionItem.ACTIO N_FETCH_MORE 372 action == ActionItem.ACTION_RELOAD || action == ActionItem.ACTIO N_FETCH_MORE
371 ? times(1) 373 ? times(1)
372 : never()) 374 : never())
373 .fetchSuggestions(anyInt(), any(String[].class)); 375 .fetchSuggestions(anyInt(), any(String[].class));
374 } 376 }
375 } 377 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698