zoukankan      html  css  js  c++  java
  • 【Python】Camera拍照休眠唤醒测试

    #!/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()
    
  • 相关阅读:
    树套树
    Luogu P2839 [国家集训队]middle
    苟随笔
    BJOI2014 大融合
    轻量树上问题选做
    sb的斜率优化笔记
    CDialogEx::OnPaint()的问题,或者为什么在对话框程序的OnPaint中绘图无效的问题
    VC6的工程转到VC2010或更高版本出现fatal error C1189编译错误的解决方法
    C语言实现的反转字符串
    在终端输入npm run serve时出现npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! test_vue_0613@1.0.0 dev: 错误的解决方法
  • 原文地址:https://www.cnblogs.com/wucaiyun1/p/11018037.html
Copyright © 2011-2022 走看看