From a40a349c0107660bfb4004467550725a3ca3ec97 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 2 Aug 2012 21:58:17 -0700 Subject: 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 --- .../com/android/providers/downloads/FakeSystemFacade.java | 5 ++++- .../providers/downloads/PublicApiFunctionalTest.java | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'tests/src/com/android') 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 { -- cgit v1.2.3