# -*- coding:UTF-8 -*-
import os
import sys
import time
#from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
rootpath = os.path.split(os.path.realpath(sys.argv[0]))[0]
screenPath = "D:\\ceshi\\1\\" #保存路径
#device = MonkeyRunner.waitForConnection()
#MonkeyRunner.sleep(1)#休眠1s
time.sleep(5)
test_times = 100 #设置测试次数
numberphone = input("请输入要呼叫的号码:")#由用户输入呼叫号码
for i in range(0,test_times):
# 1.终端发起半双工单呼,讲状态5s,等待3s系统超时释放;
os.popen("adb shell am start com.zzzz/.ui.contacts.rrrrActivity555")#打开拨号盘
os.popen("adb shell input keyevent 4")#按返回键先退出
os.popen("adb shell am start com.zzzz/.ui.contacts.rrrActivity555")#
os.popen("adb shell input tap 136 1190")#点击拨号
os.popen("adb shell input tap 80 12960")#调出拨号盘
os.popen("adb shell input text %s"%numeberphone)#输入单呼号码
os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"') #长按PTT键
time.sleep(5)
os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
time.sleep(3)
# 2.发起语音组呼,讲状态5s,等待3s系统超时释放
os.popen("adb shell input keyevent 3")#按Home键先退出
os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"') #长按PTT键
time.sleep(5)
os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
time.sleep(3)
# 3.发起视频组呼,讲状态5s,等待3s系统超时释放;
os.popen("adb shell input keyevent 3")#按Home键先退出
os.popen("adb shell input keyevent 103")#按紧急键(视频键)
os.popen('adb shell "sendevent /dev/input/event0 1 522 1 && sendevent /dev/input/event0 0 0 0"') #长按PTT键
time.sleep(5)
os.popen('adb shell "sendevent /dev/input/event0 1 522 0 && sendevent /dev/input/event0 0 0 0"')
time.sleep(3)
time.sleep(5)
# 4.终端发送一条B-TrunC短信;
os.popen("adb shell input keyevent 3")#按Home键先退出
os.popen("adb shell am start com.zzzz/.ui.sms.ActivitySms")#打开B-TrunC短信
os.popen("adb shell input tap 369 1307")#点击新建短信
os.popen("adb shell input tap 152 226")#点击输入号码
os.popen("adb shell input text %s"%numeberphone)#输入号码
os.popen("adb shell input tap 166 680")#点击新建短信
os.popen("adb shell input text aaaaSend")#输入单呼号码
os.popen("adb shell input tap 640 688")#点击发送
time.sleep(5)
#5.进入app,对群组发起视频推送,持续30s,结束视频推送。
device.press('KEYCODE_HOME',MonkeyDevice.DOWN)#先返回主界面
os.popen("adb shell am start com.zzzz/.ui.ddddActivity")#打开app
os.popen("adb shell input tap 610 1263")#点击通讯录
os.popen("adb shell input tap 594 99")#点击群组
os.popen("adb shell input tap 187 199")#点击搜索
os.popen("adb shell input text 模拟用户测试")#输入单呼号码
os.popen("adb shell input tap 288 337")#选择群组
os.popen("adb shell input tap 291 1304")#点击推送
time.sleep(30)
os.popen("adb shell input tap 481 722")#随便点击一个位置
os.popen("adb shell input tap 671 677")#点击结束
result1 = device.takeSnapshot().getSubImage((0, 0, 530, 950)) #截图整屏
now = time.strftime("%Y-%m-%d-%H-%M-%S") #获取本地时间,然后命名,防止覆盖上张图片
result1.writeToFile(screenPath + now + '.png','png')#截图
time.sleep(5)