11'''
2- Copyright (C) 2012 Diego Torres Milano
2+ Copyright (C) 2012-2013 Diego Torres Milano
33Created on Feb 2, 2012
44
55Licensed under the Apache License, Version 2.0 (the "License");
1414See the License for the specific language governing permissions and
1515limitations under the License.
1616
17- @author: diego
17+ @author: Diego Torres Milano
1818'''
1919
2020__version__ = '2.3.18'
9494
9595def __nd (name ):
9696 '''
97- @return: Returns a named decimal
97+ @return: Returns a named decimal regex
9898 '''
9999 return '(?P<%s>\d+)' % name
100100
101101def __nh (name ):
102102 '''
103- @return: Returns a named hex
103+ @return: Returns a named hex regex
104104 '''
105105 return '(?P<%s>[0-9a-f]+)' % name
106106
@@ -113,7 +113,7 @@ def __ns(name, greedy=False):
113113 @type greedy: bool
114114 @param greedy: Whether the regex is greedy or not
115115
116- @return: Returns a named string (only non-whitespace characters allowed)
116+ @return: Returns a named string regex (only non-whitespace characters allowed)
117117 '''
118118 return '(?P<%s>\S+%s)' % (name , '' if greedy else '?' )
119119
@@ -140,11 +140,11 @@ def __init__(self, num, winId, activity, wvx, wvy, wvw, wvh, px, py, visibility)
140140 @type wvw: int
141141 @param wvw: window's virtual width
142142 @type wvh: int
143+ @param wvh: window's virtual height
143144 @type px: int
144145 @param px: parent's X
145146 @type py: int
146147 @param py: parent's Y
147- @param wvh: window's virtual height
148148 @type visibility: int
149149 @param visibility: visibility of the window
150150 '''
@@ -168,6 +168,10 @@ def __str__(self):
168168
169169
170170class ViewNotFoundException (Exception ):
171+ '''
172+ ViewNotFoundException is raised when a View is not found.
173+ '''
174+
171175 def __init__ (self , attr , value , root ):
172176 if isinstance (value , org .python .modules .sre .PatternObject ):
173177 msg = "Couldn't find View with %s that matches '%s' in tree with root=%s" % (attr , value .pattern , root )
@@ -224,6 +228,7 @@ def __init__(self, map, device, version=-1, forceviewserveruse=False):
224228 ''' The parent of this View '''
225229 self .windows = {}
226230 self .currentFocus = None
231+ ''' The current focus '''
227232 self .build = {}
228233 ''' Build properties '''
229234
@@ -355,9 +360,9 @@ def __call__(self, *args, **kwargs):
355360
356361 def getClass (self ):
357362 '''
358- Gets the View class
363+ Gets the L{ View} class
359364
360- @return: the View class or None if not defined
365+ @return: the L{ View} class or C{ None} if not defined
361366 '''
362367
363368 try :
@@ -367,9 +372,9 @@ def getClass(self):
367372
368373 def getId (self ):
369374 '''
370- Gets the View Id
375+ Gets the L{ View} Id
371376
372- @return: the View Id or None if not defined
377+ @return: the L{ View} C{Id} or C{ None} if not defined
373378 @see: L{getUniqueId()}
374379 '''
375380
@@ -380,7 +385,7 @@ def getId(self):
380385
381386 def getContentDescription (self ):
382387 '''
383- Gets the content description
388+ Gets the content description.
384389 '''
385390
386391 try :
@@ -389,13 +394,17 @@ def getContentDescription(self):
389394 return None
390395
391396 def getParent (self ):
397+ '''
398+ Gets the parent.
399+ '''
400+
392401 return self .parent
393402
394403 def getText (self ):
395404 '''
396- Gets the text attribute
405+ Gets the text attribute.
397406
398- @return: the text attribute or None if not defined
407+ @return: the text attribute or C{ None} if not defined
399408 '''
400409
401410 try :
@@ -404,6 +413,10 @@ def getText(self):
404413 return None
405414
406415 def getHeight (self ):
416+ '''
417+ Gets the height.
418+ '''
419+
407420 if self .useUiAutomator :
408421 return self .map ['bounds' ][1 ][1 ] - self .map ['bounds' ][0 ][1 ]
409422 else :
@@ -413,6 +426,10 @@ def getHeight(self):
413426 return 0
414427
415428 def getWidth (self ):
429+ '''
430+ Gets the width.
431+ '''
432+
416433 if self .useUiAutomator :
417434 return self .map ['bounds' ][1 ][0 ] - self .map ['bounds' ][0 ][0 ]
418435 else :
@@ -568,6 +585,8 @@ def getXY(self):
568585 def getCoords (self ):
569586 '''
570587 Gets the coords of the View
588+
589+ @return: A tuple containing the View's coordinates (L, T, R, B)
571590 '''
572591
573592 if DEBUG_COORDS :
@@ -581,6 +600,8 @@ def getCoords(self):
581600 def getPositionAndSize (self ):
582601 '''
583602 Gets the position and size (X,Y, W, H)
603+
604+ @return: A tuple containing the View's coordinates (X, Y, W, H)
584605 '''
585606
586607 (x , y ) = self .getXY ();
@@ -1237,7 +1258,10 @@ def traverseShowClassIdAndText(view, extraInfo=None, noextrainfo=None):
12371258 @type view: I{View}
12381259 @param view: the View
12391260 @type extraInfo: method
1240- @param extraInfo: the View method to add extra info
1261+ @param extraInfo: the View method to add extra info
1262+ @type noextrainfo: bool
1263+ @param noextrainfo: Don't add extra info
1264+
12411265 @return: the string containing class, id, and text if available
12421266 '''
12431267
@@ -1318,7 +1342,13 @@ def traverseShowClassIdTextPositionAndSize(view):
13181342 ''' An alias for L{traverseShowClassIdTextPositionAndSize(view)} '''
13191343
13201344 @staticmethod
1321- def sleep (secs = 1 ):
1345+ def sleep (secs = 1.0 ):
1346+ '''
1347+ Sleeps for the specified number of seconds.
1348+
1349+ @type secs: float
1350+ @param secs: number of seconds
1351+ '''
13221352 time .sleep (secs )
13231353
13241354 def assertServiceResponse (self , response ):
@@ -1327,6 +1357,7 @@ def assertServiceResponse(self, response):
13271357
13281358 @type response: str
13291359 @param response: Response received from the server
1360+
13301361 @raise Exception: If the response received from the server is invalid
13311362 '''
13321363
@@ -1351,7 +1382,7 @@ def setViews(self, received):
13511382 Sets L{self.views} to the received value splitting it into lines.
13521383
13531384 @type received: str
1354- @param received: the string received from the I{View server }
1385+ @param received: the string received from the I{View Server }
13551386 '''
13561387
13571388 if not received or received == "" :
0 commit comments