fix emulator tests on android-10, closes #769

We have to work harder to get writeable dirs in the android-10 emulator.
This commit is contained in:
Hans-Christoph Steiner 2016-09-19 14:39:28 +02:00
parent 481468372e
commit ecd98047da
4 changed files with 10 additions and 15 deletions

View File

@ -46,7 +46,6 @@ connected10:
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- exit $EXITVALUE
allow_failure: true # remove once install segfaults are gone
connected24:
variables:

View File

@ -1,8 +1,11 @@
package org.fdroid.fdroid;
import android.app.Instrumentation;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.apache.commons.io.FileUtils;
import org.fdroid.fdroid.compat.FileCompatTest;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -19,7 +22,8 @@ public class CleanCacheServiceTest {
@Test
public void testClearOldFiles() throws IOException, InterruptedException {
File tempDir = new File(System.getProperty("java.io.tmpdir"));
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
File tempDir = FileCompatTest.getWriteableDir(instrumentation);
assertTrue(tempDir.isDirectory());
assertTrue(tempDir.canWrite());

View File

@ -80,7 +80,7 @@ public class FileCompatTest {
* Prefer internal over external storage, because external tends to be FAT filesystems,
* which don't support symlinks (which we test using this method).
*/
private static File getWriteableDir(Instrumentation instrumentation) {
public static File getWriteableDir(Instrumentation instrumentation) {
Context context = instrumentation.getContext();
Context targetContext = instrumentation.getTargetContext();

View File

@ -25,15 +25,13 @@ import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.fdroid.fdroid.AssetUtils;
import org.fdroid.fdroid.compat.FileCompatTest;
import org.fdroid.fdroid.data.Apk;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -59,18 +57,12 @@ public class ApkVerifierTest {
File sdk14Apk;
File minMaxApk;
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@Before
public void setUp() {
instrumentation = InstrumentationRegistry.getInstrumentation();
File dir = null;
try {
dir = tempFolder.newFolder("apks");
} catch (IOException e) {
fail(e.getMessage());
}
File dir = FileCompatTest.getWriteableDir(instrumentation);
assertTrue(dir.isDirectory());
assertTrue(dir.canWrite());
sdk14Apk = AssetUtils.copyAssetToDir(instrumentation.getContext(),
"org.fdroid.permissions.sdk14.apk",
dir