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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/download/DownloadActivityTest.java

Issue 2496163003: [Download Home] Pull out DeletedFileTracker from DownloadHistoryAdapter (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.download; 5 package org.chromium.chrome.browser.download;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.os.Handler; 8 import android.os.Handler;
9 import android.os.Looper; 9 import android.os.Looper;
10 import android.support.v7.widget.RecyclerView; 10 import android.support.v7.widget.RecyclerView;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return TextUtils.equals("6.00 GB downloaded", mSpaceUsedDisplay. getText()); 150 return TextUtils.equals("6.00 GB downloaded", mSpaceUsedDisplay. getText());
151 } 151 }
152 }); 152 });
153 153
154 // Add a new item. 154 // Add a new item.
155 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt(); 155 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt();
156 final DownloadItem updateItem = StubbedProvider.createDownloadItem(7, "2 0151021 07:28"); 156 final DownloadItem updateItem = StubbedProvider.createDownloadItem(7, "2 0151021 07:28");
157 ThreadUtils.runOnUiThread(new Runnable() { 157 ThreadUtils.runOnUiThread(new Runnable() {
158 @Override 158 @Override
159 public void run() { 159 public void run() {
160 mAdapter.onDownloadItemUpdated(updateItem, false); 160 mAdapter.onDownloadItemUpdated(updateItem);
161 } 161 }
162 }); 162 });
163 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount ); 163 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount );
164 assertEquals("6.50 GB downloaded", mSpaceUsedDisplay.getText()); 164 assertEquals("6.50 GB downloaded", mSpaceUsedDisplay.getText());
165 165
166 // Mark one download as deleted on disk, which should prevent it from be ing counted. 166 // Mark one download as deleted on disk, which should prevent it from be ing counted.
167 callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCount( ); 167 callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCount( );
168 final DownloadItem deletedItem = StubbedProvider.createDownloadItem(6, " 20151021 07:28"); 168 final DownloadItem deletedItem = StubbedProvider.createDownloadItem(6, " 20151021 07:28");
169 deletedItem.setHasBeenExternallyRemoved(true); 169 deletedItem.setHasBeenExternallyRemoved(true);
170 ThreadUtils.runOnUiThread(new Runnable() { 170 ThreadUtils.runOnUiThread(new Runnable() {
171 @Override 171 @Override
172 public void run() { 172 public void run() {
173 mAdapter.onDownloadItemUpdated(deletedItem, false); 173 mAdapter.onDownloadItemUpdated(deletedItem);
174 } 174 }
175 }); 175 });
176 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount ); 176 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount );
177 assertEquals("5.50 GB downloaded", mSpaceUsedDisplay.getText()); 177 assertEquals("5.50 GB downloaded", mSpaceUsedDisplay.getText());
178 178
179 // Say that the offline page has been deleted. 179 // Say that the offline page has been deleted.
180 callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCount( ); 180 callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCount( );
181 final OfflinePageDownloadItem deletedPage = 181 final OfflinePageDownloadItem deletedPage =
182 StubbedProvider.createOfflineItem(3, "20151021 07:28"); 182 StubbedProvider.createOfflineItem(3, "20151021 07:28");
183 ThreadUtils.runOnUiThread(new Runnable() { 183 ThreadUtils.runOnUiThread(new Runnable() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 SnackbarManager.setDurationForTesting(5000); 280 SnackbarManager.setDurationForTesting(5000);
281 281
282 // Add duplicate items. 282 // Add duplicate items.
283 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt(); 283 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt();
284 final DownloadItem item7 = StubbedProvider.createDownloadItem(7, "201610 21 07:28"); 284 final DownloadItem item7 = StubbedProvider.createDownloadItem(7, "201610 21 07:28");
285 final DownloadItem item8 = StubbedProvider.createDownloadItem(8, "201610 21 17:28"); 285 final DownloadItem item8 = StubbedProvider.createDownloadItem(8, "201610 21 17:28");
286 ThreadUtils.runOnUiThread(new Runnable() { 286 ThreadUtils.runOnUiThread(new Runnable() {
287 @Override 287 @Override
288 public void run() { 288 public void run() {
289 mAdapter.onDownloadItemUpdated(item7, false); 289 mAdapter.onDownloadItemUpdated(item7);
290 mAdapter.onDownloadItemUpdated(item8, false); 290 mAdapter.onDownloadItemUpdated(item8);
291 } 291 }
292 }); 292 });
293 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount , 2); 293 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount , 2);
294 294
295 // This first check is a Criteria because initialization of the Adapter is asynchronous. 295 // This first check is a Criteria because initialization of the Adapter is asynchronous.
296 CriteriaHelper.pollUiThread(new Criteria() { 296 CriteriaHelper.pollUiThread(new Criteria() {
297 @Override 297 @Override
298 public boolean isSatisfied() { 298 public boolean isSatisfied() {
299 return TextUtils.equals("7.00 GB downloaded", mSpaceUsedDisplay. getText()); 299 return TextUtils.equals("7.00 GB downloaded", mSpaceUsedDisplay. getText());
300 } 300 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 SnackbarManager.setDurationForTesting(5000); 357 SnackbarManager.setDurationForTesting(5000);
358 358
359 // Add duplicate items. 359 // Add duplicate items.
360 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt(); 360 int callCount = mAdapterObserver.onSpaceDisplayUpdatedCallback.getCallCo unt();
361 final DownloadItem item7 = StubbedProvider.createDownloadItem(7, "201610 21 07:28"); 361 final DownloadItem item7 = StubbedProvider.createDownloadItem(7, "201610 21 07:28");
362 final DownloadItem item8 = StubbedProvider.createDownloadItem(8, "201610 21 17:28"); 362 final DownloadItem item8 = StubbedProvider.createDownloadItem(8, "201610 21 17:28");
363 ThreadUtils.runOnUiThread(new Runnable() { 363 ThreadUtils.runOnUiThread(new Runnable() {
364 @Override 364 @Override
365 public void run() { 365 public void run() {
366 mAdapter.onDownloadItemUpdated(item7, false); 366 mAdapter.onDownloadItemUpdated(item7);
367 mAdapter.onDownloadItemUpdated(item8, false); 367 mAdapter.onDownloadItemUpdated(item8);
368 } 368 }
369 }); 369 });
370 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount , 2); 370 mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(callCount , 2);
371 371
372 // This first check is a Criteria because initialization of the Adapter is asynchronous. 372 // This first check is a Criteria because initialization of the Adapter is asynchronous.
373 CriteriaHelper.pollUiThread(new Criteria() { 373 CriteriaHelper.pollUiThread(new Criteria() {
374 @Override 374 @Override
375 public boolean isSatisfied() { 375 public boolean isSatisfied() {
376 return TextUtils.equals("7.00 GB downloaded", mSpaceUsedDisplay. getText()); 376 return TextUtils.equals("7.00 GB downloaded", mSpaceUsedDisplay. getText());
377 } 377 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 ThreadUtils.runOnUiThread(new Runnable() { 588 ThreadUtils.runOnUiThread(new Runnable() {
589 @Override 589 @Override
590 public void run() { 590 public void run() {
591 itemView.performLongClick(); 591 itemView.performLongClick();
592 } 592 }
593 }); 593 });
594 mAdapterObserver.onSelectionCallback.waitForCallback(callCount, 1); 594 mAdapterObserver.onSelectionCallback.waitForCallback(callCount, 1);
595 } 595 }
596 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698