1
1
package com.xxmassdeveloper.mpchartexample
2
2
3
- import androidx.test.core.app.takeScreenshot
4
3
import androidx.test.core.graphics.writeToTestStorage
5
4
import androidx.test.espresso.Espresso
6
5
import androidx.test.espresso.Espresso.onData
@@ -16,7 +15,6 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
16
15
import androidx.test.espresso.screenshot.captureToBitmap
17
16
import androidx.test.ext.junit.rules.activityScenarioRule
18
17
import androidx.test.ext.junit.runners.AndroidJUnit4
19
- import androidx.test.platform.app.InstrumentationRegistry
20
18
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
21
19
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase.Companion.optionMenus
22
20
import com.xxmassdeveloper.mpchartexample.notimportant.MainActivity
@@ -70,7 +68,8 @@ class StartTest {
70
68
.atPosition(index).perform(click())
71
69
72
70
Intents .intended(hasComponent(it.name))
73
- takeScreenshot()
71
+ onView(ViewMatchers .isRoot())
72
+ .captureToBitmap()
74
73
.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -${contentItem.name} -1SampleClick" )
75
74
76
75
optionMenu = " "
@@ -85,7 +84,8 @@ class StartTest {
85
84
Espresso .pressBack()
86
85
} catch (e: Exception ) {
87
86
Timber .e(optionMenu + e.message!! )
88
- takeScreenshot()
87
+ onView(ViewMatchers .isRoot())
88
+ .captureToBitmap()
89
89
.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -Error" )
90
90
}
91
91
}
@@ -95,7 +95,8 @@ class StartTest {
95
95
private fun screenshotOfOptionMenu (simpleName : String , menuTitle : String ) {
96
96
onView(withText(menuTitle)).perform(click())
97
97
Timber .d(" screenshotOfOptionMenu ${menuTitle} -${simpleName} " )
98
- takeScreenshot()
98
+ onView(ViewMatchers .isRoot())
99
+ .captureToBitmap()
99
100
.writeToTestStorage(" ${simpleName} -2menu-click-$menuTitle " )
100
101
}
101
102
0 commit comments