avoid android.* classes to allow for direct JUnit tests

When running tests on the host machine, android.jar contains no code at all
which is totally stupid.  We can keep android.util.Log in there because it
does not affect the logic at all.  Then just set that android.jar to return
generic values using:

 unitTests.returnDefaultValues = true
This commit is contained in:
Hans-Christoph Steiner 2016-03-22 16:08:17 +01:00
parent a1d6917ec7
commit f2621dcb55
2 changed files with 7 additions and 3 deletions

View File

@ -167,6 +167,11 @@ android {
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
// prevent tests from dying on android.util.Log calls
unitTests.returnDefaultValues = true
}
lintOptions {
checkReleaseBuilds false
abortOnError false

View File

@ -1,6 +1,5 @@
package org.fdroid.fdroid.net;
import android.text.TextUtils;
import android.util.Log;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
@ -108,8 +107,8 @@ public class HttpDownloader extends Downloader {
// workaround until NetCipher supports HTTPS SNI
// https://gitlab.com/fdroid/fdroidclient/issues/431
if (connection instanceof HttpsURLConnection
&& !TextUtils.equals(sourceUrl.getHost(), "f-droid.org")
&& !TextUtils.equals(sourceUrl.getHost(), "guardianproject.info")) {
&& "f-droid.org".equals(sourceUrl.getHost())
&& "guardianproject.info".equals(sourceUrl.getHost())) {
((HttpsURLConnection) connection).setSSLSocketFactory(HttpsURLConnection.getDefaultSSLSocketFactory());
}