summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2014-10-09 13:54:45 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2014-10-09 13:54:45 +0100
commit685d5a029cf6df6b011236f93aac1a07c9d60b39 (patch)
tree9851daea8e5be084eda43e7bc277cf39c4dcee72
parent2449dfccc4ca2a9e78271c9244c59a89af726f21 (diff)
parent2300541a1c6b5b067757913d278d7e92774afaff (diff)
Merge branch 'master' of ssh://git.linaro.org/qa/android-apk-automation
-rwxr-xr-xgeekbench3/execute.sh22
-rwxr-xr-xgeekbench3/get_result.sh24
-rwxr-xr-xgeekbench3/vc.py135
-rwxr-xr-xsettings/execute.sh12
-rwxr-xr-xsettings/vc.py97
-rw-r--r--vellamo/vc.py6
6 files changed, 293 insertions, 3 deletions
diff --git a/geekbench3/execute.sh b/geekbench3/execute.sh
new file mode 100755
index 0000000..6c43511
--- /dev/null
+++ b/geekbench3/execute.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# need to be defined for different benchmark apks
+activity="com.primatelabs.geekbench3/.HomeActivity"
+apk_file_name="com.primatelabs.geekbench3.apk"
+
+# The first added parameter has been reserved by Android View Client.
+# In order to add customised parameter, the first one must be the serial number from ADB
+if [ -z "$1" ]; then
+ device_serial_number=`adb get-serialno`
+else
+ device_serial_number=$1
+fi
+
+test_method="python vc.py $device_serial_number $excluded_test_suite"
+apk_package="com.primatelabs.geekbench3"
+
+# following should no need to modify
+parent_dir=`dirname ${0}`
+source "${parent_dir}/../common/common.sh"
+timeout=30m
+main "$@"
diff --git a/geekbench3/get_result.sh b/geekbench3/get_result.sh
new file mode 100755
index 0000000..1911688
--- /dev/null
+++ b/geekbench3/get_result.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Author: Botao Sun <botao.sun@linaro.org>
+
+function get_result(){
+ echo "Geekbench test result transfer in progress..."
+ adb pull $1 $2
+ if [ $? -ne 0 ]; then
+ echo "Test result transfer failed!"
+ return 1
+ else
+ echo "Test result transfer finished!"
+ # Rename the file, should be only one .gb3 file on target directory
+ mv *.gb3 geekbench3_result.gb3
+ if [ $? -ne 0 ]; then
+ echo "File rename failed! There should be only one .gb3 file under the current directory!"
+ return 1
+ else
+ echo "Test result file for Geekbench 3 now is geekbench3_result.gb3"
+ return 0
+ fi
+ fi
+}
+
+get_result "/data/data/com.primatelabs.geekbench3/files" "./"
diff --git a/geekbench3/vc.py b/geekbench3/vc.py
new file mode 100755
index 0000000..8c481b6
--- /dev/null
+++ b/geekbench3/vc.py
@@ -0,0 +1,135 @@
+# Author: Botao Sun <botao.sun@linaro.org>
+import os
+import sys
+import time
+from subprocess import call
+from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
+
+def collect_score(testcase, run_result):
+ call(['lava-test-case', testcase, '--result', run_result])
+
+def collect_score_with_measurement(testcase, run_result, score_number, score_unit):
+ call(['lava-test-case', testcase, '--result', run_result, '--measurement', str(score_number), '--units', score_unit])
+
+def all_fail():
+ print testcase_run + " FAILED!"
+ collect_score(testcase_run, "fail")
+ collect_score(testcase_singlecore, "skip")
+ collect_score(testcase_multicore, "skip")
+
+raw_output_file = "geekbench3_result.gb3"
+processed_output_file = "geekbench3_result.gb3.processed"
+singlecore_keyword = "score"
+singlecore_result = {}
+multicore_keyword = "multicore_score"
+multicore_result = {}
+endpoint_keyword = "multicore_rate"
+package_name = "com.primatelabs.geekbench3"
+
+# Test cases
+testcase_run = "geekbench_run"
+testcase_singlecore = "geekbench_single_core"
+testcase_multicore = "geekbench_multi_core"
+
+device, serialno = ViewClient.connectToDeviceOrExit()
+vc = ViewClient(device, serialno)
+
+try:
+ trigger = vc.findViewByIdOrRaise(package_name + ":id/runBenchmarks")
+ trigger.touch()
+ print "Geekbench 3 Test Started!"
+except ViewNotFoundException:
+ run_result = "fail"
+ print "Can not find the start button! Please check the screen!"
+ all_fail()
+ sys.exit(1)
+
+time.sleep(10)
+vc.dump()
+time.sleep(2)
+
+try:
+ vc.findViewByIdOrRaise("android:id/progress")
+except ViewNotFoundException:
+ run_result = "fail"
+ print "Something goes wrong! It is unusual that the test has not been started after 10+ seconds! Please manually check it!"
+ all_fail()
+ sys.exit(1)
+
+finished = False
+while (not finished):
+ time.sleep(45)
+ vc.dump()
+ time.sleep(2)
+ flag = vc.findViewWithText("Result")
+ if flag != None:
+ print "Geekbench 3 Test Finished!"
+ finished = True
+ else:
+ print "Geekbench 3 Test is still in progress..."
+
+# Generate the .gb3 file
+device.press('KEYCODE_MENU')
+vc.dump()
+time.sleep(1)
+share_button = vc.findViewWithText("Share")
+if share_button != None:
+ share_button.touch()
+ time.sleep(5)
+else:
+ print "Can not find the Share button to generate .gb3 file! Please check the screen!"
+ sys.exit(1)
+
+# Get and parse the result file
+call(['./get_result.sh'])
+if os.path.exists(raw_output_file) == True:
+ logfile = open(raw_output_file, "r")
+ for line in logfile:
+ # Can't believe this is an one line file!
+ # Fine the ending point with the information we want
+ endpoint = line.find(endpoint_keyword)
+ if endpoint == -1:
+ print "Can not find " + endpoint_keyword + " in log file! Please manually check it!"
+ all_fail()
+ sys.exit(1)
+ else:
+ print testcase_run + " PASSED!"
+ collect_score(testcase_run, "pass")
+ result_cut = line[0:endpoint].split(",")
+ result_cut = [element.replace('"', '').replace(' ', '') for element in result_cut]
+ for item in result_cut:
+ if singlecore_keyword == item.split(":")[0]:
+ singlecore_result[singlecore_keyword] = item.split(":")[1]
+ if multicore_keyword == item.split(":")[0]:
+ multicore_result[multicore_keyword] = item.split(":")[1]
+ if len(singlecore_result) != 1:
+ run_result = "fail"
+ print "Incorrect value for single core test result! Please check the test result file!"
+ print testcase_singlecore + " Test FAILED!"
+ collect_score(testcase_singlecore, run_result)
+ else:
+ run_result = "pass"
+ print testcase_singlecore + " Test PASSED! The Score Number is " + str(singlecore_result[singlecore_keyword])
+ collect_score_with_measurement(testcase_singlecore, run_result, singlecore_result[singlecore_keyword], "No-Unit")
+ if len(multicore_result) != 1:
+ run_result = "fail"
+ print "Incorrect value for multi core test result! Please check the test result file!"
+ print testcase_multicore + " Test FAILED!"
+ collect_score(testcase_multicore, run_result)
+ else:
+ run_result = "pass"
+ print testcase_multicore + " Test PASSED! The Score Number is " + str(multicore_result[multicore_keyword])
+ collect_score_with_measurement(testcase_multicore, run_result, multicore_result[multicore_keyword], "No-Unit")
+
+ logfile.close()
+else:
+ print "Result file does not exist!"
+ sys.exit(1)
+
+# Back to main screen, gracefully
+for i in range(0, 6):
+ device.press('KEYCODE_BACK')
+ time.sleep(2)
+
+# Renamed the test result file to processed
+os.rename(raw_output_file, processed_output_file)
diff --git a/settings/execute.sh b/settings/execute.sh
new file mode 100755
index 0000000..8ca949c
--- /dev/null
+++ b/settings/execute.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# need to be defined for different benchmark apks
+activity="com.android.settings/.Settings"
+apk_file_name=""
+test_method="python vc.py"
+apk_package="com.android.settings"
+
+# following should no need to modify
+parent_dir=`dirname ${0}`
+source "${parent_dir}/../common/common.sh"
+main "$@"
diff --git a/settings/vc.py b/settings/vc.py
new file mode 100755
index 0000000..67490ca
--- /dev/null
+++ b/settings/vc.py
@@ -0,0 +1,97 @@
+# Author: Botao Sun <botao.sun@linaro.org>
+import sys
+import time
+import commands
+from subprocess import call
+from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
+
+# Check points
+title_check = "Settings"
+network_check = "WIRELESS & NETWORKS"
+device_check = "DEVICE"
+personal_check = "PERSONAL"
+accounts_check = "Accounts"
+system_check = "SYSTEM"
+
+item_list = [network_check, device_check, personal_check, accounts_check, system_check]
+checked_item = []
+missing_item = []
+positive_counter = 0
+
+def collect_score(testcase, run_result):
+ call(['lava-test-case', testcase, '--result', run_result])
+
+device, serialno = ViewClient.connectToDeviceOrExit()
+
+vc = ViewClient(device, serialno)
+
+# Title check
+try:
+ return_text = vc.findViewByIdOrRaise("android:id/action_bar_title").getText()
+ if return_text == title_check:
+ run_result = "pass"
+ print title_check + " found!"
+ testcase = title_check + "-Title"
+ print testcase + " Test PASSED!"
+ collect_score(testcase, run_result)
+ else:
+ run_result = "fail"
+ print "Return text does not match to " + title_check + "! Please check the screen!"
+ testcase = title_check + "-Title"
+ print testcase + " Test FAILED!"
+ collect_score(testcase, run_result)
+except ViewNotFoundException:
+ run_result = "fail"
+ print title_check + " can not be found! Fatal!"
+ testcase = title_check + "-Title"
+ print testcase + " Test FAILED!"
+ collect_score(testcase, run_result)
+
+# First half screen check
+for i in range(0, len(item_list)):
+ return_object = vc.findViewWithText(item_list[i])
+ if return_object != None:
+ run_result = "pass"
+ print item_list[i] + " found!"
+ checked_item.append(item_list[i])
+ testcase = item_list[i].replace(" ", "")
+ print testcase + " Test PASSED!"
+ collect_score(testcase, run_result)
+ else:
+ missing_item.append(item_list[i])
+
+# Second half screen check
+# First click is to capture the focus, second one is to page down
+click_counter = 2
+if missing_item != []:
+ for i in (0, click_counter):
+ device.press('KEYCODE_PAGE_DOWN')
+ time.sleep(5)
+ vc.dump()
+ for i in range(0, len(missing_item)):
+ return_object = vc.findViewWithText(missing_item[i])
+ if return_object != None:
+ run_result = "pass"
+ print missing_item[i] + " found!"
+ checked_item.append(missing_item[i])
+ testcase = missing_item[i].replace(" ", "")
+ print testcase + " Test PASSED!"
+ collect_score(testcase, run_result)
+ else:
+ run_result = "fail"
+ print missing_item[i] + " can not be found!"
+ checked_item.append(missing_item[i])
+ testcase = missing_item[i].replace(" ", "")
+ print testcase + " Test FAILED!"
+ collect_score(testcase, run_result)
+else:
+ print "All checked! Test finished!"
+ sys.exit(0)
+
+# Examine the total check point number
+if len(checked_item) != len(item_list):
+ run_result = "fail"
+ print "Something is wrong in check point list!"
+ testcase = "check-point-number"
+ print testcase + " does not match!"
+ collect_score(testcase, run_result)
diff --git a/vellamo/vc.py b/vellamo/vc.py
index 8bbe162..d4826b1 100644
--- a/vellamo/vc.py
+++ b/vellamo/vc.py
@@ -56,13 +56,13 @@ vc.dump('-1')
btn_setup_2 = vc.findViewByIdOrRaise("android:id/button2")
btn_setup_2.touch()
vc.dump('-1')
-time.sleep(5)
+time.sleep(10)
#Start Button
btn_start_on = vc.findViewWithTextOrRaise("Start")
btn_start_on.touch()
vc.dump('-1')
-time.sleep(2)
+time.sleep(5)
#Enable Tutorial button
btn_setup_3 = vc.findViewByIdOrRaise("android:id/button2")
@@ -71,7 +71,7 @@ btn_setup_3.touch()
#Wait while Vellamo is running benchmark
finished = False
while (not finished):
- time.sleep(50)
+ time.sleep(1)
try:
vc.dump(window='-1')
vc.findViewByIdOrRaise("com.quicinc.vellamo:id/score_view")