Loading tests/common/com/android/documentsui/services/TestJob.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class TestJob extends Job { @Override Notification getProgressNotification() { assertStarted(); ++mNumOfNotifications; double completed = mStarted ? 1F : 0F; return mProgressBuilder Loading tests/functional/com/android/documentsui/services/FileOperationServiceTest.java +25 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.documentsui.services; import static com.android.documentsui.services.FileOperationService.EXTRA_CANCEL; import static com.android.documentsui.services.FileOperationService.EXTRA_JOB_ID; import static com.android.documentsui.services.FileOperationService.OPERATION_COPY; import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE; import static com.android.documentsui.services.FileOperations.createBaseIntent; Loading Loading @@ -321,18 +323,32 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi mTestNotificationManager.assertHasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id); job1.cancel(); startService(createCancelIntent(job1.id)); mService.onFinished(job1); mTestNotificationManager.assertHasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, null); mTestNotificationManager.assertNoNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id); job2.cancel(); startService(createCancelIntent(job2.id)); mService.onFinished(job2); mTestNotificationManager.assertNumberOfNotifications(0); } public void testCancelJobWithQueuedJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job1 = mCopyJobs.get(0); Job job2 = mCopyJobs.get(1); mService.onStart(job1); startService(createCancelIntent(job1.id)); mService.onFinished(job1); startService(createCancelIntent(job2.id)); mTestNotificationManager.assertNumberOfNotifications(0); } private Intent createCopyIntent(List<DocumentInfo> files, DocumentInfo dest) throws Exception { DocumentStack stack = new DocumentStack(); Loading Loading @@ -363,6 +379,13 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi return createBaseIntent(getContext(), createJobId(), operation); } private Intent createCancelIntent(String jobId) { Intent intent = new Intent(getContext(), FileOperationService.class); intent.putExtra(EXTRA_CANCEL, true); intent.putExtra(EXTRA_JOB_ID, jobId); return intent; } private static DocumentInfo createDoc(String name) { // Doesn't need to be valid content Uri, just some urly looking thing. Uri uri = new Uri.Builder() Loading Loading
tests/common/com/android/documentsui/services/TestJob.java +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class TestJob extends Job { @Override Notification getProgressNotification() { assertStarted(); ++mNumOfNotifications; double completed = mStarted ? 1F : 0F; return mProgressBuilder Loading
tests/functional/com/android/documentsui/services/FileOperationServiceTest.java +25 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.documentsui.services; import static com.android.documentsui.services.FileOperationService.EXTRA_CANCEL; import static com.android.documentsui.services.FileOperationService.EXTRA_JOB_ID; import static com.android.documentsui.services.FileOperationService.OPERATION_COPY; import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE; import static com.android.documentsui.services.FileOperations.createBaseIntent; Loading Loading @@ -321,18 +323,32 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi mTestNotificationManager.assertHasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id); job1.cancel(); startService(createCancelIntent(job1.id)); mService.onFinished(job1); mTestNotificationManager.assertHasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, null); mTestNotificationManager.assertNoNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id); job2.cancel(); startService(createCancelIntent(job2.id)); mService.onFinished(job2); mTestNotificationManager.assertNumberOfNotifications(0); } public void testCancelJobWithQueuedJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job1 = mCopyJobs.get(0); Job job2 = mCopyJobs.get(1); mService.onStart(job1); startService(createCancelIntent(job1.id)); mService.onFinished(job1); startService(createCancelIntent(job2.id)); mTestNotificationManager.assertNumberOfNotifications(0); } private Intent createCopyIntent(List<DocumentInfo> files, DocumentInfo dest) throws Exception { DocumentStack stack = new DocumentStack(); Loading Loading @@ -363,6 +379,13 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi return createBaseIntent(getContext(), createJobId(), operation); } private Intent createCancelIntent(String jobId) { Intent intent = new Intent(getContext(), FileOperationService.class); intent.putExtra(EXTRA_CANCEL, true); intent.putExtra(EXTRA_JOB_ID, jobId); return intent; } private static DocumentInfo createDoc(String name) { // Doesn't need to be valid content Uri, just some urly looking thing. Uri uri = new Uri.Builder() Loading