summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
diff options
context:
space:
mode:
authorOren Blasberg <orenb@google.com>2015-06-19 11:31:38 -0700
committerOren Blasberg <orenb@google.com>2015-06-25 15:50:58 -0700
commit6971133998ddc8c8c6b37b2fdaaec1d3ed152e90 (patch)
tree0f8b878bed85ec64b384fd34db87079368d78d3a /tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
parent8b2db225a6ccef9dff906ffed1e9c3193622f91d (diff)
downloadandroid_packages_providers_DownloadProvider-6971133998ddc8c8c6b37b2fdaaec1d3ed152e90.tar.gz
android_packages_providers_DownloadProvider-6971133998ddc8c8c6b37b2fdaaec1d3ed152e90.tar.bz2
android_packages_providers_DownloadProvider-6971133998ddc8c8c6b37b2fdaaec1d3ed152e90.zip
Add "Cancel" action to downloads in notification.
Add a "Cancel" action to in-progress downloads shown in notification pane. We add a new action type for a new "cancel" intent sent by DownloadNotifier to DownloadReceiver, which in turn cancels the download by way of DownloadManager. BUG=19972464 Change-Id: I83cd2f40e1442c327f756027b99f9eac913a0e70
Diffstat (limited to 'tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java')
-rw-r--r--tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
index d1048b02..17fed6d0 100644
--- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java
@@ -49,6 +49,8 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.Suppress;
import android.text.format.DateUtils;
+import com.android.providers.downloads.Constants;
+import com.android.providers.downloads.DownloadReceiver;
import com.google.mockwebserver.MockResponse;
import com.google.mockwebserver.RecordedRequest;
import com.google.mockwebserver.SocketPolicy;
@@ -71,6 +73,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
protected File mTestDirectory;
private NotificationManager mNotifManager;
+ private DownloadManager mDownloadManager;
public PublicApiFunctionalTest() {
super(new FakeSystemFacade());
@@ -82,6 +85,8 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
mNotifManager = (NotificationManager) getContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
+ mDownloadManager = (DownloadManager) getContext()
+ .getSystemService(Context.DOWNLOAD_SERVICE);
mTestDirectory = new File(Environment.getExternalStorageDirectory() + File.separator
+ "download_manager_functional_test");
@@ -552,6 +557,23 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest {
assertEquals(PACKAGE_NAME, broadcast.getPackage());
}
+ public void testNotificationCancelDownloadClicked() throws Exception {
+ Download download = enqueueRequest(getRequest());
+
+ DownloadReceiver receiver = new DownloadReceiver();
+ receiver.mSystemFacade = mSystemFacade;
+ Intent intent = new Intent(Constants.ACTION_CANCEL);
+ intent.setData(Uri.parse(Downloads.Impl.CONTENT_URI + "/" + download.mId));
+
+ long[] downloadIds = {download.mId};
+ intent.putExtra(DownloadReceiver.EXTRA_CANCELED_DOWNLOAD_IDS, downloadIds);
+ intent.putExtra(DownloadReceiver.EXTRA_CANCELED_DOWNLOAD_NOTIFICATION_TAG, "tag");
+ receiver.onReceive(mContext, intent);
+
+ verify(mNotifManager, times(1)).cancel("tag", 0);
+ verify(mDownloadManager, times(1)).remove(downloadIds);
+ }
+
public void testBasicConnectivityChanges() throws Exception {
enqueueResponse(buildResponse(HTTP_OK, FILE_CONTENT));