summaryrefslogtreecommitdiff
path: root/automated/android/apk-automation/benchmarkpi.py
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-03-30 18:54:46 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-04-28 09:50:02 +0000
commitab48dcadc4eb74a126a8d76bece720ab000b1452 (patch)
tree4cf508236cf2cf8d44ff2552bf7b2d7a6fdee58b /automated/android/apk-automation/benchmarkpi.py
parentd92cc5a7e7461e7fe493a3a1be0bbdc7a94f9892 (diff)
automated: android: add refactored apk-automation
Change-Id: I5a81b3c4317dc56f90df37c5a8f83d2547542fab Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Diffstat (limited to 'automated/android/apk-automation/benchmarkpi.py')
-rwxr-xr-xautomated/android/apk-automation/benchmarkpi.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/automated/android/apk-automation/benchmarkpi.py b/automated/android/apk-automation/benchmarkpi.py
new file mode 100755
index 0000000..94e198d
--- /dev/null
+++ b/automated/android/apk-automation/benchmarkpi.py
@@ -0,0 +1,53 @@
+import sys
+import time
+from common import ApkTestRunner
+from com.dtmilano.android.viewclient import ViewNotFoundException
+
+
+class ApkRunnerImpl(ApkTestRunner):
+ def __init__(self, config):
+ self.config = config
+ self.config['apk_file_name'] = "gr.androiddev.BenchmarkPi-1.apk"
+ self.config['apk_package'] = "gr.androiddev.BenchmarkPi"
+ self.config['activity'] = "gr.androiddev.BenchmarkPi/.BenchmarkPi"
+ super(ApkRunnerImpl, self).__init__(self.config)
+
+ def execute(self):
+ time.sleep(2)
+ self.dump_always()
+ start_button = self.vc.findViewByIdOrRaise("gr.androiddev.BenchmarkPi:id/Button01")
+ start_button.touch()
+
+ finished = False
+ while not finished:
+ time.sleep(1)
+ try:
+ self.vc.dump(window='-1')
+ self.vc.findViewByIdOrRaise("android:id/message")
+ finished = True
+ except ViewNotFoundException:
+ pass
+ except RuntimeError as e:
+ self.logger.error(e)
+ self.logger.info('benchmark pi finished')
+
+ def parseResult(self):
+ return_text = self.vc.findViewByIdOrRaise("android:id/message").getText().split(" ")
+
+ flagwordA = "calculated"
+ flagwordB = "Pi"
+
+ if flagwordA in return_text and flagwordB in return_text:
+ if return_text.index(flagwordB) == return_text.index(flagwordA) + 1:
+ score_number = return_text[return_text.index(flagwordA) + 3]
+ score_unit = return_text[return_text.index(flagwordA) + 4].split("!")[0]
+ self.logger.info('Valid test result found: %s %s' % (score_number, score_unit))
+ run_result = "pass"
+ else:
+ self.logger.error("Output string changed, parser need to be updated!")
+ sys.exit(1)
+ else:
+ self.logger.error("Can not find keyword which is supposed to show up!")
+ sys.exit(1)
+
+ self.report_result('benchmarkpi', run_result, score_number, score_unit)