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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/suggestions/TileGroupTest.java

Issue 2742433002: 📰 Do not refresh Tiles while visible (Closed)
Patch Set: move loadTiles with other private methods Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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),

Powered by Google App Engine
This is Rietveld 408576698