【Android自动化】测试android手机唤醒性能测试

# -*- coding:utf-8 -*-
import time
import os
import common.common
from common.getconfigs import GetConfigs
from uiautomator import device as d

cfg = GetConfigs('11_unlockscreen')
dict_times = cfg.get_test_times()

def CheckPhoneStatus():
"""
Check the phone status first,if it not in suspend mode,will enter the suspend mode first and start the test.

"""
if d(packageName = 'com.tct.launcher',description = 'Apps').exists:
print 'The phone isn\'t in suspend mode,will lock it first'
LockPhone()

def UnlockPhone():
"""
Unlock the phone and check the phone whether enter the homepage base on the ALL Apps icon

"""
d.wakeup()
time.sleep(1)
if d(resourceId='com.android.systemui:id/lock_icon').exists:
d.swipe(397, 1165, 500, 500, steps=5)
time.sleep(1)
if d(description='Apps').exists:
print 'unlock successfully'
else:
print 'itn\'t unlock'
else:
print 'The phone unlock failed'

def LockPhone():
d.press('power')

def Run(key):
times = int(dict_times.get(key.lower(),0))
CheckPhoneStatus()
for i in range(times):
UnlockPhone()
time.sleep(2)
LockPhone()
time.sleep(2)
print i

if __name__ == '__main__':
Run('Lock')

猜你喜欢

转载自www.cnblogs.com/51study/p/9262266.html
今日推荐