summaryrefslogtreecommitdiff
path: root/automated/android/apk-automation/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'automated/android/apk-automation/test.py')
-rwxr-xr-xautomated/android/apk-automation/test.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/automated/android/apk-automation/test.py b/automated/android/apk-automation/test.py
new file mode 100755
index 0000000..28b7df2
--- /dev/null
+++ b/automated/android/apk-automation/test.py
@@ -0,0 +1,68 @@
+import re
+import sys
+import os
+import time
+from subprocess import call
+
+from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
+
+
+kwargs1 = {'verbose': False, 'ignoresecuredevice': False}
+device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
+kwargs2 = {'startviewserver': True, 'forceviewserveruse': False, 'autodump': False, 'ignoreuiautomatorkilled': True, 'compresseddump': False}
+vc = ViewClient(device, serialno, **kwargs2)
+
+def dump_always():
+ success = False
+ while not success:
+ try:
+ vc.dump()
+ success = True
+ except RuntimeError:
+ print("Got RuntimeError when call vc.dump()")
+ time.sleep(5)
+ except ValueError:
+ print("Got ValueError when call vc.dump()")
+ time.sleep(5)
+
+
+def get_score_with_text(vc, text):
+ found_score_view = False
+
+ while not found_score_view:
+ linear_layout = vc.findViewByIdOrRaise("com.redlicense.benchmark.sqlite:id/stats")
+ for ch in linear_layout.children:
+ subitem = vc.findViewWithText(text, ch)
+ if subitem:
+ subitem_result = vc.findViewByIdOrRaise("com.redlicense.benchmark.sqlite:id/test_result", ch)
+ score = subitem_result.getText().replace("sec", "").strip()
+ score_in_ms = float(score) * 1000
+ print "RL_sqlite_%s %s %s ms" % (text.replace(" ", "_"), 'pass', str(score_in_ms))
+ found_score_view = True
+ break
+ else:
+ print("%s not found, need to pageup" % text)
+ dump_always()
+ device.press('DPAD_UP')
+ time.sleep(2)
+ dump_always()
+ device.press('DPAD_UP')
+ time.sleep(2)
+ dump_always()
+
+dump_always()
+vc.findViewWithTextOrRaise(u'Overall').touch()
+get_score_with_text(vc, "Overall")
+get_score_with_text(vc, "DROP TABLE")
+get_score_with_text(vc, "DELETE with an index")
+get_score_with_text(vc, "DELETE without an index")
+get_score_with_text(vc, "INSERTs from a SELECT")
+get_score_with_text(vc, "25000 UPDATEs with an index")
+get_score_with_text(vc, "1000 UPDATEs without an index")
+get_score_with_text(vc, "5000 SELECTs with an index")
+get_score_with_text(vc, "Creating an index")
+get_score_with_text(vc, "100 SELECTs on a string comparison")
+get_score_with_text(vc, "100 SELECTs without an index")
+get_score_with_text(vc, "25000 INSERTs into an indexed table in a transaction")
+get_score_with_text(vc, "25000 INSERTs in a transaction")
+get_score_with_text(vc, "1000 INSERTs")