diff options
author | Botao Sun <botao.sun@linaro.org> | 2014-08-19 12:41:26 +1000 |
---|---|---|
committer | Botao Sun <botao.sun@linaro.org> | 2014-08-20 10:18:38 +1000 |
commit | e8a82721fbab8606fce7c306039118b20990ab6c (patch) | |
tree | a994841789e771f384b8f8e42e2d97e2defa1b5a | |
parent | 79ff44504404bdfe4cdfdfd2279fefe1e8ef3b6d (diff) |
Add Native Calculator Test for Linaro Android
Signed-off by: Botao Sun <botao.sun@linaro.org>
Change-Id: I7d1bc3f1fa8ebe9797c86ebb053b40b53025bf79
-rwxr-xr-x | calculator/execute.sh | 12 | ||||
-rwxr-xr-x | calculator/vc.py | 44 |
2 files changed, 56 insertions, 0 deletions
diff --git a/calculator/execute.sh b/calculator/execute.sh new file mode 100755 index 0000000..c9f80d0 --- /dev/null +++ b/calculator/execute.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# need to be defined for different benchmark apks +activity="com.android.calculator2/.Calculator" +apk_file_name="" +test_method="python vc.py" +apk_package="com.android.calculator2" + +# following should no need to modify +parent_dir=`dirname ${0}` +source "${parent_dir}/../common/common.sh" +main "$@" diff --git a/calculator/vc.py b/calculator/vc.py new file mode 100755 index 0000000..dad9846 --- /dev/null +++ b/calculator/vc.py @@ -0,0 +1,44 @@ +# Author: Botao Sun <botao.sun@linaro.org> 1 +import sys +import time +import commands +from subprocess import call +from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException + +return_word = "" +testcase = "calculator" +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) + +for i in range(0, 10): + try: + return_word = vc.findViewByIdOrRaise("com.android.calculator2:id/digit" + str(i)).getText() + if return_word != str(i): + run_result = "fail" + print "Number " + str(i) + " can not be found in " + testcase + print testcase + " Test FAILED!" + collect_score(testcase, run_result) + sys.exit(1) + else: + print "Number " + str(i) + " found!" + positive_counter = positive_counter + 1 + except ViewNotFoundException: + run_result = "fail" + print "View can not be found! Fatal!" + print testcase + " Test FAILED!" + collect_score(testcase, run_result) + sys.exit(1) + +if positive_counter != 10: + print "Test count failed! Please check the screen!" + run_result = "fail" + collect_score(testcase, run_result) +else: + print testcase + " Test PASSED!" + run_result = "pass" + collect_score(testcase, run_result) |