-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-10890 Add main looper messages log to the test report (#878)
- Loading branch information
1 parent
a162a65
commit 7b6e591
Showing
6 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...unner/src/main/kotlin/com/avito/android/runner/delegates/MainLooperMessagesLogDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.avito.android.runner.delegates | ||
|
||
import android.os.Bundle | ||
import com.avito.android.runner.InstrumentationTestRunnerDelegate | ||
import com.avito.android.test.report.troubleshooting.dump.MainLooperMessagesLogDumper | ||
|
||
class MainLooperMessagesLogDelegate( | ||
private val dumper: MainLooperMessagesLogDumper | ||
) : InstrumentationTestRunnerDelegate() { | ||
|
||
override fun beforeOnStart() { | ||
dumper.start() | ||
} | ||
|
||
override fun beforeFinish(resultCode: Int, results: Bundle?) { | ||
dumper.stop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
...st-report/src/main/kotlin/com/avito/android/test/report/troubleshooting/Troubleshooter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
.../kotlin/com/avito/android/test/report/troubleshooting/dump/MainLooperMessagesLogDumper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.avito.android.test.report.troubleshooting.dump | ||
|
||
import android.os.Looper | ||
import android.util.Printer | ||
|
||
class MainLooperMessagesLogDumper : Printer { | ||
|
||
private val logs = StringBuilder() | ||
|
||
init { | ||
Looper.getMainLooper().setMessageLogging(this) | ||
} | ||
|
||
override fun println(log: String) { | ||
logs.appendLine(log) | ||
} | ||
|
||
fun getMessagesLogDump(): String { | ||
return logs.toString() | ||
} | ||
|
||
fun start() { | ||
logs.clear() // if we run a few tests with one instrumentation instance | ||
Looper.getMainLooper().setMessageLogging(this) | ||
} | ||
|
||
fun stop() { | ||
Looper.getMainLooper().setMessageLogging(null) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters