|
|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
package tv.anypoint.dsl |
|
|
|
|
|
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
import kotlinx.coroutines.runBlocking |
|
|
|
|
import tv.anypoint.proxy.model.adb.ExtraKey |
|
|
|
|
import tv.anypoint.proxy.model.adb.IntentAction |
|
|
|
|
import tv.anypoint.dsl.handler.HttpHandler |
|
|
|
|
import tv.anypoint.dsl.model.Log |
|
|
|
|
import tv.anypoint.dsl.model.Logcat |
|
|
|
|
import tv.anypoint.dsl.model.Tc |
|
|
|
|
import tv.anypoint.dsl.service.TestCase |
|
|
|
|
import java.io.BufferedReader |
|
|
|
|
import java.io.FileReader |
|
|
|
|
import java.io.LineNumberReader |
|
|
|
|
@ -32,27 +29,27 @@ fun adb(
|
|
|
|
|
println("[ADB] adb shell am broadcast $aStr $esStr") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun Log.expected( |
|
|
|
|
fun Logcat.expected( |
|
|
|
|
expectedLog: String, |
|
|
|
|
timeout: Long = 10_000L |
|
|
|
|
) { |
|
|
|
|
val log = this |
|
|
|
|
val logcat = this |
|
|
|
|
val startedAt = LocalDateTime.now() |
|
|
|
|
val reader = LineNumberReader(BufferedReader(FileReader(log.logcatFilePath))) |
|
|
|
|
val reader = LineNumberReader(BufferedReader(FileReader(logcat.logcatFilePath))) |
|
|
|
|
while (true) { |
|
|
|
|
val now = LocalDateTime.now() |
|
|
|
|
if (ChronoUnit.MILLIS.between(startedAt, now) > timeout) { |
|
|
|
|
throw TimeoutException("failed to find log. expectedLog: $expectedLog") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reader.lineNumber = log.cursor |
|
|
|
|
reader.lineNumber = logcat.cursor |
|
|
|
|
|
|
|
|
|
var line: String? |
|
|
|
|
while ((reader.readLine().also { line = it }) != null) { |
|
|
|
|
if (line!!.contains(expectedLog)) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
log.cursor = reader.lineNumber |
|
|
|
|
logcat.cursor = reader.lineNumber |
|
|
|
|
} |
|
|
|
|
Thread.sleep(100) |
|
|
|
|
} |
|
|
|
|
|