summaryrefslogtreecommitdiffhomepage
path: root/android/app/src/test
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-10-16 16:16:59 +0200
committerDavid Göransson <david.goransson@mullvad.net>2024-10-18 09:39:03 +0200
commitb71e78a641788a0660cc4da5a4ae40b2b18014b4 (patch)
treef5af089ca00b821b8523502d88f19183db017e16 /android/app/src/test
parentf5157257a7ea6db7df17b6126ae7464f48765915 (diff)
downloadmullvadvpn-b71e78a641788a0660cc4da5a4ae40b2b18014b4.tar.xz
mullvadvpn-b71e78a641788a0660cc4da5a4ae40b2b18014b4.zip
Remove old test
Diffstat (limited to 'android/app/src/test')
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt5
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt2
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/AppInfoViewModelTest.kt78
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModelTest.kt78
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt2
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt2
6 files changed, 5 insertions, 162 deletions
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
index e38d6bebbc..1524549e57 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
@@ -1,6 +1,5 @@
package net.mullvad.mullvadvpn.repository
-import android.content.SharedPreferences
import io.mockk.every
import io.mockk.mockk
import net.mullvad.mullvadvpn.lib.common.test.assertLists
@@ -9,11 +8,9 @@ import org.junit.jupiter.api.Test
class ChangelogRepositoryTest {
- private val mockedPreferences: SharedPreferences = mockk()
private val mockDataProvider: IChangelogDataProvider = mockk()
- private val changelogRepository =
- ChangelogRepository(preferences = mockedPreferences, dataProvider = mockDataProvider)
+ private val changelogRepository = ChangelogRepository(dataProvider = mockDataProvider)
@Test
fun `when given a changelog text should return a list of correctly formatted strings`() {
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt
index 1aead39d85..e9452884cf 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/usecase/VersionNotificationUseCaseTest.kt
@@ -29,7 +29,7 @@ class VersionNotificationUseCaseTest {
@BeforeEach
fun setup() {
MockKAnnotations.init(this)
- every { mockAppVersionInfoRepository.versionInfo() } returns versionInfo
+ every { mockAppVersionInfoRepository.versionInfo } returns versionInfo
versionNotificationUseCase =
VersionNotificationUseCase(
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/AppInfoViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/AppInfoViewModelTest.kt
deleted file mode 100644
index 1d370b75a8..0000000000
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/AppInfoViewModelTest.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-package net.mullvad.mullvadvpn.viewmodel
-
-import app.cash.turbine.test
-import io.mockk.MockKAnnotations
-import io.mockk.Runs
-import io.mockk.every
-import io.mockk.impl.annotations.MockK
-import io.mockk.just
-import io.mockk.unmockkAll
-import kotlin.test.assertEquals
-import kotlinx.coroutines.test.runTest
-import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule
-import net.mullvad.mullvadvpn.lib.model.BuildVersion
-import net.mullvad.mullvadvpn.repository.ChangelogRepository
-import org.junit.jupiter.api.AfterEach
-import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.extension.ExtendWith
-
-@ExtendWith(TestCoroutineRule::class)
-class AppInfoViewModelTest {
-
- @MockK private lateinit var mockedChangelogRepository: ChangelogRepository
-
- private lateinit var viewModel: AppInfoViewModel
-
- private val buildVersion = BuildVersion("1.0", 10)
-
- @BeforeEach
- fun setup() {
- MockKAnnotations.init(this)
- every { mockedChangelogRepository.setVersionCodeOfMostRecentChangelogShowed(any()) } just
- Runs
- }
-
- @AfterEach
- fun teardown() {
- unmockkAll()
- }
-
- @Test
- fun `given up to date version code uiSideEffect should not emit`() = runTest {
- // Arrange
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns
- buildVersion.code
- viewModel = AppInfoViewModel(mockedChangelogRepository, buildVersion, false)
-
- // If we have the most up to date version code, we should not show the changelog dialog
- viewModel.uiSideEffect.test { expectNoEvents() }
- }
-
- @Test
- fun `given old version code uiSideEffect should emit ChangeLog`() = runTest {
- // Arrange
- val version = -1
- val changes = listOf("first change", "second change")
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns
- version
- every { mockedChangelogRepository.getLastVersionChanges() } returns changes
-
- viewModel = AppInfoViewModel(mockedChangelogRepository, buildVersion, false)
- // Given a new version with a change log we should return it
- viewModel.uiSideEffect.test {
- assertEquals(awaitItem(), Changelog(version = buildVersion.name, changes = changes))
- }
- }
-
- @Test
- fun `given old version code and empty change log uiSideEffect should not emit`() = runTest {
- // Arrange
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns -1
- every { mockedChangelogRepository.getLastVersionChanges() } returns emptyList()
-
- viewModel = AppInfoViewModel(mockedChangelogRepository, buildVersion, false)
- // Given a new version with a change log we should not return it
- viewModel.uiSideEffect.test { expectNoEvents() }
- }
-}
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModelTest.kt
deleted file mode 100644
index 7888f02a4d..0000000000
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModelTest.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-package net.mullvad.mullvadvpn.viewmodel
-
-import app.cash.turbine.test
-import io.mockk.MockKAnnotations
-import io.mockk.Runs
-import io.mockk.every
-import io.mockk.impl.annotations.MockK
-import io.mockk.just
-import io.mockk.unmockkAll
-import kotlin.test.assertEquals
-import kotlinx.coroutines.test.runTest
-import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule
-import net.mullvad.mullvadvpn.lib.model.BuildVersion
-import net.mullvad.mullvadvpn.repository.ChangelogRepository
-import org.junit.jupiter.api.AfterEach
-import org.junit.jupiter.api.BeforeEach
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.extension.ExtendWith
-
-@ExtendWith(TestCoroutineRule::class)
-class ChangelogViewModelTest {
-
- @MockK private lateinit var mockedChangelogRepository: ChangelogRepository
-
- private lateinit var viewModel: ChangelogViewModel
-
- private val buildVersion = BuildVersion("1.0", 10)
-
- @BeforeEach
- fun setup() {
- MockKAnnotations.init(this)
- every { mockedChangelogRepository.setVersionCodeOfMostRecentChangelogShowed(any()) } just
- Runs
- }
-
- @AfterEach
- fun teardown() {
- unmockkAll()
- }
-
- @Test
- fun `given up to date version code uiSideEffect should not emit`() = runTest {
- // Arrange
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns
- buildVersion.code
- viewModel = ChangelogViewModel(mockedChangelogRepository, buildVersion, false)
-
- // If we have the most up to date version code, we should not show the changelog dialog
- viewModel.uiSideEffect.test { expectNoEvents() }
- }
-
- @Test
- fun `given old version code uiSideEffect should emit ChangeLog`() = runTest {
- // Arrange
- val version = -1
- val changes = listOf("first change", "second change")
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns
- version
- every { mockedChangelogRepository.getLastVersionChanges() } returns changes
-
- viewModel = ChangelogViewModel(mockedChangelogRepository, buildVersion, false)
- // Given a new version with a change log we should return it
- viewModel.uiSideEffect.test {
- assertEquals(awaitItem(), Changelog(version = buildVersion.name, changes = changes))
- }
- }
-
- @Test
- fun `given old version code and empty change log uiSideEffect should not emit`() = runTest {
- // Arrange
- every { mockedChangelogRepository.getVersionCodeOfMostRecentChangelogShowed() } returns -1
- every { mockedChangelogRepository.getLastVersionChanges() } returns emptyList()
-
- viewModel = ChangelogViewModel(mockedChangelogRepository, buildVersion, false)
- // Given a new version with a change log we should not return it
- viewModel.uiSideEffect.test { expectNoEvents() }
- }
-}
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
index 9696a30539..33e836acd8 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
@@ -124,7 +124,9 @@ class ConnectViewModelTest {
connectionProxy = mockConnectionProxy,
lastKnownLocationUseCase = mockLastKnownLocationUseCase,
vpnPermissionRepository = mockVpnPermissionRepository,
+ resources = mockk(),
isPlayBuild = false,
+ packageName = "net.mullvad.mullvadvpn",
)
}
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt
index 97259b8b43..8857eb364a 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SettingsViewModelTest.kt
@@ -35,7 +35,7 @@ class SettingsViewModelTest {
val deviceState = MutableStateFlow<DeviceState>(DeviceState.LoggedOut)
every { mockDeviceRepository.deviceState } returns deviceState
- every { mockAppVersionInfoRepository.versionInfo() } returns versionInfo
+ every { mockAppVersionInfoRepository.versionInfo } returns versionInfo
viewModel =
SettingsViewModel(