diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-08-04 17:04:50 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-08-08 13:04:00 +0200 |
| commit | b82153a408f035155c5a26fb68fcaa09e428ca2c (patch) | |
| tree | eb8e89e724ea6ca5403c1c38dce4eb846702e823 /android/app/src/androidTest | |
| parent | 6dee63b6cb3e7dbf9e0d6c77d20a3a6e0dba0de1 (diff) | |
| download | mullvadvpn-b82153a408f035155c5a26fb68fcaa09e428ca2c.tar.xz mullvadvpn-b82153a408f035155c5a26fb68fcaa09e428ca2c.zip | |
Replace select hop code with use cases
Also split the select hop code into select hop and modify multihop
Refactor relay list type
Diffstat (limited to 'android/app/src/androidTest')
2 files changed, 30 insertions, 18 deletions
diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt index fa41fa8ff5..46fa1b0e58 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt @@ -12,9 +12,9 @@ import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_ITEM_CUSTOM_LISTS import net.mullvad.mullvadvpn.compose.setContentWithTheme +import net.mullvad.mullvadvpn.compose.state.RelayListType import net.mullvad.mullvadvpn.compose.state.SearchLocationUiState import net.mullvad.mullvadvpn.lib.model.CustomListId -import net.mullvad.mullvadvpn.lib.model.Hop import net.mullvad.mullvadvpn.lib.model.RelayItem import net.mullvad.mullvadvpn.lib.model.RelayItemId import net.mullvad.mullvadvpn.lib.ui.component.relaylist.RelayListItem @@ -41,7 +41,7 @@ class SearchLocationScreenTest { private fun ComposeContext.initScreen( state: Lce<Unit, SearchLocationUiState, Unit>, - onSelectHop: (Hop) -> Unit = {}, + onSelectRelayItem: (RelayItem, RelayListType) -> Unit = { _, _ -> }, onToggleExpand: (RelayItemId, CustomListId?, Boolean) -> Unit = { _, _, _ -> }, onSearchInputChanged: (String) -> Unit = {}, onCreateCustomList: (location: RelayItem.Location?) -> Unit = {}, @@ -63,7 +63,7 @@ class SearchLocationScreenTest { setContentWithTheme { SearchLocationScreen( state = state, - onSelectHop = onSelectHop, + onSelectRelayItem = onSelectRelayItem, onToggleExpand = onToggleExpand, onSearchInputChanged = onSearchInputChanged, onCreateCustomList = onCreateCustomList, @@ -89,9 +89,10 @@ class SearchLocationScreenTest { Lce.Content( SearchLocationUiState( searchTerm = "", + relayListType = RelayListType.Single, filterChips = emptyList(), relayListItems = emptyList(), - emptyList(), + customLists = emptyList(), ) ), onSearchInputChanged = mockedSearchTermInput, @@ -115,6 +116,7 @@ class SearchLocationScreenTest { Lce.Content( SearchLocationUiState( searchTerm = mockSearchString, + relayListType = RelayListType.Single, filterChips = emptyList(), relayListItems = listOf(RelayListItem.LocationsEmptyText(mockSearchString)), @@ -138,6 +140,7 @@ class SearchLocationScreenTest { Lce.Content( SearchLocationUiState( searchTerm = mockSearchString, + relayListType = RelayListType.Single, filterChips = emptyList(), relayListItems = emptyList(), customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt index 35faa62190..5fdf9c047c 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt @@ -15,6 +15,7 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_COUNTRIES import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_ITEM_CUSTOM_LISTS import net.mullvad.mullvadvpn.compose.setContentWithTheme +import net.mullvad.mullvadvpn.compose.state.MultihopRelayListType import net.mullvad.mullvadvpn.compose.state.RelayListType import net.mullvad.mullvadvpn.compose.state.SelectLocationListUiState import net.mullvad.mullvadvpn.compose.state.SelectLocationUiState @@ -57,7 +58,8 @@ class SelectLocationScreenTest { private fun ComposeContext.initScreen( state: Lc<Unit, SelectLocationUiState> = Lc.Loading(Unit), - onSelectHop: (hop: Hop, relayListType: RelayListType) -> Unit = { _, _ -> }, + onSelectHop: (hop: Hop) -> Unit = {}, + onModifyMultihop: (RelayItem, MultihopRelayListType) -> Unit = { _, _ -> }, onSearchClick: (RelayListType) -> Unit = {}, onBackClick: () -> Unit = {}, onFilterClick: () -> Unit = {}, @@ -76,7 +78,7 @@ class SelectLocationScreenTest { onEditCustomListName: (RelayItem.CustomList) -> Unit = {}, onEditLocationsCustomList: (RelayItem.CustomList) -> Unit = {}, onDeleteCustomList: (RelayItem.CustomList) -> Unit = {}, - onSelectRelayList: (RelayListType) -> Unit = {}, + onSelectRelayList: (MultihopRelayListType) -> Unit = {}, openDaitaSettings: () -> Unit = {}, onRecentsToggleEnableClick: () -> Unit = {}, ) { @@ -85,6 +87,7 @@ class SelectLocationScreenTest { SelectLocationScreen( state = state, onSelectHop = onSelectHop, + onModifyMultihop = onModifyMultihop, onSearchClick = onSearchClick, onBackClick = onBackClick, onFilterClick = onFilterClick, @@ -112,6 +115,7 @@ class SelectLocationScreenTest { MutableStateFlow( Lce.Content( SelectLocationListUiState( + relayListType = RelayListType.Single, relayListItems = DUMMY_RELAY_COUNTRIES.map { RelayListItem.GeoLocationItem( @@ -129,7 +133,7 @@ class SelectLocationScreenTest { SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, @@ -156,6 +160,7 @@ class SelectLocationScreenTest { SelectLocationListUiState( relayListItems = listOf(RelayListItem.CustomListFooter(false)), customLists = emptyList(), + relayListType = RelayListType.Single, ) ) ) @@ -165,7 +170,7 @@ class SelectLocationScreenTest { SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, @@ -188,17 +193,18 @@ class SelectLocationScreenTest { SelectLocationListUiState( relayListItems = listOf(RelayListItem.CustomListItem(customList)), customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + relayListType = RelayListType.Single, ) ) ) - val mockedOnSelectHop: (Hop, RelayListType) -> Unit = mockk(relaxed = true) + val mockedOnSelectHop: (Hop) -> Unit = mockk(relaxed = true) initScreen( state = Lc.Content( SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, @@ -211,7 +217,7 @@ class SelectLocationScreenTest { onNodeWithText(customList.relay.name).performClick() // Assert - verify { mockedOnSelectHop(customList, RelayListType.EXIT) } + verify { mockedOnSelectHop(customList) } } @Test @@ -225,17 +231,18 @@ class SelectLocationScreenTest { SelectLocationListUiState( relayListItems = listOf(RelayListItem.RecentListItem(recent)), customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + relayListType = RelayListType.Single, ) ) ) - val mockedOnSelectHop: (Hop, RelayListType) -> Unit = mockk(relaxed = true) + val mockedOnSelectHop: (Hop) -> Unit = mockk(relaxed = true) initScreen( state = Lc.Content( SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, @@ -248,7 +255,7 @@ class SelectLocationScreenTest { onNodeWithText(recent.relay.name).performClick() // Assert - verify { mockedOnSelectHop(recent, RelayListType.EXIT) } + verify { mockedOnSelectHop(recent) } } @Test @@ -262,17 +269,18 @@ class SelectLocationScreenTest { SelectLocationListUiState( relayListItems = listOf(RelayListItem.CustomListItem(hop = customList)), customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + relayListType = RelayListType.Single, ) ) ) - val mockedOnSelectHop: (Hop, RelayListType) -> Unit = mockk(relaxed = true) + val mockedOnSelectHop: (Hop) -> Unit = mockk(relaxed = true) initScreen( state = Lc.Content( SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, @@ -305,17 +313,18 @@ class SelectLocationScreenTest { ) ), customLists = emptyList(), + relayListType = RelayListType.Single, ) ) ) - val mockedOnSelectHop: (Hop, RelayListType) -> Unit = mockk(relaxed = true) + val mockedOnSelectHop: (Hop) -> Unit = mockk(relaxed = true) initScreen( state = Lc.Content( SelectLocationUiState( filterChips = emptyList(), multihopEnabled = false, - relayListType = RelayListType.EXIT, + relayListType = RelayListType.Single, isSearchButtonEnabled = true, isFilterButtonEnabled = true, isRecentsEnabled = true, |
