mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Checking lab flag before updating the client info
This commit is contained in:
parent
f753e475d8
commit
8b30ab69c5
3 changed files with 34 additions and 2 deletions
|
@ -21,6 +21,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||
import im.vector.app.core.extensions.startSyncing
|
||||
import im.vector.app.core.session.clientinfo.UpdateMatrixClientInfoUseCase
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.sync.FilterService
|
||||
import timber.log.Timber
|
||||
|
@ -30,6 +31,7 @@ class ConfigureAndStartSessionUseCase @Inject constructor(
|
|||
@ApplicationContext private val context: Context,
|
||||
private val webRtcCallManager: WebRtcCallManager,
|
||||
private val updateMatrixClientInfoUseCase: UpdateMatrixClientInfoUseCase,
|
||||
private val vectorPreferences: VectorPreferences,
|
||||
) {
|
||||
|
||||
suspend fun execute(session: Session, startSyncing: Boolean = true) {
|
||||
|
@ -41,6 +43,8 @@ class ConfigureAndStartSessionUseCase @Inject constructor(
|
|||
}
|
||||
session.pushersService().refreshPushers()
|
||||
webRtcCallManager.checkForProtocolsSupportIfNeeded()
|
||||
updateMatrixClientInfoUseCase.execute(session)
|
||||
if (vectorPreferences.isClientInfoRecordingEnabled()) {
|
||||
updateMatrixClientInfoUseCase.execute(session)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import im.vector.app.core.extensions.startSyncing
|
|||
import im.vector.app.core.session.clientinfo.UpdateMatrixClientInfoUseCase
|
||||
import im.vector.app.test.fakes.FakeContext
|
||||
import im.vector.app.test.fakes.FakeSession
|
||||
import im.vector.app.test.fakes.FakeVectorPreferences
|
||||
import im.vector.app.test.fakes.FakeWebRtcCallManager
|
||||
import io.mockk.coJustRun
|
||||
import io.mockk.coVerify
|
||||
|
@ -41,11 +42,13 @@ class ConfigureAndStartSessionUseCaseTest {
|
|||
private val fakeContext = FakeContext()
|
||||
private val fakeWebRtcCallManager = FakeWebRtcCallManager()
|
||||
private val fakeUpdateMatrixClientInfoUseCase = mockk<UpdateMatrixClientInfoUseCase>()
|
||||
private val fakeVectorPreferences = FakeVectorPreferences()
|
||||
|
||||
private val configureAndStartSessionUseCase = ConfigureAndStartSessionUseCase(
|
||||
context = fakeContext.instance,
|
||||
webRtcCallManager = fakeWebRtcCallManager.instance,
|
||||
updateMatrixClientInfoUseCase = fakeUpdateMatrixClientInfoUseCase,
|
||||
vectorPreferences = fakeVectorPreferences.instance,
|
||||
)
|
||||
|
||||
@Before
|
||||
|
@ -59,11 +62,12 @@ class ConfigureAndStartSessionUseCaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `given a session and start sync needed when configuring and starting the session then it should be configured properly`() = runTest {
|
||||
fun `given start sync needed and client info recording enabled when configuring and starting the session then it should be configured properly`() = runTest {
|
||||
// Given
|
||||
val fakeSession = givenASession()
|
||||
fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
|
||||
coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
|
||||
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
|
||||
|
||||
// When
|
||||
configureAndStartSessionUseCase.execute(fakeSession, startSyncing = true)
|
||||
|
@ -76,12 +80,32 @@ class ConfigureAndStartSessionUseCaseTest {
|
|||
coVerify { fakeUpdateMatrixClientInfoUseCase.execute(fakeSession) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given start sync needed and client info recording disabled when configuring and starting the session then it should be configured properly`() = runTest {
|
||||
// Given
|
||||
val fakeSession = givenASession()
|
||||
fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
|
||||
coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
|
||||
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = false)
|
||||
|
||||
// When
|
||||
configureAndStartSessionUseCase.execute(fakeSession, startSyncing = true)
|
||||
|
||||
// Then
|
||||
verify { fakeSession.startSyncing(fakeContext.instance) }
|
||||
fakeSession.fakeFilterService.verifySetFilter(FilterService.FilterPreset.ElementFilter)
|
||||
fakeSession.fakePushersService.verifyRefreshPushers()
|
||||
fakeWebRtcCallManager.verifyCheckForProtocolsSupportIfNeeded()
|
||||
coVerify(inverse = true) { fakeUpdateMatrixClientInfoUseCase.execute(fakeSession) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a session and no start sync needed when configuring and starting the session then it should be configured properly`() = runTest {
|
||||
// Given
|
||||
val fakeSession = givenASession()
|
||||
fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
|
||||
coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
|
||||
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
|
||||
|
||||
// When
|
||||
configureAndStartSessionUseCase.execute(fakeSession, startSyncing = false)
|
||||
|
|
|
@ -36,4 +36,8 @@ class FakeVectorPreferences {
|
|||
fun verifySetSpaceBackstack(value: List<String?>, inverse: Boolean = false) {
|
||||
verify(inverse = inverse) { instance.setSpaceBackstack(value) }
|
||||
}
|
||||
|
||||
fun givenIsClientInfoRecordingEnabled(isEnabled: Boolean) {
|
||||
every { instance.isClientInfoRecordingEnabled() } returns isEnabled
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue