From d73dac73adbc5a02d05788704da93778cdc18eee Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 5 May 2016 10:21:10 +0200 Subject: [PATCH] delete DownloaderServiceTest stub, it is now crashing DownloaderServiceTest is just a stub of a test that doesn't really test anything yet. It is now causing a NullPointerException, so its a problem: java.lang.NullPointerException at org.fdroid.fdroid.net.DownloaderService.notifyDownloadComplete(DownloaderService.java:313) at org.fdroid.fdroid.net.DownloaderService.handleIntent(DownloaderService.java:287) at org.fdroid.fdroid.net.DownloaderService$ServiceHandler.handleMessage(DownloaderService.java:104) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.os.HandlerThread.run(HandlerThread.java:60) --- .../fdroid/net/DownloaderServiceTest.java | 41 ------------------- .../fdroid/fdroid/net/DownloaderService.java | 4 ++ 2 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 app/src/androidTest/java/org/fdroid/fdroid/net/DownloaderServiceTest.java diff --git a/app/src/androidTest/java/org/fdroid/fdroid/net/DownloaderServiceTest.java b/app/src/androidTest/java/org/fdroid/fdroid/net/DownloaderServiceTest.java deleted file mode 100644 index d859d7c0d..000000000 --- a/app/src/androidTest/java/org/fdroid/fdroid/net/DownloaderServiceTest.java +++ /dev/null @@ -1,41 +0,0 @@ - -package org.fdroid.fdroid.net; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.support.v4.content.LocalBroadcastManager; -import android.test.ServiceTestCase; -import android.util.Log; - -@SuppressWarnings("PMD") // TODO port this to JUnit 4 semantics -public class DownloaderServiceTest extends ServiceTestCase { - public static final String TAG = "DownloaderServiceTest"; - - String[] urls = { - "https://en.wikipedia.org/wiki/Index.html", - "https://mirrors.kernel.org/debian/dists/stable/Release", - "https://f-droid.org/archive/de.we.acaldav_5.apk", - // sites that use SNI for HTTPS - "https://guardianproject.info/fdroid/repo/index.jar", - }; - - public DownloaderServiceTest() { - super(DownloaderService.class); - } - - public void testQueueingDownload() throws InterruptedException { - LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getContext()); - localBroadcastManager.registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - Log.i(TAG, "onReceive " + intent); - } - }, new IntentFilter(Downloader.ACTION_PROGRESS)); - for (String url : urls) { - DownloaderService.queue(getContext(), null, url); - } - Thread.sleep(30000); - } -} diff --git a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java index 14b7432e5..0f53a4693 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/DownloaderService.java @@ -302,6 +302,10 @@ public class DownloaderService extends Service { downloader = null; } + /** + * Post a notification about a completed download. {@code packageName} must be a valid + * and currently in the app index database. + */ private void notifyDownloadComplete(String packageName, String urlString) { String title; try {