forked from upstream-mirrors/OpenTracks
Use an in-memory database when running instrumented tests.
- added new TestRunner and new TestApplication - The TestRunner loads TestApplication as the apps Application instance when running the tests - added new interface AppConfig to retrieve the database name - changed Startup (Application) so that it implements AppConfig - changed CustomSQLiteOpenHelper so that it retrieves the database name from the Application instance - Startup provides the production database name - TestApplication provides null which yields an in-mememory database
This commit is contained in:
@@ -11,6 +11,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import de.dennisguse.opentracks.AppConfig;
|
||||
import de.dennisguse.opentracks.content.data.MarkerColumns;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPointsColumns;
|
||||
@@ -27,11 +28,8 @@ public class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final int DATABASE_VERSION = 31;
|
||||
|
||||
@VisibleForTesting
|
||||
public static final String DATABASE_NAME = "database.db";
|
||||
|
||||
public CustomSQLiteOpenHelper(Context context) {
|
||||
this(context, DATABASE_NAME);
|
||||
this(context, ((AppConfig) context.getApplicationContext()).getDatabaseName());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user