@@ -17,18 +17,18 @@ import androidx.test.uiautomator.UiSelector
1717import dev.turingcomplete.kotlinonetimepassword.HmacAlgorithm
1818import dev.turingcomplete.kotlinonetimepassword.TimeBasedOneTimePasswordConfig
1919import dev.turingcomplete.kotlinonetimepassword.TimeBasedOneTimePasswordGenerator
20+ import java.net.HttpURLConnection
21+ import java.net.URL
22+ import java.util.concurrent.TimeUnit
23+ import kotlin.time.Duration.Companion.minutes
24+ import kotlin.time.Duration.Companion.seconds
2025import org.apache.commons.codec.binary.Base32
2126import org.junit.After
2227import org.junit.Assert
2328import org.junit.Before
2429import org.junit.Rule
2530import org.junit.Test
2631import org.junit.runner.RunWith
27- import java.net.HttpURLConnection
28- import java.net.URL
29- import java.util.concurrent.TimeUnit
30- import kotlin.time.Duration.Companion.minutes
31- import kotlin.time.Duration.Companion.seconds
3232
3333@RunWith(AndroidJUnit4 ::class )
3434@LargeTest
@@ -59,18 +59,18 @@ class MainActivityTest {
5959 timeStep = 30 ,
6060 timeStepUnit = TimeUnit .SECONDS )
6161 val githubTOTP = TimeBasedOneTimePasswordGenerator (github2FASecret, config)
62-
6362 val device = UiDevice .getInstance(InstrumentationRegistry .getInstrumentation())
64- Log .d(TAG , " Wait for VPN permission prompt and accept" )
65- device.find(By .text(" Connection request" ))
66- device.find(By .text(" OK" )).click()
6763
6864 Log .d(TAG , " Click through Get Started screen" )
6965 device.find(By .text(" Get Started" ))
7066 device.find(By .text(" Get Started" )).click()
7167
68+ Log .d(TAG , " Wait for VPN permission prompt and accept" )
69+ device.find(By .text(" Connection request" ))
70+ device.find(By .text(" OK" )).click()
71+
7272 asNecessary(
73- timeout = 2 .minutes,
73+ 2 .minutes,
7474 {
7575 Log .d(TAG , " Log in" )
7676 device.find(By .text(" Log in" )).click()
@@ -93,7 +93,6 @@ class MainActivityTest {
9393 },
9494 {
9595 Log .d(TAG , " Make sure GitHub page has loaded" )
96- device.find(By .text(" New to GitHub" ))
9796 device.find(By .text(" Username or email address" ))
9897 device.find(By .text(" Sign in" ))
9998 },
@@ -115,19 +114,23 @@ class MainActivityTest {
115114 .setText(githubTOTP.generate())
116115 device.find(UiSelector ().instance(0 ).className(Button ::class .java)).click()
117116 },
117+ {
118+ Log .d(TAG , " Authorizing Tailscale" )
119+ device.find(By .text(" Authorize tailscale" )).click()
120+ },
118121 {
119122 Log .d(TAG , " Accept Tailscale app" )
120123 device.find(By .text(" Learn more about OAuth" ))
121124 // Sleep a little to give button time to activate
125+
122126 Thread .sleep(5 .seconds.inWholeMilliseconds)
123127 device.find(UiSelector ().instance(1 ).className(Button ::class .java)).click()
124128 },
125129 {
126130 Log .d(TAG , " Connect device" )
127131 device.find(By .text(" Connect device" ))
128132 device.find(UiSelector ().instance(0 ).className(Button ::class .java)).click()
129- },
130- )
133+ })
131134
132135 try {
133136 Log .d(TAG , " Accept Permission (Either Storage or Notifications)" )
0 commit comments