Merge branch 'latest-android-testing-support' into 'master'
use latest android testing support setup With 2.0 of Android Studio and gradle pluging coming out shortly, I wanted to start trying to use the improved testing setup. So this is a place to track that stuff until it stabilizes. See merge request !252
This commit is contained in:
commit
ac151716c9
@ -8,6 +8,8 @@ cache:
|
|||||||
variables:
|
variables:
|
||||||
AVD_SDK: "17"
|
AVD_SDK: "17"
|
||||||
SKIN: "QVGA"
|
SKIN: "QVGA"
|
||||||
|
# switch glibc to a memory conserving mode
|
||||||
|
MALLOC_ARENA_MAX: "2"
|
||||||
|
|
||||||
gradle:
|
gradle:
|
||||||
script:
|
script:
|
||||||
@ -17,9 +19,9 @@ gradle:
|
|||||||
# always report on lint errors to the build log
|
# always report on lint errors to the build log
|
||||||
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
|
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
|
||||||
# 'build' means assemble and check
|
# 'build' means assemble and check
|
||||||
- ./gradlew build || {
|
- ./gradlew build -PdisablePreDex || {
|
||||||
for log in app/build/reports/*ests/*/*ml; do
|
for log in app/build/reports/*ests/*/*ml; do
|
||||||
echo "read $log here:"
|
echo "read $log here:";
|
||||||
cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
|
cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
|
||||||
done;
|
done;
|
||||||
exit 1;
|
exit 1;
|
||||||
@ -38,9 +40,9 @@ gradle:
|
|||||||
--target android-$AVD_SDK
|
--target android-$AVD_SDK
|
||||||
- emulator64-arm -avd fcl-test -no-skin -no-audio -no-window &
|
- emulator64-arm -avd fcl-test -no-skin -no-audio -no-window &
|
||||||
- ./tools/wait-for-emulator
|
- ./tools/wait-for-emulator
|
||||||
- adb shell input keyevent 82
|
- adb shell input keyevent 82 &
|
||||||
- export EXITVALUE=0
|
- export EXITVALUE=0
|
||||||
- ADB_INSTALL_TIMEOUT=8 ./gradlew connectedCheck || {
|
- ADB_INSTALL_TIMEOUT=8 ./gradlew connectedCheck -PdisablePreDex || {
|
||||||
adb -e logcat -d '*:E';
|
adb -e logcat -d '*:E';
|
||||||
echo "get the full logcat here:";
|
echo "get the full logcat here:";
|
||||||
adb -e logcat -d | curl --silent -F 'clbin=<-' https://clbin.com;
|
adb -e logcat -d | curl --silent -F 'clbin=<-' https://clbin.com;
|
||||||
@ -52,17 +54,19 @@ gradle:
|
|||||||
cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
|
cat "$log" | curl --silent -F 'clbin=<-' https://clbin.com;
|
||||||
done
|
done
|
||||||
- sed -n 's/.*"ctr2">\([0-9]*\)%<.*/Coverage - \1.0% covered\n/p' app/build/reports/coverage/debug/index.html
|
- sed -n 's/.*"ctr2">\([0-9]*\)%<.*/Coverage - \1.0% covered\n/p' app/build/reports/coverage/debug/index.html
|
||||||
|
# this file changes every time but should not be cached
|
||||||
|
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
|
||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
|
|
||||||
pmd:
|
pmd:
|
||||||
script:
|
script:
|
||||||
- export GRADLE_USER_HOME=$PWD/.gradle
|
- export GRADLE_USER_HOME=$PWD/.gradle
|
||||||
- ./gradlew pmd
|
- ./gradlew pmd -PdisablePreDex
|
||||||
|
|
||||||
checkstyle:
|
checkstyle:
|
||||||
script:
|
script:
|
||||||
- export GRADLE_USER_HOME=$PWD/.gradle
|
- export GRADLE_USER_HOME=$PWD/.gradle
|
||||||
- ./gradlew checkstyle
|
- ./gradlew checkstyle -PdisablePreDex
|
||||||
|
|
||||||
tools:
|
tools:
|
||||||
script:
|
script:
|
||||||
|
@ -157,8 +157,17 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
|
unitTests {
|
||||||
// prevent tests from dying on android.util.Log calls
|
// prevent tests from dying on android.util.Log calls
|
||||||
unitTests.returnDefaultValues = true
|
returnDefaultValues = true
|
||||||
|
all {
|
||||||
|
// All the usual Gradle options.
|
||||||
|
testLogging {
|
||||||
|
events "skipped", "failed", "standardOut", "standardError"
|
||||||
|
showStandardStreams = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
@ -16,13 +16,11 @@ import static org.junit.Assert.fail;
|
|||||||
public class HttpDownloaderTest {
|
public class HttpDownloaderTest {
|
||||||
|
|
||||||
String[] urls = {
|
String[] urls = {
|
||||||
"https://www.google.com",
|
|
||||||
"https://en.wikipedia.org/wiki/Index.html",
|
"https://en.wikipedia.org/wiki/Index.html",
|
||||||
"https://mirrors.kernel.org/debian/dists/stable/Release",
|
"https://mirrors.kernel.org/debian/dists/stable/Release",
|
||||||
"https://f-droid.org/archive/de.we.acaldav_5.apk",
|
"https://f-droid.org/repo/index.jar",
|
||||||
// sites that use SNI for HTTPS
|
// sites that use SNI for HTTPS
|
||||||
"https://guardianproject.info/fdroid/repo/index.jar",
|
"https://guardianproject.info/fdroid/repo/index.jar",
|
||||||
"https://firstlook.org",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private boolean receivedProgress;
|
private boolean receivedProgress;
|
||||||
@ -42,24 +40,39 @@ public class HttpDownloaderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadUninterruptedTestWithProgress() throws IOException, InterruptedException {
|
public void downloadUninterruptedTestWithProgress() throws IOException, InterruptedException {
|
||||||
for (String urlString : urls) {
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
String urlString = "https://f-droid.org/repo/index.jar";
|
||||||
|
receivedProgress = false;
|
||||||
|
System.out.println("downloadUninterruptedTestWithProgress: " + urlString);
|
||||||
receivedProgress = false;
|
receivedProgress = false;
|
||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
File destFile = File.createTempFile("dl-", "");
|
File destFile = File.createTempFile("dl-", "");
|
||||||
HttpDownloader httpDownloader = new HttpDownloader(url, destFile);
|
final HttpDownloader httpDownloader = new HttpDownloader(url, destFile);
|
||||||
httpDownloader.setListener(new Downloader.DownloaderProgressListener() {
|
httpDownloader.setListener(new Downloader.DownloaderProgressListener() {
|
||||||
@Override
|
@Override
|
||||||
public void sendProgress(URL sourceUrl, int bytesRead, int totalBytes) {
|
public void sendProgress(URL sourceUrl, int bytesRead, int totalBytes) {
|
||||||
|
System.out.println("DownloaderProgressListener.sendProgress " + sourceUrl + " " + bytesRead + " / " + totalBytes);
|
||||||
receivedProgress = true;
|
receivedProgress = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
httpDownloader.download();
|
httpDownloader.download();
|
||||||
|
latch.countDown();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
latch.await(100, TimeUnit.SECONDS); // either 2 progress reports or 100 seconds
|
||||||
assertTrue(destFile.exists());
|
assertTrue(destFile.exists());
|
||||||
assertTrue(destFile.canRead());
|
assertTrue(destFile.canRead());
|
||||||
assertTrue(receivedProgress);
|
assertTrue(receivedProgress);
|
||||||
destFile.deleteOnExit();
|
destFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadHttpBasicAuth() throws IOException, InterruptedException {
|
public void downloadHttpBasicAuth() throws IOException, InterruptedException {
|
||||||
|
16
build.gradle
16
build.gradle
@ -7,3 +7,19 @@ buildscript {
|
|||||||
classpath files('libs/gradle-witness.jar')
|
classpath files('libs/gradle-witness.jar')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Improve build server performance by allowing disabling of pre-dexing
|
||||||
|
* (see http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.)
|
||||||
|
*/
|
||||||
|
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
project.plugins.whenPluginAdded { plugin ->
|
||||||
|
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
|
||||||
|
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
|
||||||
|
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
|
||||||
|
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user