Skip to content

Commit

Permalink
Add culebra-calculator-simple-test example
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmilano committed Sep 4, 2023
1 parent 1469df7 commit f68cb27
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
143 changes: 143 additions & 0 deletions examples/helper/culebra/culebra-calculator-simple-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit f68cb27

Please sign in to comment.