Permalink
Browse files

Added more verbose output to UiAutomator 'dumped' error

- Version 2.3.6
- Added forceviewserveruse to viewclientconnected tests
- Added help, ignore-secure-device, force-viewserver-use nad
do-no-start-view-server options to dump.py
- Renamed test to viewclient-with-real-devices-connected
  • Loading branch information...
1 parent 5343b8e commit b645bd9549a96dfde7a3b266dab0361c041b1a8a @dtmilano committed Feb 4, 2013
@@ -28,8 +28,11 @@
from com.dtmilano.android.viewclient import ViewClient
+HELP = 'help'
VERBOSE = 'verbose'
+IGNORE_SECURE_DEVICE = 'ignore-secure-device'
FORCE_VIEW_SERVER_USE = 'force-view-server-use'
+DO_NOT_START_VIEW_SERVER = 'do-not-start-view-server'
UNIQUE_ID = 'uniqueId'
POSITION = 'position'
CONTENT_DESCRIPTION = 'content-description'
@@ -39,29 +42,36 @@
'd':ViewClient.TRAVERSE_CITCD, CONTENT_DESCRIPTION:ViewClient.TRAVERSE_CITCD,
'c':ViewClient.TRAVERSE_CITC, CENTER:ViewClient.TRAVERSE_CITC,
}
+LONG_OPTS = [HELP, VERBOSE, IGNORE_SECURE_DEVICE, FORCE_VIEW_SERVER_USE, DO_NOT_START_VIEW_SERVER,
+ UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER]
-def usage():
- print >> sys.stderr, 'usage: dump.py [-V|--%s] [-F|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
- (VERBOSE, FORCE_VIEW_SERVER_USE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
- sys.exit(1)
+def usage(exitVal=1):
+ print >> sys.stderr, 'usage: dump.py [-H|--%s] [-V|--%s] [-I|--%s] [-F|--%s] [-S|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
+ tuple(LONG_OPTS)
+ sys.exit(exitVal)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'VFuxdc',
- [VERBOSE, FORCE_VIEW_SERVER_USE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
+ opts, args = getopt.getopt(sys.argv[1:], 'HVIFSuxdc', LONG_OPTS)
except getopt.GetoptError, e:
print >>sys.stderr, 'ERROR:', str(e)
usage()
-verbose = False
-kwargs = {'forceviewserveruse': False}
+kwargs1 = {VERBOSE: False, 'ignoresecuredevice': False}
+kwargs2 = {'forceviewserveruse': False, 'startviewserver': True}
transform = ViewClient.TRAVERSE_CIT
for o, a in opts:
o = o.strip('-')
- if o in ['V', VERBOSE]:
- verbose = True
+ if o in ['H', HELP]:
+ usage(0)
+ elif o in ['V', VERBOSE]:
+ kwargs1[VERBOSE] = True
+ elif o in ['I', IGNORE_SECURE_DEVICE]:
+ kwargs1['ignoresecuredevice'] = True
elif o in ['F', FORCE_VIEW_SERVER_USE]:
- kwargs['forceviewserveruse'] = True
+ kwargs2['forceviewserveruse'] = True
+ elif o in ['S', DO_NOT_START_VIEW_SERVER]:
+ kwargs2['startviewserver'] = False
else:
transform = MAP[o]
-ViewClient(*ViewClient.connectToDeviceOrExit(verbose=verbose), **kwargs).traverse(transform=transform)
+ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2).traverse(transform=transform)
@@ -17,7 +17,7 @@
@author: diego
'''
-__version__ = '2.3.5'
+__version__ = '2.3.6'
import sys
import subprocess
@@ -1481,7 +1481,7 @@ def dump(self, windowId=-1, sleep=1):
if not output:
raise RuntimeError('ERROR: Getting UIAutomator dump')
if not re.search('dumped', output):
- raise RuntimeError("ERROR: UIAutomator dump doesn't containt 'dumped'")
+ raise RuntimeError("ERROR: UIAutomator dump output doesn't containt 'dumped' (%s)" % output)
received = self.device.shell('cat %s 2>/dev/null' % windowDump)
if received:
received = received.encode('ascii', 'ignore')
@@ -23,16 +23,17 @@
pass
from com.dtmilano.android.viewclient import *
+from mocks import MockDevice
-VERBOSE = False
+VERBOSE = True
# NOTE:
# Because there's no way of disconnect a MonkeyDevice and there's no
# either the alternative of connecting twice from the same script
# this is the only alternative
SERIALNO = 'emulator-5554'
sys.argv = ['ViewClientConnectedTest', SERIALNO]
-device, serialno = ViewClient.connectToDeviceOrExit(verbose=True)
+device, serialno = ViewClient.connectToDeviceOrExit(verbose=VERBOSE, serialno=SERIALNO)
class ViewClientConnectedTest(unittest.TestCase):
@@ -49,11 +50,11 @@ def tearDown(self):
def testInit_adbNone(self):
device = MockDevice()
- vc = ViewClient(device, adb=None, autodump=False)
+ vc = ViewClient(device, serialno, adb=None, autodump=False)
self.assertNotEqual(None, vc)
def testAutodumpVsDump(self):
- vc = ViewClient(self.device, self.serialno)
+ vc = ViewClient(self.device, self.serialno, forceviewserveruse=True)
ids = vc.getViewIds()
views = vc.dump()
self.assertEquals(len(ids), len(views))
@@ -65,7 +66,7 @@ def testNewViewClientInstancesDontDuplicateTreeConnected(self):
d = {}
for i in range(10):
- vc[i] = ViewClient(self.device, self.serialno)
+ vc[i] = ViewClient(self.device, self.serialno, forceviewserveruse=True)
n[i] = len(vc[i].getViewIds())
m[i] = len(vc[i].dump())
d[i] = len(vc[i].getViewIds())

0 comments on commit b645bd9

Please sign in to comment.