Index: chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java |
index 18b21dc42e07bf2b1f21a715fdb49477c02aecd9..052e1d2052a119be8fcef9d9afa1a124afb0c747 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java |
@@ -16,11 +16,13 @@ import android.view.View; |
import android.widget.Button; |
import android.widget.RelativeLayout; |
+import org.chromium.base.VisibleForTesting; |
import org.chromium.chrome.R; |
import org.chromium.chrome.browser.widget.selection.SelectableListLayout; |
import org.chromium.chrome.browser.widget.selection.SelectionDelegate; |
import org.chromium.ui.PhotoPickerListener; |
+import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.List; |
@@ -90,6 +92,9 @@ public class PickerCategoryView extends RelativeLayout |
// Whether the connection to the service has been established. |
private boolean mServiceReady; |
+ // A list of files to use for testing (instead of reading files on disk). |
+ private static List<PickerBitmap> sTestFiles; |
+ |
public PickerCategoryView(Context context) { |
super(context); |
postConstruction(context); |
@@ -285,6 +290,11 @@ public class PickerCategoryView extends RelativeLayout |
* Asynchronously enumerates bitmaps on disk. |
*/ |
private void enumerateBitmaps() { |
+ if (sTestFiles != null) { |
+ filesEnumeratedCallback(sTestFiles); |
+ return; |
+ } |
+ |
if (mWorkerTask != null) { |
mWorkerTask.cancel(true); |
} |
@@ -344,4 +354,15 @@ public class PickerCategoryView extends RelativeLayout |
outRect.set(left, top, right, bottom); |
} |
} |
+ |
+ /** Sets a list of files to use as data for the dialog. For testing use only. */ |
+ @VisibleForTesting |
+ public static void setTestFiles(List<PickerBitmap> testFiles) { |
+ sTestFiles = new ArrayList<>(testFiles); |
+ } |
+ |
+ @VisibleForTesting |
+ public SelectionDelegate<PickerBitmap> getSelectionDelegateForTesting() { |
+ return mSelectionDelegate; |
+ } |
} |