Slide 9
Slide 9 text
ScreenRecordRule
9
class ScreenRecordRule : TestWatcher() {
private val shell = Shell()
private var screenRecordProcessIds: List = emptyList()
override fun starting(description: Description) {
shell.executeCommand(cmd = "screenrecord /sdcard/record_${description.methodName}.mp4", awaitOutput =
false)
screenRecordProcessIds = shell.findProcessIds(processName = "screenrecord")
}
override fun finished(description: Description) {
// গ͠Ԇ͔ͤͯ͞Βऴྃͤ͞ͳ͍ͱ࠷ޙ·ͰըͰ͖ͳ͍ͱ͖͕͋ͬͨͷͰํͳ͘
Thread.sleep(5000)
// ͯ͢ͷscreenrecordϓϩηεΛࢭΊΔ
// 1σόΠεͰ࣮ߦ͍ͯ͠ΕଞͷςετέʔεͷըΛࢭΊͯ͠·͏Մೳੑ͍ͣ
screenRecordProcessIds.forEach { pid ->
shell.executeCommand(cmd = "kill -SIGINT $pid", awaitOutput = false)
}
}
}