diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-08 15:19:12 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-08 15:19:12 +0200 |
| commit | d5c67e4aaa0959a92f6b04ff49476f21baeb57e9 (patch) | |
| tree | 10eccef3e012b8777afd6e64b210327f22a96335 /android/app/src | |
| parent | 49f624c93975a50c309f5d47979b2ce361ac7f64 (diff) | |
| parent | 639c4a8cdf2042b6c013482a54ffacaa5bdb5f68 (diff) | |
| download | mullvadvpn-d5c67e4aaa0959a92f6b04ff49476f21baeb57e9.tar.xz mullvadvpn-d5c67e4aaa0959a92f6b04ff49476f21baeb57e9.zip | |
Merge branch 'filter-in-location-always-block-uk-droid-323'
Diffstat (limited to 'android/app/src')
| -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) { |
