This commit is contained in:
kunfei
2023-03-25 16:20:41 +08:00
parent e916067c46
commit 2c5989919c
4 changed files with 18 additions and 9 deletions
+1
View File
@@ -139,6 +139,7 @@ dependencies {
//coreLibraryDesugaring('com.android.tools:desugar_jdk_libs_nio:2.0.2')
testImplementation('junit:junit:4.13.2')
androidTestImplementation('androidx.test:runner:1.5.2')
androidTestImplementation('androidx.test.ext:junit:1.1.3')
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
//kotlin
//noinspection GradleDependency,DifferentStdlibGradleVersion
@@ -1,9 +1,10 @@
package io.legado.app
import android.content.Context
import android.net.Uri
import android.util.Log
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
@@ -17,10 +18,17 @@ class ExampleInstrumentedTest {
@Test
fun testContentProvider() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
Log.d("test",
appContext.contentResolver.query(Uri.parse("content://io.legado.app.api.ReaderProvider/sources/query"),null,null,null,null)
!!.getString(0)
val appContext = ApplicationProvider.getApplicationContext<Context>()
Log.d(
"test",
appContext.contentResolver.query(
Uri.parse("content://io.legado.app.api.ReaderProvider/sources/query"),
null,
null,
null,
null
)
!!.getString(0)
)
}
}
}
@@ -4,8 +4,8 @@ import androidx.room.Room
import androidx.room.migration.Migration
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import io.legado.app.data.AppDatabase
import org.junit.Rule
import org.junit.Test
@@ -14,6 +14,7 @@ import java.io.IOException
@RunWith(AndroidJUnit4::class)
class MigrationTest {
private val TEST_DB = "migration-test"
private val ALL_MIGRATIONS = arrayOf<Migration>(
-1
View File
@@ -11,7 +11,6 @@ android {
minSdk 21
targetSdk 33
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}