mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix ImportTest on Nougat
This commit is contained in:
@@ -40,8 +40,6 @@ import static org.junit.Assert.*;
|
|||||||
@MediumTest
|
@MediumTest
|
||||||
public class ImportTest extends BaseAndroidTest
|
public class ImportTest extends BaseAndroidTest
|
||||||
{
|
{
|
||||||
private File baseDir;
|
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,11 +48,8 @@ public class ImportTest extends BaseAndroidTest
|
|||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
DateUtils.setFixedLocalTime(null);
|
DateUtils.setFixedLocalTime(null);
|
||||||
|
|
||||||
fixtures.purgeHabits(habitList);
|
fixtures.purgeHabits(habitList);
|
||||||
context = InstrumentationRegistry.getInstrumentation().getContext();
|
context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||||
baseDir = FileUtils.getFilesDir(context, "Backups");
|
|
||||||
if (baseDir == null) fail("baseDir should not be null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -149,8 +144,7 @@ public class ImportTest extends BaseAndroidTest
|
|||||||
|
|
||||||
private void importFromFile(String assetFilename) throws IOException
|
private void importFromFile(String assetFilename) throws IOException
|
||||||
{
|
{
|
||||||
File file =
|
File file = File.createTempFile("asset", "");
|
||||||
new File(String.format("%s/%s", baseDir.getPath(), assetFilename));
|
|
||||||
copyAssetToFile(assetFilename, file);
|
copyAssetToFile(assetFilename, file);
|
||||||
assertTrue(file.exists());
|
assertTrue(file.exists());
|
||||||
assertTrue(file.canRead());
|
assertTrue(file.canRead());
|
||||||
@@ -159,5 +153,7 @@ public class ImportTest extends BaseAndroidTest
|
|||||||
assertThat(importer.canHandle(file), is(true));
|
assertThat(importer.canHandle(file), is(true));
|
||||||
|
|
||||||
importer.importHabitsFromFile(file);
|
importer.importHabitsFromFile(file);
|
||||||
|
|
||||||
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user