summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java')
-rw-r--r--tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java35
1 files changed, 16 insertions, 19 deletions
diff --git a/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java b/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
index 6934b86d..0330fd38 100644
--- a/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
@@ -17,13 +17,14 @@
package com.android.providers.downloads;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import android.app.DownloadManager;
import android.app.NotificationManager;
-import android.content.ComponentName;
+import android.app.job.JobParameters;
+import android.app.job.JobScheduler;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.ProviderInfo;
import android.database.ContentObserver;
import android.database.Cursor;
@@ -49,7 +50,7 @@ import java.net.MalformedURLException;
import java.net.UnknownHostException;
public abstract class AbstractDownloadProviderFunctionalTest extends
- ServiceTestCase<DownloadService> {
+ ServiceTestCase<DownloadJobService> {
protected static final String LOG_TAG = "DownloadProviderFunctionalTest";
private static final String PROVIDER_AUTHORITY = "downloads";
@@ -102,14 +103,14 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
private final ContentResolver mResolver;
private final NotificationManager mNotifManager;
private final DownloadManager mDownloadManager;
-
- boolean mHasServiceBeenStarted = false;
+ private final JobScheduler mJobScheduler;
public TestContext(Context realContext) {
super(realContext, FILENAME_PREFIX);
mResolver = new MockContentResolverWithNotify(this);
mNotifManager = mock(NotificationManager.class);
mDownloadManager = mock(DownloadManager.class);
+ mJobScheduler = mock(JobScheduler.class);
}
/**
@@ -129,26 +130,16 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
return mNotifManager;
} else if (Context.DOWNLOAD_SERVICE.equals(name)) {
return mDownloadManager;
+ } else if (Context.JOB_SCHEDULER_SERVICE.equals(name)) {
+ return mJobScheduler;
}
return super.getSystemService(name);
}
-
- /**
- * Record when DownloadProvider starts DownloadService.
- */
- @Override
- public ComponentName startService(Intent service) {
- if (service.getComponent().getClassName().equals(DownloadService.class.getName())) {
- mHasServiceBeenStarted = true;
- return service.getComponent();
- }
- throw new UnsupportedOperationException("Unexpected service: " + service);
- }
}
public AbstractDownloadProviderFunctionalTest(FakeSystemFacade systemFacade) {
- super(DownloadService.class);
+ super(DownloadJobService.class);
mSystemFacade = systemFacade;
}
@@ -177,7 +168,7 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
setContext(mTestContext);
setupService();
- getService().mSystemFacade = mSystemFacade;
+ Helpers.setSystemFacade(mSystemFacade);
mSystemFacade.setUp();
assertTrue(isDatabaseEmpty()); // ensure we're not messing with real data
@@ -193,6 +184,12 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
super.tearDown();
}
+ protected void startDownload(long id) {
+ final JobParameters params = mock(JobParameters.class);
+ when(params.getJobId()).thenReturn((int) id);
+ getService().onStartJob(params);
+ }
+
private boolean isDatabaseEmpty() {
Cursor cursor = mResolver.query(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI,
null, null, null, null);