File tree Expand file tree Collapse file tree 5 files changed +104
-0
lines changed
src/androidTest/java/com/example/virosample Expand file tree Collapse file tree 5 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 1+ [submodule "android/git-diff-image "]
2+ path = android/git-diff-image
3+ url = git@github.com:ewanmellor/git-diff-image.git
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ android {
1717 versionName getTag()
1818 buildConfigField " String" , ' GIT_REPOSITORY' , " \" " + getGitOriginRemote() + " \" "
1919 buildConfigField " String" , ' VERSION' , " \" " + getTag() + " \" "
20+
21+ testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
22+ testInstrumentationRunnerArguments useTestStorageService : ' true'
2023 }
2124
2225 buildTypes {
@@ -64,6 +67,11 @@ dependencies {
6467
6568 implementation " org.jetbrains.kotlin:kotlin-stdlib:2.0.0"
6669 implementation " androidx.core:core-ktx:1.8.0"
70+
71+ testImplementation ' junit:junit:4.13.2'
72+ androidTestImplementation ' com.github.AppDevNext:Moka:1.6'
73+ androidTestImplementation " androidx.test.ext:junit-ktx:1.1.5"
74+ androidTestUtil " androidx.test.services:test-services:1.4.2"
6775}
6876
6977static def getTag () {
Original file line number Diff line number Diff line change 1+ package com.example.virosample
2+
3+ import android.view.Gravity
4+ import androidx.test.core.graphics.writeToTestStorage
5+ import androidx.test.espresso.Espresso
6+ import androidx.test.espresso.assertion.ViewAssertions.matches
7+ import androidx.test.espresso.contrib.DrawerActions
8+ import androidx.test.espresso.contrib.DrawerMatchers.isClosed
9+ import androidx.test.espresso.matcher.ViewMatchers
10+ import androidx.test.espresso.matcher.ViewMatchers.withId
11+ import androidx.test.espresso.screenshot.captureToBitmap
12+ import androidx.test.ext.junit.rules.activityScenarioRule
13+ import androidx.test.ext.junit.runners.AndroidJUnit4
14+ import org.junit.Rule
15+ import org.junit.Test
16+ import org.junit.rules.TestName
17+ import org.junit.runner.RunWith
18+
19+
20+ @RunWith(AndroidJUnit4 ::class )
21+ class ExtendedMainTest {
22+
23+ @get:Rule
24+ var nameRule = TestName ()
25+
26+ @get:Rule
27+ val activityScenarioRule = activityScenarioRule<MLMainActivity >()
28+
29+ @Test
30+ fun mainSmokeTest () {
31+ Espresso .onView(withId(R .id.drawer_layout))
32+ .check(matches(isClosed(Gravity .LEFT ))) // Left Drawer should be closed.
33+ .perform(DrawerActions .open())
34+ Espresso .onView(ViewMatchers .isRoot())
35+ .captureToBitmap()
36+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -End" )
37+ }
38+
39+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ diffFiles=./screenshotDiffs
4+ mkdir $diffFiles
5+ set -x
6+ ./git-diff-image/install.sh
7+ GIT_DIFF_IMAGE_OUTPUT_DIR=$diffFiles git diff-image
8+
9+ source scripts/lib.sh
10+
11+ PR=$( echo " $GITHUB_REF_NAME " | sed " s/\// /" | awk ' {print $1}' )
12+ echo pr=$PR
13+ brew install jq
14+
15+ echo " delete all old comments, starting with Screenshot differs:$emulatorApi "
16+ oldComments=$( curl_gh -X GET https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/" $PR " /comments | jq ' .[] | (.id |tostring) + "|" + (.user.login | test("github-actions") | tostring) + "|" + (.body | test("Screenshot differs:' $emulatorApi ' .*") | tostring)' | grep " true|true" | tr -d " \" " | cut -f1 -d" |" )
17+ echo " comments=$comments "
18+ echo " $oldComments " | while read comment; do
19+ echo " delete comment=$comment "
20+ curl_gh -X DELETE https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/comments/" $comment "
21+ done
22+
23+ pushd $diffFiles
24+ body=" "
25+ COUNTER=0
26+ ls -la
27+
28+ # ignore an error, when no files where found https://unix.stackexchange.com/a/723909/201876
29+ setopt no_nomatch
30+ for f in * .png; do
31+ if [[ ${f} == " *.png" ]]
32+ then
33+ echo " nothing found"
34+ else
35+ (( COUNTER++ ))
36+
37+ newName=" $1 -${f} "
38+ mv " ${f} " " $newName "
39+ echo " ==> Uploaded screenshot $newName "
40+ curl -i -F " file=@$newName " https://www.mxtracks.info/github
41+ echo " ==> Add screenshot comment $PR "
42+ body=" $body ${f}  <br/><br/>"
43+ fi
44+ done
45+
46+ if [ ! " $body " == " " ]; then
47+ curl_gh -X POST https://api.github.com/repos/" $GITHUB_REPOSITORY " /issues/$PR /comments -d " { \" body\" : \" Screenshot differs:$emulatorApi $COUNTER <br/><br/> $body \" }"
48+ fi
49+
50+ popd 1> /dev/null
51+
52+ # set error when diffs are there
53+ [ " $( ls -A $diffFiles ) " ] && exit 1 || exit 0
You can’t perform that action at this time.
0 commit comments