Update related account data event on notification method change

This commit is contained in:
Maxime NATUREL 2022-11-23 14:45:37 +01:00
parent e99dc1d163
commit 637961bbb1
12 changed files with 207 additions and 85 deletions

View file

@ -22,5 +22,5 @@ import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class LocalNotificationSettingsContent(
@Json(name = "is_silenced")
val isSilenced: Boolean? = false
val isSilenced: Boolean?
)

View file

@ -1,39 +0,0 @@
/*
* Copyright (c) 2022 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.core.notification
import im.vector.app.features.session.coroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class EnableNotificationsSettingUpdater @Inject constructor(
private val updateEnableNotificationsSettingOnChangeUseCase: UpdateEnableNotificationsSettingOnChangeUseCase,
) {
private var job: Job? = null
fun onSessionsStarted(session: Session) {
job?.cancel()
job = session.coroutineScope.launch {
updateEnableNotificationsSettingOnChangeUseCase.execute(session)
}
}
}

View file

@ -0,0 +1,74 @@
/*
* Copyright (c) 2022 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.core.notification
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import im.vector.app.features.session.coroutineScope
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorPreferences.Companion.SETTINGS_FDROID_BACKGROUND_SYNC_MODE
import im.vector.app.features.settings.devices.v2.notification.UpdateNotificationSettingsAccountDataUseCase
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject
import javax.inject.Singleton
/**
* Listen changes in Pusher or Account Data to update the local setting for notification toggle.
* Listen changes on background sync mode preference to update the corresponding Account Data event.
*/
@Singleton
class NotificationsSettingUpdater @Inject constructor(
private val updateEnableNotificationsSettingOnChangeUseCase: UpdateEnableNotificationsSettingOnChangeUseCase,
private val vectorPreferences: VectorPreferences,
private val updateNotificationSettingsAccountDataUseCase: UpdateNotificationSettingsAccountDataUseCase,
) {
private var job: Job? = null
private var prefChangeListener: OnSharedPreferenceChangeListener? = null
// TODO add unit tests
fun onSessionsStarted(session: Session) {
updateEnableNotificationsSettingOnChange(session)
updateNotificationSettingsAccountDataOnChange(session)
}
private fun updateEnableNotificationsSettingOnChange(session: Session) {
job?.cancel()
job = session.coroutineScope.launch {
updateEnableNotificationsSettingOnChangeUseCase.execute(session)
}
}
private fun updateNotificationSettingsAccountDataOnChange(session: Session) {
prefChangeListener?.let { vectorPreferences.unsubscribeToChanges(it) }
prefChangeListener = null
prefChangeListener = createPrefListener(session).also {
vectorPreferences.subscribeToChanges(it)
}
}
private fun createPrefListener(session: Session): OnSharedPreferenceChangeListener {
return OnSharedPreferenceChangeListener { _, key ->
session.coroutineScope.launch {
if (key == SETTINGS_FDROID_BACKGROUND_SYNC_MODE) {
updateNotificationSettingsAccountDataUseCase.execute(session)
}
}
}
}
}

View file

@ -19,7 +19,7 @@ package im.vector.app.core.session
import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import im.vector.app.core.extensions.startSyncing
import im.vector.app.core.notification.EnableNotificationsSettingUpdater
import im.vector.app.core.notification.NotificationsSettingUpdater
import im.vector.app.core.session.clientinfo.UpdateMatrixClientInfoUseCase
import im.vector.app.features.call.webrtc.WebRtcCallManager
import im.vector.app.features.session.coroutineScope
@ -36,7 +36,7 @@ class ConfigureAndStartSessionUseCase @Inject constructor(
private val webRtcCallManager: WebRtcCallManager,
private val updateMatrixClientInfoUseCase: UpdateMatrixClientInfoUseCase,
private val vectorPreferences: VectorPreferences,
private val enableNotificationsSettingUpdater: EnableNotificationsSettingUpdater,
private val notificationsSettingUpdater: NotificationsSettingUpdater,
private val updateNotificationSettingsAccountDataUseCase: UpdateNotificationSettingsAccountDataUseCase,
) {
@ -53,7 +53,7 @@ class ConfigureAndStartSessionUseCase @Inject constructor(
webRtcCallManager.checkForProtocolsSupportIfNeeded()
updateMatrixClientInfoIfNeeded(session)
createNotificationSettingsAccountDataIfNeeded(session)
enableNotificationsSettingUpdater.onSessionsStarted(session)
notificationsSettingUpdater.onSessionsStarted(session)
}
private fun updateMatrixClientInfoIfNeeded(session: Session) {
@ -66,9 +66,7 @@ class ConfigureAndStartSessionUseCase @Inject constructor(
private fun createNotificationSettingsAccountDataIfNeeded(session: Session) {
session.coroutineScope.launch {
if (vectorPreferences.isBackgroundSyncEnabled()) {
updateNotificationSettingsAccountDataUseCase.execute(session)
}
updateNotificationSettingsAccountDataUseCase.execute(session)
}
}
}

View file

@ -24,15 +24,17 @@ import javax.inject.Inject
* Delete the content of any associated notification settings to the current session.
*/
class DeleteNotificationSettingsAccountDataUseCase @Inject constructor(
private val getNotificationSettingsAccountDataUseCase: GetNotificationSettingsAccountDataUseCase,
private val setNotificationSettingsAccountDataUseCase: SetNotificationSettingsAccountDataUseCase,
) {
// TODO to be called when switching to push notifications method (check notification method setting)
suspend fun execute(session: Session) {
val deviceId = session.sessionParams.deviceId ?: return
val emptyNotificationSettingsContent = LocalNotificationSettingsContent(
isSilenced = null
)
setNotificationSettingsAccountDataUseCase.execute(session, deviceId, emptyNotificationSettingsContent)
if (getNotificationSettingsAccountDataUseCase.execute(session, deviceId)?.isSilenced != null) {
val emptyNotificationSettingsContent = LocalNotificationSettingsContent(
isSilenced = null
)
setNotificationSettingsAccountDataUseCase.execute(session, deviceId, emptyNotificationSettingsContent)
}
}
}

View file

@ -22,24 +22,37 @@ import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject
/**
* Update the notification settings account data for the current session.
* Update the notification settings account data for the current session depending on whether
* the background sync is enabled or not.
*/
class UpdateNotificationSettingsAccountDataUseCase @Inject constructor(
private val vectorPreferences: VectorPreferences,
private val getNotificationSettingsAccountDataUseCase: GetNotificationSettingsAccountDataUseCase,
private val setNotificationSettingsAccountDataUseCase: SetNotificationSettingsAccountDataUseCase
private val setNotificationSettingsAccountDataUseCase: SetNotificationSettingsAccountDataUseCase,
private val deleteNotificationSettingsAccountDataUseCase: DeleteNotificationSettingsAccountDataUseCase,
) {
// TODO to be called when switching to background sync (in notification method setting)
suspend fun execute(session: Session) {
if (vectorPreferences.isBackgroundSyncEnabled()) {
setCurrentNotificationStatus(session)
} else {
deleteCurrentNotificationStatus(session)
}
}
private suspend fun setCurrentNotificationStatus(session: Session) {
val deviceId = session.sessionParams.deviceId ?: return
val isSilencedLocal = !vectorPreferences.areNotificationEnabledForDevice()
val isSilencedRemote = getNotificationSettingsAccountDataUseCase.execute(session, deviceId)?.isSilenced
if (isSilencedLocal != isSilencedRemote) {
val areNotificationsSilenced = !vectorPreferences.areNotificationEnabledForDevice()
val isSilencedAccountData = getNotificationSettingsAccountDataUseCase.execute(session, deviceId)?.isSilenced
if (areNotificationsSilenced != isSilencedAccountData) {
val notificationSettingsContent = LocalNotificationSettingsContent(
isSilenced = isSilencedLocal
isSilenced = areNotificationsSilenced
)
setNotificationSettingsAccountDataUseCase.execute(session, deviceId, notificationSettingsContent)
}
}
private suspend fun deleteCurrentNotificationStatus(session: Session) {
deleteNotificationSettingsAccountDataUseCase.execute(session)
}
}

View file

@ -22,7 +22,7 @@ import im.vector.app.features.session.coroutineScope
import im.vector.app.features.sync.SyncUtils
import im.vector.app.features.settings.devices.v2.notification.UpdateNotificationSettingsAccountDataUseCase
import im.vector.app.test.fakes.FakeContext
import im.vector.app.test.fakes.FakeEnableNotificationsSettingUpdater
import im.vector.app.test.fakes.FakeNotificationsSettingUpdater
import im.vector.app.test.fakes.FakeSession
import im.vector.app.test.fakes.FakeVectorPreferences
import im.vector.app.test.fakes.FakeWebRtcCallManager
@ -47,7 +47,7 @@ class ConfigureAndStartSessionUseCaseTest {
private val fakeWebRtcCallManager = FakeWebRtcCallManager()
private val fakeUpdateMatrixClientInfoUseCase = mockk<UpdateMatrixClientInfoUseCase>()
private val fakeVectorPreferences = FakeVectorPreferences()
private val fakeEnableNotificationsSettingUpdater = FakeEnableNotificationsSettingUpdater()
private val fakeNotificationsSettingUpdater = FakeNotificationsSettingUpdater()
private val fakeUpdateNotificationSettingsAccountDataUseCase = mockk<UpdateNotificationSettingsAccountDataUseCase>()
private val configureAndStartSessionUseCase = ConfigureAndStartSessionUseCase(
@ -55,7 +55,7 @@ class ConfigureAndStartSessionUseCaseTest {
webRtcCallManager = fakeWebRtcCallManager.instance,
updateMatrixClientInfoUseCase = fakeUpdateMatrixClientInfoUseCase,
vectorPreferences = fakeVectorPreferences.instance,
enableNotificationsSettingUpdater = fakeEnableNotificationsSettingUpdater.instance,
notificationsSettingUpdater = fakeNotificationsSettingUpdater.instance,
updateNotificationSettingsAccountDataUseCase = fakeUpdateNotificationSettingsAccountDataUseCase,
)
@ -71,7 +71,7 @@ class ConfigureAndStartSessionUseCaseTest {
}
@Test
fun `given start sync needed and enabled related preferences when execute then it should be configured properly`() = runTest {
fun `given start sync needed and client info recording enabled when execute then it should be configured properly`() = runTest {
// Given
val aSession = givenASession()
every { aSession.coroutineScope } returns this
@ -79,8 +79,7 @@ class ConfigureAndStartSessionUseCaseTest {
coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
fakeVectorPreferences.givenIsBackgroundSyncEnabled(isEnabled = true)
fakeEnableNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
// When
configureAndStartSessionUseCase.execute(aSession, startSyncing = true)
@ -98,14 +97,14 @@ class ConfigureAndStartSessionUseCaseTest {
}
@Test
fun `given start sync needed and disabled related preferences when execute then it should be configured properly`() = runTest {
fun `given start sync needed and client info recording disabled when execute then it should be configured properly`() = runTest {
// Given
val aSession = givenASession()
every { aSession.coroutineScope } returns this
fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = false)
fakeVectorPreferences.givenIsBackgroundSyncEnabled(isEnabled = false)
fakeEnableNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
// When
configureAndStartSessionUseCase.execute(aSession, startSyncing = true)
@ -118,6 +117,8 @@ class ConfigureAndStartSessionUseCaseTest {
fakeWebRtcCallManager.verifyCheckForProtocolsSupportIfNeeded()
coVerify(inverse = true) {
fakeUpdateMatrixClientInfoUseCase.execute(aSession)
}
coVerify {
fakeUpdateNotificationSettingsAccountDataUseCase.execute(aSession)
}
}
@ -125,27 +126,26 @@ class ConfigureAndStartSessionUseCaseTest {
@Test
fun `given a session and no start sync needed when execute then it should be configured properly`() = runTest {
// Given
val fakeSession = givenASession()
every { fakeSession.coroutineScope } returns this
val aSession = givenASession()
every { aSession.coroutineScope } returns this
fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
fakeVectorPreferences.givenIsBackgroundSyncEnabled(isEnabled = true)
fakeEnableNotificationsSettingUpdater.givenOnSessionsStarted(fakeSession)
fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
// When
configureAndStartSessionUseCase.execute(fakeSession, startSyncing = false)
configureAndStartSessionUseCase.execute(aSession, startSyncing = false)
advanceUntilIdle()
// Then
verify(inverse = true) { fakeSession.startSyncing(fakeContext.instance) }
fakeSession.fakeFilterService.verifySetSyncFilter(SyncUtils.getSyncFilterBuilder())
fakeSession.fakePushersService.verifyRefreshPushers()
verify(inverse = true) { aSession.startSyncing(fakeContext.instance) }
aSession.fakeFilterService.verifySetSyncFilter(SyncUtils.getSyncFilterBuilder())
aSession.fakePushersService.verifyRefreshPushers()
fakeWebRtcCallManager.verifyCheckForProtocolsSupportIfNeeded()
coVerify {
fakeUpdateMatrixClientInfoUseCase.execute(fakeSession)
fakeUpdateNotificationSettingsAccountDataUseCase.execute(fakeSession)
fakeUpdateMatrixClientInfoUseCase.execute(aSession)
fakeUpdateNotificationSettingsAccountDataUseCase.execute(aSession)
}
}

View file

@ -19,7 +19,9 @@ package im.vector.app.features.settings.devices.v2.notification
import im.vector.app.test.fakes.FakeSession
import io.mockk.coJustRun
import io.mockk.coVerify
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
@ -27,17 +29,22 @@ import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
class DeleteNotificationSettingsAccountDataUseCaseTest {
private val fakeSetNotificationSettingsAccountDataUseCase = mockk<SetNotificationSettingsAccountDataUseCase>()
private val fakeGetNotificationSettingsAccountDataUseCase = mockk<GetNotificationSettingsAccountDataUseCase>()
private val deleteNotificationSettingsAccountDataUseCase = DeleteNotificationSettingsAccountDataUseCase(
setNotificationSettingsAccountDataUseCase = fakeSetNotificationSettingsAccountDataUseCase,
getNotificationSettingsAccountDataUseCase = fakeGetNotificationSettingsAccountDataUseCase,
)
@Test
fun `given a device id when execute then empty content is set for the account data`() = runTest {
fun `given a device id and existing account data content when execute then empty content is set for the account data`() = runTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
aSession.givenSessionId(aDeviceId)
every { fakeGetNotificationSettingsAccountDataUseCase.execute(any(), any()) } returns LocalNotificationSettingsContent(
isSilenced = true,
)
coJustRun { fakeSetNotificationSettingsAccountDataUseCase.execute(any(), any(), any()) }
val expectedContent = LocalNotificationSettingsContent(
isSilenced = null
@ -47,6 +54,25 @@ class DeleteNotificationSettingsAccountDataUseCaseTest {
deleteNotificationSettingsAccountDataUseCase.execute(aSession)
// Then
verify { fakeGetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId) }
coVerify { fakeSetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId, expectedContent) }
}
@Test
fun `given a device id and empty existing account data content when execute then nothing is done`() = runTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
aSession.givenSessionId(aDeviceId)
every { fakeGetNotificationSettingsAccountDataUseCase.execute(any(), any()) } returns LocalNotificationSettingsContent(
isSilenced = null,
)
// When
deleteNotificationSettingsAccountDataUseCase.execute(aSession)
// Then
verify { fakeGetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId) }
coVerify(inverse = true) { fakeSetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId, any()) }
}
}

View file

@ -32,7 +32,27 @@ class GetNotificationSettingsAccountDataUseCaseTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
val expectedContent = LocalNotificationSettingsContent()
val expectedContent = LocalNotificationSettingsContent(isSilenced = true)
aSession
.accountDataService()
.givenGetUserAccountDataEventReturns(
type = UserAccountDataTypes.TYPE_LOCAL_NOTIFICATION_SETTINGS + aDeviceId,
content = expectedContent.toContent(),
)
// When
val result = getNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId)
// Then
result shouldBeEqualTo expectedContent
}
@Test
fun `given a device id and empty content when execute then retrieve the account data event corresponding to this id if any`() {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
val expectedContent = LocalNotificationSettingsContent(isSilenced = null)
aSession
.accountDataService()
.givenGetUserAccountDataEventReturns(

View file

@ -31,7 +31,7 @@ class SetNotificationSettingsAccountDataUseCaseTest {
fun `given a content when execute then update local notification settings with this content`() = runTest {
// Given
val sessionId = "a_session_id"
val localNotificationSettingsContent = LocalNotificationSettingsContent()
val localNotificationSettingsContent = LocalNotificationSettingsContent(isSilenced = true)
val fakeSession = FakeSession()
fakeSession.accountDataService().givenUpdateUserAccountDataEventSucceeds()

View file

@ -32,15 +32,17 @@ class UpdateNotificationSettingsAccountDataUseCaseTest {
private val fakeVectorPreferences = FakeVectorPreferences()
private val fakeGetNotificationSettingsAccountDataUseCase = mockk<GetNotificationSettingsAccountDataUseCase>()
private val fakeSetNotificationSettingsAccountDataUseCase = mockk<SetNotificationSettingsAccountDataUseCase>()
private val fakeDeleteNotificationSettingsAccountDataUseCase = mockk<DeleteNotificationSettingsAccountDataUseCase>()
private val updateNotificationSettingsAccountDataUseCase = UpdateNotificationSettingsAccountDataUseCase(
vectorPreferences = fakeVectorPreferences.instance,
getNotificationSettingsAccountDataUseCase = fakeGetNotificationSettingsAccountDataUseCase,
setNotificationSettingsAccountDataUseCase = fakeSetNotificationSettingsAccountDataUseCase,
deleteNotificationSettingsAccountDataUseCase = fakeDeleteNotificationSettingsAccountDataUseCase,
)
@Test
fun `given a device id and a different local setting compared to remote when execute then content is updated`() = runTest {
fun `given back sync enabled, a device id and a different local setting compared to remote when execute then content is updated`() = runTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
@ -48,6 +50,7 @@ class UpdateNotificationSettingsAccountDataUseCaseTest {
coJustRun { fakeSetNotificationSettingsAccountDataUseCase.execute(any(), any(), any()) }
val areNotificationsEnabled = true
fakeVectorPreferences.givenAreNotificationEnabled(areNotificationsEnabled)
fakeVectorPreferences.givenIsBackgroundSyncEnabled(true)
every { fakeGetNotificationSettingsAccountDataUseCase.execute(any(), any()) } returns
LocalNotificationSettingsContent(
isSilenced = null
@ -61,14 +64,16 @@ class UpdateNotificationSettingsAccountDataUseCaseTest {
// Then
verify {
fakeVectorPreferences.instance.isBackgroundSyncEnabled()
fakeVectorPreferences.instance.areNotificationEnabledForDevice()
fakeGetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId)
}
coVerify(inverse = true) { fakeDeleteNotificationSettingsAccountDataUseCase.execute(aSession) }
coVerify { fakeSetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId, expectedContent) }
}
@Test
fun `given a device id and a same local setting compared to remote when execute then content is not updated`() = runTest {
fun `given back sync enabled, a device id and a same local setting compared to remote when execute then content is not updated`() = runTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
@ -76,6 +81,7 @@ class UpdateNotificationSettingsAccountDataUseCaseTest {
coJustRun { fakeSetNotificationSettingsAccountDataUseCase.execute(any(), any(), any()) }
val areNotificationsEnabled = true
fakeVectorPreferences.givenAreNotificationEnabled(areNotificationsEnabled)
fakeVectorPreferences.givenIsBackgroundSyncEnabled(true)
every { fakeGetNotificationSettingsAccountDataUseCase.execute(any(), any()) } returns
LocalNotificationSettingsContent(
isSilenced = false
@ -89,9 +95,31 @@ class UpdateNotificationSettingsAccountDataUseCaseTest {
// Then
verify {
fakeVectorPreferences.instance.isBackgroundSyncEnabled()
fakeVectorPreferences.instance.areNotificationEnabledForDevice()
fakeGetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId)
}
coVerify(inverse = true) { fakeDeleteNotificationSettingsAccountDataUseCase.execute(aSession) }
coVerify(inverse = true) { fakeSetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId, expectedContent) }
}
@Test
fun `given back sync disabled and a device id when execute then content is deleted`() = runTest {
// Given
val aDeviceId = "device-id"
val aSession = FakeSession()
aSession.givenSessionId(aDeviceId)
coJustRun { fakeDeleteNotificationSettingsAccountDataUseCase.execute(any()) }
fakeVectorPreferences.givenIsBackgroundSyncEnabled(false)
// When
updateNotificationSettingsAccountDataUseCase.execute(aSession)
// Then
verify {
fakeVectorPreferences.instance.isBackgroundSyncEnabled()
}
coVerify { fakeDeleteNotificationSettingsAccountDataUseCase.execute(aSession) }
coVerify(inverse = true) { fakeSetNotificationSettingsAccountDataUseCase.execute(aSession, aDeviceId, any()) }
}
}

View file

@ -16,14 +16,14 @@
package im.vector.app.test.fakes
import im.vector.app.core.notification.EnableNotificationsSettingUpdater
import im.vector.app.core.notification.NotificationsSettingUpdater
import io.mockk.justRun
import io.mockk.mockk
import org.matrix.android.sdk.api.session.Session
class FakeEnableNotificationsSettingUpdater {
class FakeNotificationsSettingUpdater {
val instance = mockk<EnableNotificationsSettingUpdater>()
val instance = mockk<NotificationsSettingUpdater>()
fun givenOnSessionsStarted(session: Session) {
justRun { instance.onSessionsStarted(session) }