-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calling): show double tap indicator once per application lifetim…
…e (WPB-314) (#1905) * feat(calling): show double tap indicator once per application lifetime * chore: detekt * chore: address comments
- Loading branch information
Showing
3 changed files
with
52 additions
and
19 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
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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
package com.wire.android.ui.calling | ||
|
||
import androidx.lifecycle.SavedStateHandle | ||
import com.wire.android.datastore.GlobalDataStore | ||
import com.wire.android.navigation.NavigationManager | ||
import com.wire.android.ui.calling.model.UICallParticipant | ||
import com.wire.android.ui.calling.ongoing.OngoingCallViewModel | ||
|
@@ -30,24 +31,19 @@ import com.wire.kalium.logic.data.call.CallClient | |
import com.wire.kalium.logic.data.id.ConversationId | ||
import com.wire.kalium.logic.data.id.QualifiedID | ||
import com.wire.kalium.logic.data.id.QualifiedIdMapper | ||
import com.wire.kalium.logic.data.user.UserId | ||
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase | ||
import com.wire.kalium.logic.feature.call.usecase.RequestVideoStreamsUseCase | ||
import io.mockk.MockKAnnotations | ||
import io.mockk.coEvery | ||
import io.mockk.coVerify | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.StandardTestDispatcher | ||
import kotlinx.coroutines.test.TestCoroutineScheduler | ||
import kotlinx.coroutines.test.resetMain | ||
import kotlinx.coroutines.test.setMain | ||
import org.junit.After | ||
import kotlinx.coroutines.test.runTest | ||
import org.amshove.kluent.internal.assertEquals | ||
import org.junit.Test | ||
import org.junit.jupiter.api.BeforeEach | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
class OngoingCallViewModelTest { | ||
|
||
@MockK | ||
|
@@ -68,23 +64,26 @@ class OngoingCallViewModelTest { | |
@MockK | ||
private lateinit var currentScreenManager: CurrentScreenManager | ||
|
||
@MockK | ||
private lateinit var globalDataStore: GlobalDataStore | ||
|
||
private lateinit var ongoingCallViewModel: OngoingCallViewModel | ||
|
||
@BeforeEach | ||
fun setup() { | ||
val scheduler = TestCoroutineScheduler() | ||
Dispatchers.setMain(StandardTestDispatcher(scheduler)) | ||
val dummyConversationId = "[email protected]" | ||
MockKAnnotations.init(this) | ||
every { savedStateHandle.get<String>(any()) } returns dummyConversationId | ||
every { savedStateHandle.set(any(), any<String>()) } returns Unit | ||
coEvery { | ||
qualifiedIdMapper.fromStringToQualifiedID("[email protected]") | ||
} returns QualifiedID("some-dummy-value", "some.dummy.domain") | ||
qualifiedIdMapper.fromStringToQualifiedID(dummyConversationId) | ||
} returns conversationId | ||
|
||
ongoingCallViewModel = OngoingCallViewModel( | ||
savedStateHandle = savedStateHandle, | ||
qualifiedIdMapper = qualifiedIdMapper, | ||
currentUserId = currentUserId, | ||
globalDataStore = globalDataStore, | ||
navigationManager = navigationManager, | ||
establishedCalls = establishedCall, | ||
requestVideoStreams = requestVideoStreams, | ||
|
@@ -105,13 +104,19 @@ class OngoingCallViewModelTest { | |
coVerify(exactly = 1) { requestVideoStreams(conversationId, expectedClients) } | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
Dispatchers.resetMain() | ||
@Test | ||
fun givenDoubleTabIndicatorIsDisplayed_whenUserTapsOnIt_thenHideIt() = runTest { | ||
coEvery { globalDataStore.setShouldShowDoubleTapToastStatus(currentUserId.toString(), false) } returns Unit | ||
|
||
ongoingCallViewModel.hideDoubleTapToast() | ||
|
||
assertEquals(false, ongoingCallViewModel.shouldShowDoubleTapToast) | ||
coVerify(exactly = 1) { globalDataStore.setShouldShowDoubleTapToastStatus(currentUserId.toString(), false) } | ||
} | ||
|
||
companion object { | ||
val conversationId = ConversationId("some-dummy-value", "some.dummy.domain") | ||
val currentUserId = UserId("userId", "some.dummy.domain") | ||
private val participant1 = UICallParticipant( | ||
id = QualifiedID("value1", "domain"), | ||
clientId = "client-id1", | ||
|