Compare commits
1 Commits
f5d1a995a3
...
bf7204c1ce
Author | SHA1 | Date | |
---|---|---|---|
bf7204c1ce |
@ -43,6 +43,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
api-level: 29
|
api-level: 29
|
||||||
script: |
|
script: |
|
||||||
|
./gradlew androidApp:createScreenshotDirectory
|
||||||
./gradlew androidApp:connectedAndroidTest || true
|
./gradlew androidApp:connectedAndroidTest || true
|
||||||
./gradlew androidApp:fetchScreenshots
|
./gradlew androidApp:fetchScreenshots
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
@ -242,30 +242,27 @@ aboutLibraries {
|
|||||||
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP
|
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screenshot failure handling
|
|
||||||
val reportsDirectory = file("$buildDir/reports/androidTests/connected")
|
|
||||||
|
|
||||||
val clearScreenshotsTask =
|
val clearScreenshotsTask =
|
||||||
tasks.register<Exec>("clearScreenshots") {
|
tasks.register<Exec>("clearScreenshots") {
|
||||||
println("AMINE : clear")
|
println("AMINE : clear")
|
||||||
commandLine = listOf("adb", "shell", "rm", "-r", "/storage/emulated/0//Pictures/selfoss_tests")
|
commandLine = listOf("adb", "shell", "rm", "-r", "/storage/emulated/0/Pictures/selfoss_tests/screenshots/*")
|
||||||
}
|
}
|
||||||
|
|
||||||
val createScreenshotDirectoryTask =
|
val createScreenshotDirectoryTask =
|
||||||
tasks.register<Exec>("createScreenshotDirectory") {
|
tasks.register<Exec>("createScreenshotDirectory") {
|
||||||
println("AMINE : create directory")
|
println("AMINE : create directory")
|
||||||
group = "reporting"
|
group = "reporting"
|
||||||
commandLine = listOf("adb", "shell", "mkdir", "-p", "/storage/emulated/0//Pictures/selfoss_tests")
|
commandLine = listOf("adb", "shell", "mkdir", "-p", "/storage/emulated/0/Pictures/selfoss_tests/screenshots")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<Exec>("fetchScreenshots") {
|
tasks.register<Exec>("fetchScreenshots") {
|
||||||
|
val reportsDirectory = file("$buildDir/reports/androidTests/connected")
|
||||||
println("AMINE : fetch")
|
println("AMINE : fetch")
|
||||||
group = "reporting"
|
group = "reporting"
|
||||||
executable(android.adbExecutable.toString())
|
executable(android.adbExecutable.toString())
|
||||||
commandLine = listOf("adb", "pull", "/storage/emulated/0//Pictures/selfoss_tests/.", reportsDirectory.toString())
|
commandLine = listOf("adb", "pull", "/storage/emulated/0/Pictures/selfoss_tests/screenshots", reportsDirectory.toString())
|
||||||
|
|
||||||
finalizedBy(clearScreenshotsTask)
|
finalizedBy(clearScreenshotsTask)
|
||||||
dependsOn(createScreenshotDirectoryTask)
|
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
reportsDirectory.mkdirs()
|
reportsDirectory.mkdirs()
|
||||||
|
@ -141,8 +141,6 @@ fun testAddSourceWithUrl(
|
|||||||
@Suppress("detekt:UtilityClassWithPublicConstructor")
|
@Suppress("detekt:UtilityClassWithPublicConstructor")
|
||||||
open class WithANRException {
|
open class WithANRException {
|
||||||
companion object {
|
companion object {
|
||||||
private var testNumber = 0
|
|
||||||
|
|
||||||
// Running count of the number of Android Not Responding dialogues to prevent endless dismissal.
|
// Running count of the number of Android Not Responding dialogues to prevent endless dismissal.
|
||||||
private var anrCount = 0
|
private var anrCount = 0
|
||||||
|
|
||||||
@ -168,24 +166,19 @@ open class WithANRException {
|
|||||||
fun setUpHandler() {
|
fun setUpHandler() {
|
||||||
Espresso.setFailureHandler { error, viewMatcher ->
|
Espresso.setFailureHandler { error, viewMatcher ->
|
||||||
|
|
||||||
takeScreenshot("test-failures/", testNumber.toString())
|
takeScreenshot()
|
||||||
if (error.message!!.contains(rootViewWithoutFocusExceptionMsg) && anrCount < 3) {
|
if (error.message!!.contains(rootViewWithoutFocusExceptionMsg) && anrCount < 3) {
|
||||||
anrCount++
|
anrCount++
|
||||||
handleAnrDialogue()
|
handleAnrDialogue()
|
||||||
} else { // chain all failures down to the default espresso handler
|
} else { // chain all failures down to the default espresso handler
|
||||||
DefaultFailureHandler(getInstrumentation().targetContext).handle(error, viewMatcher)
|
DefaultFailureHandler(getInstrumentation().targetContext).handle(error, viewMatcher)
|
||||||
}
|
}
|
||||||
testNumber++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun takeScreenshot(
|
fun takeScreenshot() {
|
||||||
parentFolderPath: String = "",
|
|
||||||
screenShotName: String,
|
|
||||||
) {
|
|
||||||
Log.d("Screenshots", "Taking screenshot of '$screenShotName'")
|
|
||||||
try {
|
try {
|
||||||
val bitmap = getInstrumentation().uiAutomation.takeScreenshot()
|
val bitmap = getInstrumentation().uiAutomation.takeScreenshot()
|
||||||
|
|
||||||
@ -195,15 +188,16 @@ fun takeScreenshot(
|
|||||||
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
|
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
|
||||||
"selfoss_tests",
|
"selfoss_tests",
|
||||||
).absolutePath,
|
).absolutePath,
|
||||||
"screenshots/$parentFolderPath",
|
"screenshots",
|
||||||
)
|
)
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdirs()
|
folder.mkdirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
var out: BufferedOutputStream? = null
|
var out: BufferedOutputStream? = null
|
||||||
|
val size = folder.list().size + 1
|
||||||
try {
|
try {
|
||||||
out = BufferedOutputStream(FileOutputStream(folder.path + "/" + screenShotName + ".png"))
|
out = BufferedOutputStream(FileOutputStream(folder.path + "/" + size + ".png"))
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)
|
||||||
Log.d("Screenshots", "Screenshot taken")
|
Log.d("Screenshots", "Screenshot taken")
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
87
androidApp/src/debug/AndroidManifest.xml
Normal file
87
androidApp/src/debug/AndroidManifest.xml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".MyApp"
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:configChanges="uiMode"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="false"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/NoBar"
|
||||||
|
tools:replace="android:allowBackup">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/SplashTheme">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.shortcuts"
|
||||||
|
android:resource="@xml/shortcuts" />
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".LoginActivity"
|
||||||
|
android:label="@string/title_activity_login"></activity>
|
||||||
|
<activity android:name=".HomeActivity"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".settings.SettingsActivity"
|
||||||
|
android:label="@string/title_activity_settings"
|
||||||
|
android:parentActivityName=".HomeActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".HomeActivity" />
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".SourcesActivity"
|
||||||
|
android:parentActivityName=".HomeActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".HomeActivity" />
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".UpsertSourceActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:parentActivityName=".SourcesActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".SourcesActivity" />
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".ReaderActivity"></activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ImageActivity"
|
||||||
|
android:theme="@style/Theme.AppCompat.ImageActivity"></activity>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.webkit.WebView.MetricsOptOut"
|
||||||
|
android:value="true" />
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
||||||
|
android:value="true" />
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="android.max_aspect"
|
||||||
|
android:value="2.1" />
|
||||||
|
</application>
|
||||||
|
</manifest>
|
Loading…
x
Reference in New Issue
Block a user