本文整理汇总了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