Issue#100 Update to API based logic
This commit is contained in:
parent
cc2b745d2e
commit
69f5f15c3a
3 changed files with 13 additions and 18 deletions
|
|
@ -23,7 +23,6 @@ afterEvaluate {
|
||||||
from components.release
|
from components.release
|
||||||
|
|
||||||
groupId "$testUtilGroupId"
|
groupId "$testUtilGroupId"
|
||||||
println("$testUtilArtifactId")
|
|
||||||
version "$testUtilVersion"
|
version "$testUtilVersion"
|
||||||
artifactId "$testUtilArtifactId"
|
artifactId "$testUtilArtifactId"
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ def findAdbFromLocal = {
|
||||||
def sdkDir = properties.getProperty('sdk.dir')
|
def sdkDir = properties.getProperty('sdk.dir')
|
||||||
return "$sdkDir/platform-tools/adb"
|
return "$sdkDir/platform-tools/adb"
|
||||||
} else {
|
} else {
|
||||||
System.err.println("WARNING: SDK dir not found by local properties, returning static: $System.env.HOME/Library/Android/sdk/platform-tools/adb")
|
println("WARNING: SDK dir not found by local properties, returning static: $System.env.HOME/Library/Android/sdk/platform-tools/adb")
|
||||||
return "$System.env.HOME/Library/Android/sdk/platform-tools/adb"
|
return "$System.env.HOME/Library/Android/sdk/platform-tools/adb"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.fnives.test.showcase.android.testutil.screenshot
|
package org.fnives.test.showcase.android.testutil.screenshot
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
|
@ -20,21 +21,16 @@ fun basicScreenCaptureProcessor(subDir: String = "test-screenshots"): ScreenCapt
|
||||||
* see example issue: https://github.com/android/android-test/issues/818
|
* see example issue: https://github.com/android/android-test/issues/818
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
fun getTestPicturesDir(): File? {
|
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")
|
||||||
|
|
||||||
|
InstrumentationRegistry.getInstrumentation().targetContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
||||||
|
} else {
|
||||||
val packageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName
|
val packageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName
|
||||||
val environmentFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
val environmentFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||||
val externalFolder = File(environmentFolder, packageName)
|
val externalFolder = File(environmentFolder, packageName)
|
||||||
if (externalFolder.canWrite()) {
|
|
||||||
Log.d(ScreenshotRule.TAG, "external folder")
|
Log.d(ScreenshotRule.TAG, "external folder")
|
||||||
return externalFolder
|
|
||||||
}
|
|
||||||
|
|
||||||
val internalFolder = InstrumentationRegistry.getInstrumentation().targetContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
|
externalFolder
|
||||||
if (internalFolder?.canWrite() == true) {
|
|
||||||
Log.d(ScreenshotRule.TAG, "internal folder")
|
|
||||||
return internalFolder
|
|
||||||
}
|
|
||||||
Log.d(ScreenshotRule.TAG, "cant find directory the screenshots could be saved into")
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue