11package info.hannes.logcat
22
3+ import android.graphics.Bitmap
34import androidx.test.core.graphics.writeToTestStorage
45import androidx.test.espresso.Espresso.onView
6+ import androidx.test.espresso.action.ViewActions.captureToBitmap
57import androidx.test.espresso.action.ViewActions.click
68import androidx.test.espresso.assertion.ViewAssertions.matches
79import androidx.test.espresso.matcher.ViewMatchers.*
8- import androidx.test.espresso.screenshot.captureToBitmap
910import androidx.test.ext.junit.rules.activityScenarioRule
1011import androidx.test.ext.junit.runners.AndroidJUnit4
1112import info.hannes.logcat.app.MainActivity
12- import org.hamcrest.Matchers .allOf
13+ import org.hamcrest.CoreMatchers .allOf
1314import org.junit.Before
1415import org.junit.Rule
1516import org.junit.Test
@@ -31,8 +32,7 @@ class MainActivityTest {
3132 val navMain = onView(allOf(withContentDescription(" Navigate up" ), isDisplayed()))
3233 navMain.perform(click())
3334 onView(isRoot())
34- .captureToBitmap()
35- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
35+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " ) })
3636 }
3737
3838 @Test
@@ -42,8 +42,7 @@ class MainActivityTest {
4242 menu.perform(click())
4343 Thread .sleep(1000 )
4444 onView(isRoot())
45- .captureToBitmap()
46- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
45+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " ) })
4746 }
4847
4948 @Test
@@ -52,8 +51,7 @@ class MainActivityTest {
5251 menu.check(matches(isDisplayed()))
5352 menu.perform(click())
5453 onView(isRoot())
55- .captureToBitmap()
56- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
54+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " ) })
5755 }
5856
5957 @Test
@@ -63,8 +61,7 @@ class MainActivityTest {
6361 menu.perform(click())
6462 Thread .sleep(1000 )
6563 onView(isRoot())
66- .captureToBitmap()
67- .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
64+ .perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " ) })
6865 }
6966
7067}
0 commit comments