mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
WIP. add test for CallRecordingViewModel
fails for now... Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
97298c8169
commit
4fee81c460
@ -20,7 +20,6 @@
|
||||
|
||||
package com.nextcloud.talk.viewmodels
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
@ -123,7 +122,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "failure in CallStartRecordingObserver", e)
|
||||
// Log.e(TAG, "failure in CallStartRecordingObserver", e)
|
||||
_viewState.value = RecordingErrorState
|
||||
}
|
||||
|
||||
@ -144,7 +143,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "failure in CallStopRecordingObserver", e)
|
||||
// Log.e(TAG, "failure in CallStopRecordingObserver", e)
|
||||
_viewState.value = RecordingErrorState
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Álvaro Brey
|
||||
* Copyright (C) 2022 Álvaro Brey
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.test.fakes
|
||||
|
||||
import com.nextcloud.talk.models.domain.StartCallRecordingModel
|
||||
import com.nextcloud.talk.models.domain.StopCallRecordingModel
|
||||
import com.nextcloud.talk.repositories.callrecording.CallRecordingRepository
|
||||
import io.reactivex.Observable
|
||||
|
||||
class FakeCallRecordingRepository : CallRecordingRepository {
|
||||
|
||||
override fun startRecording(
|
||||
roomToken: String
|
||||
): Observable<StartCallRecordingModel> {
|
||||
return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
|
||||
}
|
||||
|
||||
override fun stopRecording(
|
||||
roomToken: String
|
||||
): Observable<StopCallRecordingModel> {
|
||||
return Observable.just<StopCallRecordingModel>(StopCallRecordingModel(true))
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.nextcloud.talk.viewmodels
|
||||
|
||||
import com.nextcloud.talk.test.fakes.FakeCallRecordingRepository
|
||||
import com.vividsolutions.jts.util.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
internal class CallRecordingViewModelTest {
|
||||
|
||||
val repository = FakeCallRecordingRepository()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCallRecordingViewModel_startRecord() {
|
||||
val viewModel = CallRecordingViewModel(repository)
|
||||
|
||||
viewModel.clickRecordButton()
|
||||
|
||||
// implement extension function for liveData to await value?!
|
||||
|
||||
Assert.equals(CallRecordingViewModel.RecordingStartedState, viewModel.viewState)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user