Skip to content

Commit 0a2c95f

Browse files
committed
Merge branch 'master' into find-views-containing-point
2 parents 62801f6 + 1bfc683 commit 0a2c95f

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

AndroidViewClient/src/com/dtmilano/android/viewclient.py

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

20-
__version__ = '2.3.18'
20+
__version__ = '2.3.19'
2121

2222
import sys
2323
import subprocess
@@ -940,7 +940,7 @@ class ViewClient:
940940
No service is started.
941941
'''
942942

943-
def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse=False, localport=VIEW_SERVER_PORT, remoteport=VIEW_SERVER_PORT, startviewserver=True):
943+
def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse=False, localport=VIEW_SERVER_PORT, remoteport=VIEW_SERVER_PORT, startviewserver=True, ignoreuiautomatorkilled=False):
944944
'''
945945
Constructor
946946
@@ -962,6 +962,8 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
962962
emulator
963963
@type startviewserver: boolean
964964
@param startviewserver: Whether to start the B{global} ViewServer
965+
@type ignoreuiautomatorkilled: boolean
966+
@param ignoreuiautomatorkilled: Ignores received B{Killed} message from C{uiautomator}
965967
'''
966968

967969
if not device:
@@ -1034,6 +1036,11 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
10341036
''' Force the use of ViewServer even if the conditions to use UiAutomator are satisfied '''
10351037
self.useUiAutomator = (self.build[VERSION_SDK_PROPERTY] >= 16) and not forceviewserveruse # jelly bean 4.1 & 4.2
10361038
''' If UIAutomator is supported by the device it will be used '''
1039+
self.ignoreUiAutomatorKilled = ignoreuiautomatorkilled
1040+
''' On some devices (i.e. Nexus 7 running 4.2.2) uiautomator is killed just after generating
1041+
the dump file. In many cases the file is already complete so we can ask to ignore the 'Killed'
1042+
message by setting L{ignoreuiautomatorkilled} to C{True}
1043+
'''
10371044

10381045
if self.useUiAutomator:
10391046
self.textProperty = TEXT_PROPERTY_UI_AUTOMATOR
@@ -1638,7 +1645,10 @@ def dump(self, window=-1, sleep=1):
16381645
if not output:
16391646
raise RuntimeError('ERROR: Getting UIAutomator dump')
16401647
if not re.search('dumped', output):
1641-
raise RuntimeError("ERROR: UIAutomator dump output doesn't contain 'dumped' (%s)" % output)
1648+
if re.search('Killed', output) and self.ignoreUiAutomatorKilled:
1649+
pass
1650+
else:
1651+
raise RuntimeError("ERROR: UIAutomator dump output doesn't contain 'dumped' (%s)" % output)
16421652
received = self.device.shell('cat %s 2>/dev/null' % windowDump)
16431653
if received:
16441654
received = received.encode('ascii', 'ignore')

AndroidViewClient/tools/culebra

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ___________________/ /__/ /__/ /__/ /________________________________
2222

2323
'''
2424

25-
__version__ = '0.9.10'
25+
__version__ = '0.9.11'
2626

2727
import re
2828
import sys
@@ -324,7 +324,7 @@ except getopt.GetoptError, e:
324324
usage()
325325

326326
kwargs1 = {VERBOSE: False, 'ignoresecuredevice': False}
327-
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False}
327+
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False, 'ignoreuiautomatorkilled': True}
328328
options = {FIND_VIEWS_BY_ID: True, FIND_VIEWS_WITH_TEXT: False, FIND_VIEWS_WITH_CONTENT_DESCRIPTION: False,
329329
USE_REGEXPS: False, VERBOSE_COMMENTS: False,
330330
UNIT_TEST: False, USE_JAR: True, USE_DICTIONARY: False, DICTIONARY_KEYS_FROM: 'id',
@@ -436,19 +436,21 @@ print '''\
436436
from com.dtmilano.android.viewclient import ViewClient
437437

438438
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
439-
440-
device, serialno = ViewClient.connectToDeviceOrExit()
441-
''',
439+
440+
kwargs1 = %s
441+
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
442+
''' % kwargs1,
442443

443444
if options[START_ACTIVITY]:
444445
print '''\
445446
device.startActivity(component='%s')
446447
''' % options[START_ACTIVITY],
447448

448449
print '''\
449-
vc = ViewClient(device, serialno, autodump=False)
450+
kwargs2 = %s
451+
vc = ViewClient(device, serialno, **kwargs2)
450452
vc.dump(window=%s)
451-
''' % getWindowOption()
453+
''' % (kwargs2, getWindowOption())
452454

453455
if options[USE_DICTIONARY]:
454456
print '''views = dict()'''

AndroidViewClient/tools/dump

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Created on Feb 3, 2012
66
@author: diego
77
'''
88

9-
__version__ = '0.9.8'
9+
__version__ = '0.9.11'
1010

1111
import sys
1212
import os
@@ -111,7 +111,7 @@ except getopt.GetoptError, e:
111111
usage()
112112

113113
kwargs1 = {VERBOSE: False, 'ignoresecuredevice': False}
114-
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False}
114+
kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': False, 'ignoreuiautomatorkilled': True}
115115
options = {WINDOW: -1}
116116
transform = ViewClient.TRAVERSE_CIT
117117
for o, a in opts:

0 commit comments

Comments
 (0)