diff options
author | Amit Khare <amit.khare@linaro.org> | 2014-08-19 18:01:33 +0530 |
---|---|---|
committer | Amit Khare <amit.khare@linaro.org> | 2014-08-19 18:01:33 +0530 |
commit | f5640a2c4350708d57d1089d15d0fe57fc299085 (patch) | |
tree | 2c983b11e43dfc2db0d026598651b9ad37eab23c | |
parent | cd9f13b491827808f3507a5a0b6e03ee7db682a5 (diff) | |
parent | 27bb96ad3922d6eccf43e158f41d16090a67bc63 (diff) |
Merge branch 'master' of ssh://git.linaro.org/qa/android-apk-automation
-rw-r--r-- | cf-bench/vc.py | 38 | ||||
-rwxr-xr-x | common/common.sh | 47 |
2 files changed, 58 insertions, 27 deletions
diff --git a/cf-bench/vc.py b/cf-bench/vc.py index 33b92f0..47b1f39 100644 --- a/cf-bench/vc.py +++ b/cf-bench/vc.py @@ -8,13 +8,19 @@ from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException def get_score_with_content_desc(vc, content_desc, offset=1): try: - score_view = vc.findViewWithText(content_desc) + score_view = vc.findViewWithTextOrRaise(content_desc) score_uid = score_view.getUniqueId() uid = int(re.search("id/no_id/(?P<uid>\d+)", score_uid).group('uid')) score = vc.findViewByIdOrRaise("id/no_id/%s" % (uid + offset)) - call(['lava-test-case', content_desc, '--result', 'pass', '--measurement', score.getText()]) + score_text = score.getText() + if score_text.find("%") > 0: + score_value, units = score_text.split(" ") + call(['lava-test-case', content_desc, '--result', 'pass', '--measurement', score_value, "--units", units]) + else: + call(['lava-test-case', content_desc, '--result', 'pass', '--measurement', score_text]) except ViewNotFoundException: - pass + print "%s not found" % (content_desc) + pass kwargs1 = {'verbose': False, 'ignoresecuredevice': False} device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) @@ -27,19 +33,21 @@ vc.dump(window='-1') start_button = vc.findViewByIdOrRaise("id/no_id/23") start_button.touch() -#Wait while cf-bench running +#Wait while cf-bench running finished = False while(not finished): - time.sleep(1) - vc.dump('-1') - try: - progress_button = vc.findViewByIdOrRaise("eu.chainfire.cfbench:id/admob_preference_layout") - finished = True - except ViewNotFoundException: - pass + try: + time.sleep(1) + vc.dump('-1') + progress_button = vc.findViewByIdOrRaise("eu.chainfire.cfbench:id/admob_preference_layout") + finished = True + except ViewNotFoundException: + pass + except RuntimeError as e: + print e print("Benchmark Finished") -device.drag((300,1000), (150,150), 300) +device.drag((300,1000), (300,300), 300) time.sleep(5) vc.dump(window='-1') @@ -57,6 +65,12 @@ get_score_with_content_desc(vc, "Native Memory Write") get_score_with_content_desc(vc, "Java Memory Write") get_score_with_content_desc(vc, "Native Disk Read") get_score_with_content_desc(vc, "Native Disk Write") + +# drag screen once more to reveal remaining results +device.drag((300,1000), (300,300), 300) +time.sleep(5) +vc.dump(window='-1') + get_score_with_content_desc(vc, "Java Efficiency MIPS") get_score_with_content_desc(vc, "Java Efficiency MSFLOPS") get_score_with_content_desc(vc, "Java Efficiency MDFLOPS") diff --git a/common/common.sh b/common/common.sh index a5cd3ab..57957b5 100755 --- a/common/common.sh +++ b/common/common.sh @@ -41,14 +41,14 @@ function pull_png_files_from_device(){ } function init(){ - - #install_linaro_android_jar - - #uninstall the apk application - echo "trying to unistall ${apk_package}" - adb uninstall "${apk_package}" - echo "unistalled ${apk_package}" - #clear the logcat information + # uninstall the apk application + # don't uninstall if apk file name is empty + if [ ! -z "$apk_file_name" ]; then + echo "trying to unistall ${apk_package}" + adb uninstall "${apk_package}" + echo "unistalled ${apk_package}" + fi + # clear the logcat information adb logcat -c sleep 5 @@ -169,11 +169,18 @@ function get_file_with_base_url(){ function install_run_uninstall(){ #install the apk files - apk_file="${APKS_DIR}/${apk_file_name}" - adb install "${apk_file}" - if [ $? -ne 0 ]; then - echo "Failed to install ${apk_file}." - exit 1 + if [ ! -z "$apk_file_name" ]; then + apk_file="${APKS_DIR}/${apk_file_name}" + adb install "${apk_file}" + if [ $? -ne 0 ]; then + echo "Failed to install ${apk_file}." + exit 1 + fi + else + # force stop activity if apk is already installed + echo "stopping ${apk_package}" + adb shell am force-stop "${apk_package}" + sleep 5 fi if [ -n "${post_install}" ]; then ${post_install} @@ -192,7 +199,15 @@ function install_run_uninstall(){ if [ -n "${pre_uninstall}" ]; then ${pre_uninstall} fi - adb uninstall "${apk_package}" + + if [ ! -z "$apk_file_name" ]; then + adb uninstall "${apk_package}" + else + # force stop activity if apk is a stock app + echo "stopping ${apk_package}" + adb shell am force-stop "${apk_package}" + sleep 5 + fi } function collect_log(){ @@ -319,7 +334,9 @@ function main(){ echo "exports done" init echo "init done" - get_file_with_base_url "${apk_file_name}" + if [ ! -z "$apk_file_name" ]; then + get_file_with_base_url "${apk_file_name}" + fi install_run_uninstall echo "testing done" pull_png_files_from_device "${png_dir_device}" ${parent_dir} |