-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'implement-wireguard-over-shadowsocks-droid-1276'
- Loading branch information
Showing
66 changed files
with
1,304 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ShadowsocksSettingsScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package net.mullvad.mullvadvpn.compose.screen | ||
|
||
import androidx.compose.ui.test.ExperimentalTestApi | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension | ||
import net.mullvad.mullvadvpn.compose.setContentWithTheme | ||
import net.mullvad.mullvadvpn.compose.state.ShadowsocksSettingsState | ||
import net.mullvad.mullvadvpn.compose.test.SHADOWSOCKS_CUSTOM_PORT_TEXT_TEST_TAG | ||
import net.mullvad.mullvadvpn.lib.model.Constraint | ||
import net.mullvad.mullvadvpn.lib.model.Port | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.RegisterExtension | ||
|
||
@OptIn(ExperimentalTestApi::class) | ||
class ShadowsocksSettingsScreenTest { | ||
@JvmField @RegisterExtension val composeExtension = createEdgeToEdgeComposeExtension() | ||
|
||
@Test | ||
fun testShowShadowsocksCustomPort() = | ||
composeExtension.use { | ||
// Arrange | ||
setContentWithTheme { | ||
ShadowsocksSettingsScreen(state = ShadowsocksSettingsState(customPort = Port(4000))) | ||
} | ||
|
||
// Assert | ||
onNodeWithText("4000").assertExists() | ||
} | ||
|
||
@Test | ||
fun testSelectShadowsocksCustomPort() = | ||
composeExtension.use { | ||
// Arrange | ||
val onObfuscationPortSelected: (Constraint<Port>) -> Unit = mockk(relaxed = true) | ||
setContentWithTheme { | ||
ShadowsocksSettingsScreen( | ||
state = | ||
ShadowsocksSettingsState( | ||
port = Constraint.Only(Port(4000)), | ||
customPort = Port(4000), | ||
), | ||
onObfuscationPortSelected = onObfuscationPortSelected, | ||
) | ||
} | ||
|
||
// Act | ||
onNodeWithTag(testTag = SHADOWSOCKS_CUSTOM_PORT_TEXT_TEST_TAG).performClick() | ||
|
||
// Assert | ||
verify { onObfuscationPortSelected.invoke(Constraint.Only(Port(4000))) } | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/Udp2TcpSettingsScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.mullvad.mullvadvpn.compose.screen | ||
|
||
import androidx.compose.ui.test.ExperimentalTestApi | ||
import androidx.compose.ui.test.performClick | ||
import io.mockk.coVerify | ||
import io.mockk.mockk | ||
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension | ||
import net.mullvad.mullvadvpn.compose.setContentWithTheme | ||
import net.mullvad.mullvadvpn.compose.state.Udp2TcpSettingsState | ||
import net.mullvad.mullvadvpn.compose.test.UDP_OVER_TCP_PORT_ITEM_X_TEST_TAG | ||
import net.mullvad.mullvadvpn.lib.model.Constraint | ||
import net.mullvad.mullvadvpn.lib.model.Port | ||
import net.mullvad.mullvadvpn.onNodeWithTagAndText | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.RegisterExtension | ||
|
||
@OptIn(ExperimentalTestApi::class) | ||
class Udp2TcpSettingsScreenTest { | ||
@JvmField @RegisterExtension val composeExtension = createEdgeToEdgeComposeExtension() | ||
|
||
@Test | ||
fun testSelectTcpOverUdpPortOption() = | ||
composeExtension.use { | ||
// Arrange | ||
val onObfuscationPortSelected: (Constraint<Port>) -> Unit = mockk(relaxed = true) | ||
setContentWithTheme { | ||
Udp2TcpSettingsScreen( | ||
state = Udp2TcpSettingsState(port = Constraint.Any), | ||
onObfuscationPortSelected = onObfuscationPortSelected, | ||
) | ||
} | ||
|
||
// Act | ||
onNodeWithTagAndText( | ||
testTag = String.format(UDP_OVER_TCP_PORT_ITEM_X_TEST_TAG, 5001), | ||
text = "5001", | ||
) | ||
.assertExists() | ||
.performClick() | ||
|
||
// Assert | ||
coVerify(exactly = 1) { onObfuscationPortSelected.invoke(Constraint.Only(Port(5001))) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.