2 # This file is part of NIT ( http://www.nitlanguage.org ).
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # Script to test Android apps using `adb monkey`
18 # Show the emulator window?
21 # Name of an already running device, as shown by `adb devices`
24 # Parse command line options
26 while [ $stop = false
]; do
28 --show
) show
=true
; shift;;
29 --dev
) dev
=$2; shift; shift;;
36 echo "Usage: check_android.sh [--show] [--dev android-device-name] file.apk [other_file.apk [...]]"
42 # Create an AVD if none is specified
44 if [ $dev = none
]; then
48 # TODO have alternatives AVD with different specs
51 # Port for the emulator
56 # Time to wait for the emulator to be ready
59 # Does the AVD exists?
60 android list avd |
grep $avd
63 echo no | android create avd
-n
$avd --snapshot
-t android
-19 --abi x86 || true
67 # Show the emulator window on request only
69 if [ $show = false
]; then
73 emulator
-avd
$avd -port
$port -logcat app.nit
$emu_opts &
74 # To use hardware optimization add: -qemu -m 512 -enable-kvm
82 pkg
=`aapt dump badging $apk | grep package | sed -e "s/.*name='\([a-z._]*\)'.*/\1/"`
85 adb
-s
$dev uninstall
$pkg
86 adb
-s
$dev install -r
"$apk"
89 adb
-s
$dev shell input keyevent
82
90 adb
-s
$dev shell input keyevent
4
93 tools_dir
=`dirname $0`
94 $tools_dir/unitrun.sh
"android-`basename $apk .apk`" \
95 adb
-s
$dev shell monkey
-p
$pkg \
96 --monitor
-native
-crashes
--throttle
2 --pct
-touch 50 --pct
-motion
50 5000
99 if [ $kill_emu = true
]; then