Home | History | Annotate | Download | only in theme
      1 #!/bin/sh
      2 # Copyright (C) 2015 The Android Open Source Project
      3 #
      4 # Licensed under the Apache License, Version 2.0 (the "License");
      5 # you may not use this file except in compliance with the License.
      6 # You may obtain a copy of the License at
      7 #
      8 #      http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 # Unless required by applicable law or agreed to in writing, software
     11 # distributed under the License is distributed on an "AS IS" BASIS,
     12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     15 
     16 # This script is used to generate reference images for the CTS theme tests.
     17 # See the accompanying README file for more information.
     18 
     19 # retry <command> <tries> <message> <delay>
     20 function retry {
     21   RETRY="0"
     22   while true; do
     23     if (("$RETRY" >= "$2")); then
     24       echo $OUTPUT
     25       exit
     26     fi
     27 
     28     OUTPUT=`$1 |& grep error`
     29 
     30     if [ -z "$OUTPUT" ]; then
     31       break
     32     fi
     33 
     34     echo $3
     35     sleep $4
     36     RETRY=$[$RETRY + 1]
     37   done
     38 }
     39 
     40 themeApkPath="$ANDROID_HOST_OUT/cts/android-cts/testcases/CtsThemeDeviceApp.apk"
     41 outDir="$ANDROID_BUILD_TOP/cts/hostsidetests/theme/assets"
     42 exe="$ANDROID_BUILD_TOP/cts/hostsidetests/theme/run_theme_capture_device.py"
     43 
     44 if [ -z "$ANDROID_BUILD_TOP" ]; then
     45   echo "Missing environment variables. Did you run build/envsetup.sh and lunch?"
     46   exit
     47 fi
     48 
     49 if [ ! -e "$themeApkPath" ]; then
     50   echo "Couldn't find test APK. Did you run make cts?"
     51   exit
     52 fi
     53 
     54 adb devices
     55 python $exe $themeApkPath $outDir
     56