1818@author: Diego Torres Milano
1919'''
2020
21- __version__ = '11.1.0 '
21+ __version__ = '11.2.2 '
2222
2323import os
2424import subprocess
@@ -197,6 +197,12 @@ def __httpCommand(self, url, params=None, method='GET'):
197197 raise RuntimeError ("method not supported: " + method )
198198 return response .content
199199
200+ #
201+ # Device
202+ #
203+ def getDisplayRealSize (self ):
204+ return self .__httpCommand ('/Device/getDisplayRealSize' )
205+
200206 #
201207 # UiAutomatorHelper internal commands
202208 #
@@ -210,6 +216,16 @@ def quit(self):
210216 #
211217 # UiDevice
212218 #
219+ def click (self , x , y ):
220+ params = {'x' : x , 'y' : y }
221+ return self .__httpCommand ('/UiDevice/click' , params )
222+
223+ def dumpWindowHierarchy (self ):
224+ dump = self .__httpCommand ('/UiDevice/dumpWindowHierarchy' ).decode (encoding = 'UTF-8' , errors = 'replace' )
225+ if DEBUG :
226+ print >> sys .stderr , "DUMP: " , dump
227+ return dump
228+
213229 def findObject (self , resourceId ):
214230 if not resourceId :
215231 raise RuntimeError ('findObject: resourceId must have a value' )
@@ -221,23 +237,29 @@ def findObject(self, resourceId):
221237 return int ("0x" + m .group (1 ), 16 )
222238 raise RuntimeError ("Invalid response: " + response )
223239
224- def takeScreenshot (self , scale = 1.0 , quality = 90 ):
225- params = {'scale' : scale , 'quality' : quality }
226- return self .__httpCommand ('/UiDevice/takeScreenshot' , params )
240+ def pressBack (self ):
241+ return self .__httpCommand ('/UiDevice/pressBack' )
227242
228- def click (self , x , y ):
229- params = {'x' : x , 'y' : y }
230- return self .__httpCommand ('/UiDevice/click' , params )
243+ def pressHome (self ):
244+ return self .__httpCommand ('/UiDevice/pressHome' )
231245
232- def swipe (self , (x0 , y0 ), (x1 , y1 ), steps ):
233- params = {'x0' : x0 , 'y0' : y0 , 'x1' : x1 , 'y1' : y1 , 'steps' : steps }
246+ def pressKeyCode (self , keyCode , metaState = 0 ):
247+ params = {'keyCode' : keyCode , 'metaState' : metaState }
248+ return self .__httpCommand ('/UiDevice/pressKeyCode' , params )
249+
250+ def pressRecentApps (self ):
251+ return self .__httpCommand ('/UiDevice/pressRecentApps' )
252+
253+ def swipe (self , startX = - 1 , startY = - 1 , endX = - 1 , endY = - 1 , steps = 10 , segments = [], segmentSteps = 5 ):
254+ if startX != - 1 and startY != - 1 :
255+ params = {'startX' : startX , 'startY' : startY , 'endX' : endX , 'endY' : endY , 'steps' : steps }
256+ else :
257+ params = {'segments' : ',' .join (str (p ) for p in segments ), "segmentSteps" : segmentSteps }
234258 return self .__httpCommand ('/UiDevice/swipe' , params )
235259
236- def dumpWindowHierarchy (self ):
237- dump = self .__httpCommand ('/UiDevice/dumpWindowHierarchy' ).decode (encoding = 'UTF-8' , errors = 'replace' )
238- if DEBUG :
239- print >> sys .stderr , "DUMP: " , dump
240- return dump
260+ def takeScreenshot (self , scale = 1.0 , quality = 90 ):
261+ params = {'scale' : scale , 'quality' : quality }
262+ return self .__httpCommand ('/UiDevice/takeScreenshot' , params )
241263
242264 #
243265 # UiObject
0 commit comments