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

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

Issue 2722243002: 📰 Add tests for Tile and TileGroup (Closed)
Patch Set: Revert default Rule effect Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java
index 8c8b0781bf7f419e41360e766c8f3d4581086b7d..672f2d35e673e132780153281a41e11706c7062e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGroup.java
@@ -23,6 +23,7 @@
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback;
@@ -240,34 +241,32 @@ public void startObserving(int maxResults) {
/**
* Renders tile views in the given {@link TileGridLayout}, reusing existing tile views where
* possible because view inflation and icon loading are slow.
- * @param tileGridLayout The layout to render the tile views into.
+ * @param parent The layout to render the tile views into.
* @param trackLoadTasks Whether to track load tasks.
* @param condensed Whether to use a condensed layout.
*/
- public void renderTileViews(
- TileGridLayout tileGridLayout, boolean trackLoadTasks, boolean condensed) {
+ public void renderTileViews(ViewGroup parent, boolean trackLoadTasks, boolean condensed) {
// Map the old tile views by url so they can be reused later.
Map<String, TileView> oldTileViews = new HashMap<>();
- int childCount = tileGridLayout.getChildCount();
+ int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
- TileView tileView = (TileView) tileGridLayout.getChildAt(i);
+ TileView tileView = (TileView) parent.getChildAt(i);
oldTileViews.put(tileView.getUrl(), tileView);
}
// Remove all views from the layout because even if they are reused later they'll have to be
// added back in the correct order.
- tileGridLayout.removeAllViews();
+ parent.removeAllViews();
for (Tile tile : mTiles) {
TileView tileView = oldTileViews.get(tile.getUrl());
if (tileView == null) {
- tileView = buildTileView(
- tile, tileGridLayout, trackLoadTasks, mTitleLinesCount, condensed);
+ tileView = buildTileView(tile, parent, trackLoadTasks, condensed);
} else {
tileView.updateIfDataChanged(tile);
}
- tileGridLayout.addView(tileView);
+ parent.addView(tileView);
}
}
@@ -284,15 +283,15 @@ public boolean hasReceivedData() {
* @param tile The tile that holds the data to populate the new tile view.
* @param parentView The parent of the new tile view.
* @param trackLoadTask Whether to track a load task.
- * @param titleLines The number of text lines to use for each tile title.
* @param condensed Whether to use a condensed layout.
* @return The new tile view.
*/
- private TileView buildTileView(Tile tile, ViewGroup parentView, boolean trackLoadTask,
- int titleLines, boolean condensed) {
+ @VisibleForTesting
+ TileView buildTileView(
+ Tile tile, ViewGroup parentView, boolean trackLoadTask, boolean condensed) {
TileView tileView = (TileView) LayoutInflater.from(parentView.getContext())
.inflate(R.layout.tile_view, parentView, false);
- tileView.initialize(tile, titleLines, condensed);
+ tileView.initialize(tile, mTitleLinesCount, condensed);
// Note: It is important that the callbacks below don't keep a reference to the tile or
// modify them as there is no guarantee that the same tile would be used to update the view.
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698