#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import sys
import time
rebootCount = int(input("请输入测试次数:"));
print ("你输入的次数是: ", rebootCount)
def copyright():
print("
")
print("Lenovo R&T automated testing script version 0.1")
def usage():
print("Usage : python " + sys.argv[0])
print(" Please turn on the device and make sure that you can use ADB Command.")
print("
")
def find_device():
# os.system('adb kill-serve')
# os.system('adb start-server')
# os.system('adb root')
# os.system('adb remount')
print("adb devices")
os.system('adb devices')
def open_camera():
print("打开相机:")
os.system('adb shell am start -a android.media.action.STILL_IMAGE_CAMERA')
def back():
print("返回")
os.system('adb shell input keyevent 4')
def backToHome():
print("返回主页")
os.system('adb shell input keyevent 3')
def menulist():
print("菜单")
os.system('adb shell input keyevent 82')
def vol_up():
print("音量加")
os.system('adb shell input keyevent 24')
def vol_dn():
print("音量减")
os.system('adb shell input keyevent 25')
def mute():
print("扬声器静音")
os.system('adb shell input keyevent 164')
def take_photo():
print("拍照")
os.system('adb shell input keyevent 27')
def get_log(name,count):
os.system('adb logcat -t 50000 > '+name+count+'.log')
def screen_downup():
os.system('adb shell input keyevent 26')
def power_downup():
os.system('adb shell sendevent /dev/input/event0 1 116 1')
os.system('adb shell sendevent /dev/input/event0 0 0 0')
os.system('adb shell sendevent /dev/input/event0 1 116 0')
os.system('adb shell sendevent /dev/input/event0 0 0 0')
E_BADARGS = 1
copyright()
usage()
find_device()
message = os.popen('adb devices').readlines()
print(message)
count=len(message)
if (count < 3):
print("can't find device|找不到设备")
sys.exit(E_BADARGS)
else: #打开相机拍照
for i in range(0,rebootCount):
open_camera()
time.sleep(10)
take_photo()
time.sleep(10)
back()
count=str(i)
get_log(name="take_photo",count=count)
print("take photo finish
")
#Camera一直开,休眠唤醒屏幕
for i in range(0,rebootCount):
open_camera()
time.sleep(10)
print("screen down up")
screen_downup()
time.sleep(10)
screen_downup()
time.sleep(10)
count=str(i)
get_log(name="screen_down_up",count=count)
print("screen_down_up finish
")
#Camera一直开,模拟按power键
# for i in range(1,5):
# open_camera()
# time.sleep(10)
# print("power down up")
# power_downup()
# time.sleep(10)
# power_downup()
# time.sleep(10)
# count=str(i)
# get_log(name="power_down_up",count=count)
# print("power_down_up finish
")
# back()
#Camera一直开,模拟按音量、静音键
for i in range(0,rebootCount):
open_camera()
time.sleep(10)
print("vol up")
vol_up()
time.sleep(10)
print("vol down")
vol_dn()
time.sleep(10)
mute()
count=str(i)
get_log(name="vol_down_up",count=count)
print("vol_down_up finish
")
backToHome()
menulist()
back()