diff options
author | Botao Sun <botao.sun@linaro.org> | 2014-08-20 12:26:08 +1000 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2014-09-30 12:41:58 +0000 |
commit | 2300541a1c6b5b067757913d278d7e92774afaff (patch) | |
tree | 5664ccbc9fd9ef227290ecbad7422f4ac4520835 /settings | |
parent | a08c1a40b24c9547c9e4ef9997675ec371dbfc05 (diff) |
Add System Settings Test for Linaro Android
Signed-off by: Botao Sun <botao.sun@linaro.org>
Change-Id: I2a702d5828b82b8784d299594da36781b8207893
Diffstat (limited to 'settings')
-rwxr-xr-x | settings/execute.sh | 12 | ||||
-rwxr-xr-x | settings/vc.py | 97 |
2 files changed, 109 insertions, 0 deletions
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) |