Fix or improve tests

This commit is contained in:
Martin Fietz 2016-03-24 20:00:45 +01:00
parent bae78fe7af
commit 7f1143edde
5 changed files with 9 additions and 4 deletions

View File

@ -53,7 +53,10 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
super.setUp(); super.setUp();
assertionError = null; assertionError = null;
final Context context = getInstrumentation().getTargetContext();
// create new database // create new database
PodDBAdapter.init(context);
PodDBAdapter.deleteDatabase(); PodDBAdapter.deleteDatabase();
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();
@ -62,7 +65,6 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
httpServer = new HTTPBin(); httpServer = new HTTPBin();
httpServer.start(); httpServer.start();
final Context context = getInstrumentation().getTargetContext();
File cacheDir = context.getExternalFilesDir("testFiles"); File cacheDir = context.getExternalFilesDir("testFiles");
if (cacheDir == null) if (cacheDir == null)
cacheDir = context.getExternalFilesDir("testFiles"); cacheDir = context.getExternalFilesDir("testFiles");

View File

@ -34,6 +34,7 @@ public class PlaybackServiceTaskManagerTest extends InstrumentationTestCase {
super.setUp(); super.setUp();
// create new database // create new database
PodDBAdapter.init(getInstrumentation().getTargetContext());
PodDBAdapter.deleteDatabase(); PodDBAdapter.deleteDatabase();
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();

View File

@ -58,7 +58,7 @@ public class DBNullCleanupAlgorithmTest extends InstrumentationTestCase {
assertTrue(destFolder.canWrite()); assertTrue(destFolder.canWrite());
// create new database // create new database
PodDBAdapter.init(getInstrumentation().getTargetContext()); PodDBAdapter.init(context);
PodDBAdapter.deleteDatabase(); PodDBAdapter.deleteDatabase();
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();

View File

@ -39,7 +39,7 @@ public class DBTasksTest extends InstrumentationTestCase {
context = getInstrumentation().getTargetContext(); context = getInstrumentation().getTargetContext();
// create new database // create new database
PodDBAdapter.init(getInstrumentation().getTargetContext()); PodDBAdapter.init(context);
PodDBAdapter.deleteDatabase(); PodDBAdapter.deleteDatabase();
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();

View File

@ -41,10 +41,12 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
uiTestUtils = new UITestUtils(getInstrumentation().getTargetContext()); Context context = getInstrumentation().getTargetContext();
uiTestUtils = new UITestUtils(context);
uiTestUtils.setup(); uiTestUtils.setup();
// create new database // create new database
PodDBAdapter.init(context);
PodDBAdapter.deleteDatabase(); PodDBAdapter.deleteDatabase();
PodDBAdapter adapter = PodDBAdapter.getInstance(); PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();