Skip to content

Commit c2a9bee

Browse files
committed
Added new methods.
- Version 2.3.18 - Added ViewClient.sleep() & ViewClient.isKeyboardDown() - Added adb field
1 parent ef7dfcc commit c2a9bee

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@author: diego
1818
'''
1919

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

2222
import sys
2323
import subprocess
@@ -957,6 +957,8 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
957957
else:
958958
adb = ViewClient.__obtainAdbPath()
959959

960+
self.adb = adb
961+
''' The adb command '''
960962
self.root = None
961963
''' The root node '''
962964
self.viewsById = {}
@@ -1033,7 +1035,7 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
10331035
self.localPort = localport
10341036
self.remotePort = remoteport
10351037
# FIXME: it seems there's no way of obtaining the serialno from the MonkeyDevice
1036-
subprocess.check_call([adb, '-s', self.serialno, 'forward', 'tcp:%d' % self.localPort,
1038+
subprocess.check_call([self.adb, '-s', self.serialno, 'forward', 'tcp:%d' % self.localPort,
10371039
'tcp:%d' % self.remotePort])
10381040

10391041
self.windows = None
@@ -1315,6 +1317,10 @@ def traverseShowClassIdTextPositionAndSize(view):
13151317
TRAVERSE_CITPS = traverseShowClassIdTextPositionAndSize
13161318
''' An alias for L{traverseShowClassIdTextPositionAndSize(view)} '''
13171319

1320+
@staticmethod
1321+
def sleep(secs=1):
1322+
time.sleep(secs)
1323+
13181324
def assertServiceResponse(self, response):
13191325
'''
13201326
Checks whether the response received from the server is correct or raises and Exception.
@@ -1955,7 +1961,22 @@ def __getFocusedWindowPosition(self):
19551961
return self.__getFocusedWindowId()
19561962

19571963
def getSdkVersion(self):
1964+
'''
1965+
Gets the SDK version.
1966+
'''
1967+
19581968
return self.build[VERSION_SDK_PROPERTY]
1969+
1970+
def isKeyboardShown(self):
1971+
'''
1972+
Whether the keyboard is displayed.
1973+
'''
1974+
1975+
dim = self.device.shell('dumpsys input_method')
1976+
if dim:
1977+
# FIXME: API >= 15 ?
1978+
return "mInputShown=true" in dim
1979+
return False
19591980

19601981

19611982
if __name__ == "__main__":

0 commit comments

Comments
 (0)