-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delays and clean the state independently of the orchestrator
- Loading branch information
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/androidTest/kotlin/com/fibelatti/pinboard/TestUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.fibelatti.pinboard | ||
|
||
import android.view.View | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.UiController | ||
import androidx.test.espresso.ViewAction | ||
import androidx.test.espresso.matcher.ViewMatchers.isRoot | ||
import org.hamcrest.Matcher | ||
import java.util.concurrent.TimeUnit | ||
|
||
object TestUtil { | ||
|
||
fun delay(seconds: Long) { | ||
onView(isRoot()).perform(waitOnId(TimeUnit.SECONDS.toMillis(seconds))) | ||
} | ||
|
||
fun waitOnId(millis: Long): ViewAction = object : ViewAction { | ||
|
||
override fun getConstraints(): Matcher<View> = isRoot() | ||
|
||
override fun getDescription(): String = "Wait a specified amount of time." | ||
|
||
override fun perform(uiController: UiController?, view: View?) { | ||
uiController?.loopMainThreadForAtLeast(millis) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/kotlin/com/fibelatti/pinboard/core/di/modules/TestDatabaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.fibelatti.pinboard.core.di.modules | ||
|
||
import android.app.Application | ||
import androidx.room.Room | ||
import com.fibelatti.pinboard.core.persistence.database.AppDatabase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.hilt.testing.TestInstallIn | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@TestInstallIn( | ||
components = [SingletonComponent::class], | ||
replaces = [DatabaseModule::class], | ||
) | ||
object TestDatabaseModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun appDatabase( | ||
application: Application, | ||
): AppDatabase = Room.inMemoryDatabaseBuilder(application, AppDatabase::class.java).build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters