Issue#67 Extract OkHttp IdlingResources into a separate module
This commit is contained in:
parent
bbe077dde8
commit
756c74e174
9 changed files with 26 additions and 21 deletions
|
|
@ -11,12 +11,12 @@ import androidx.test.rule.ActivityTestRule
|
||||||
import androidx.test.runner.AndroidJUnit4
|
import androidx.test.runner.AndroidJUnit4
|
||||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||||
import org.fnives.test.showcase.R
|
import org.fnives.test.showcase.R
|
||||||
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.CompositeDisposable
|
||||||
import org.fnives.test.showcase.testutils.idling.CompositeDisposable
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.Disposable
|
||||||
import org.fnives.test.showcase.testutils.idling.Disposable
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.IdlingResourceDisposable
|
||||||
import org.fnives.test.showcase.testutils.idling.IdlingResourceDisposable
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.OkHttp3IdlingResource
|
||||||
import org.fnives.test.showcase.testutils.idling.OkHttp3IdlingResource
|
|
||||||
import org.fnives.test.showcase.android.testutil.synchronization.loopMainThreadFor
|
import org.fnives.test.showcase.android.testutil.synchronization.loopMainThreadFor
|
||||||
|
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
||||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||||
import org.fnives.test.showcase.ui.splash.SplashActivity
|
import org.fnives.test.showcase.ui.splash.SplashActivity
|
||||||
import org.hamcrest.Description
|
import org.hamcrest.Description
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,15 @@ import kotlinx.coroutines.test.TestDispatcher
|
||||||
import kotlinx.coroutines.test.resetMain
|
import kotlinx.coroutines.test.resetMain
|
||||||
import kotlinx.coroutines.test.setMain
|
import kotlinx.coroutines.test.setMain
|
||||||
import org.fnives.test.showcase.R
|
import org.fnives.test.showcase.R
|
||||||
|
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.CompositeDisposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.Disposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.IdlingResourceDisposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.OkHttp3IdlingResource
|
||||||
import org.fnives.test.showcase.network.mockserver.MockServerScenarioSetup
|
import org.fnives.test.showcase.network.mockserver.MockServerScenarioSetup
|
||||||
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
import org.fnives.test.showcase.network.mockserver.scenario.auth.AuthScenario
|
||||||
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
||||||
import org.fnives.test.showcase.testutils.idling.CompositeDisposable
|
|
||||||
import org.fnives.test.showcase.testutils.idling.Disposable
|
|
||||||
import org.fnives.test.showcase.testutils.idling.IdlingResourceDisposable
|
|
||||||
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule.Companion.advanceUntilIdleWithIdlingResources
|
import org.fnives.test.showcase.testutils.idling.MainDispatcherTestRule.Companion.advanceUntilIdleWithIdlingResources
|
||||||
import org.fnives.test.showcase.testutils.idling.OkHttp3IdlingResource
|
|
||||||
import org.fnives.test.showcase.android.testutil.activity.safeClose
|
|
||||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||||
import org.fnives.test.showcase.ui.auth.AuthActivity
|
import org.fnives.test.showcase.ui.auth.AuthActivity
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
package org.fnives.test.showcase.testutils.idling
|
|
||||||
|
|
||||||
interface Disposable {
|
|
||||||
val isDisposed: Boolean
|
|
||||||
fun dispose()
|
|
||||||
}
|
|
||||||
|
|
@ -3,6 +3,10 @@ package org.fnives.test.showcase.testutils.idling
|
||||||
import androidx.annotation.CheckResult
|
import androidx.annotation.CheckResult
|
||||||
import androidx.test.espresso.IdlingResource
|
import androidx.test.espresso.IdlingResource
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.CompositeDisposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.Disposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.IdlingResourceDisposable
|
||||||
|
import org.fnives.test.showcase.android.testutil.synchronization.idlingresources.OkHttp3IdlingResource
|
||||||
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
import org.fnives.test.showcase.network.testutil.NetworkTestConfigurationHelper
|
||||||
import org.junit.rules.TestRule
|
import org.junit.rules.TestRule
|
||||||
import org.junit.runner.Description
|
import org.junit.runner.Description
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,5 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
|
||||||
implementation "androidx.test:core:$androidx_test_version"
|
implementation "androidx.test:core:$androidx_test_version"
|
||||||
implementation"androidx.test.espresso:espresso-core:$espresso_version"
|
implementation"androidx.test.espresso:espresso-core:$espresso_version"
|
||||||
|
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.fnives.test.showcase.testutils.idling
|
package org.fnives.test.showcase.android.testutil.synchronization.idlingresources
|
||||||
|
|
||||||
class CompositeDisposable(disposable: List<Disposable> = emptyList()) : Disposable {
|
class CompositeDisposable(disposable: List<Disposable> = emptyList()) : Disposable {
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.fnives.test.showcase.android.testutil.synchronization.idlingresources
|
||||||
|
|
||||||
|
interface Disposable {
|
||||||
|
val isDisposed: Boolean
|
||||||
|
fun dispose()
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package org.fnives.test.showcase.testutils.idling
|
package org.fnives.test.showcase.android.testutil.synchronization.idlingresources
|
||||||
|
|
||||||
import androidx.test.espresso.IdlingRegistry
|
import androidx.test.espresso.IdlingRegistry
|
||||||
import androidx.test.espresso.IdlingResource
|
import androidx.test.espresso.IdlingResource
|
||||||
|
|
||||||
internal class IdlingResourceDisposable(private val idlingResource: IdlingResource) : Disposable {
|
class IdlingResourceDisposable(private val idlingResource: IdlingResource) : Disposable {
|
||||||
override var isDisposed: Boolean = false
|
override var isDisposed: Boolean = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.fnives.test.showcase.testutils.idling
|
package org.fnives.test.showcase.android.testutil.synchronization.idlingresources
|
||||||
|
|
||||||
import androidx.annotation.CheckResult
|
import androidx.annotation.CheckResult
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
|
|
@ -40,7 +40,7 @@ class OkHttp3IdlingResource private constructor(
|
||||||
* this instance using `Espresso.registerIdlingResources`.
|
* this instance using `Espresso.registerIdlingResources`.
|
||||||
*/
|
*/
|
||||||
@CheckResult
|
@CheckResult
|
||||||
@NonNull // Extra guards as a library.
|
@NonNull
|
||||||
fun create(@NonNull name: String?, @NonNull client: OkHttpClient?): OkHttp3IdlingResource {
|
fun create(@NonNull name: String?, @NonNull client: OkHttpClient?): OkHttp3IdlingResource {
|
||||||
if (name == null) throw NullPointerException("name == null")
|
if (name == null) throw NullPointerException("name == null")
|
||||||
if (client == null) throw NullPointerException("client == null")
|
if (client == null) throw NullPointerException("client == null")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue