diff --git a/cases/smoke/basic/screenshot32/DistributedTest/config/user_config.xml b/cases/smoke/basic/screenshot32/DistributedTest/config/user_config.xml
deleted file mode 100644
index d2a9f63abcb59405f3912326fe29e44730540356..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/config/user_config.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
- 7001005458323933328a017ce1b13800;7001005458323933328a258f3d043900
-
-
-
-
- cmd
- 115200
- 8
- 1
- 20
-
-
-
- deploy
- 115200
-
-
-
-
-
- cmd
- 115200
- 8
- 1
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DEBUG
- ON
-
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/DistributedTest/main.py b/cases/smoke/basic/screenshot32/DistributedTest/main.py
deleted file mode 100644
index 3eeb592cd30fb4c3149f055927178de3442f9346..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/main.py
+++ /dev/null
@@ -1,9 +0,0 @@
-import sys
-from xdevice.__main__ import main_process
-from testcases.set_sn import get_devices_sn
-
-if __name__ == '__main__':
- get_devices_sn()
- argv = "{} {} {}".format(sys.argv[1], sys.argv[2], sys.argv[3])
- print(">>>>>>>:{}".format(argv))
- main_process(argv)
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.json b/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.json
deleted file mode 100644
index 8188504822d6d044c229c768aa35df981ecad1bb..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "description": "Config for OpenHarmony devicetest test cases",
- "environment": [
- {
- "type": "device",
- "label": "phone"
- },
- {
- "type": "device",
- "label": "phone"
- }
- ],
- "driver": {
- "type": "DeviceTest",
- "py_file": ["DistributedTest.py"]
- }
-}
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.py b/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.py
deleted file mode 100644
index 39917a6ff80cf5b264d676b0c78fc375c40fd65d..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/testcases/DistributedTest.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- coding: utf-8 -*-
-import time
-import threading
-import re
-from devicetest.core.test_case import TestCase
-from devicetest.aw.OpenHarmony import CommonOH
-from testcases.orc import Orc
-
-
-class DistributedTest(TestCase):
- def __init__(self, controllers):
- self.TAG = self.__class__.__name__
- self.tests = [
- # 设备组网
- "sub_distributed_smoke_testcase_0100",
- # pin码连接
- "sub_distributed_smoke_testcase_0200",
- # 结果校验
- "sub_distributed_smoke_testcase_0300"
- ]
- TestCase.__init__(self, self.TAG, controllers)
-
- def setup(self):
- print("预置工作:初始化设备开始...........................")
- print(self.devices[0].device_id)
- print(self.devices[1].device_id)
-
- def sub_distributed_smoke_testcase_0100(self):
- t1 = threading.Thread(target=self.net_connect1)
- t2 = threading.Thread(target=self.net_connect2)
- t1.start()
- t2.start()
- t1.join()
- t2.join()
-
- def sub_distributed_smoke_testcase_0200(self):
- CommonOH.startAbility(self.Phone1, "ohos.samples.distributedcalc.MainAbility", "ohos.samples.distributedcalc")
- time.sleep(1)
- # 授权
- CommonOH.click(self.Phone1, 500, 1130)
- CommonOH.click(self.Phone1, 500, 1130)
- CommonOH.click(self.Phone1, 610, 110)
- time.sleep(2)
- CommonOH.click(self.Phone1, 380, 1150)
- CommonOH.click(self.Phone1, 610, 110)
- time.sleep(2)
- CommonOH.click(self.Phone1, 580, 1090)
- time.sleep(2)
- #确定
- CommonOH.click(self.Phone2, 520, 520)
- CommonOH.click(self.Phone2, 520, 520)
- CommonOH.hdc_std(self.Phone2, "shell snapshot_display -f /data/distributedcalc_step.jpeg")
- CommonOH.hdc_std(self.Phone2, "file recv /data/distributedcalc_step.jpeg testcases\\distributedcalc_step.jpeg")
- time.sleep(2)
- code = Orc("testcases\\distributedcalc_step.jpeg")
- self.code = re.findall("[0-9]{6}", code)[0]
- #输pin码
- CommonOH.click(self.Phone1, 340, 530)
- CommonOH.click(self.Phone1, 340, 530)
- time.sleep(1)
- #切换至数字输入
- CommonOH.click(self.Phone1, 60, 1145)
- time.sleep(1)
- for i in self.code:
- if i == "0":
- CommonOH.click(self.Phone1, 676, 778)
- else:
- j = int(i) - 1
- CommonOH.click(self.Phone1, 46 + j * 70, 778)
- time.sleep(1)
- CommonOH.click(self.Phone1, 60, 1145)
- # 确定
- CommonOH.click(self.Phone1, 500, 600)
-
- def sub_distributed_smoke_testcase_0300(self):
- # 切入后台,结束进程
- CommonOH.click(self.Phone1, 512, 1246)
- CommonOH.click(self.Phone1, 360, 1168)
- # 重启计算器应用
- CommonOH.startAbility(self.Phone1, "ohos.samples.distributedcalc.MainAbility", "ohos.samples.distributedcalc")
- time.sleep(2)
- # 拉起远端设备
- CommonOH.click(self.Phone1, 610, 110)
- time.sleep(3)
- CommonOH.click(self.Phone1, 580, 1090)
- CommonOH.click(self.Phone1, 580, 1090)
- # 设备二授权
- time.sleep(1)
- CommonOH.click(self.Phone2, 500, 1130)
- # 校验远端计算器是否被拉起
- CommonOH.hdc_std(self.Phone2, 'shell "aa dump -a | grep distributedcalc > /data/report.txt"')
- CommonOH.hdc_std(self.Phone2, "file recv /data/report.txt testcases\\report.txt")
- time.sleep(1)
- CommonOH.hdc_std(self.Phone1, "file send testcases\\report.txt /data/report.txt")
-
- def net_connect1(self):
- # 点亮屏幕
- CommonOH.wake(self.Phone1)
- # 设置不息屏
- CommonOH.hdc_std(self.Phone1, 'shell "power-shell setmode 602"')
-
- def net_connect2(self):
- # 点亮屏幕
- CommonOH.wake(self.Phone2)
- # 设置不息屏
- CommonOH.hdc_std(self.Phone2, 'shell "power-shell setmode 602"')
-
- def teardown(self):
- # 切入后台,结束进程
- CommonOH.hdc_std(self.Phone1, "shell killall ohos.samples.distributedcalc")
- CommonOH.hdc_std(self.Phone2, "shell killall ohos.samples.distributedcalc")
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/DistributedTest/testcases/orc.py b/cases/smoke/basic/screenshot32/DistributedTest/testcases/orc.py
deleted file mode 100644
index 54ab14b87e9dba3ec819d9900c37ac33110a5cc1..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/testcases/orc.py
+++ /dev/null
@@ -1,10 +0,0 @@
-import pytesseract
-from PIL import Image
-
-
-def Orc(path):
- pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
- tessdata_dir_config = '--tessdata-dir "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"'
- image = Image.open(path)
- code = pytesseract.image_to_string(image, config=tessdata_dir_config)
- return code
diff --git a/cases/smoke/basic/screenshot32/DistributedTest/testcases/set_sn.py b/cases/smoke/basic/screenshot32/DistributedTest/testcases/set_sn.py
deleted file mode 100644
index 6ccbba0df5ffa912b6010907567300855f88445b..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/DistributedTest/testcases/set_sn.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import encodings
-import os
-import re
-from xml.dom.minidom import parse
-
-def get_devices_sn():
- cmd_sn = os.popen("hdc_std list targets").read()
- device_sn = re.findall('[\w+]{32}', cmd_sn) + re.findall('[\w+]{16}', cmd_sn)
- dom_tree = parse('config\\user_config.xml')
- collection = dom_tree.documentElement
- sn1 = collection.getElementsByTagName('sn')[0]
- if len(device_sn[0]) == len(device_sn[1]):
- sn1.childNodes[0].data = "{};{}".format(device_sn[0], device_sn[1])
- else:
- sn1.childNodes[0].data = device_sn[0]
- with open('config\\user_config.xml', 'w', encoding='utf-8') as f:
- dom_tree.writexml(f, encoding='utf-8')
- f.close()
-
-if __name__ == '__main__':
- get_devices_sn()
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/l2tool/busybox b/cases/smoke/basic/screenshot32/l2tool/busybox
deleted file mode 100644
index bb8c6c2a7f66274277dad579038b44a355c505d4..0000000000000000000000000000000000000000
Binary files a/cases/smoke/basic/screenshot32/l2tool/busybox and /dev/null differ
diff --git a/cases/smoke/basic/screenshot32/l2tool/dhcpc.sh b/cases/smoke/basic/screenshot32/l2tool/dhcpc.sh
deleted file mode 100644
index b94b73965638945289d1a31eb8bdd6449b3d5f95..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/l2tool/dhcpc.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/system/bin/sh
-# udhcpc script edited by Tim Riker
-
-[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
-
-RESOLV_CONF="/etc/resolv.conf"
-[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
-[ -n "$subnet" ] && NETMASK="netmask $subnet"
-
-case "$1" in
- deconfig)
- /system/bin/ifconfig $interface 0.0.0.0
- ;;
-
- renew|bound)
- /system/bin/ifconfig $interface $ip $BROADCAST $NETMASK
-
- if [ -n "$router" ] ; then
- echo "deleting routers"
- while ./busybox route del default gw 0.0.0.0 dev $interface ; do
- :
- done
-
- for i in $router ; do
- ./busybox route add default gw $i dev $interface
- done
- fi
-
- echo -n > $RESOLV_CONF
- [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
- for i in $dns ; do
- echo adding dns $i
- echo nameserver $i >> $RESOLV_CONF
- done
- ;;
-esac
-
-exit 0
-
diff --git a/cases/smoke/basic/screenshot32/l2tool/wpa_supplicant.conf b/cases/smoke/basic/screenshot32/l2tool/wpa_supplicant.conf
deleted file mode 100644
index 81ffc27a5435f2d6edd8da554b7103fd3f3a35e8..0000000000000000000000000000000000000000
--- a/cases/smoke/basic/screenshot32/l2tool/wpa_supplicant.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-country=GB
-#update_config=1
-#ap_scan=1
-
-network={
- ssid="testapold"
- psk="passw0rd1!"
-}
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/resource/2_wifi.jpeg b/cases/smoke/basic/screenshot32/resource/2_wifi.jpeg
new file mode 100644
index 0000000000000000000000000000000000000000..61fdb3b24ffa8e211c87e4a2da8bdd0747e6cb1d
Binary files /dev/null and b/cases/smoke/basic/screenshot32/resource/2_wifi.jpeg differ
diff --git a/cases/smoke/basic/screenshot32/resource/app_capture_screen_test_config.json b/cases/smoke/basic/screenshot32/resource/app_capture_screen_test_config.json
index b65dfabc40ed36449f9d63ad9c762fc16f979a65..37f3cbb36a2b37eb6746c193c9981af3b4b8fca8 100644
--- a/cases/smoke/basic/screenshot32/resource/app_capture_screen_test_config.json
+++ b/cases/smoke/basic/screenshot32/resource/app_capture_screen_test_config.json
@@ -2,11 +2,13 @@
{
"DEVICE_1":[],
"DEVICE_2":[1],
- "DEVICE_3":[6, 7, 8, 9 ,10, 11],
- "DEVICE_4":[1, 2, 3, 4, 5],
+ "DEVICE_3":[5, 6, 7, 8, 9, 10],
+ "DEVICE_4":[1, 2, 3, 4],
"recent-x-y":[515, 1240],
"recent_del-x-y":[360, 1170],
"permisson_ok-x-y":[500, 1130],
+ "wlan-x-y":[300, 300],
+ "wlan_button-x-y":[640, 200],
"note_content-x-y":[500, 310],
"kill_keyboard-x-y":[690, 690],
"take_photos-x-y":[360, 1095],
@@ -23,11 +25,13 @@
"send_file_to_dev":["", ""]
},
{
- "app_name": "wifi_connect",
- "entry": "",
- "check_ping_baidu":["ping www.baidu.com", "64 bytes from"],
+ "app_name": "settings_wifi",
+ "entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
+ "crop_range":[140, 450, 30, 500],
+ "kill_settings": ["killall com.ohos.settings"],
"all_actions": [
- [2, "connect_wifi"], [1, "check_ping_baidu"]
+ [1, "shot_cmd", "settings"], [1, "cmp_cmd-level", "settings"], [8, "wlan-x-y"], [1, "shot_cmd", "wlan_list"], [8, "connect_wifi", "wlan_list"], [1, "shot_cmd", "wifi"],
+ [1, "cmp_twice", "wifi", 90, "crop_range"], [1, "kill_settings"]
]
},
{
@@ -45,7 +49,7 @@
"pull_down_cmd":["uinput -T -m 500 0 500 80"],
"swipe_up_cmd":["uinput -T -m 500 500 500 300"],
"all_actions": [
- [2, "pull_down_cmd"], [2, "pull_down_cmd"], [2, "shot_cmd", "notification_bar"], [1, "cmp_cmd-level", "notification_bar", 70], [1, "swipe_up_cmd"], [1, "swipe_up_cmd"]
+ [2, "pull_down_cmd"], [2, "pull_down_cmd"], [1, "shot_cmd", "notification_bar"], [1, "cmp_cmd-level", "notification_bar", 70], [1, "swipe_up_cmd"], [1, "swipe_up_cmd"]
]
},
{
@@ -71,10 +75,11 @@
"pull_down_cmd":["uinput -T -m 500 0 550 30"],
"start_screenshot": ["aa start -a com.ohos.screenshot.ServiceExtAbility -b com.ohos.screenshot"],
"start_photos": ["aa start -a com.ohos.photos.MainAbility -b com.ohos.photos"],
+ "process_check": ["ps -elf", "com.ohos.medialibrary.medialibrarydata"],
"kill_photos": ["killall com.ohos.photos"],
"all_actions": [
- [2, "pull_down_cmd"], [5, "screenshot-x-y"], [5, "start_photos"], [2, "last_photos-x-y"], [2, "shot_cmd", "photos"], [1, "cmp_cmd-level", "photos", 70],
- [1, "process_check", "com.ohos.medialibrary.medialibrarydata"], [2, "sandbox_path_check"], [1, "kill_photos"]
+ [2, "pull_down_cmd"], [5, "screenshot-x-y"], [5, "start_photos"], [2, "last_photos-x-y"], [1, "shot_cmd", "photos"], [1, "cmp_cmd-level", "photos", 70],
+ [1, "process_check"], [2, "sandbox_path_check"], [1, "kill_photos"]
]
},
{
@@ -91,20 +96,12 @@
[5, "start_test"], [1, "stop_hilog"], [1, "compress_log"], [1, "get_file_from_dev", "/data/log/hilog/video_log.tar"], [1, "kill_video"]
]
},
- {
- "app_name": "settings",
- "entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
- "kill_settings": ["killall com.ohos.settings"],
- "all_actions": [
- [2, "shot_cmd", "settings"], [1, "cmp_cmd-level", "settings"], [1, "kill_settings"]
- ]
- },
{
"app_name": "note",
"entry": "aa start -a MainAbility -b com.ohos.note",
"kill_note": ["killall com.ohos.note"],
"all_actions": [
- [2, "kill_keyboard-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [5, "note_content-x-y"], [2, "note_content-x-y"], [2, "shot_cmd", "note"], [1, "cmp_cmd-level", "note", 70], [2, "recent-x-y"], [1, "recent_del-x-y"]
+ [2, "kill_keyboard-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [5, "note_content-x-y"], [2, "note_content-x-y"], [1, "shot_cmd", "note"], [1, "cmp_cmd-level", "note"], [2, "recent-x-y"], [1, "recent_del-x-y"]
]
},
{
@@ -112,7 +109,7 @@
"entry": "aa start -a com.ohos.contacts.MainAbility -b com.ohos.contacts",
"kill_contacts": ["killall com.ohos.contacts"],
"all_actions": [
- [2, "phone-x-y"], [2, "phone-x-y"], [2, "shot_cmd", "contacts"], [1, "cmp_cmd-level", "contacts", 75], [1, "kill_contacts"]
+ [2, "phone-x-y"], [2, "phone-x-y"], [1, "shot_cmd", "contacts"], [1, "cmp_cmd-level", "contacts"], [1, "kill_contacts"]
]
},
{
@@ -120,7 +117,7 @@
"entry": "aa start -a com.ohos.mms.MainAbility -b com.ohos.mms",
"kill_mms": ["killall com.ohos.mms"],
"all_actions": [
- [2, "shot_cmd", "mms"], [1, "cmp_cmd-level", "mms", 75], [1, "kill_mms"]
+ [1, "shot_cmd", "mms"], [1, "cmp_cmd-level", "mms"], [1, "kill_mms"]
]
},
{
@@ -128,7 +125,7 @@
"entry": "aa start -a ohos.samples.distributedmusicplayer.MainAbility -b ohos.samples.distributedmusicplayer",
"kill_distributedmusicplayer": ["killall ohos.samples.distributedmusicplayer"],
"all_actions": [
- [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd", "distributedmusicplayer"], [1, "cmp_cmd-level", "distributedmusicplayer", 70], [1, "kill_distributedmusicplayer"]
+ [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [1, "shot_cmd", "distributedmusicplayer"], [1, "cmp_cmd-level", "distributedmusicplayer"], [1, "kill_distributedmusicplayer"]
]
}
]
diff --git a/cases/smoke/basic/screenshot32/resource/capturescreentest.py b/cases/smoke/basic/screenshot32/resource/capturescreentest.py
index 1c9274b64607c7026b1461d171544d9efc09714b..5765170e82c7f7fcb63da063584288e8c0aeb328 100644
--- a/cases/smoke/basic/screenshot32/resource/capturescreentest.py
+++ b/cases/smoke/basic/screenshot32/resource/capturescreentest.py
@@ -27,6 +27,8 @@ import sqlite3
import shutil
import numpy
import cv2
+import pytesseract
+from pytesseract import Output
from PIL import Image
@@ -136,59 +138,44 @@ def sandbox_check(process):
return 1
-def is_image_file(filename):
- IMG_EXTENSIONS = ['.png', '.PNG', 'jpeg']
- return any(filename.endswith(extension) for extension in IMG_EXTENSIONS)
+def get_coordinate(path, target):
+ coordinate = []
+ img = cv2.imread(path)
+ tessdata_dir_config = '--tessdata-dir "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"'
+ data = pytesseract.image_to_data(img, output_type=Output.DICT, config=tessdata_dir_config, lang='eng')
+ for i in range(len(data['text'])):
+ if data['text'][i] == target:
+ (x, y, w, h) = (data['left'][i], data['top'][i], data['width'][i], data['height'][i])
+ dx = int(x + w / 2)
+ dy = int(y + h / 2)
+ coordinate.append(dx)
+ coordinate.append(dy)
+ return coordinate
-def picture_save(pic_path):
- for root, dirs, files in os.walk(pic_path):
- for file in files:
- file_path = os.path.join(root, file)
- if is_image_file(file_path):
- shutil.copy2(file_path, args.save_path)
- print_to_log("SmokeTest:: send {} to save_path Successfully".format(file_path))
-
-
-def connect_wifi(tools_path):
- enter_shell_cmd("mkdir /data/l2tool", 1)
- file_to_dev(os.path.normpath(os.path.join(tools_path, "l2tool/busybox")), "/data/l2tool/")
- file_to_dev(os.path.normpath(os.path.join(tools_path, "l2tool/dhcpc.sh")), "/data/l2tool/")
- file_to_dev(os.path.normpath(os.path.join(tools_path, "l2tool/wpa_supplicant.conf")), "/data/l2tool/")
- enter_shell_cmd("wpa_supplicant -B -d -i wlan0 -c /data/l2tool/wpa_supplicant.conf", 1)
- enter_shell_cmd("chmod 777 ./data/l2tool/busybox", 1)
- cnt = 2
- while cnt:
- try:
- print_to_log("SmokeTest:: hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh")
- p = subprocess.check_output(shlex.split("hdc_std -t {} shell ./data/l2tool/busybox udhcpc -i wlan0 -s \
- /data/l2tool/dhcpc.sh".format(args.device_num)), timeout=8)
- print_to_log(p.decode(encoding="utf-8"))
- with open(os.path.join(args.save_path, 'test_{}.bat'.format(args.device_num)),\
- mode='a', encoding='utf-8') as cmd_f:
- cmd_f.write('hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh' + '\n')
- cmd_f.close()
- ret_code = 0
- except subprocess.TimeoutExpired as time_e:
- print_to_log(time_e)
- ret_code = 1
- if ret_code == 0:
- ip = re.findall(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", p.decode(encoding="utf-8"))
- print_to_log(ip)
- if len(ip) <= 0:
- break
- if len(re.findall(r'(?= 80:
+ if launcher_similarity >= 90:
print_to_log("SmokeTest:: launcher screenshot comparison is ok!")
break
elif reboot_cnt >= 1:
@@ -330,68 +379,26 @@ if __name__ == "__main__":
else:
print_to_log("SmokeTest:: first processes check is ok")
- power_state = enter_shell_cmd("hidumper -s 3308", 1)
+ power_state = enter_shell_cmd("hidumper -s 3308", WAIT_TIME_ONE)
if "State=2" not in power_state:
print_to_log("SmokeTest:: DISPLAY POWER MANAGER DUMP State=0")
sys_exit()
- if "1/2" in args.test_num or "2/2" in args.test_num:
- enter_shell_cmd("param set persist.ace.testmode.enabled 1")
- enter_shell_cmd("rm /data/log/hilog/*;hilog -r;hilog -Q pidoff;hilog -Q domainoff;hilog -G 512M;hilog -b D")
- picture_path = os.path.normpath(os.path.join(args.tools_path, "DistributedTest\\testcases"))
- report_path = os.path.normpath(os.path.join(args.tools_path, "DistributedTest\\testcases\\report.txt"))
- if args.test_num == "2/2":
- enter_shell_cmd("ifconfig eth0 192.168.0.1", 1)
- ping_result = enter_shell_cmd("ping 192.168.0.2 -i 1 -c 2", 3)
- file_is_exist = enter_shell_cmd("cd /data; find . -name report.txt")
- ping_cnt = 0
- wait_cnt = 0
- while "2 packets transmitted, 2 received" not in ping_result and ping_cnt < 60:
- ping_result = enter_shell_cmd("ping 192.168.0.2 -i 1 -c 2", 3)
- ping_cnt += 1
- if ping_cnt == 60:
- print_to_log("SmokeTest:: Ping failed, timeout of 3 minutes")
- sys_exit()
- while "report.txt" not in file_is_exist and wait_cnt < 60:
- print_to_log("SmokeTest:: waiting for the distributed test to end ")
- file_is_exist = enter_shell_cmd("cd /data; find . -name report.txt", 3)
- wait_cnt += 1
- elif args.test_num == "1/2":
- enter_shell_cmd("ifconfig eth0 192.168.0.2", 1)
- ping_result = enter_shell_cmd("ping 192.168.0.1 -i 1 -c 2", 3)
- ping_cnt = 0
- while "2 packets transmitted, 2 received" not in ping_result and ping_cnt < 60:
- ping_result = enter_shell_cmd("ping 192.168.0.1 -i 1 -c 2", 3)
- ping_cnt += 1
- if ping_cnt == 60:
- print_to_log("SmokeTest:: Ping failed, timeout of 3 minutes")
- print_to_log("SmokeTest:: ##### case 0 : distributed test start #####")
- execute_path = os.path.normpath(os.path.join(args.tools_path, "DistributedTest"))
- print_to_log("SmokeTest:: execute_path {}".format(execute_path))
- os.system("cd {} && python main.py run -l DistributedTest".format(execute_path))
- distributed_result = ""
- try:
- with open(report_path, mode='r', encoding='utf-8', errors='ignore') as f:
- f.seek(0)
- distributed_result = f.read()
- f.close()
- except Exception as reason:
- print_to_log("SmokeTest:: report.txt is not exist!")
- if "distributedcalc" in distributed_result:
- picture_save(picture_path)
- print_to_log("SmokeTest:: testcase 0, distributed is ok!")
- else:
- picture_save(picture_path)
- print_to_log("SmokeTest:: error:testcase 0, distributed failed!")
- enter_shell_cmd("ifconfig eth0 down", 1)
-
- if "arkui_ace_engine" in args.pr_url or "developtools_integration_verification" in args.pr_url:
- if args.test_num == "1/2":
- args.test_num = "3/2"
- elif args.test_num == "2/2":
- args.test_num = "4/2"
- else:
- args.test_num = "1/1"
+ distributed_test()
+ open_wlan()
+
+ special_warehouse = [
+ "arkui_ace_engine",
+ "developtools_integration_verification",
+ "graphic_graphic_2d",
+ "windowmanager"]
+
+ for warehouse in special_warehouse:
+ if warehouse in args.pr_url:
+ if args.test_num == "1/2":
+ args.test_num = "3/2"
+ elif args.test_num == "2/2":
+ args.test_num = "4/2"
print(args.pr_url)
try:
args.test_num.index('/')
@@ -432,7 +439,7 @@ if __name__ == "__main__":
cmd_f.write("\nSmokeTest::::::Last failed, try again \n")
cmd_f.close()
if single_app['entry'] != "":
- enter_shell_cmd(call_app_cmd, 5)
+ enter_shell_cmd(call_app_cmd, WAIT_TIME_FOUR)
print_to_log("SmokeTest:: execute command {}".format(single_app['all_actions']))
prefix = args.device_num
raw_pic_name = ''
@@ -443,25 +450,46 @@ if __name__ == "__main__":
pic_name = "{}{}".format(single_action[2], ".jpeg")
else:
pic_name = "{}{}".format(single_app['app_name'], ".jpeg")
- enter_shell_cmd("rm /data/screen_test/*{}".format(pic_name), 1)
- enter_shell_cmd(capture_screen_cmd.format(prefix, pic_name), 1)
+ enter_shell_cmd("rm /data/screen_test/*{}".format(pic_name), WAIT_TIME_ONE)
+ enter_shell_cmd(capture_screen_cmd.format(prefix, pic_name), WAIT_TIME_ONE)
file_from_dev("/data/screen_test/{}_{}".format(prefix, pic_name), args.save_path)
next_cmd = ""
+ elif type(single_action[1]) == str and single_action[1] == 'cmp_twice':
+ next_cmd = ""
+ sys.stdout.flush()
+ pic = "{}{}".format(single_action[2], ".jpeg")
+ similarity = single_action[3]
+ crop_range = single_app[single_action[4]]
+ crop_picture(prefix, pic, crop_range)
+ first_similarity = cmp_picture(prefix, pic)
+ second_similarity = cmp_picture(prefix, pic, WAIT_TIME_TWO)
+ print_to_log("SmokeTest:: first picture similarity is {}%".format(first_similarity))
+ print_to_log("SmokeTest:: second picture similarity is {}%".format(second_similarity))
+ if first_similarity >= similarity or second_similarity >= similarity:
+ if testok != -1:
+ testok = 1
+ print_to_log("SmokeTest:: {} screenshot check is ok".format(pic))
+ else:
+ testok = -1
+ print_to_log("SmokeTest:: {} screenshot check is abnarmal".format(pic))
elif type(single_action[1]) == str and single_action[1] == 'cmp_cmd-level':
next_cmd = ""
sys.stdout.flush()
- if len(single_action) == 4 or len(single_action) == 5:
+ if len(single_action) == 4:
similarity = single_action[3]
else:
similarity = global_pos['cmp_cmd-level'][1]
+ similarity = int(similarity)
print_to_log("SmokeTest:: start to contrast screenshot")
pic = "{}{}".format(single_action[2], ".jpeg")
- crop_picture(prefix, pic)
+ crop_range = [80, 1200, 0, 720]
+ crop_picture(prefix, pic, crop_range)
pic_similarity = cmp_picture(prefix, pic)
print_to_log("SmokeTest:: picture similarity is {}%".format(pic_similarity))
- if len(single_action) == 3 or len(single_action) == 4:
+ if len(single_action) >= 3:
if pic_similarity >= similarity:
- testok = 1
+ if testok != -1:
+ testok = 1
print_to_log("SmokeTest:: {} screenshot check is ok".format(pic))
else:
testok = -1
@@ -483,28 +511,14 @@ if __name__ == "__main__":
os.path.normpath(os.path.join(args.tools_path, single_action[2])), single_action[3]))
elif type(single_action[1]) == str and single_action[1] == 'connect_wifi':
next_cmd = ""
- connect_wifi(args.tools_path)
+ pic = "{}{}".format(single_action[2], ".jpeg")
+ connect_wifi(prefix, pic)
elif type(single_action[1]) == str and single_action[1] == 'sandbox_path_check':
next_cmd = ""
if sandbox_check("com.ohos.medialibrary.medialibrarydata") == 1 and testok == 1:
testok = 1
else:
testok = -1
- elif type(single_action[1]) == str and single_action[1] == 'process_check':
- next_cmd = ""
- if len(single_action) == 3:
- p = enter_shell_cmd("ps -elf", single_action[0])
- result = "".join(p)
- findsome = result.find(single_action[2], 0, len(result))
- if findsome != -1 and testok == 1:
- testok = 1
- print_to_log("SmokeTest:: \"{}\" is ok, find process \"{}\"!".format(single_action[1],\
- single_action[2]))
- else:
- testok = -1
- print_to_log("SmokeTest:: \"{}\" failed, not find process \"{}\"!".format(single_action[1],\
- single_action[2]))
- sys.stdout.flush()
elif type(single_action[1]) == str and single_action[1] == 'process_crash_check':
next_cmd = ""
if len(single_action) == 3:
diff --git a/cases/smoke/basic/screenshot32/resource/distributedtest.py b/cases/smoke/basic/screenshot32/resource/distributedtest.py
new file mode 100644
index 0000000000000000000000000000000000000000..3913fe287f66bcbec3bba44ca2b6e5f5f721dede
--- /dev/null
+++ b/cases/smoke/basic/screenshot32/resource/distributedtest.py
@@ -0,0 +1,154 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2023 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import time
+import re
+import encodings
+import subprocess
+import argparse
+import os
+import cv2
+import pytesseract
+from ast import parse
+from PIL import Image
+
+
+def enter_cmd(mycmd, waittime):
+ if mycmd == "":
+ return
+ global cmd_retry_cnt
+ cmd_retry_cnt = 1
+ enter_cmd_retry = 2
+ while enter_cmd_retry:
+ enter_cmd_retry -= 1
+ try:
+ p = subprocess.Popen(mycmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ result, unused_err = p.communicate(timeout=25)
+ try:
+ result=result.decode(encoding="utf-8")
+ except UnicodeDecodeError:
+ result=result.decode('gbk', errors='ignore')
+ break
+ except Exception as e:
+ result = 'retry failed again'
+ print(e)
+ cmd_retry_cnt += 1
+ p.kill()
+ if waittime != 0:
+ time.sleep(waittime)
+ print(result)
+ return result
+
+
+def enter_shell_cmd(shellcmd, waittime, sn):
+ global sn1
+ global sn2
+ if shellcmd == "":
+ return
+ cmd = "hdc_std -t {} shell \"{}\"".format(sn, shellcmd)
+ return enter_cmd(cmd, waittime)
+
+
+def file_from_dev(src, dst, sn):
+ cmd = "hdc_std -t {} file recv \"{}\" \"{}\"".format(sn, src, dst)
+ return enter_cmd(cmd, 2)
+
+
+def get_devices_sn():
+ global sn1
+ global sn2
+ cmd_sn = os.popen("hdc_std list targets").read()
+ device_sn = re.findall('[\w+]{32}', cmd_sn)
+ sn1 = device_sn[0]
+ sn2 = device_sn[1]
+ print(sn1)
+ print(sn2)
+
+
+def orc(path):
+ pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
+ tessdata_dir_config = '--tessdata-dir "C:\\Program Files (x86)\\Tesseract-OCR\\tessdata"'
+ image = Image.open(path)
+ code = pytesseract.image_to_string(image, config=tessdata_dir_config)
+ return code
+
+
+def crop_picture(pic, target, crop_range):
+ pic_path = "{}\\{}".format(args.path, pic)
+ save_path = "{}\\{}".format(args.path, target)
+ im = cv2.imread(pic_path)
+ im = im[crop_range[0]:crop_range[1], crop_range[2]:crop_range[3]]
+ cv2.imwrite(save_path, im)
+
+
+def distributed_calc():
+ time_one = 1
+ time_two = 2
+ time_four = 4
+ crop_range = [520, 585, 250, 460]
+ enter_shell_cmd("aa start -a ohos.samples.distributedcalc.MainAbility -b ohos.samples.distributedcalc",\
+ time_four, sn1)
+ enter_shell_cmd("uinput -M -m 500 1130 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 500 1130 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 610 110 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 380 1150 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 610 110 -c 0", time_two, sn1)
+ enter_shell_cmd("snapshot_display -f /data/distributedcalc.jpeg", time_two, sn1)
+ file_from_dev("/data/distributedcalc.jpeg", "{}\\distributedcalc.jpeg".format(args.path), sn1)
+ enter_shell_cmd("uinput -M -m 580 1090 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 520 520 -c 0", time_two, sn2)
+ enter_shell_cmd("uinput -M -m 520 520 -c 0", time_two, sn2)
+ enter_shell_cmd("snapshot_display -f /data/pin.jpeg", time_two, sn2)
+ file_from_dev("/data/pin.jpeg", "{}\\pin.jpeg".format(args.path), sn2)
+ crop_picture("pin.jpeg", "pin_code.jpeg", crop_range)
+ enter_shell_cmd("uinput -M -m 340 530 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 340 530 -c 0", time_two, sn1)
+ #Enter pin code
+ enter_shell_cmd("uinput -M -m 60 1145 -c 0", time_two, sn1)
+ code = orc(f"{args.path}\\pin_code.jpeg")
+ pin_code = re.findall("[0-9]{6}", code)[0]
+ print(pin_code)
+ for i in pin_code:
+ if i == "0":
+ enter_shell_cmd("uinput -M -m 672 800 -c 0", time_one, sn1)
+ else:
+ j = int(i) - 1
+ dx = 42 + j * 70
+ enter_shell_cmd(f"uinput -M -m {dx} 800 -c 0", time_one, sn1)
+ time.sleep(1)
+ enter_shell_cmd("uinput -M -m 60 1145 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 500 600 -c 0", time_two, sn1)
+ enter_shell_cmd("killall ohos.samples.distributedcalc", time_two, sn1)
+ #Pull up the opposite device
+ enter_shell_cmd("aa start -a ohos.samples.distributedcalc.MainAbility -b ohos.samples.distributedcalc",\
+ time_four, sn1)
+ enter_shell_cmd("uinput -M -m 610 110 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 580 1090 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 580 1090 -c 0", time_two, sn1)
+ enter_shell_cmd("uinput -M -m 500 1130 -c 0", time_two, sn2)
+ enter_shell_cmd("aa dump -a | grep distributedcalc > /data/distributed_report.txt", time_two, sn2)
+ file_from_dev("/data/distributed_report.txt", "{}\\distributed_report.txt".format(args.path), sn2)
+ enter_shell_cmd("killall ohos.samples.distributedcalc", time_two, sn2)
+ enter_shell_cmd("killall ohos.samples.distributedcalc", time_two, sn1)
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='manual to this script')
+ parser.add_argument('--path', type=str, default = '.')
+ args = parser.parse_args()
+
+ sn1 = ""
+ sn2 = ""
+ get_devices_sn()
+ distributed_calc()
\ No newline at end of file
diff --git a/cases/smoke/basic/screenshot32/resource/wifi.jpeg b/cases/smoke/basic/screenshot32/resource/wifi.jpeg
new file mode 100644
index 0000000000000000000000000000000000000000..8d06193cdf300b62ea825f5a438856018fb4fc20
Binary files /dev/null and b/cases/smoke/basic/screenshot32/resource/wifi.jpeg differ