|
|
|
|
@ -4,6 +4,13 @@ import tv.anypoint.dsl.handler.HttpHandler
|
|
|
|
|
import tv.anypoint.dsl.model.adb.ExtraKey |
|
|
|
|
import tv.anypoint.dsl.model.adb.IntentAction |
|
|
|
|
import tv.anypoint.dsl.model.Tc |
|
|
|
|
import tv.anypoint.dsl.service.TestCase |
|
|
|
|
import java.time.Duration |
|
|
|
|
import java.time.LocalDateTime |
|
|
|
|
import java.time.Period |
|
|
|
|
import java.time.temporal.ChronoUnit |
|
|
|
|
import java.util.concurrent.TimeUnit |
|
|
|
|
import java.util.concurrent.TimeoutException |
|
|
|
|
|
|
|
|
|
inline fun tc( |
|
|
|
|
block: Tc.() -> Unit |
|
|
|
|
@ -15,17 +22,29 @@ inline fun <reified T>http(
|
|
|
|
|
|
|
|
|
|
data class Adb( |
|
|
|
|
val a: IntentAction, |
|
|
|
|
val es: Pair<ExtraKey, String> |
|
|
|
|
val es: Map<ExtraKey, String> |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
inline fun adb( |
|
|
|
|
a: IntentAction, |
|
|
|
|
es: Pair<ExtraKey, String> |
|
|
|
|
es: Map<ExtraKey, String> |
|
|
|
|
) { |
|
|
|
|
val adb = Adb(a, es) |
|
|
|
|
println("[ADB] adb shell am broadcast -a $a --es ${es.first} ${es.second}") |
|
|
|
|
val aStr = "-a $a" |
|
|
|
|
val esStr: String = es.entries.joinToString(" ") { "--es ${it.key.string} ${it.value}" } |
|
|
|
|
println("[ADB] adb shell am broadcast $aStr $esStr") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun expected(expectedLog: String) { |
|
|
|
|
// TODO: logcat 스트림에서 expectedLog 찾기, 제한시간 내에 못찾으면 TimeoutException 뱉기 |
|
|
|
|
fun TestCase.expected( |
|
|
|
|
expectedLog: String, |
|
|
|
|
timeout: Long = 10_000L |
|
|
|
|
) { |
|
|
|
|
val startedAt = LocalDateTime.now() |
|
|
|
|
while (true) { |
|
|
|
|
val now = LocalDateTime.now() |
|
|
|
|
if (ChronoUnit.MILLIS.between(startedAt, now) > timeout) { |
|
|
|
|
throw TimeoutException("failed to find log. expectedLog: $expectedLog, absoluteFilePath: ${this.tc.logInfo.absoluteFilePath}") |
|
|
|
|
} |
|
|
|
|
// TODO: tc 로그에서 expectedLog 찾기 tc.logInfo.cursor ~ 마지막 라인까지의 로그 중에 찾으면 됨 |
|
|
|
|
} |
|
|
|
|
} |