Commit 225fffa6 authored by Habib Kazemi's avatar Habib Kazemi Committed by Geoffrey Métais

Add InstantTaskExecutorRule to androidTest

without that the getValue() throws "java.lang.IllegalStateException: Cannot
invoke observeForever on a background thread"
Signed-off-by: 's avatarGeoffrey Métais <geoffrey.metais@gmail.com>
parent 15282d90
Pipeline #4503 passed with stage
in 3 minutes and 49 seconds
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
package org.videolan.vlc.database package org.videolan.vlc.database
import androidx.arch.core.executor.testing.CountingTaskExecutorRule import androidx.arch.core.executor.testing.CountingTaskExecutorRule
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.room.Room import androidx.room.Room
import androidx.test.InstrumentationRegistry import androidx.test.InstrumentationRegistry
import org.junit.After import org.junit.After
...@@ -30,6 +31,9 @@ import java.util.concurrent.TimeUnit ...@@ -30,6 +31,9 @@ import java.util.concurrent.TimeUnit
abstract class DbTest { abstract class DbTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
@Rule @Rule
@JvmField @JvmField
val countingTaskExecutorRule = CountingTaskExecutorRule() val countingTaskExecutorRule = CountingTaskExecutorRule()
......
...@@ -25,6 +25,7 @@ import androidx.room.Room ...@@ -25,6 +25,7 @@ import androidx.room.Room
import androidx.room.migration.Migration import androidx.room.migration.Migration
import androidx.room.testing.MigrationTestHelper import androidx.room.testing.MigrationTestHelper
import android.net.Uri import android.net.Uri
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.test.InstrumentationRegistry import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4 import androidx.test.runner.AndroidJUnit4
import org.hamcrest.CoreMatchers.`is` import org.hamcrest.CoreMatchers.`is`
...@@ -48,6 +49,9 @@ private const val TEST_DB_NAME = "test-db" ...@@ -48,6 +49,9 @@ private const val TEST_DB_NAME = "test-db"
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class MigrationTest { class MigrationTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
@get:Rule @get:Rule
val migrationTestHelper = MigrationTestHelper( val migrationTestHelper = MigrationTestHelper(
InstrumentationRegistry.getInstrumentation(), InstrumentationRegistry.getInstrumentation(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment