monkeyrunner + layouts for different screen densities

This commit is contained in:
Sergey Solovyev
2012-11-25 15:27:28 +04:00
parent 1c7cb51383
commit 642c7eb076
10 changed files with 139 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
declare -a densities=("160" "213" "240" "320")
declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768" "1536x1152" "1920x1200")
declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768")
declare -a targets=("android-16")
for target in ${targets[@]}
@@ -24,13 +24,23 @@ do
$ANDROID_HOME/tools/android -s create avd -n $name -t $target -b x86 --force -s $resolution
# replace density in config.ini
sed -i "s/hw.lcd.density=240/hw.lcd.density=$density/g" $HOME/.android/avd/$name.avd/config.ini
if grep -R "hw.lcd.density" $HOME/.android/avd/$name.avd/config.ini
then
# replace density in config.ini
sed -i "s/hw.lcd.density=240/hw.lcd.density=$density/g" $HOME/.android/avd/$name.avd/config.ini
else
# code if not found
echo "hw.lcd.density=$density" >> $HOME/.android/avd/$name.avd/config.ini
fi
arr=(${resolution//x/ })
echo "sdcard.size=64M" >> $HOME/.android/avd/$name.avd/config.ini
echo "vm.heapSize=48" >> $HOME/.android/avd/$name.avd/config.ini
echo "hw.ramSize=256" >> $HOME/.android/avd/$name.avd/config.ini
echo "hw.lcd.width = ${arr[0]}" >> $HOME/.android/avd/$name.avd/config.ini
echo "hw.lcd.height = ${arr[1]}" >> $HOME/.android/avd/$name.avd/config.ini
#arr=(${resolution//x/ })
#echo "hw.lcd.width = ${arr[0]}" >> $HOME/.android/avd/$name.avd/config.ini
#echo "hw.lcd.height = ${arr[1]}" >> $HOME/.android/avd/$name.avd/config.ini
done
done
@@ -50,7 +60,7 @@ do
$ANDROID_HOME/tools/emulator -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./wait_device.py
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
$ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done
done

View File

@@ -12,7 +12,7 @@ print 'Screenshot will be located in ' + outFolder + ' with name ' + outFilename
apk = '/home/serso/projects/java/android/calculatorpp/calculatorpp/target/calculatorpp.apk'
package = 'org.solovyev.android.calculator'
activity = 'org.solovyev.android.calculator.CalculatorActivity'
deviceName = 'emulator-5554'
deviceName = 'emulator-5580'
def takeScreenshot (folder, filename):
screenshot = device.takeSnapshot()
@@ -20,12 +20,9 @@ def takeScreenshot (folder, filename):
return
print 'Waiting for device ' + deviceName + '...'
device = MonkeyRunner.waitForConnection(50, deviceName)
device = MonkeyRunner.waitForConnection(100, deviceName)
if device:
# unlock device
device.wake()
device.drag((130, 620), (500, 620), 1.0, 120)
print 'Device found, removing application if any ' + package + '...'
device.removePackage(package)
@@ -39,10 +36,11 @@ if device:
device.startActivity(component=runComponent)
# sleep while application will be loaded
MonkeyRunner.sleep(10);
MonkeyRunner.sleep(3);
print 'Taking screenshot...'
takeScreenshot(outFolder, outFilename + '_' + str(time.time()) );
#outFilename = outFilename + '_' + str(time.time())
takeScreenshot(outFolder, outFilename);
print 'Changing orientation...'

View File

@@ -1,7 +1,7 @@
#!/bin/bash
declare -a densities=("160" "213" "240" "320")
declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768" "1536x1152" "1920x1200")
declare -a resolutions=("320x480" "480x640" "480x800" "480x854" "640x960" "1024x600" "1024x768" "1280x768")
declare -a targets=("android-16")
for target in ${targets[@]}
@@ -16,10 +16,10 @@ do
name="$name$resolution"
name="$name$target"
$ANDROID_HOME/tools/emulator -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp $name
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
$ANDROID_HOME/tools/emulator -ports 5580,5581 -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/other/tmp/2012.11.25 $name
$ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done
done
done
done

View File

@@ -9,5 +9,5 @@ for name in ${names[@]}
do
$ANDROID_HOME/tools/emulator -avd $name &
$ANDROID_HOME/tools/monkeyrunner ./take_screenshots.py ~/projects/java/android/calculatorpp/calculatorpp/misc/aux/tmp $name
$ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
$ANDROID_HOME/platform-tools/adb -s emulator-5580 emu kill
done

View File

@@ -1,7 +1,7 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print 'Waiting for device...'
device = MonkeyRunner.waitForConnection(100, 'emulator-5554')
device = MonkeyRunner.waitForConnection(100, 'emulator-5580')
print 'Finished'
if device :
print 'Success'