本文整理匯總了Python中uiautomator.Device.wakeup方法的典型用法代碼示例。如果您正苦於以下問題:Python Device.wakeup方法的具體用法?Python Device.wakeup怎麽用?Python Device.wakeup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類uiautomator.Device
的用法示例。
在下文中一共展示了Device.wakeup方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Mobile
# 需要導入模塊: from uiautomator import Device [as 別名]
# 或者: from uiautomator.Device import wakeup [as 別名]
class Mobile():
"""
"""
def __init__(self, android_serial = None):
# logger.info("Importing Android library")
# print "Importing Android library"
# clm.message("Importing Android library")
self.adb = ADB(android_serial)
self.device = Device(android_serial)
self.test_helper = TestHelper(android_serial)
def set_serial(self, android_serial):
"""
Set device serial
"""
self.adb = ADB(android_serial)
self.device = Device(android_serial)
self.test_helper = TestHelper(android_serial)
def get_info(self):
"""
Retrieve the device info
"""
return self.device.info
#Key Event Actions of the device
"""
Turn on/off screen
"""
def turn_on_screen(self):
"""
Turn on screen
"""
self.device.screen.on()
def turn_off_screen(self):
"""
Turn off screen
"""
self.device.screen.off()
def wakeup_the_device(self):
"""
wakeup the device
"""
self.device.wakeup()
"""
Press hard/soft key
"""
def press_key(self, *key):
"""
press *key* keycode
"""
self.device.press(*key)
def press_home(self):
"""
press home key
"""
self.device.press.home()
def press_back(self):
"""
press back key
"""
self.device.press.back()
def press_left(self):
"""
press left key
"""
self.device.pres.left()
def press_right(self):
"""
press right key
"""
self.device.press.right()
def press_up(self):
"""
press up key
"""
self.device.press.up()
def press_down(self):
"""
press down key
"""
self.device.press.down()
def press_center(self):
"""
press center key
"""
self.device.press.center()
#.........這裏部分代碼省略.........
示例2: enable_developer_setting
# 需要導入模塊: from uiautomator import Device [as 別名]
# 或者: from uiautomator.Device import wakeup [as 別名]
from uiautomator import Device
import utility.common as u
def enable_developer_setting(self, name):
checkbox = self(className="android.widget.ListView",resourceId="android:id/list").\
child_by_text(name,className="android.widget.LinearLayout").\
child(className="android.widget.CheckBox")
if checkbox.checked == False:
print (name + " is not enabled, enabling it")
checkbox.click()
else:
print(name + " enabled")
def ChangeDeveloper_settings(self):
package = 'com.android.settings'
activity = '.DevelopmentSettings'
component_name = package + '/' + activity
u.start_activity(self,component_name)
self.wait.update()
enable_developer_setting(self,u'Stay awake')
enable_developer_setting(self,u'Allow mock locations')
if __name__ == '__main__':
d = Device()
d.wakeup()
# Press the HOME button to start the test from the home screen
d.press.home()
ChangeDeveloper_settings(d)
# Press the HOME button to start the test from the home screen
# d.press.home()
示例3: ModelInfo
# 需要導入模塊: from uiautomator import Device [as 別名]
# 或者: from uiautomator.Device import wakeup [as 別名]
class ModelInfo():
'''
classdocs
'''
def __init__(self, deviceserial):
'''
Constructor
'''
#sndLog = CLS("test", "test")
self.osType = sys.platform
self.mstrInfo = {}
#self.devSerials = self.instAdb.device_serial()
self.mstrDevice = Device(deviceserial)
self.mstrInfo = self.mstrDevice.info
'''
DEVICE Infoamtions
{ u'displayRotation': 0,
u'displaySizeDpY': 640,
u'displaySizeDpX': 360,
u'currentPackageName': u'com.android.launcher',
u'productName': u'takju',
u'displayWidth': 720,
u'sdkInt': 18,
u'displayHeight': 1184,
u'naturalOrientation': True
}
'''
def getCurrntProductInfo(self):
return self.mstrInfo
def getProductNmae(self):
return self.mstrInfo['productName']
def getCurrntPkg(self):
return self.mstrInfo['currentPackageName']
def getSDKInt(self):
return self.mstrInfo['sdkInt']
def getRotation(self):
return self.mstrInfo['displayRotation']
def getNaturalOri(self):
return self.mstrInfo['naturalOrientation']
def getDisplayState(self):
return self.mstrDevice.screen
def setReflash(self):
pass
#define Key activity
def setDevScrnOn(self):
self.mstrDevice.screen.on()
def setMstDevScrnOff(self):
self.mstrDevice.screen.off()
def setWakeup(self):
self.mstrDevice.wakeup()
def setSleep(self):
self.mstrDevice.sleep()
#Hard key Soft key
def pressHome(self):
return self.mstrDevice.press.home()
def pressBack(self):
return self.mstrDevice.press.back()
######################################################################
def pressLeft(self):
return self.mstrDevice.press.left()
def pressRight(self):
return self.mstrDevice.press.right()
def pressUp(self):
return self.mstrDevice.press.up()
def pressDown(self):
return self.mstrDevice.press.down()
def pressCenter(self):
return self.mstrDevice.press.center()
######################################################################
def pressMenu(self):
#.........這裏部分代碼省略.........
示例4: UiTestLib
# 需要導入模塊: from uiautomator import Device [as 別名]
# 或者: from uiautomator.Device import wakeup [as 別名]
class UiTestLib(object):
"""Ui Test Lib
"""
def __init__(self, serial=None):
"""
"""
logger.info("<p>Device=%s>" % serial, html=True)
print "<p>Device=%s>" % serial
self._result = ""
self.starttime = 0
self.d = Device(serial)
self.adb = Adb(serial)
self.debug = "True"
def set_debugable(flag):
self.debug = flag
def set_serial(self, serial):
"""Specify given *serial* device to perform test.
or export ANDROID_SERIAL=CXFS42343 if you have many devices connected but you don't use this
interface
When you need to use multiple devices, do not use this keyword to switch between devices in test execution.
And set the serial to each library.
Using different library name when importing this library according to
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.5.
Examples:
| Setting | Value | Value | Value |
| Library | UiTestLib | WITH NAME | Mobile1 |
| Library | UiTestLib | WITH NAME | Mobile2 |
And set the serial to each library.
| Test Case | Action | Argument |
| Multiple Devices | Mobile1.Set Serial | device_1's serial |
| | Mobile2.Set Serial | device_2's serial |
"""
self.d = Device(serial)
self.adb = Adb(serial)
def logmsg(self, msg):
if self.debug == "True":
print msg
def exe_adb_command(self, cmd):
""" Execute adb *cmd*
Examples:
| Exe Adb Command | shell getprop |
"""
return self.adb.cmd(cmd).wait()
def exe_adb_and_result(self, cmd):
"""Execute adb *cmd* and return lines of the command"""
lproc = self.adb.cmd(cmd)
lproc.poll()
lines = lproc.stdout.readlines()
return lines
def get_device_info(self):
"""Get Device information
return info dictionary
"""
return self.d.info
def light_screen(self):
"""Light screen by wakeup.
Examples:
| Action |
|Light screen|
Use `Light screen` to light screen.
"""
self.d.wakeup()
self._result = self.d.press.home()
def open_application(self, appname):
"""Open application by it name `appname`.
Example:
| Action | Argument |
| Open application | "com.android.settings/com.android.settings.Settings" |
"""
appname = "shell am start -n " + appname
print "Open Application:", appname
self._result = self.exe_adb_command(appname)
def click_text(self, text, instance=0):
"""Click text label on screen
instance=0 is default, change when you needed.
Example:
| Action | Argument | Argument |
| Click Text | text | instance |
"""
return self.d(text=text, instance=instance).click.wait()
#.........這裏部分代碼省略.........