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

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

Issue 1696963002: Move SharedPreference for download into DownloadNotificationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.Context; 7 import android.content.Context;
8 import android.test.InstrumentationTestCase; 8 import android.test.InstrumentationTestCase;
9 import android.test.suitebuilder.annotation.SmallTest; 9 import android.test.suitebuilder.annotation.SmallTest;
10 10
11 import org.chromium.base.ThreadUtils; 11 import org.chromium.base.ThreadUtils;
12 import org.chromium.base.test.util.AdvancedMockContext;
12 import org.chromium.base.test.util.Feature; 13 import org.chromium.base.test.util.Feature;
13 import org.chromium.content.browser.DownloadInfo; 14 import org.chromium.content.browser.DownloadInfo;
14 15
15 /** 16 /**
16 * Tests of {@link SystemDownloadNotifier}. 17 * Tests of {@link SystemDownloadNotifier}.
17 */ 18 */
18 public class SystemDownloadNotifierTest extends InstrumentationTestCase { 19 public class SystemDownloadNotifierTest extends InstrumentationTestCase {
19 private MockSystemDownloadNotifier mDownloadNotifier; 20 private MockSystemDownloadNotifier mDownloadNotifier;
20 private MockDownloadNotificationService mService; 21 private MockDownloadNotificationService mService;
21 22
(...skipping 22 matching lines...) Expand all
44 } 45 }
45 46
46 /** 47 /**
47 * Helper method to simulate that the DownloadNotificationService is connect ed. 48 * Helper method to simulate that the DownloadNotificationService is connect ed.
48 */ 49 */
49 private void onServiceConnected() { 50 private void onServiceConnected() {
50 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 51 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
51 @Override 52 @Override
52 public void run() { 53 public void run() {
53 mService = new MockDownloadNotificationService(); 54 mService = new MockDownloadNotificationService();
54 mService.setContext( 55 mService.setContext(new AdvancedMockContext(
55 getInstrumentation().getTargetContext().getApplicationCo ntext()); 56 getInstrumentation().getTargetContext().getApplicationCo ntext()));
56 mService.onCreate(); 57 mService.onCreate();
57 } 58 }
58 }); 59 });
59 mDownloadNotifier.setDownloadNotificationService(mService); 60 mDownloadNotifier.setDownloadNotificationService(mService);
60 mDownloadNotifier.handlePendingNotifications(); 61 mDownloadNotifier.handlePendingNotifications();
61 } 62 }
62 63
63 /** 64 /**
64 * Tests that pending notifications will be handled after service is connect ed. 65 * Tests that pending notifications will be handled after service is connect ed.
65 */ 66 */
(...skipping 21 matching lines...) Expand all
87 assertTrue(mDownloadNotifier.mStarted); 88 assertTrue(mDownloadNotifier.mStarted);
88 DownloadInfo info2 = new DownloadInfo.Builder().setDownloadId(2).build() ; 89 DownloadInfo info2 = new DownloadInfo.Builder().setDownloadId(2).build() ;
89 mDownloadNotifier.notifyDownloadProgress(info2, 1L); 90 mDownloadNotifier.notifyDownloadProgress(info2, 1L);
90 91
91 mDownloadNotifier.notifyDownloadFailed(info); 92 mDownloadNotifier.notifyDownloadFailed(info);
92 assertTrue(mDownloadNotifier.mStarted); 93 assertTrue(mDownloadNotifier.mStarted);
93 mDownloadNotifier.notifyDownloadSuccessful(info2, null); 94 mDownloadNotifier.notifyDownloadSuccessful(info2, null);
94 assertFalse(mDownloadNotifier.mStarted); 95 assertFalse(mDownloadNotifier.mStarted);
95 } 96 }
96 } 97 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/MockDownloadNotificationService.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698