Browse Source

Merge pull request #7051 from nextcloud/dependabot/gradle/com.karumi-shot-5.0.1

Bump shot from 4.4.0 to 5.1.0
Andy Scherzinger 4 years ago
parent
commit
a90ba47849
4 changed files with 22 additions and 2 deletions
  1. 2 0
      .drone.yml
  2. 4 1
      build.gradle
  3. 15 1
      scripts/androidScreenshotTest
  4. 1 0
      scripts/runAllScreenshotCombinations

+ 2 - 0
.drone.yml

@@ -185,6 +185,7 @@ steps:
       GIT_TOKEN:
         from_secret: GIT_TOKEN
       ORG_GRADLE_PROJECT_coverage: ''
+      ORG_GRADLE_PROJECT_screenshot: ''
     commands:
       - scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
       - emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
@@ -239,6 +240,7 @@ steps:
       GIT_TOKEN:
         from_secret: GIT_TOKEN
       ORG_GRADLE_PROJECT_coverage: ''
+      ORG_GRADLE_PROJECT_screenshot: ''
     commands:
       - scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
       - emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &

+ 4 - 1
build.gradle

@@ -27,7 +27,7 @@ buildscript {
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
         classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.14.2"
         classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
-        classpath 'com.karumi:shot:4.4.0'
+        classpath 'com.karumi:shot:5.3.0'
     }
 }
 
@@ -156,6 +156,9 @@ android {
         buildTypes {
             debug {
                 testCoverageEnabled (project.hasProperty('coverage'))
+                if (project.hasProperty('screenshot')) {
+                    minSdkVersion 21 // remove once we use 21 globally, only needed for karumi.shot
+                }
             }
         }
 

+ 15 - 1
scripts/androidScreenshotTest

@@ -47,7 +47,19 @@ fi
 
 sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
 
-emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
+# 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)
+
+if [ ! $emulatorIsRunning ] ; then
+    emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
+fi
 
 if [ -e $5 ] ; then
     color=""
@@ -59,6 +71,7 @@ if [[ $4 = "all" ]]; then
     scripts/runAllScreenshotCombinations "noCI" "$1" "-Pandroid.testInstrumentationRunnerArguments.class=$class$method"
 else
     ./gradlew --offline gplayDebugExecuteScreenshotTests $record \
+    -Pscreenshot=true \
     -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
     -Pandroid.testInstrumentationRunnerArguments.class=$class$method \
     $darkMode \
@@ -67,3 +80,4 @@ fi
 
 
 sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml
+unset ANDROID_SERIAL

+ 1 - 0
scripts/runAllScreenshotCombinations

@@ -22,6 +22,7 @@ do
     if [[ $1 = "noCI" ]]; then
         ./gradlew --console plain gplayDebugExecuteScreenshotTests \
         $record \
+        -Pscreenshot=true \
         -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
         -Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
         -Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" \