2020-07-17 08:47:59 +03:00
|
|
|
#!/bin/bash
|
2024-03-29 18:56:51 +03:00
|
|
|
#
|
|
|
|
# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
# SPDX-FileCopyrightText: 2020-2024 Tobias Kaminsky <tobias@kaminsky.me>
|
2024-03-29 21:22:56 +03:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2024-03-29 18:56:51 +03:00
|
|
|
#
|
2021-09-03 13:29:58 +03:00
|
|
|
set -e
|
2020-07-17 08:47:59 +03:00
|
|
|
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
echo "1: record: true/false
|
|
|
|
2: class name
|
2020-07-28 23:14:14 +03:00
|
|
|
3: method name
|
2020-07-29 13:04:44 +03:00
|
|
|
4: darkMode: dark/light / \"all\" to run all screenshot combinations
|
2020-07-28 23:14:14 +03:00
|
|
|
5: color"
|
2020-07-17 10:38:32 +03:00
|
|
|
|
2020-07-17 08:47:59 +03:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-03-11 13:28:21 +03:00
|
|
|
pushd app/src/androidTest/java
|
2020-07-17 08:47:59 +03:00
|
|
|
|
2020-07-28 14:17:34 +03:00
|
|
|
class=$(find | grep $2 | grep -E "java$|kt$" | head -n1|sed s'/\//\./'g | sed s'#^\.\.##' | sed s'#\.java##'| sed s'#\.kt##')
|
|
|
|
|
|
|
|
if [[ -z $class ]]; then
|
|
|
|
echo "Class not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-07-17 08:47:59 +03:00
|
|
|
|
|
|
|
cd ../../../
|
|
|
|
|
|
|
|
if [ $1 == "true" ] ; then
|
|
|
|
record="-Precord"
|
2020-07-17 10:38:32 +03:00
|
|
|
else
|
2020-07-17 08:47:59 +03:00
|
|
|
record=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e $3 ] ; then
|
|
|
|
method=""
|
|
|
|
else
|
|
|
|
method="#$3"
|
2020-07-28 14:17:34 +03:00
|
|
|
|
|
|
|
# check if method exists
|
|
|
|
if [[ $(grep -c $3 $(find | grep $2 | grep -E "java$|kt$" | head -n1)) -eq 0 ]]; then
|
|
|
|
echo "Method not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-07-17 08:47:59 +03:00
|
|
|
fi
|
|
|
|
|
2020-07-28 23:14:14 +03:00
|
|
|
if [ -e $4 ] ; then
|
|
|
|
darkMode=""
|
|
|
|
else
|
|
|
|
darkMode="-Pandroid.testInstrumentationRunnerArguments.DARKMODE=$4"
|
|
|
|
fi
|
|
|
|
|
2022-03-11 13:28:21 +03:00
|
|
|
popd
|
|
|
|
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
|
2020-07-24 14:12:31 +03:00
|
|
|
|
2020-10-07 17:35:47 +03:00
|
|
|
# check if emulator is running
|
|
|
|
emulatorIsRunning=false
|
|
|
|
while read line ; do
|
|
|
|
if [[ $(adb -s $line emu avd name 2>/dev/null | head -n1) =~ uiComparison.* ]]; then
|
|
|
|
emulatorIsRunning=true
|
|
|
|
export ANDROID_SERIAL=$line
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done < <(adb devices | cut -f1)
|
|
|
|
|
2021-09-03 08:35:27 +03:00
|
|
|
if [ "$emulatorIsRunning" == false ] ; then
|
2021-09-03 13:35:38 +03:00
|
|
|
"$(command -v emulator)" -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
|
2022-06-13 10:15:20 +03:00
|
|
|
sleep 20
|
2020-10-07 17:35:47 +03:00
|
|
|
fi
|
2020-07-24 14:12:31 +03:00
|
|
|
|
2020-07-28 23:14:14 +03:00
|
|
|
if [ -e $5 ] ; then
|
|
|
|
color=""
|
|
|
|
else
|
|
|
|
color="-Pandroid.testInstrumentationRunnerArguments.COLOR=$5"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $4 = "all" ]]; then
|
|
|
|
scripts/runAllScreenshotCombinations "noCI" "$1" "-Pandroid.testInstrumentationRunnerArguments.class=$class$method"
|
|
|
|
else
|
2024-02-22 12:13:22 +03:00
|
|
|
SHOT_TEST=true ./gradlew --offline gplayDebugExecuteScreenshotTests $record \
|
2023-06-07 13:40:40 +03:00
|
|
|
-Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED" \
|
2020-11-04 14:42:11 +03:00
|
|
|
-Pscreenshot=true \
|
2020-07-28 23:14:14 +03:00
|
|
|
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
|
|
|
-Pandroid.testInstrumentationRunnerArguments.class=$class$method \
|
|
|
|
$darkMode \
|
|
|
|
$color
|
|
|
|
fi
|
|
|
|
|
2020-07-17 08:47:59 +03:00
|
|
|
|
2022-03-11 13:28:21 +03:00
|
|
|
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g app/src/main/res/values/setup.xml
|
2020-10-07 17:35:47 +03:00
|
|
|
unset ANDROID_SERIAL
|