11package com.xxmassdeveloper.mpchartexample
22
3+ import android.graphics.Bitmap
34import androidx.test.core.graphics.writeToTestStorage
45import androidx.test.espresso.Espresso
56import androidx.test.espresso.Espresso.onData
67import androidx.test.espresso.Espresso.onView
78import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
9+ import androidx.test.espresso.action.ViewActions.captureToBitmap
810import androidx.test.espresso.action.ViewActions.click
911import androidx.test.espresso.intent.Intents
1012import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
1113import androidx.test.espresso.matcher.ViewMatchers
1214import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
1315import androidx.test.espresso.matcher.ViewMatchers.withId
1416import androidx.test.espresso.matcher.ViewMatchers.withText
15- import androidx.test.espresso.screenshot.captureToBitmap
1617import androidx.test.ext.junit.rules.activityScenarioRule
1718import androidx.test.ext.junit.runners.AndroidJUnit4
1819import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
@@ -53,8 +54,7 @@ class StartTest {
5354 @Test
5455 fun smokeTestStart () {
5556 onView(ViewMatchers .isRoot())
56- .captureToBitmap()
57- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
57+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " ) })
5858
5959 var optionMenu = " "
6060 // iterate samples
@@ -69,8 +69,7 @@ class StartTest {
6969
7070 Intents .intended(hasComponent(it.name))
7171 onView(ViewMatchers .isRoot())
72- .captureToBitmap()
73- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -${contentItem.name} -1SampleClick" )
72+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -${contentItem.name} -1SampleClick" ) })
7473
7574 optionMenu = " "
7675 optionMenus.filter { plain -> Character .isDigit(plain.first()) }.forEach { filteredTitle ->
@@ -85,8 +84,7 @@ class StartTest {
8584 } catch (e: Exception ) {
8685 Timber .e(optionMenu + e.message!! )
8786 onView(ViewMatchers .isRoot())
88- .captureToBitmap()
89- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -Error" )
87+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} -Error" ) })
9088 }
9189 }
9290 }
@@ -96,8 +94,7 @@ class StartTest {
9694 onView(withText(menuTitle)).perform(click())
9795 Timber .d(" screenshotOfOptionMenu ${menuTitle} -${simpleName} " )
9896 onView(ViewMatchers .isRoot())
99- .captureToBitmap()
100- .writeToTestStorage(" ${simpleName} -2menu-click-$menuTitle " )
97+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${simpleName} -2menu-click-$menuTitle " ) })
10198 }
10299
103100}
0 commit comments