Skip to content

Commit

Permalink
Verify screenshot content (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpusok authored Sep 5, 2022
1 parent 4eb0657 commit a8bb8ee
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
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: main

workflows:
test_emulator_start_23:
envs:
- EMU_VER: 23
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -15,6 +21,7 @@ workflows:
envs:
- EMU_VER: 26
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -24,6 +31,7 @@ workflows:
envs:
- EMU_VER: 28
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -33,6 +41,7 @@ workflows:
envs:
- EMU_VER: 29
- PROFILE: pixel
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
Expand All @@ -42,18 +51,30 @@ workflows:
envs:
- EMU_VER: 30
- PROFILE: pixel_2
- ABI: x86
after_run:
- _start-emulator
- _take_screenshot
- _kill-emulator

test_emulator_start_32:
envs:
- EMU_VER: 32
- PROFILE: pixel_2
- ABI: x86_64
after_run:
- _start-emulator
- _run_ui_test_and_take_screenshot
- _kill-emulator

_start-emulator:
steps:
- path::./:
title: Step Test
inputs:
- profile: $PROFILE
- api_level: $EMU_VER
- abi: $ABI
- script:
inputs:
- content: |
Expand All @@ -69,6 +90,46 @@ workflows:
fi
- wait-for-android-emulator: { }

_run_ui_test_and_take_screenshot:
steps:
- script:
inputs:
- content: |-
#!/bin/env bash
set -ex
rm -rf ./_tmp
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
inputs:
- 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
- app_file_include_filter: dontexport
- test_apk_file_include_filter: dontexport
- script:
inputs:
- content: |
#!/bin/bash
set -euxo pipefail
SCREENSHOT=./_tmp/app/screenshots/test_screenshot.png
cp $SCREENSHOT $BITRISE_DEPLOY_DIR/screen_$EMU_VER.png
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install tesseract
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update
sudo apt-get install tesseract-ocr -y
fi
OUT=./_tmp/out
tesseract -l eng "$SCREENSHOT" "$OUT"
cat "${OUT}.txt" | grep 'Hello World!'
_take_screenshot:
steps:
- change-workdir:
Expand Down

0 comments on commit a8bb8ee

Please sign in to comment.