Skip to content

Commit 55ae6ba

Browse files
committed
Fixed concertina default probability values
- Added concertina debug option
1 parent 8bc2adf commit 55ae6ba

6 files changed

Lines changed: 38 additions & 21 deletions

File tree

src/com/dtmilano/android/common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020

2121
__version__ = '15.2.4'
2222

23+
import ast
2324
import os
2425
import platform
26+
import re
2527

2628

2729
def _nd(name):
@@ -183,3 +185,21 @@ def profileEnd():
183185
print >> sys.stderr, '.' * 60
184186
print >> sys.stderr, "STATS:\n", s.getvalue()
185187
print >> sys.stderr, '.' * 60
188+
189+
190+
def debugArgsToDict(a):
191+
"""
192+
Converts a string representation of debug arguments to a dictionary.
193+
The string can be of the form
194+
195+
IDENTIFIER1=val1,IDENTIFIER2=val2
196+
197+
198+
:param a: the argument string
199+
:return: the dictionary
200+
201+
"""
202+
s = a.replace('+', ' ')
203+
s = s.replace('=', ':')
204+
s = re.sub(r'([A-Z][A-Z_]+)', r"'\1'", s)
205+
return ast.literal_eval('{ ' + s + ' }')

src/com/dtmilano/android/concertina.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def readConcertinaConfig(concertinaConfigFile):
267267
config['limits']['maxNoTargetViewsIterations'] = 25
268268
if 'probabilities' not in config:
269269
config['probabilities'] = dict()
270-
config['probabilities']['systemKeys'] = 1 / 6
271-
config['probabilities']['views'] = 5 / 6
270+
config['probabilities']['systemKeys'] = 1 / 6.0
271+
config['probabilities']['views'] = 5 / 6.0
272272
if 'systemKeys' not in config:
273273
config['systemKeys'] = dict()
274274
config['systemKeys']['keys'] = ['ENTER', 'BACK', 'HOME', 'MENU']

src/com/dtmilano/android/culebron.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ def __init__(self, vc, device, serialno, printOperation, scale=1, concertina=Fal
238238
'''
239239

240240
self.vc = vc
241+
if 'CONCERTINA' in self.vc.debug:
242+
global DEBUG_CONCERTINA
243+
DEBUG_CONCERTINA = self.vc.debug['CONCERTINA'] is not None
241244
self.printOperation = printOperation
242245
self.device = device
243246
self.sdkVersion = device.getSdkVersion()

src/com/dtmilano/android/viewclient.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '15.2.4'
21+
__version__ = '15.3.0'
2222

2323
import sys
2424
import warnings
@@ -2431,6 +2431,7 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
24312431
self.uiAutomatorHelper = None
24322432
''' The UiAutomatorHelper '''
24332433

2434+
self.debug = debug
24342435
if debug:
24352436
if 'DEVICE' in debug:
24362437
global DEBUG_DEVICE
@@ -4376,7 +4377,7 @@ class CulebraOptions:
43764377
CONCERTINA_CONFIG = 'concertina-config'
43774378
INSTALL_APK = 'install-apk'
43784379

4379-
SHORT_OPTS = 'HVvIEFSkw:i:t:d:rCUM:j:D:K:R:a:o:pf:W:GuP:Os:mLA:ZB0hcJ:1:'
4380+
SHORT_OPTS = 'HVvIEFSkw:i:t:d:rCUM:j:D:K:R:a:o:pf:W:GuP:Os:mLA:ZB0hcJ:1:X:'
43804381
LONG_OPTS = [HELP, VERBOSE, VERSION, IGNORE_SECURE_DEVICE, IGNORE_VERSION_CHECK, FORCE_VIEW_SERVER_USE,
43814382
DO_NOT_START_VIEW_SERVER,
43824383
DO_NOT_IGNORE_UIAUTOMATOR_KILLED,
@@ -4400,6 +4401,7 @@ class CulebraOptions:
44004401
CONCERTINA,
44014402
CONCERTINA_CONFIG + '=',
44024403
INSTALL_APK + '=',
4404+
'debug' + '=',
44034405
]
44044406
LONG_OPTS_ARG = {WINDOW: 'WINDOW',
44054407
FIND_VIEWS_BY_ID: 'BOOL', FIND_VIEWS_WITH_TEXT: 'BOOL', FIND_VIEWS_WITH_CONTENT_DESCRIPTION: 'BOOL',
@@ -4412,7 +4414,8 @@ class CulebraOptions:
44124414
SERIALNO: 'LIST',
44134415
DEVICE_ART: 'MODEL',
44144416
CONCERTINA_CONFIG: 'FILENAME',
4415-
INSTALL_APK: 'FILENAME'}
4417+
INSTALL_APK: 'FILENAME',
4418+
'debug': 'LIST',}
44164419
OPTS_HELP = {
44174420
'H': 'prints this help',
44184421
'V': 'verbose comments',
@@ -4450,6 +4453,7 @@ class CulebraOptions:
44504453
'c': 'enable concertina mode (EXPERIMENTAL)',
44514454
'J': 'concertina config file (JSON)',
44524455
'1': 'install APK as precondition (use with -U)',
4456+
'X': 'debug options',
44534457
}
44544458

44554459
class CulebraTestCase(unittest.TestCase):

tools/culebra

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ except:
3939
from com.dtmilano.android.viewclient import ViewClient, ViewClientOptions, View, CulebraOptions
4040
from com.dtmilano.android.culebron import Culebron, Operation, Unit
4141
from com.dtmilano.android.concertina import Concertina
42+
from com.dtmilano.android.common import debugArgsToDict
4243

4344
DEBUG = False
4445
USAGE = 'usage: %s [OPTION]... [serialno]'
@@ -1109,7 +1110,7 @@ progname = os.path.basename(sys.argv[0])
11091110
try:
11101111
optlist, args = getopt.getopt(sys.argv[1:], CulebraOptions.SHORT_OPTS, CulebraOptions.LONG_OPTS)
11111112
sys.argv[1:] = args
1112-
except getopt.GetoptError, e:
1113+
except getopt.GetoptError as e:
11131114
error(str(e))
11141115
usage()
11151116

@@ -1119,6 +1120,7 @@ kwargs2 = {ViewClientOptions.FORCE_VIEW_SERVER_USE: False, ViewClientOptions.STA
11191120
ViewClientOptions.AUTO_DUMP: False, ViewClientOptions.IGNORE_UIAUTOMATOR_KILLED: True,
11201121
ViewClientOptions.COMPRESSED_DUMP: True,
11211122
ViewClientOptions.USE_UIAUTOMATOR_HELPER: False,
1123+
ViewClientOptions.DEBUG: {},
11221124
}
11231125
options = {CulebraOptions.FIND_VIEWS_BY_ID: True, CulebraOptions.FIND_VIEWS_WITH_TEXT: True,
11241126
CulebraOptions.FIND_VIEWS_WITH_CONTENT_DESCRIPTION: True,
@@ -1244,6 +1246,8 @@ for o, a in optlist:
12441246
concertinaConfigHelp()
12451247
elif o in ['1', CulebraOptions.INSTALL_APK]:
12461248
options[CulebraOptions.INSTALL_APK] = a
1249+
elif o in ['X', ViewClientOptions.DEBUG]:
1250+
kwargs2[ViewClientOptions.DEBUG] = debugArgsToDict(a)
12471251

12481252
if not (options[CulebraOptions.FIND_VIEWS_BY_ID] or options[CulebraOptions.FIND_VIEWS_WITH_TEXT] or options[
12491253
CulebraOptions.FIND_VIEWS_WITH_CONTENT_DESCRIPTION]):

tools/dump

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ Created on Feb 3, 2012
88

99
__version__ = '15.2.4'
1010

11-
import ast
1211
import getopt
1312
import os
14-
import re
1513
import sys
1614

1715
try:
@@ -20,6 +18,7 @@ except:
2018
pass
2119

2220
from com.dtmilano.android.viewclient import ViewClient, View, ViewClientOptions
21+
from com.dtmilano.android.common import debugArgsToDict
2322

2423
HELP = 'help'
2524
VERBOSE = 'verbose'
@@ -141,19 +140,6 @@ def version():
141140
sys.exit(0)
142141

143142

144-
def debugArgsToDict(a):
145-
'''
146-
Converts a string representation of debug arguments to a dictionary.
147-
The string can be of the form
148-
149-
IDENTIFIER1=val1,IDENTIFIER2=val2
150-
151-
'''
152-
s = a.replace('+', ' ')
153-
s = re.sub(r'([A-Z][A-Z_]+)', r"'\1'", s)
154-
return ast.literal_eval('{ ' + s + ' }')
155-
156-
157143
# __main__
158144
progname = os.path.basename(sys.argv[0])
159145
try:

0 commit comments

Comments
 (0)