Skip to content

Commit b9ad78c

Browse files
committed
Merge branch 'master' into find-views-containing-point
2 parents 192131b + 4309a48 commit b9ad78c

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

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

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

20-
__version__ = '2.3.20'
20+
__version__ = '2.3.21'
2121

2222
import sys
2323
import subprocess
@@ -1101,7 +1101,10 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
11011101
self.ignoreUiAutomatorKilled = ignoreuiautomatorkilled
11021102
''' On some devices (i.e. Nexus 7 running 4.2.2) uiautomator is killed just after generating
11031103
the dump file. In many cases the file is already complete so we can ask to ignore the 'Killed'
1104-
message by setting L{ignoreuiautomatorkilled} to C{True}
1104+
message by setting L{ignoreuiautomatorkilled} to C{True}.
1105+
1106+
Changes in 2.3.21 that uses C{/dev/tty} instead of a file may have turned this variable
1107+
unnnecessary, however it has been kept for backward compatibility.
11051108
'''
11061109

11071110
if self.useUiAutomator:
@@ -1701,26 +1704,12 @@ def dump(self, window=-1, sleep=1):
17011704
MonkeyRunner.sleep(sleep)
17021705

17031706
if self.useUiAutomator:
1704-
# FIXME: this might not be the path on some devices
1705-
windowDump = '/mnt/sdcard/window_dump.xml'
1706-
output = self.device.shell('uiautomator dump %s' % windowDump)
1707-
if not output:
1707+
# NOTICE:
1708+
# Using /dev/tty this works even on devices with no sdcard
1709+
received = self.device.shell('uiautomator dump /dev/tty >/dev/null')
1710+
if not received:
17081711
raise RuntimeError('ERROR: Getting UIAutomator dump')
1709-
if not re.search('dumped', output):
1710-
if re.search('Killed', output) and self.ignoreUiAutomatorKilled:
1711-
pass
1712-
else:
1713-
raise RuntimeError("ERROR: UIAutomator dump output doesn't contain 'dumped' (%s)" % output)
1714-
received = self.device.shell('cat %s 2>/dev/null' % windowDump)
1715-
if received:
1716-
received = received.encode('ascii', 'ignore')
1717-
else:
1718-
msg = ''
1719-
output = self.device.shell('mount')
1720-
if output:
1721-
if not re.search('sdcard', output):
1722-
msg = ", it seems there's no sdcard mounted and uiautomator creates dump there."
1723-
raise RuntimeError("ERROR: Received empty UIAutomator dump" + msg)
1712+
received = received.encode('ascii', 'ignore')
17241713
if DEBUG:
17251714
self.received = received
17261715
if DEBUG_RECEIVED:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dont-commit-*

AndroidViewClient/tests/com/dtmilano/android/mocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@ def shell(self, cmd):
541541

542542
m = re.match('uiautomator dump (\S+)', cmd)
543543
if m and self.version >= 16:
544-
return 'dumped %s' % m.group(1)
544+
# it was simulating a dump to sdcard before
545+
#return 'dumped %s' % m.group(1)
546+
return WINDOW_DUMP
545547
m = re.match('cat (\S+) .*', cmd)
546548
if m:
547549
return WINDOW_DUMP

0 commit comments

Comments
 (0)