diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-05 16:15:29 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-06 10:53:29 +0200 |
| commit | bf4428f11454f6287535edad4876166286e04c31 (patch) | |
| tree | c7b7cc423f3297baaef8d48517cf498d219be6d9 /android/app/src/test | |
| parent | e05a9dcdc927e18184a3e19b3262ebacfca96670 (diff) | |
| download | mullvadvpn-bf4428f11454f6287535edad4876166286e04c31.tar.xz mullvadvpn-bf4428f11454f6287535edad4876166286e04c31.zip | |
Added two unit tests related to location updates
Diffstat (limited to 'android/app/src/test')
| -rw-r--r-- | android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt | 43 |
1 files changed, 43 insertions, 0 deletions
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 d8ec2b26f7..776136d1c5 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 @@ -221,6 +221,49 @@ class ConnectViewModelTest { } @Test + fun testLocationUpdateFilteredCountry() = + // Arrange + runTest(testCoroutineRule.testDispatcher) { + val locationTestItem = + GeoIpLocation( + ipv4 = mockk(relaxed = true), + ipv6 = mockk(relaxed = true), + country = "SW", + city = "gb", + hostname = "Ho" + ) + + // Act, Assert + viewModel.uiState.test { + assertEquals(ConnectUiState.INITIAL, awaitItem()) + serviceConnectionState.value = + ServiceConnectionState.ConnectedReady(mockServiceConnectionContainer) + locationSlot.captured.invoke(locationTestItem) + relaySlot.captured.invoke(mockk(), mockk()) + expectNoEvents() + } + } + + @Test + fun testLocationUpdateNullLocation() = + // Arrange + runTest(testCoroutineRule.testDispatcher) { + val locationTestItem = null + + // Act, Assert + viewModel.uiState.test { + assertEquals(ConnectUiState.INITIAL, awaitItem()) + serviceConnectionState.value = + ServiceConnectionState.ConnectedReady(mockServiceConnectionContainer) + locationSlot.captured.invoke(locationTestItem) + relaySlot.captured.invoke(mockk(), mockk()) + expectNoEvents() + val result = awaitItem() + assertEquals(locationTestItem, result.location) + } + } + + @Test fun testOnDisconnectClick() = runTest(testCoroutineRule.testDispatcher) { val mockConnectionProxy: ConnectionProxy = mockk(relaxed = true) |
