mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
extracting the rx instant setup to a reuseable test rule
This commit is contained in:
parent
daa3125e57
commit
b55e94b938
@ -17,12 +17,11 @@
|
||||
package im.vector.app.features.crypto.quads
|
||||
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.app.test.InstantRxRule
|
||||
import im.vector.app.test.fakes.FakeSession
|
||||
import im.vector.app.test.fakes.FakeStringProvider
|
||||
import im.vector.app.test.test
|
||||
import io.reactivex.android.plugins.RxAndroidPlugins
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.session.securestorage.IntegrityResult
|
||||
import org.matrix.android.sdk.api.session.securestorage.KeyInfo
|
||||
@ -39,14 +38,12 @@ private val KEY_INFO_WITHOUT_PASSPHRASE = KeyInfo(id = "id", content = SecretSto
|
||||
|
||||
class SharedSecureStorageViewModelTest {
|
||||
|
||||
@get:Rule
|
||||
val instantRx = InstantRxRule()
|
||||
|
||||
private val stringProvider = FakeStringProvider()
|
||||
private val session = FakeSession()
|
||||
|
||||
init {
|
||||
RxJavaPlugins.setInitNewThreadSchedulerHandler { Schedulers.trampoline() }
|
||||
RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a key info with passphrase when initialising then step is EnterPassphrase`() {
|
||||
givenKey(KEY_INFO_WITH_PASSPHRASE)
|
||||
|
32
vector/src/test/java/im/vector/app/test/InstantRxRule.kt
Normal file
32
vector/src/test/java/im/vector/app/test/InstantRxRule.kt
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.test
|
||||
|
||||
import io.reactivex.android.plugins.RxAndroidPlugins
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
||||
class InstantRxRule : TestRule {
|
||||
override fun apply(base: Statement, description: Description?): Statement {
|
||||
RxJavaPlugins.setInitNewThreadSchedulerHandler { Schedulers.trampoline() }
|
||||
RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }
|
||||
return base
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user