diff options
| author | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-10-23 16:15:02 +0200 |
|---|---|---|
| committer | Kalle Lindström <karl.lindstrom@mullvad.net> | 2025-10-28 15:55:52 +0100 |
| commit | 376372c84c6b881e0097e5dab5348adab3e5f100 (patch) | |
| tree | 94b43c656977a037bea9f2da45345e66ff737bf6 /android/lib/shared/src/test | |
| parent | 721496daaab896dd29980fd4b7a234fc7dfd5607 (diff) | |
| download | mullvadvpn-376372c84c6b881e0097e5dab5348adab3e5f100.tar.xz mullvadvpn-376372c84c6b881e0097e5dab5348adab3e5f100.zip | |
Add option to show relay location in notification
This PR adds the following:
- An option to show the relay location in the connection notification.
- A new submenu under Settings called Notifications.
- In the new Notifications screen a toggle to enable/disable showing the
location in the notification.
Diffstat (limited to 'android/lib/shared/src/test')
2 files changed, 0 insertions, 141 deletions
diff --git a/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepositoryTest.kt b/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepositoryTest.kt deleted file mode 100644 index ff2ecb88b2..0000000000 --- a/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepositoryTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -package net.mullvad.mullvadvpn.lib.shared - -import arrow.core.right -import io.mockk.coEvery -import io.mockk.coVerify -import io.mockk.every -import io.mockk.mockk -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.MainScope -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.test.runTest -import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule -import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService -import net.mullvad.mullvadvpn.lib.model.AccountData -import net.mullvad.mullvadvpn.lib.model.AccountNumber -import net.mullvad.mullvadvpn.lib.model.DeviceState -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@OptIn(ExperimentalCoroutinesApi::class) -@ExtendWith(TestCoroutineRule::class) -class AccountRepositoryTest { - - private val mockManagementService: ManagementService = mockk() - private val mockDeviceRepository: DeviceRepository = mockk() - - private val mockDeviceStateFlow = MutableStateFlow<DeviceState>(DeviceState.LoggedOut) - - private lateinit var accountRepository: AccountRepository - - @BeforeEach - fun setup() { - every { mockDeviceRepository.deviceState } returns mockDeviceStateFlow - every { mockManagementService.deviceState } returns mockDeviceStateFlow - - accountRepository = - AccountRepository( - managementService = mockManagementService, - deviceRepository = mockDeviceRepository, - scope = MainScope(), - ) - } - - @Test - fun `given force is true should always call managementService getAccountData`() = runTest { - // Arrange - val accountData: AccountData = mockk() - val accountNumber = AccountNumber("1234567890") - every { accountData.accountNumber } returns accountNumber - coEvery { mockManagementService.getAccountData(accountNumber) } returns accountData.right() - - // Act - mockDeviceStateFlow.emit(DeviceState.LoggedIn(accountNumber, mockk(relaxed = true))) - accountRepository.refreshAccountData(ignoreTimeout = true) - - // Assert - coVerify { mockManagementService.getAccountData(accountNumber) } - } - - @Test - fun `given last latestAccountDataFetch null should always call managementService getAccountData`() = - runTest { - // Arrange - val accountData: AccountData = mockk() - val accountNumber = AccountNumber("1234567890") - every { accountData.accountNumber } returns accountNumber - coEvery { mockManagementService.getAccountData(accountNumber) } returns - accountData.right() - - // Act - mockDeviceStateFlow.emit(DeviceState.LoggedIn(accountNumber, mockk(relaxed = true))) - accountRepository.refreshAccountData(ignoreTimeout = false) - - // Assert - coVerify { mockManagementService.getAccountData(accountNumber) } - } -} diff --git a/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/ConnectionProxyTest.kt b/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/ConnectionProxyTest.kt deleted file mode 100644 index b9d276c34b..0000000000 --- a/android/lib/shared/src/test/kotlin/net/mullvad/mullvadvpn/lib/shared/ConnectionProxyTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -package net.mullvad.mullvadvpn.lib.shared - -import android.content.Intent -import arrow.core.left -import arrow.core.right -import io.mockk.coVerify -import io.mockk.every -import io.mockk.mockk -import io.mockk.unmockkAll -import kotlinx.coroutines.test.runTest -import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService -import net.mullvad.mullvadvpn.lib.model.PrepareError -import net.mullvad.mullvadvpn.lib.model.Prepared -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.Test - -class ConnectionProxyTest { - - private val mockManagementService: ManagementService = mockk(relaxed = true) - private val mockVpnPermissionRepository: PrepareVpnUseCase = mockk() - private val mockTranslationRepository: RelayLocationTranslationRepository = - mockk(relaxed = true) - - private val connectionProxy: ConnectionProxy = - ConnectionProxy( - managementService = mockManagementService, - prepareVpnUseCase = mockVpnPermissionRepository, - translationRepository = mockTranslationRepository, - ) - - @Test - fun `connect with vpn permission allowed should call managementService connect`() = runTest { - every { mockVpnPermissionRepository.invoke() } returns Prepared.right() - connectionProxy.connect() - coVerify(exactly = 1) { mockManagementService.connect() } - } - - @Test - fun `connect with vpn permission not allowed should not call managementService connect`() = - runTest { - every { mockVpnPermissionRepository.invoke() } returns - PrepareError.NotPrepared(Intent()).left() - connectionProxy.connect() - coVerify(exactly = 0) { mockManagementService.connect() } - } - - @Test - fun `disconnect should call managementService disconnect`() = runTest { - connectionProxy.disconnect() - coVerify(exactly = 1) { mockManagementService.disconnect() } - } - - @Test - fun `reconnect should call managementService reconnect`() = runTest { - connectionProxy.reconnect() - coVerify(exactly = 1) { mockManagementService.reconnect() } - } - - @AfterEach - fun tearDown() { - unmockkAll() - } -} |
