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