Skip to content

Commit f68cb27

Browse files
committed
Add culebra-calculator-simple-test example
1 parent 1469df7 commit f68cb27

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed
Loading
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#! /usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Copyright (C) 2013-2022 Diego Torres Milano
5+
Created on 2023-09-03 by Culebra v22.6.0
6+
__ __ __ __
7+
/ \ / \ / \ / \
8+
____________________/ __\/ __\/ __\/ __\_____________________________
9+
___________________/ /__/ /__/ /__/ /________________________________
10+
| / \ / \ / \ / \ \___
11+
|/ \_/ \_/ \_/ \ o \
12+
\_____/--<
13+
@author: Diego Torres Milano
14+
@author: Jennifer E. Swofford (ascii art snake)
15+
"""
16+
17+
18+
import os
19+
import re
20+
import sys
21+
import time
22+
23+
from com.dtmilano.android.viewclient import ViewClient, KEY_EVENT
24+
25+
26+
TAG = 'CULEBRA'
27+
_s = 5
28+
_v = '--verbose' in sys.argv
29+
pid = os.getpid()
30+
31+
32+
kwargs1 = {'verbose': False, 'ignoresecuredevice': False, 'ignoreversioncheck': False}
33+
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
34+
35+
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False, 'ignoreuiautomatorkilled': True, 'compresseddump': True, 'useuiautomatorhelper': True, 'debug': {}}
36+
vc = ViewClient(device, serialno, **kwargs2)
37+
38+
helper = vc.uiAutomatorHelper
39+
40+
obj_ref = helper.until.find_object(body={'checkable': False,
41+
'checked': None,
42+
'clazz': 'android.widget.ImageButton',
43+
'clickable': True,
44+
'depth': None,
45+
'desc': '3',
46+
'has_child': None,
47+
'has_descendant': None,
48+
'index': None,
49+
'instance': None,
50+
'pkg': 'com.google.android.calculator',
51+
'res': 'com.google.android.calculator:id/digit_3',
52+
'scrollable': None,
53+
'text': ''})
54+
response = helper.ui_device.wait(oid=obj_ref.oid)
55+
helper.ui_object2.click(oid=response['oid'])
56+
helper.ui_device.wait_for_window_update()
57+
58+
obj_ref = helper.until.find_object(body={'checkable': False,
59+
'checked': None,
60+
'clazz': 'android.widget.ImageButton',
61+
'clickable': True,
62+
'depth': None,
63+
'desc': 'multiply',
64+
'has_child': None,
65+
'has_descendant': None,
66+
'index': None,
67+
'instance': None,
68+
'pkg': 'com.google.android.calculator',
69+
'res': 'com.google.android.calculator:id/op_mul',
70+
'scrollable': None,
71+
'text': ''})
72+
response = helper.ui_device.wait(oid=obj_ref.oid)
73+
helper.ui_object2.click(oid=response['oid'])
74+
helper.ui_device.wait_for_window_update()
75+
76+
obj_ref = helper.until.find_object(body={'checkable': False,
77+
'checked': None,
78+
'clazz': 'android.widget.ImageButton',
79+
'clickable': True,
80+
'depth': None,
81+
'desc': '2',
82+
'has_child': None,
83+
'has_descendant': None,
84+
'index': None,
85+
'instance': None,
86+
'pkg': 'com.google.android.calculator',
87+
'res': 'com.google.android.calculator:id/digit_2',
88+
'scrollable': None,
89+
'text': ''})
90+
response = helper.ui_device.wait(oid=obj_ref.oid)
91+
helper.ui_object2.click(oid=response['oid'])
92+
helper.ui_device.wait_for_window_update()
93+
94+
obj_ref = helper.until.find_object(body={'checkable': False,
95+
'checked': None,
96+
'clazz': 'android.widget.ImageButton',
97+
'clickable': True,
98+
'depth': None,
99+
'desc': 'equals',
100+
'has_child': None,
101+
'has_descendant': None,
102+
'index': None,
103+
'instance': None,
104+
'pkg': 'com.google.android.calculator',
105+
'res': 'com.google.android.calculator:id/eq',
106+
'scrollable': None,
107+
'text': ''})
108+
response = helper.ui_device.wait(oid=obj_ref.oid)
109+
helper.ui_object2.click(oid=response['oid'])
110+
helper.ui_device.wait_for_window_update()
111+
112+
assert helper.ui_device.has_object(body={'checkable': False,
113+
'checked': None,
114+
'clazz': 'android.widget.TextView',
115+
'clickable': False,
116+
'depth': None,
117+
'desc': '',
118+
'has_child': None,
119+
'has_descendant': None,
120+
'index': None,
121+
'instance': None,
122+
'pkg': 'com.google.android.calculator',
123+
'res': 'com.google.android.calculator:id/result_final',
124+
'scrollable': None,
125+
'text': '6'})
126+
127+
obj_ref = helper.until.find_object(body={'checkable': False,
128+
'checked': None,
129+
'clazz': 'android.widget.ImageButton',
130+
'clickable': True,
131+
'depth': None,
132+
'desc': 'clear',
133+
'has_child': None,
134+
'has_descendant': None,
135+
'index': None,
136+
'instance': None,
137+
'pkg': 'com.google.android.calculator',
138+
'res': 'com.google.android.calculator:id/clr',
139+
'scrollable': None,
140+
'text': ''})
141+
response = helper.ui_device.wait(oid=obj_ref.oid)
142+
helper.ui_object2.click(oid=response['oid'])
143+
helper.ui_device.wait_for_window_update()

0 commit comments

Comments
 (0)