Skip to content

Commit 0e63a48

Browse files
authored
Fix waitFor to work with real system time (#15)
1 parent cffb79a commit 0e63a48

File tree

1 file changed

+2
-3
lines changed
  • app/src/androidTest/java/com/pcapplusplus/toyvpn

1 file changed

+2
-3
lines changed

app/src/androidTest/java/com/pcapplusplus/toyvpn/TestUtils.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ suspend fun waitFor(
66
timeoutMillis: Long = 10000L,
77
condition: () -> Boolean,
88
) {
9-
var elapsedTime = 0L
10-
while (!condition() && elapsedTime < timeoutMillis) {
9+
val timeout = System.currentTimeMillis() + timeoutMillis
10+
while (!condition() && System.currentTimeMillis() < timeout) {
1111
delay(10)
12-
elapsedTime += 10
1312
}
1413
if (!condition()) {
1514
throw AssertionError("Condition not met within timeout")

0 commit comments

Comments
 (0)