本文整理匯總了Python中uiautomator.Device.checkConnected方法的典型用法代碼示例。如果您正苦於以下問題:Python Device.checkConnected方法的具體用法?Python Device.checkConnected怎麽用?Python Device.checkConnected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類uiautomator.Device
的用法示例。
在下文中一共展示了Device.checkConnected方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AdbDevice
# 需要導入模塊: from uiautomator import Device [as 別名]
# 或者: from uiautomator.Device import checkConnected [as 別名]
#.........這裏部分代碼省略.........
img.save(path, 'PNG')
def getCurrDisplay(self):
output = self.cmd.dumpsys(['display'])
match = re.search('mCurrentOrientation=(?P<orientation>[\d])[\w\d\s\(\),-=]+'
+ 'mCurrentDisplayRect=Rect\(0, 0 - (?P<width>[\d]+),\s+(?P<height>[\d]+)', output)
if match:
width = int(match.group('width'))
height = int(match.group('height'))
orientation = int(match.group('orientation'))
mode = 'landscape' if width > height else 'portrait'
return {'width': width, 'height': height, 'orientation': orientation, 'mode': mode}
def getRealDisplay(self):
output = self.cmd.dumpsys(['display'])
match = re.search('real\s(?P<width>[\d]+)\sx\s(?P<height>[\d]+)', output)
return {'width': int(match.group('width')), 'height': int(match.group('height'))}
def getProp(self, propType=None):
if propType:
return self.cmd.getProp(propType)
else:
return self.cmd.getProp(propType)
def uninstall(self, package):
self.cmd.uninstall(package)
def install(self, name):
self.cmd.install(name)
def close(self):
pass
def checkConnected(self):
return self.d.checkConnected()
def extractComponentName(self, packageName):
if packageName == 'com.google.android.youtube':
return 'com.google.android.youtube/.app.honeycomb.Shell$HomeActivity'
output = self.cmd.dumpsys(['package', packageName])
try:
if os.name == 'nt':
splitOutput = output.split('\r\r\n')
else:
splitOutput = output.split('\r\n')
num = splitOutput.index(next(x for x in splitOutput if x.find('android.intent.action.MAIN:') != -1))
if num != -1:
print splitOutput[num + 1]
return splitOutput[num + 1].split()[1]
else:
return None
except:
return None
def screenTimeout(self):
timeout = self.cmd.getSettings(['system', 'screen_off_timeout'])
return long(timeout) / 1000
def setScreenTimeout(self, value):
self.cmd.putSettings(['system', 'screen_off_timeout', value])
def isNfcOn(self):
match = re.search('mState=(on|off)', self.cmd.dumpsys(['nfc']))
if match:
if match.group(1) == 'on':
return True