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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java

Issue 2874563002: Download home : Added info menu icon (Closed)
Patch Set: Fixed tests Created 3 years, 7 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/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java
index aba0daaa0d90d0da0d123b42145c7388b5a1ecce..591a2a133cb691ae63594cae1e8df85b541140f0 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapterTest.java
@@ -8,6 +8,7 @@ import static org.chromium.chrome.browser.widget.DateDividedAdapter.TYPE_DATE;
import static org.chromium.chrome.browser.widget.DateDividedAdapter.TYPE_HEADER;
import static org.chromium.chrome.browser.widget.DateDividedAdapter.TYPE_NORMAL;
+import android.content.SharedPreferences.Editor;
import android.support.test.filters.SmallTest;
import android.support.v7.widget.RecyclerView;
@@ -17,6 +18,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.CallbackHelper;
@@ -70,6 +72,9 @@ public class DownloadHistoryAdapterTest {
*/
private static final Integer HEADER = -1;
+ private static final String PREF_SHOW_STORAGE_INFO_HEADER =
+ "download_home_show_storage_info_header";
+
private DownloadHistoryAdapter mAdapter;
private Observer mObserver;
private StubbedDownloadDelegate mDownloadDelegate;
@@ -82,6 +87,8 @@ public class DownloadHistoryAdapterTest {
mBackendProvider = new StubbedProvider();
mDownloadDelegate = mBackendProvider.getDownloadDelegate();
mOfflineDelegate = mBackendProvider.getOfflinePageBridge();
+ Editor editor = ContextUtils.getAppSharedPreferences().edit();
+ editor.putBoolean(PREF_SHOW_STORAGE_INFO_HEADER, true).apply();
}
private void initializeAdapter(boolean showOffTheRecord) throws Exception {
@@ -158,6 +165,50 @@ public class DownloadHistoryAdapterTest {
Assert.assertEquals(11, mAdapter.getTotalDownloadSize());
}
+ /** Storage header shouldn't show up if user has already turned it off. */
+ @Test
+ @SmallTest
+ public void testInitialize_SingleItemNoStorageHeader() throws Exception {
+ Editor editor = ContextUtils.getAppSharedPreferences().edit();
+ editor.putBoolean(PREF_SHOW_STORAGE_INFO_HEADER, false).apply();
+ DownloadItem item = StubbedProvider.createDownloadItem(0, "19840116 12:00");
+ mDownloadDelegate.regularItems.add(item);
+ initializeAdapter(false);
+ checkAdapterContents(null, item);
+ Assert.assertEquals(1, mAdapter.getTotalDownloadSize());
+ }
+
+ /** Toggle the info button. Storage header should turn off/on accordingly. */
+ @Test
+ @SmallTest
+ public void testToggleStorageHeader() throws Exception {
+ DownloadItem item0 = StubbedProvider.createDownloadItem(0, "19840116 12:00");
+ DownloadItem item1 = StubbedProvider.createDownloadItem(1, "19840116 12:01");
+ mDownloadDelegate.regularItems.add(item0);
+ mDownloadDelegate.regularItems.add(item1);
+ initializeAdapter(false);
+ checkAdapterContents(HEADER, null, item1, item0);
+ Assert.assertEquals(11, mAdapter.getTotalDownloadSize());
+
+ // Turn off info and check that header is gone.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mAdapter.setShowStorageInfoHeader(false);
+ }
+ });
+ checkAdapterContents(null, item1, item0);
+
+ // Turn on info and check that header is back again.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mAdapter.setShowStorageInfoHeader(true);
+ }
+ });
+ checkAdapterContents(HEADER, null, item1, item0);
+ }
+
/** Off the record downloads are ignored if the DownloadHistoryAdapter isn't watching them. */
@Test
@SmallTest

Powered by Google App Engine
This is Rietveld 408576698