diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-08-02 21:58:17 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-11-09 15:40:00 -0800 |
commit | a40a349c0107660bfb4004467550725a3ca3ec97 (patch) | |
tree | 3fb1f96ad2d1da1d346fd32f239d1ee8ef149376 /tests/src/com | |
parent | 2fa007ef678b2283d47d007aa3dc91af683cc52c (diff) | |
download | android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.tar.gz android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.tar.bz2 android_packages_providers_DownloadProvider-a40a349c0107660bfb4004467550725a3ca3ec97.zip |
Rewrite of download notifications.
Switch to using new inbox-style notifications when collapsing multiple
downloads. Correctly handles clustering, including cancellation of
stale notifications. All notifications are now handled in a single
class, making it easier to reason about correctness.
Fixed bugs around handling of visibility flags. Move away from using
"int" as internal keys, since they can overflow. Started work for
time estimates, will finish in a future CL.
Explicitly pass all relevant IDs to DownloadReceiver instead of doing
a second racy query. Fix StrictMode warnings when querying in
DownloadReceiver.
Bug: 6777872, 5463678, 6663547, 6967346, 6634261, 5608365
Change-Id: I5eb47b73b90b6250acec2ce5bf8d7a274ed9d3a9
Diffstat (limited to 'tests/src/com')
-rw-r--r-- | tests/src/com/android/providers/downloads/FakeSystemFacade.java | 5 | ||||
-rw-r--r-- | tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/tests/src/com/android/providers/downloads/FakeSystemFacade.java b/tests/src/com/android/providers/downloads/FakeSystemFacade.java index 6898efdb..481b5cba 100644 --- a/tests/src/com/android/providers/downloads/FakeSystemFacade.java +++ b/tests/src/com/android/providers/downloads/FakeSystemFacade.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.NetworkInfo.DetailedState; import java.util.ArrayList; import java.util.LinkedList; @@ -36,7 +37,9 @@ public class FakeSystemFacade implements SystemFacade { if (mActiveNetworkType == null) { return null; } else { - return new NetworkInfo(mActiveNetworkType, 0, null, null); + final NetworkInfo info = new NetworkInfo(mActiveNetworkType, 0, null, null); + info.setDetailedState(DetailedState.CONNECTED, null, null); + return info; } } diff --git a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java index 34a69df9..2661a1f2 100644 --- a/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java +++ b/tests/src/com/android/providers/downloads/PublicApiFunctionalTest.java @@ -17,6 +17,7 @@ package com.android.providers.downloads; import static com.google.testing.littlemock.LittleMock.anyInt; +import static com.google.testing.littlemock.LittleMock.anyString; import static com.google.testing.littlemock.LittleMock.atLeastOnce; import static com.google.testing.littlemock.LittleMock.isA; import static com.google.testing.littlemock.LittleMock.never; @@ -449,6 +450,8 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { receiver.mSystemFacade = mSystemFacade; Intent intent = new Intent(Constants.ACTION_LIST); intent.setData(Uri.parse(Downloads.Impl.CONTENT_URI + "/" + download.mId)); + intent.putExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS, + new long[] { download.mId }); receiver.onReceive(mContext, intent); assertEquals(1, mSystemFacade.mBroadcastsSent.size()); @@ -523,7 +526,7 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { download.runUntilStatus(DownloadManager.STATUS_SUCCESSFUL); runService(); - verify(mNotifManager, never()).notify(anyInt(), isA(Notification.class)); + verify(mNotifManager, never()).notify(anyString(), anyInt(), isA(Notification.class)); // TODO: verify that it never cancels } @@ -536,8 +539,8 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { runService(); // TODO: verify different notif types with tags - verify(mNotifManager, atLeastOnce()).notify(anyInt(), isA(Notification.class)); - verify(mNotifManager, times(1)).cancel(anyInt()); + verify(mNotifManager, atLeastOnce()).notify(anyString(), anyInt(), isA(Notification.class)); + verify(mNotifManager, times(1)).cancel(anyString(), anyInt()); } public void testNotificationVisibleComplete() throws Exception { @@ -549,8 +552,8 @@ public class PublicApiFunctionalTest extends AbstractPublicApiTest { runService(); // TODO: verify different notif types with tags - verify(mNotifManager, atLeastOnce()).notify(anyInt(), isA(Notification.class)); - verify(mNotifManager, times(1)).cancel(anyInt()); + verify(mNotifManager, atLeastOnce()).notify(anyString(), anyInt(), isA(Notification.class)); + verify(mNotifManager, times(1)).cancel(anyString(), anyInt()); } public void testRetryAfter() throws Exception { |