mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-05 11:46:48 -04:00
Testing file opening from browser, file manager, and via file piker on tablet in CI.
This commit is contained in:
parent
968cbfa19a
commit
9fadeff0cc
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@ -52,6 +52,26 @@ jobs:
|
|||||||
~/.android/adb*
|
~/.android/adb*
|
||||||
key: avd-${{ matrix.api-level }}
|
key: avd-${{ matrix.api-level }}
|
||||||
|
|
||||||
|
- name: File Opening test on Tablet
|
||||||
|
if: ${{ matrix.api-level!=25 }}
|
||||||
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
|
env:
|
||||||
|
GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.network.retry.max.attempts=6 -Dorg.gradle.internal.network.retry.initial.backOff=2000"
|
||||||
|
with:
|
||||||
|
api-level: ${{ matrix.api-level }}
|
||||||
|
target: default
|
||||||
|
arch: x86_64
|
||||||
|
profile: pixel_tablet
|
||||||
|
ram-size: 3072M
|
||||||
|
cores: 4
|
||||||
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
|
disable-animations: true
|
||||||
|
force-avd-creation: true
|
||||||
|
sdcard-path-or-size: 1024M
|
||||||
|
emulator-boot-timeout: 1200
|
||||||
|
heap-size: 512M
|
||||||
|
script: bash contrib/instrumentation-file-opening-on-tablet.sh
|
||||||
|
|
||||||
- name: Create AVD and generate snapshot for caching
|
- name: Create AVD and generate snapshot for caching
|
||||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
|
@ -21,6 +21,7 @@ package org.kiwix.kiwixmobile.localLibrary
|
|||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.media.MediaScannerConnection
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
@ -163,7 +164,6 @@ class OpeningFilesFromStorageTest : BaseActivityTest() {
|
|||||||
"application%2Foctet-stream"
|
"application%2Foctet-stream"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
testCopyMoveDialogShowing(Uri.parse("content://media/external/downloads/2825"))
|
|
||||||
testCopyMoveDialogShowing(
|
testCopyMoveDialogShowing(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
"content://org.mozilla.firefox.DownloadProvider/" +
|
"content://org.mozilla.firefox.DownloadProvider/" +
|
||||||
@ -174,10 +174,10 @@ class OpeningFilesFromStorageTest : BaseActivityTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun testCopyMoveDialogShowing(uri: Uri) {
|
private fun testCopyMoveDialogShowing(uri: Uri) {
|
||||||
|
sharedPreferenceUtil.copyMoveZimFilePermissionDialog = false
|
||||||
ActivityScenario.launch<KiwixMainActivity>(
|
ActivityScenario.launch<KiwixMainActivity>(
|
||||||
createDeepLinkIntent(uri)
|
createDeepLinkIntent(uri)
|
||||||
).onActivity {}
|
).onActivity {}
|
||||||
sharedPreferenceUtil.copyMoveZimFilePermissionDialog = false
|
|
||||||
copyMoveFileHandler {
|
copyMoveFileHandler {
|
||||||
assertCopyMovePermissionDialogDisplayed()
|
assertCopyMovePermissionDialogDisplayed()
|
||||||
clickOnCancel()
|
clickOnCancel()
|
||||||
@ -261,6 +261,12 @@ class OpeningFilesFromStorageTest : BaseActivityTest() {
|
|||||||
contentValues.clear()
|
contentValues.clear()
|
||||||
contentValues.put(MediaStore.Downloads.IS_PENDING, false)
|
contentValues.put(MediaStore.Downloads.IS_PENDING, false)
|
||||||
resolver.update(uri, contentValues, null, null)
|
resolver.update(uri, contentValues, null, null)
|
||||||
|
MediaScannerConnection.scanFile(
|
||||||
|
context,
|
||||||
|
arrayOf(uri.toString()),
|
||||||
|
arrayOf("application/octet-stream"),
|
||||||
|
null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uri
|
return uri
|
||||||
|
68
contrib/instrumentation-file-opening-on-tablet.sh
Normal file
68
contrib/instrumentation-file-opening-on-tablet.sh
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Enable Wi-Fi on the emulator
|
||||||
|
adb shell svc wifi enable
|
||||||
|
adb logcat -c
|
||||||
|
# shellcheck disable=SC2035
|
||||||
|
adb logcat *:E -v color &
|
||||||
|
|
||||||
|
PACKAGE_NAME="org.kiwix.kiwixmobile"
|
||||||
|
TEST_PACKAGE_NAME="${PACKAGE_NAME}.test"
|
||||||
|
TEST_SERVICES_PACKAGE="androidx.test.services"
|
||||||
|
TEST_ORCHESTRATOR_PACKAGE="androidx.test.orchestrator"
|
||||||
|
# Function to check if the application is installed
|
||||||
|
is_app_installed() {
|
||||||
|
adb shell pm list packages | grep -q "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_app_installed "$PACKAGE_NAME"; then
|
||||||
|
adb uninstall "${PACKAGE_NAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_app_installed "$TEST_PACKAGE_NAME"; then
|
||||||
|
adb uninstall "${TEST_PACKAGE_NAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_app_installed "$TEST_SERVICES_PACKAGE"; then
|
||||||
|
adb uninstall "${TEST_SERVICES_PACKAGE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_app_installed "$TEST_ORCHESTRATOR_PACKAGE"; then
|
||||||
|
adb uninstall "${TEST_ORCHESTRATOR_PACKAGE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
retry=0
|
||||||
|
while [ $retry -le 3 ]; do
|
||||||
|
if ./gradlew connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=org.kiwix.kiwixmobile.localLibrary.OpeningFilesFromStorageTest "-Dorg.gradle.jvmargs=-Xmx16G -XX:+UseParallelGC" -Dfile.encoding=UTF-8; then
|
||||||
|
echo "connectedDebugAndroidTest for file opening in tablet succeeded" >&2
|
||||||
|
break
|
||||||
|
else
|
||||||
|
adb kill-server
|
||||||
|
adb start-server
|
||||||
|
# Enable Wi-Fi on the emulator
|
||||||
|
adb shell svc wifi enable
|
||||||
|
adb logcat -c
|
||||||
|
# shellcheck disable=SC2035
|
||||||
|
adb logcat *:E -v color &
|
||||||
|
|
||||||
|
if is_app_installed "$PACKAGE_NAME"; then
|
||||||
|
adb uninstall "${PACKAGE_NAME}"
|
||||||
|
fi
|
||||||
|
if is_app_installed "$TEST_PACKAGE_NAME"; then
|
||||||
|
adb uninstall "${TEST_PACKAGE_NAME}"
|
||||||
|
fi
|
||||||
|
if is_app_installed "$TEST_SERVICES_PACKAGE"; then
|
||||||
|
adb uninstall "${TEST_SERVICES_PACKAGE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_app_installed "$TEST_ORCHESTRATOR_PACKAGE"; then
|
||||||
|
adb uninstall "${TEST_ORCHESTRATOR_PACKAGE}"
|
||||||
|
fi
|
||||||
|
./gradlew clean
|
||||||
|
retry=$(( retry + 1 ))
|
||||||
|
if [ $retry -eq 3 ]; then
|
||||||
|
adb exec-out screencap -p >screencap.png
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
x
Reference in New Issue
Block a user