diff --git a/cases/smoke/basic/screenshot32/new_script/resource/ui_hap.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/ui_hap.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..0df82d89baf02ee016b2744d27530482aee0dcd1 Binary files /dev/null and b/cases/smoke/basic/screenshot32/new_script/resource/ui_hap.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/testcases.json b/cases/smoke/basic/screenshot32/new_script/testcases.json index 249b9b99e80703e18853d7a95bd7ec598d86a91d..e0cce51227d5e4313aa49499215683b0e50ac3c9 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases.json +++ b/cases/smoke/basic/screenshot32/new_script/testcases.json @@ -54,5 +54,9 @@ { "case_file": "testcases/test_hap.py", "description": "hap包测试" + }, + { + "case_file": "testcases/test_ui_hap.py", + "description": "ui_hap包测试" } ] \ No newline at end of file diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_ui_hap.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_ui_hap.py new file mode 100644 index 0000000000000000000000000000000000000000..9dc12f09bf244f63aa477a47aecf6dc7074427e0 --- /dev/null +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_ui_hap.py @@ -0,0 +1,37 @@ +import logging +import os.path +import time + +import pytest + +from utils.images import compare_image_similarity, crop_picture + + +@pytest.fixture(autouse=True) +def uninstall_hap(device): + yield + try: + device.uninstall_hap('com.samples.ArkUIInteropSample') + except: + pass + + +class Test: + ability_name = 'EntryAbility' + bundle_name = 'com.samples.ArkUIInteropSample' + + @pytest.mark.parametrize('setup_teardown', [None], indirect=True) + def test(self, setup_teardown, device): + logging.info('install hap') + hap_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(device.resource_path))), 'ArkUIInteropSample','entry-default-signed.hap') + device.install_hap(hap_path) + time.sleep(5) + logging.info('start app') + device.start_ability(self.bundle_name, self.ability_name) + time.sleep(2) + main_page = device.save_snapshot_to_local('{}_hap.jpeg'.format(device.sn)) + crop_picture(picture=main_page, x1=0, y1=50, x2=700, y2=1150) + stand_pic = os.path.join(device.resource_path, 'ui_hap.jpeg') + + similarity = compare_image_similarity(main_page, stand_pic) + assert similarity > 0.8, '截图对比失败'