未验证 提交 e5dcb326 编写于 作者: O openharmony_ci 提交者: Gitee

!17 门禁截图联合构建测试

Merge pull request !17 from lnlan/master
[
{
"return-x-y":[199, 1262],
"recent-x-y":[500, 1262],
"home-x-y":[350, 1262],
"recent_del-x-y":[350, 1140],
"permisson_ok-x-y":[495, 690],
"permisson_no-x-y":[241, 690],
"shot_cmd":[""],
"cmp_cmd-level":["", 443200]
},
{
"app_name": "launcher",
"entry": "",
"all_actions": [[2, "shot_cmd"], [2, "cmp_cmd-level"]]
},
{
"app_name": "settings",
"entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
"all_actions": [
[3, "shot_cmd", "settings"], [3, "cmp_cmd-level"], [3, 400, 120], [3, 400, 120], [20, 400, 80], [3, 400, 80],
[3, "shot_cmd", "keyboard"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "cmp_cmd-level", 200000]
]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "distributedcalc",
"entry": "aa start -a com.example.distributedcalc.default -b com.example.distributedcalc",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "mms",
"entry": "aa start -a com.ohos.mms.MainAbility -b com.ohos.mms",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]
]
},
{
"app_name": "note",
"entry": "aa start -a com.ohos.note.MainAbility -b com.ohos.note",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
}
]
\ No newline at end of file
from ast import parse
import json
import sys
import os
import time
import argparse
import re
def EnterCmd(mycmd, waittime = 0, printresult = 1):
if mycmd == "":
return
with os.popen(mycmd) as p:
result = p.readlines()
if printresult == 1:
print(result)
sys.stdout.flush()
if waittime != 0:
time.sleep(waittime)
return result
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='manual to this script')
parser.add_argument('--config', type=str, default = './app_capture_screen_test_config.json')
parser.add_argument('--anwser_path', type=str, default = 'screenshot\\RK\\')
parser.add_argument('--save_path', type=str, default = './report/screenshot_1/')
args = parser.parse_args()
with open(args.config) as f:
all_app = json.load(f)
cmp_status = 0
global_pos = all_app[0]
return_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['return-x-y'][0], global_pos['return-x-y'][1])
recent_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent-x-y'][0], global_pos['recent-x-y'][1])
home_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['home-x-y'][0], global_pos['home-x-y'][1])
recent_del_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent_del-x-y'][0], global_pos['recent_del-x-y'][1])
os.system("hdc_std kill")
os.system("hdc_std start")
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std shell rm -rf /data/screen_test/train_set")
EnterCmd("hdc_std shell mkdir -p /data/screen_test/train_set")
EnterCmd("hdc_std file send {} {}".format(os.path.join(os.path.dirname(args.config), "printscreen"), "/data/screen_test/"))
EnterCmd("hdc_std shell chmod 777 /data/screen_test/printscreen")
for single_app in all_app[1:]:
print(single_app['entry'])
print(single_app['all_actions'])
call_app_cmd = "hdc_std shell " + single_app['entry']
send_file_cmd = "hdc_std file send {} {}"
capture_screen_cmd = "hdc_std shell /data/screen_test/printscreen -f /data/screen_test/{}"
recv_file_cmd = "hdc_std file recv /data/screen_test/{} {}"
cmp_cmd = "hdc_std shell \"cmp -l /data/screen_test/{} /data/screen_test/train_set/{} | wc -l\""
if single_app['entry'] != "":
EnterCmd(call_app_cmd, 3)
for single_action in single_app['all_actions']:
#shot_cmd is stable, different to other cmd,so handle it specialy
if type(single_action[1]) == str and single_action[1] == 'shot_cmd':
if len(single_action) == 3:
pic_name = single_action[2] + ".png"
raw_pic_name = single_action[2] + ".pngraw"
else:
pic_name = single_app['app_name'] + ".png"
raw_pic_name = single_app['app_name'] + ".pngraw"
next_cmd = capture_screen_cmd.format(pic_name)
#cmp_cmd-level is stable, different to other cmd,so handle it specialy
elif type(single_action[1]) == str and single_action[1] == 'cmp_cmd-level':
next_cmd = ""
print(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
EnterCmd(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
new_cmp_cmd = cmp_cmd.format(raw_pic_name, raw_pic_name)
if len(single_action) == 3:
tolerance = single_action[2]
else:
tolerance = global_pos['cmp_cmd-level'][1]
p = EnterCmd(new_cmp_cmd, single_action[0])
num = re.findall(r'[-+]?\d+', p[0])
EnterCmd(recv_file_cmd.format(pic_name, args.save_path))
EnterCmd(recv_file_cmd.format(raw_pic_name, args.save_path))
if type(num) == list and len(num) > 0 and int(num[0]) < tolerance:
print("{} screenshot check is ok!\n\n".format(raw_pic_name))
else:
print("{} screenshot check is abnarmal!\n\n".format(raw_pic_name))
cmp_status = cmp_status + 1
#other cmd handle
elif type(single_action[1]) == str:
if single_action[1] not in single_app.keys():
target_ = global_pos[single_action[1]]
else:
target_ = single_app[single_action[1]]
#this cmd is real cmd,and have a except answer
if type(target_[0]) == str:
next_cmd = ""
p = EnterCmd(target_[0], single_action[0])
result = "".join(p)
if len(target_) > 1:
findsome = result.find(target_[1], 0, len(result))
if findsome != -1:
print("\"{}\" execut result success!\n\n".format(target_[0]))
else:
print("\"{}\" execut result failed!\n\n".format(target_[0]))
cmp_status = cmp_status + 1
#this cmd only is a name of x,y postion, to get x,y an click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(target_[0], target_[1])
#input x,y postion, to click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(single_action[1], single_action[2])
EnterCmd(next_cmd, single_action[0])
if cmp_status != 0:
print("screenshot check is abnarmal {}".format(cmp_status))
print("End of check, test failed!")
else:
print("screenshot check is ok {}".format(cmp_status))
print("End of check, test succeeded!")
sys.exit(cmp_status)
\ No newline at end of file
此差异已折叠。
hdf_devmgr
param_watcher
storage_manager
appspawn
hilogd
samgr
storage_daemon
udevd
uinput_inject
multimodalinput
token_sync_serv
huks_service
memmgrservice
bluetooth_servi
pulseaudio
accessibility
resource_schedu
faceauth
work_scheduler_
bgtaskmgr_servi
audio_policy
deviceauth_service
softbus_server
wifi_hal_service
deviceinfoservi
faultloggerd
accountmgr
time_service
distributeddata
medialibrary_se
useriam
updater_sa
inputmethod_ser
ui_service
fms_service
distributedfile
distributedfile
netmanager
battery_stats
dslm_service
sensors
media_service
wifi_manager_se
distributedsche
installs
hiview
telephony
usb_service
camera_service
render_service
thermal
foundation
accesstoken_ser
hdcd
disp_gralloc_host
light_dal_host
vibrator_dal_host
sensor_dal_host
input_user_host
camera_host
audio_hdi_server_host
wifi_host
usbfnMaster_host
usb_host
blue_host
wifi_hal_service
com.ohos.systemui
device_usage_st
com.ohos.launcher
power_host
\ No newline at end of file
[
{
"return-x-y":[199, 1262],
"recent-x-y":[500, 1262],
"home-x-y":[350, 1262],
"recent_del-x-y":[350, 1140],
"permisson_ok-x-y":[495, 690],
"permisson_no-x-y":[241, 690],
"shot_cmd":[""],
"cmp_cmd-level":["", 443200]
},
{
"app_name": "launcher",
"entry": "",
"all_actions": [[2, "shot_cmd"], [2, "cmp_cmd-level"]]
},
{
"app_name": "settings",
"entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
"all_actions": [
[3, "shot_cmd", "settings"], [3, "cmp_cmd-level"], [3, 400, 120], [3, 400, 120], [20, 400, 80], [3, 400, 80],
[3, "shot_cmd", "keyboard"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "cmp_cmd-level", 200000]
]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "distributedcalc",
"entry": "aa start -a com.example.distributedcalc.default -b com.example.distributedcalc",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "mms",
"entry": "aa start -a com.ohos.mms.MainAbility -b com.ohos.mms",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]
]
},
{
"app_name": "note",
"entry": "aa start -a com.ohos.note.MainAbility -b com.ohos.note",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
}
]
\ No newline at end of file
from ast import parse
import json
import sys
import os
import time
import argparse
import re
def EnterCmd(mycmd, waittime = 0, printresult = 1):
if mycmd == "":
return
with os.popen(mycmd) as p:
result = p.readlines()
if printresult == 1:
print(result)
sys.stdout.flush()
if waittime != 0:
time.sleep(waittime)
return result
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='manual to this script')
parser.add_argument('--config', type=str, default = './app_capture_screen_test_config.json')
parser.add_argument('--anwser_path', type=str, default = 'screenshot\\RK\\')
parser.add_argument('--save_path', type=str, default = './report/screenshot_1/')
args = parser.parse_args()
with open(args.config) as f:
all_app = json.load(f)
cmp_status = 0
global_pos = all_app[0]
return_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['return-x-y'][0], global_pos['return-x-y'][1])
recent_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent-x-y'][0], global_pos['recent-x-y'][1])
home_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['home-x-y'][0], global_pos['home-x-y'][1])
recent_del_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent_del-x-y'][0], global_pos['recent_del-x-y'][1])
os.system("hdc_std kill")
os.system("hdc_std start")
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std shell rm -rf /data/screen_test/train_set")
EnterCmd("hdc_std shell mkdir -p /data/screen_test/train_set")
EnterCmd("hdc_std file send {} {}".format(os.path.join(os.path.dirname(args.config), "printscreen"), "/data/screen_test/"))
EnterCmd("hdc_std shell chmod 777 /data/screen_test/printscreen")
for single_app in all_app[1:]:
print(single_app['entry'])
print(single_app['all_actions'])
call_app_cmd = "hdc_std shell " + single_app['entry']
send_file_cmd = "hdc_std file send {} {}"
capture_screen_cmd = "hdc_std shell /data/screen_test/printscreen -f /data/screen_test/{}"
recv_file_cmd = "hdc_std file recv /data/screen_test/{} {}"
cmp_cmd = "hdc_std shell \"cmp -l /data/screen_test/{} /data/screen_test/train_set/{} | wc -l\""
if single_app['entry'] != "":
EnterCmd(call_app_cmd, 3)
for single_action in single_app['all_actions']:
#shot_cmd is stable, different to other cmd,so handle it specialy
if type(single_action[1]) == str and single_action[1] == 'shot_cmd':
if len(single_action) == 3:
pic_name = single_action[2] + ".png"
raw_pic_name = single_action[2] + ".pngraw"
else:
pic_name = single_app['app_name'] + ".png"
raw_pic_name = single_app['app_name'] + ".pngraw"
next_cmd = capture_screen_cmd.format(pic_name)
#cmp_cmd-level is stable, different to other cmd,so handle it specialy
elif type(single_action[1]) == str and single_action[1] == 'cmp_cmd-level':
next_cmd = ""
print(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
EnterCmd(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
new_cmp_cmd = cmp_cmd.format(raw_pic_name, raw_pic_name)
if len(single_action) == 3:
tolerance = single_action[2]
else:
tolerance = global_pos['cmp_cmd-level'][1]
p = EnterCmd(new_cmp_cmd, single_action[0])
num = re.findall(r'[-+]?\d+', p[0])
EnterCmd(recv_file_cmd.format(pic_name, args.save_path))
EnterCmd(recv_file_cmd.format(raw_pic_name, args.save_path))
if type(num) == list and len(num) > 0 and int(num[0]) < tolerance:
print("{} screenshot check is ok!\n\n".format(raw_pic_name))
else:
print("{} screenshot check is abnarmal!\n\n".format(raw_pic_name))
cmp_status = cmp_status + 1
#other cmd handle
elif type(single_action[1]) == str:
if single_action[1] not in single_app.keys():
target_ = global_pos[single_action[1]]
else:
target_ = single_app[single_action[1]]
#this cmd is real cmd,and have a except answer
if type(target_[0]) == str:
next_cmd = ""
p = EnterCmd(target_[0], single_action[0])
result = "".join(p)
if len(target_) > 1:
findsome = result.find(target_[1], 0, len(result))
if findsome != -1:
print("\"{}\" execut result success!\n\n".format(target_[0]))
else:
print("\"{}\" execut result failed!\n\n".format(target_[0]))
cmp_status = cmp_status + 1
#this cmd only is a name of x,y postion, to get x,y an click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(target_[0], target_[1])
#input x,y postion, to click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(single_action[1], single_action[2])
EnterCmd(next_cmd, single_action[0])
if cmp_status != 0:
print("screenshot check is abnarmal {}".format(cmp_status))
print("End of check, test failed!")
else:
print("screenshot check is ok {}".format(cmp_status))
print("End of check, test succeeded!")
sys.exit(cmp_status)
\ No newline at end of file
hdf_devmgr
param_watcher
storage_manager
appspawn
hilogd
samgr
storage_daemon
udevd
uinput_inject
multimodalinput
token_sync_serv
huks_service
memmgrservice
bluetooth_servi
pulseaudio
accessibility
resource_schedu
faceauth
work_scheduler_
bgtaskmgr_servi
audio_policy
deviceauth_service
softbus_server
wifi_hal_service
deviceinfoservi
faultloggerd
accountmgr
time_service
distributeddata
medialibrary_se
useriam
updater_sa
inputmethod_ser
ui_service
fms_service
distributedfile
distributedfile
netmanager
battery_stats
dslm_service
sensors
media_service
wifi_manager_se
distributedsche
installs
hiview
telephony
usb_service
camera_service
render_service
thermal
foundation
accesstoken_ser
hdcd
disp_gralloc_host
light_dal_host
vibrator_dal_host
sensor_dal_host
input_user_host
camera_host
audio_hdi_server_host
wifi_host
usbfnMaster_host
usb_host
blue_host
wifi_hal_service
com.ohos.systemui
device_usage_st
com.ohos.launcher
power_host
\ No newline at end of file
[
{
"return-x-y":[199, 1262],
"recent-x-y":[500, 1262],
"home-x-y":[350, 1262],
"recent_del-x-y":[350, 1140],
"permisson_ok-x-y":[495, 690],
"permisson_no-x-y":[241, 690],
"shot_cmd":[""],
"cmp_cmd-level":["", 443200]
},
{
"app_name": "launcher",
"entry": "",
"all_actions": [[2, "shot_cmd"], [2, "cmp_cmd-level"]]
},
{
"app_name": "settings",
"entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
"all_actions": [
[3, "shot_cmd", "settings"], [3, "cmp_cmd-level"], [3, 400, 120], [3, 400, 120], [20, 400, 80], [3, 400, 80],
[3, "shot_cmd", "keyboard"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "cmp_cmd-level", 200000]
]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "distributedcalc",
"entry": "aa start -a com.example.distributedcalc.default -b com.example.distributedcalc",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "camera",
"entry": "aa start -a com.ohos.camera.MainAbility -b com.ohos.camera",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "contacts",
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "music",
"entry": "aa start -a com.ohos.distributedmusicplayer.MainAbility -b com.ohos.distributedmusicplayer",
"all_actions": [[2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
},
{
"app_name": "mms",
"entry": "aa start -a com.ohos.mms.MainAbility -b com.ohos.mms",
"all_actions": [
[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"],
[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]
]
},
{
"app_name": "note",
"entry": "aa start -a com.ohos.note.MainAbility -b com.ohos.note",
"all_actions": [[2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400]]
}
]
\ No newline at end of file
from ast import parse
import json
import sys
import os
import time
import argparse
import re
def EnterCmd(mycmd, waittime = 0, printresult = 1):
if mycmd == "":
return
with os.popen(mycmd) as p:
result = p.readlines()
if printresult == 1:
print(result)
sys.stdout.flush()
if waittime != 0:
time.sleep(waittime)
return result
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='manual to this script')
parser.add_argument('--config', type=str, default = './app_capture_screen_test_config.json')
parser.add_argument('--anwser_path', type=str, default = 'screenshot\\RK\\')
parser.add_argument('--save_path', type=str, default = './report/screenshot_1/')
args = parser.parse_args()
with open(args.config) as f:
all_app = json.load(f)
cmp_status = 0
global_pos = all_app[0]
return_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['return-x-y'][0], global_pos['return-x-y'][1])
recent_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent-x-y'][0], global_pos['recent-x-y'][1])
home_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['home-x-y'][0], global_pos['home-x-y'][1])
recent_del_cmd = "hdc_std shell input -M -m {} {} -c 0".format(global_pos['recent_del-x-y'][0], global_pos['recent_del-x-y'][1])
os.system("hdc_std kill")
os.system("hdc_std start")
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std shell rm -rf /data/screen_test/train_set")
EnterCmd("hdc_std shell mkdir -p /data/screen_test/train_set")
EnterCmd("hdc_std file send {} {}".format(os.path.join(os.path.dirname(args.config), "printscreen"), "/data/screen_test/"))
EnterCmd("hdc_std shell chmod 777 /data/screen_test/printscreen")
for single_app in all_app[1:]:
print(single_app['entry'])
print(single_app['all_actions'])
call_app_cmd = "hdc_std shell " + single_app['entry']
send_file_cmd = "hdc_std file send {} {}"
capture_screen_cmd = "hdc_std shell /data/screen_test/printscreen -f /data/screen_test/{}"
recv_file_cmd = "hdc_std file recv /data/screen_test/{} {}"
cmp_cmd = "hdc_std shell \"cmp -l /data/screen_test/{} /data/screen_test/train_set/{} | wc -l\""
if single_app['entry'] != "":
EnterCmd(call_app_cmd, 3)
for single_action in single_app['all_actions']:
#shot_cmd is stable, different to other cmd,so handle it specialy
if type(single_action[1]) == str and single_action[1] == 'shot_cmd':
if len(single_action) == 3:
pic_name = single_action[2] + ".png"
raw_pic_name = single_action[2] + ".pngraw"
else:
pic_name = single_app['app_name'] + ".png"
raw_pic_name = single_app['app_name'] + ".pngraw"
next_cmd = capture_screen_cmd.format(pic_name)
#cmp_cmd-level is stable, different to other cmd,so handle it specialy
elif type(single_action[1]) == str and single_action[1] == 'cmp_cmd-level':
next_cmd = ""
print(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
EnterCmd(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
new_cmp_cmd = cmp_cmd.format(raw_pic_name, raw_pic_name)
if len(single_action) == 3:
tolerance = single_action[2]
else:
tolerance = global_pos['cmp_cmd-level'][1]
p = EnterCmd(new_cmp_cmd, single_action[0])
num = re.findall(r'[-+]?\d+', p[0])
EnterCmd(recv_file_cmd.format(pic_name, args.save_path))
EnterCmd(recv_file_cmd.format(raw_pic_name, args.save_path))
if type(num) == list and len(num) > 0 and int(num[0]) < tolerance:
print("{} screenshot check is ok!\n\n".format(raw_pic_name))
else:
print("{} screenshot check is abnarmal!\n\n".format(raw_pic_name))
cmp_status = cmp_status + 1
#other cmd handle
elif type(single_action[1]) == str:
if single_action[1] not in single_app.keys():
target_ = global_pos[single_action[1]]
else:
target_ = single_app[single_action[1]]
#this cmd is real cmd,and have a except answer
if type(target_[0]) == str:
next_cmd = ""
p = EnterCmd(target_[0], single_action[0])
result = "".join(p)
if len(target_) > 1:
findsome = result.find(target_[1], 0, len(result))
if findsome != -1:
print("\"{}\" execut result success!\n\n".format(target_[0]))
else:
print("\"{}\" execut result failed!\n\n".format(target_[0]))
cmp_status = cmp_status + 1
#this cmd only is a name of x,y postion, to get x,y an click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(target_[0], target_[1])
#recent_del sometimes click no effect,so double click
if single_action[1] == 'recent_del-x-y':
EnterCmd(next_cmd, single_action[0])
#input x,y postion, to click it
else:
next_cmd = "hdc_std shell input -M -m {} {} -c 0".format(single_action[1], single_action[2])
EnterCmd(next_cmd, single_action[0])
if cmp_status != 0:
print("screenshot check is abnarmal {}".format(cmp_status))
print("End of check, test failed!")
else:
print("screenshot check is ok {}".format(cmp_status))
print("End of check, test succeeded!")
sys.exit(cmp_status)
\ No newline at end of file
此差异已折叠。
hdf_devmgr
param_watcher
storage_manager
appspawn
hilogd
samgr
storage_daemon
udevd
uinput_inject
multimodalinput
token_sync_serv
huks_service
memmgrservice
bluetooth_servi
pulseaudio
accessibility
resource_schedu
faceauth
work_scheduler_
bgtaskmgr_servi
audio_policy
deviceauth_service
softbus_server
wifi_hal_service
deviceinfoservi
faultloggerd
accountmgr
time_service
distributeddata
medialibrary_se
useriam
updater_sa
inputmethod_ser
ui_service
fms_service
distributedfile
distributedfile
netmanager
battery_stats
dslm_service
sensors
media_service
wifi_manager_se
distributedsche
installs
hiview
telephony
usb_service
camera_service
render_service
thermal
foundation
accesstoken_ser
hdcd
disp_gralloc_host
light_dal_host
vibrator_dal_host
sensor_dal_host
input_user_host
camera_host
audio_hdi_server_host
wifi_host
usbfnMaster_host
usb_host
blue_host
wifi_hal_service
com.ohos.systemui
device_usage_st
com.ohos.launcher
power_host
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册