From 1ad67ad78c5321fcb38421cbe5aa5fed86c2835b Mon Sep 17 00:00:00 2001 From: Laszlo Pusok Date: Mon, 5 Sep 2022 13:15:03 +0200 Subject: [PATCH] Verify screenshot content --- e2e/bitrise.yml | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/e2e/bitrise.yml b/e2e/bitrise.yml index 3bd7fe0..1557761 100644 --- a/e2e/bitrise.yml +++ b/e2e/bitrise.yml @@ -1,6 +1,11 @@ format_version: "11" default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git +app: + envs: + - TEST_APP_URL: https://github.com/bitrise-io/Bitrise-Android-Sample + - TEST_APP_BRANCH: BE-231-screenshot + workflows: test_emulator_start_23: envs: @@ -71,18 +76,38 @@ workflows: _take_screenshot: steps: - - change-workdir: + - script: + inputs: + - content: |- + #!/bin/env bash + set -ex + rm -rf ./_tmp + - git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git: inputs: - - path: $BITRISE_DEPLOY_DIR + - repository_url: $TEST_APP_URL + - clone_into_dir: ./_tmp + - branch: $TEST_APP_BRANCH + - gradle-runner: + inputs: + - gradle_file: ./_tmp/build.gradle + - gradle_task: connectedDebugAndroidTest + - gradlew_path: ./_tmp/gradlew - script: inputs: - content: | #!/bin/bash set -euxo pipefail - sleep 15 - cd $BITRISE_DEPLOY_DIR - $ANDROID_HOME/platform-tools/adb -s $BITRISE_EMULATOR_SERIAL shell "screencap -p /sdcard/screen.png" - $ANDROID_HOME/platform-tools/adb -s $BITRISE_EMULATOR_SERIAL pull "/sdcard/screen.png" "./screen_$EMU_VER.png" + + cp ./_tmp/app/screenshots/test_screenshot.png $BITRISE_DEPLOY_DIR/screen_$EMU_VER.png + + if [[ "$OSTYPE" == "darwin"* ]]; then + brew install tesseract + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo apt install tesseract-ocr libtesseract-dev tesseract-ocr-eng + fi + + tesseract -l eng test_screenshot.png out.txt + cat ./out.txt | grep 'Hello World!' _kill-emulator: steps: