Issue#104 Create Test verifying screenshot pulling works
This commit is contained in:
parent
69f5f15c3a
commit
bae8c0fc96
8 changed files with 212 additions and 80 deletions
|
|
@ -54,6 +54,7 @@ class ScreenshotRule(
|
|||
capture.format = Bitmap.CompressFormat.JPEG
|
||||
try {
|
||||
capture.process(setOf(processor))
|
||||
Log.d(TAG, "Saved image: $filename")
|
||||
} catch (e: IOException) {
|
||||
Log.d(TAG, "Couldn't save image: $e")
|
||||
e.printStackTrace()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.io.File
|
|||
|
||||
fun basicScreenCaptureProcessor(subDir: String = "test-screenshots"): ScreenCaptureProcessor {
|
||||
val directory = File(getTestPicturesDir(), subDir)
|
||||
Log.d(ScreenshotRule.TAG, "directory to save screenshots = $directory")
|
||||
Log.d(ScreenshotRule.TAG, "directory to save screenshots = ${directory.absolutePath}")
|
||||
return basicScreenCaptureProcessor(File(getTestPicturesDir(), subDir))
|
||||
}
|
||||
|
||||
|
|
@ -22,15 +22,19 @@ fun basicScreenCaptureProcessor(subDir: String = "test-screenshots"): ScreenCapt
|
|||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
fun getTestPicturesDir(): File? =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S || Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
|
||||
Log.d(ScreenshotRule.TAG, "internal folder")
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
Log.d(ScreenshotRule.TAG, "context.internal folder")
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().targetContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
||||
} else {
|
||||
InstrumentationRegistry.getInstrumentation().targetContext.filesDir
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
val packageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName
|
||||
val environmentFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
val externalFolder = File(environmentFolder, packageName)
|
||||
Log.d(ScreenshotRule.TAG, "external folder")
|
||||
Log.d(ScreenshotRule.TAG, "environment.external folder")
|
||||
|
||||
externalFolder
|
||||
} else {
|
||||
Log.d(ScreenshotRule.TAG, "context.external folder")
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().targetContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue