Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors
Fixing Tests
Arka Prava Basu68cf160e0173
diff --git a/build.gradle b/build.gradleindex 701daf3..3cd1a74 100644--- a/build.gradle+++ b/build.gradle@@ -99,8 +99,10 @@ android {abiFilters "armeabi", "armeabi-v7a", "x86"}- testInstrumentationRunner "android.test.InstrumentationTestRunner"- testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"++ // clear app state completely between tests+ testInstrumentationRunnerArguments clearPackageData: 'true'javaCompileOptions {annotationProcessorOptions {@@ -170,8 +172,11 @@ dependencies {implementation "android.arch.lifecycle:extensions:1.1.1"testImplementation "junit:junit:4.12"- androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"- androidTestImplementation "com.android.support.test.espresso:espresso-intents:3.0.2"+ androidTestImplementation 'androidx.test:runner:1.1.0'+ androidTestImplementation 'androidx.test:core:1.0.0'+ androidTestImplementation 'androidx.test:rules:1.1.0'+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'+ androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'androidTestImplementation "android.arch.persistence.room:testing:1.1.1"// android-jobdiff --git a/src/androidTest/java/org/havenapp/main/ListActivityTest.kt b/src/androidTest/java/org/havenapp/main/ListActivityTest.ktdeleted file mode 100644index 2be225d..0000000--- a/src/androidTest/java/org/havenapp/main/ListActivityTest.kt+++ /dev/null@@ -1,58 +0,0 @@-package org.havenapp.main--import android.content.Intent-import android.support.test.annotation.UiThreadTest-import android.support.test.espresso.Espresso-import android.support.test.espresso.assertion.ViewAssertions.doesNotExist-import android.support.test.espresso.assertion.ViewAssertions.matches-import android.support.test.espresso.matcher.ViewMatchers.isDisplayed-import android.support.test.espresso.matcher.ViewMatchers.withText-import android.support.v4.content.LocalBroadcastManager-import android.test.ActivityInstrumentationTestCase2-import junit.framework.Assert-import org.havenapp.main.database.DB_INIT_END-import org.havenapp.main.database.DB_INIT_START-import org.havenapp.main.database.DB_INIT_STATUS--/**- * Created by Arka Prava Basu <[email protected]> on 20/10/18.- */-class ListActivityTest : ActivityInstrumentationTestCase2<ListActivity>(ListActivity::class.java) {- private var listActivity: ListActivity? = null-- override fun setUp() {- super.setUp()- listActivity = activity- }-- fun testCheckActivityNotNull() {- Assert.assertNotNull(listActivity)- }-- /**- * Test that we show a progress dialog while database init/migration is in process.- * Test that we remove that on db init/migration success- */- @UiThreadTest- fun testCheckProgressBarShownOnBroadcast() {- Assert.assertNotNull(listActivity)-- var dbIntent = Intent()- dbIntent.putExtra(DB_INIT_STATUS, DB_INIT_START)- dbIntent.action = DB_INIT_STATUS- LocalBroadcastManager.getInstance(activity).sendBroadcast(dbIntent)-- Espresso.onView(withText(R.string.please_wait)).check(matches(isDisplayed()))- Espresso.onView(withText(R.string.migrating_data)).check(matches(isDisplayed()))-- Thread.sleep(5000) // keeping a waiting time to check the view-- dbIntent = Intent()- dbIntent.putExtra(DB_INIT_STATUS, DB_INIT_END)- dbIntent.action = DB_INIT_STATUS- LocalBroadcastManager.getInstance(activity).sendBroadcast(dbIntent)-- Espresso.onView(withText(R.string.please_wait)).check(doesNotExist())- Espresso.onView(withText(R.string.migrating_data)).check(doesNotExist())- }-}diff --git a/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt b/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.ktindex 1bc4c2c..1d94b57 100644--- a/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt+++ b/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt@@ -1,10 +1,12 @@package org.havenapp.main.database.migration-import android.arch.persistence.db.framework.FrameworkSQLiteOpenHelperFactory-import android.arch.persistence.room.Room-import android.arch.persistence.room.testing.MigrationTestHelper-import android.support.test.InstrumentationRegistry+import androidx.test.core.app.ApplicationProvider+import androidx.room.Room+import androidx.room.testing.MigrationTestHelper+import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory+import androidx.test.platform.app.InstrumentationRegistryimport junit.framework.Assert.assertEquals+import org.havenapp.main.database.HavenEventDBimport org.havenapp.main.database.converter.HavenEventDBConverters.Companion.dateToTimestampimport org.junit.Afterimport org.junit.Before@@ -17,7 +19,7 @@ import org.junit.Testclass RoomMigrationTest {@get:Ruleval migrationTestHelper = MigrationTestHelper(InstrumentationRegistry.getInstrumentation(),- org.havenapp.main.database.HavenEventDB::class.java.canonicalName,+ HavenEventDB::class.java.canonicalName,FrameworkSQLiteOpenHelperFactory())private var sugarDbOpenHelper: SugarDbOpenHelper? = null@@ -27,7 +29,7 @@ class RoomMigrationTest {@Beforefun setUpDb() {sugarDbOpenHelper =- SugarDbOpenHelper(InstrumentationRegistry.getTargetContext(), TEST_DB_NAME)+ SugarDbOpenHelper(ApplicationProvider.getApplicationContext(), TEST_DB_NAME)SugarDbTestHelper.createTables(sugarDbOpenHelper!!)}@@ -57,7 +59,7 @@ class RoomMigrationTest {}private fun getMigratedRoomDb(): org.havenapp.main.database.HavenEventDB {- val db = Room.databaseBuilder(InstrumentationRegistry.getTargetContext(),+ val db = Room.databaseBuilder(ApplicationProvider.getApplicationContext(),org.havenapp.main.database.HavenEventDB::class.java, TEST_DB_NAME).addMigrations(RoomMigration()).build()