| Index: chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java
|
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java
|
| index 67685d9bd926e7c0ad8142c68d9507a9f82d7bae..998386ffa515a6d206af8ddf8a2e8acb5f40c329 100644
|
| --- a/chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java
|
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java
|
| @@ -171,6 +171,44 @@ public void testReceiveNewTilesWithCountChanges() {
|
| }
|
|
|
| @Test
|
| + public void testTileLoadingWhenVisibleNotBlockedForInit() {
|
| + SuggestionsUiDelegate uiDelegate = mock(SuggestionsUiDelegate.class);
|
| + when(uiDelegate.isVisible()).thenReturn(true);
|
| + TileGroup tileGroup = new TileGroup(RuntimeEnvironment.application, uiDelegate,
|
| + mock(ContextMenuManager.class), mTileGroupDelegate, mTileGroupObserver,
|
| + mock(OfflinePageBridge.class), TILE_TITLE_LINES);
|
| + tileGroup.startObserving(MAX_TILES_TO_FETCH);
|
| +
|
| + notifyTileUrlsAvailable(URLS);
|
| +
|
| + // Because it's the first load, we accept the incoming tiles and refresh the view.
|
| + verify(mTileGroupObserver).onTileDataChanged();
|
| + }
|
| +
|
| + @Test
|
| + public void testTileLoadingWhenVisibleBlocked() {
|
| + SuggestionsUiDelegate uiDelegate = mock(SuggestionsUiDelegate.class);
|
| + when(uiDelegate.isVisible()).thenReturn(true);
|
| + TileGroup tileGroup = new TileGroup(RuntimeEnvironment.application, uiDelegate,
|
| + mock(ContextMenuManager.class), mTileGroupDelegate, mTileGroupObserver,
|
| + mock(OfflinePageBridge.class), TILE_TITLE_LINES);
|
| + tileGroup.startObserving(MAX_TILES_TO_FETCH);
|
| +
|
| + notifyTileUrlsAvailable(URLS);
|
| + reset(mTileGroupObserver);
|
| + notifyTileUrlsAvailable(URLS[0]);
|
| +
|
| + // Even though the data changed, the notification should not happen because we want to not
|
| + // show changes to UI elements currently visible
|
| + verify(mTileGroupObserver, never()).onTileDataChanged();
|
| +
|
| + // Simulating a switch from background to foreground should force the tilegrid to load the
|
| + // new data.
|
| + tileGroup.onSwitchToForeground();
|
| + verify(mTileGroupObserver).onTileDataChanged();
|
| + }
|
| +
|
| + @Test
|
| public void testRenderTileView() {
|
| TileGroup tileGroup =
|
| new TileGroup(RuntimeEnvironment.application, mock(SuggestionsUiDelegate.class),
|
|
|