diff options
Diffstat (limited to 'android/app')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt | 13 | ||||
| -rw-r--r-- | android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt | 24 |
2 files changed, 4 insertions, 33 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt index e6256e2be6..bf3414b0e1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt @@ -14,7 +14,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.emptyFlow -import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.shareIn @@ -132,14 +131,10 @@ class ConnectViewModel( .debounce(UI_STATE_DEBOUNCE_DURATION_MILLIS) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), ConnectUiState.INITIAL) - private fun LocationInfoCache.locationCallbackFlow() = - callbackFlow { - onNewLocation = { this.trySend(it) } - awaitClose { onNewLocation = null } - } - // Filter out empty or short-name country representations. - // We want to keep null location to handle those situations - .filter { it?.let { location -> location.country.length > 2 } ?: true } + private fun LocationInfoCache.locationCallbackFlow() = callbackFlow { + onNewLocation = { this.trySend(it) } + awaitClose { onNewLocation = null } + } private fun RelayListListener.relayListCallbackFlow() = callbackFlow { onRelayCountriesChange = { _, item -> this.trySend(item) } 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 517281e6c2..a2a39e54c4 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 @@ -224,30 +224,6 @@ 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) { |
