From dd7a7d99772fdc9c698240f9921c9021f67884d1 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 5 May 2023 21:01:31 +0530 Subject: [PATCH] feat: use Maestro to automatically generate Play Store screenshots --- .gitignore | 1 + maestro/play_store_flow.yml | 18 ++++++++++++++++++ scripts/run-maestro-flows.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 maestro/play_store_flow.yml create mode 100755 scripts/run-maestro-flows.sh diff --git a/.gitignore b/.gitignore index 33cdccb2..48355020 100644 --- a/.gitignore +++ b/.gitignore @@ -245,3 +245,4 @@ hs_err_pid* keystore.properties distribution/ +screenshots/ diff --git a/maestro/play_store_flow.yml b/maestro/play_store_flow.yml new file mode 100644 index 00000000..71fda49f --- /dev/null +++ b/maestro/play_store_flow.yml @@ -0,0 +1,18 @@ +appId: dev.msfjarvis.claw.android +--- +- launchApp +- tapOn: + text: "Add to saved posts" + index: 0 +- tapOn: + text: "Add to saved posts" + index: 2 +- takeScreenshot: "HottestPosts" +- tapOn: "Saved" +- takeScreenshot: "SavedPosts" +- tapOn: "Hottest" +- tapOn: + text: "Open comments" + index: 0 +- waitForAnimationToEnd +- takeScreenshot: "CommentsPage" diff --git a/scripts/run-maestro-flows.sh b/scripts/run-maestro-flows.sh new file mode 100755 index 00000000..4834db52 --- /dev/null +++ b/scripts/run-maestro-flows.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Get the absolute path to the script file +SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" + +# Create a directory for generated screenshots since Maestro puts them iN $PWD +mkdir -p "${SCRIPT_DIR}"/../screenshots +pushd "${SCRIPT_DIR}"/../screenshots || exit 1 +# Delete any existing screenshots +rm -rf ./*.png + +# Enable Demo Mode on the device with the following settings +# - Hide notification icons +# - Set clock to 1200 hrs +adb shell am broadcast -a com.android.systemui.demo \ + -e command enter \ + -e command notifications -e visible false \ + -e command clock -e hhmm 1200 + +# Clear data for the app to make re-runs consistent +adb shell pm clear dev.msfjarvis.claw.android + +# Run the Maestro Flows from $PROJECT_DIR/maestro +maestro test "${SCRIPT_DIR}"/../maestro/*.yml + +# Turn off Demo Mode on the device +adb shell am broadcast -a com.android.systemui.demo -e command exit + +# Return to the original $PWD +popd || exit 1