Make F-Droid tests runnable from Gradle.

This also makes AndroidStudio integration work better, which makes
running and debugging tests much nicer than the CLI.

Also cleaned up imports in one test, and made the symlink tests not
fail on older devices below API 19.
This commit is contained in:
Peter Serwylo 2015-03-23 23:15:27 +11:00
parent da566b44ce
commit 9dfa18aead
3 changed files with 21 additions and 9 deletions

View File

@ -39,6 +39,8 @@ if ( !hasProperty( 'sourceDeps' ) ) {
// Upstream doesn't have a binary on mavenCentral. // Upstream doesn't have a binary on mavenCentral.
compile(name: 'zipsigner') compile(name: 'zipsigner')
androidTestCompile 'commons-io:commons-io:2.2'
} }
} else { } else {
@ -76,6 +78,8 @@ if ( !hasProperty( 'sourceDeps' ) ) {
compile 'com.android.support:support-v4:20.0.+', compile 'com.android.support:support-v4:20.0.+',
'com.android.support:appcompat-v7:20.0.+', 'com.android.support:appcompat-v7:20.0.+',
'com.android.support:support-annotations:20.0.+' 'com.android.support:support-annotations:20.0.+'
androidTestCompile 'commons-io:commons-io:2.2'
} }
} }
@ -135,7 +139,16 @@ android {
assets.srcDirs = ['assets'] assets.srcDirs = ['assets']
} }
instrumentTest.setRoot('test') androidTest.setRoot('test')
androidTest {
manifest.srcFile 'test/AndroidManifest.xml'
java.srcDirs = ['test/src']
resources.srcDirs = ['test/src']
aidl.srcDirs = ['test/src']
renderscript.srcDirs = ['test/src']
res.srcDirs = ['test/res']
assets.srcDirs = ['test/assets']
}
} }
buildTypes { buildTypes {

View File

@ -25,8 +25,13 @@ public class FileCompatTest extends InstrumentationTestCase {
} }
public void tearDown() { public void tearDown() {
assertTrue("Can't delete " + sourceFile.getAbsolutePath() + ".", sourceFile.delete()); if (sourceFile.exists()) {
assertTrue("Can't delete " + destFile.getAbsolutePath() + ".", destFile.delete()); assertTrue("Can't delete " + sourceFile.getAbsolutePath() + ".", sourceFile.delete());
}
if (destFile.exists()) {
assertTrue("Can't delete " + destFile.getAbsolutePath() + ".", destFile.delete());
}
} }
public void testSymlinkRuntime() { public void testSymlinkRuntime() {

View File

@ -3,21 +3,15 @@ package org.fdroid.fdroid.updater;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.os.Environment;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import android.util.Log;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.fdroid.fdroid.TestUtils; import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Repo; import org.fdroid.fdroid.data.Repo;
import org.fdroid.fdroid.updater.RepoUpdater.UpdateException; import org.fdroid.fdroid.updater.RepoUpdater.UpdateException;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@TargetApi(8) @TargetApi(8)
public class SignedRepoUpdaterTest extends InstrumentationTestCase { public class SignedRepoUpdaterTest extends InstrumentationTestCase {