mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-01 20:22:03 +00:00
CallRecordingViewModelTest: enable testing LiveData and Rx without Looper
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
4fee81c460
commit
4687341755
@ -290,6 +290,7 @@ dependencies {
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.mockito:mockito-core:5.1.1'
|
||||
testImplementation 'androidx.arch.core:core-testing:2.1.0'
|
||||
|
||||
androidTestImplementation "androidx.test:core:1.5.0"
|
||||
|
||||
|
@ -1,12 +1,20 @@
|
||||
package com.nextcloud.talk.viewmodels
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.nextcloud.talk.test.fakes.FakeCallRecordingRepository
|
||||
import com.vividsolutions.jts.util.Assert
|
||||
import io.reactivex.android.plugins.RxAndroidPlugins
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.junit.Before
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
internal class CallRecordingViewModelTest {
|
||||
class CallRecordingViewModelTest {
|
||||
|
||||
@get:Rule
|
||||
val instantExecutorRule = InstantTaskExecutorRule()
|
||||
|
||||
val repository = FakeCallRecordingRepository()
|
||||
|
||||
@ -19,10 +27,22 @@ internal class CallRecordingViewModelTest {
|
||||
fun testCallRecordingViewModel_startRecord() {
|
||||
val viewModel = CallRecordingViewModel(repository)
|
||||
|
||||
viewModel.setData("foo")
|
||||
|
||||
viewModel.clickRecordButton()
|
||||
|
||||
// implement extension function for liveData to await value?!
|
||||
|
||||
Assert.equals(CallRecordingViewModel.RecordingStartedState, viewModel.viewState)
|
||||
Assert.equals(CallRecordingViewModel.RecordingStartLoadingState, viewModel.viewState.value)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@BeforeClass
|
||||
fun setUpClass() {
|
||||
RxAndroidPlugins.setInitMainThreadSchedulerHandler {
|
||||
Schedulers.trampoline()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user