diff --git a/cases/smoke/basic/screenshot32/new_script/testcases.json b/cases/smoke/basic/screenshot32/new_script/testcases.json index ce74b5f74e04201e331702cab39a649d3b09a1f6..249b9b99e80703e18853d7a95bd7ec598d86a91d 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases.json +++ b/cases/smoke/basic/screenshot32/new_script/testcases.json @@ -50,5 +50,9 @@ { "case_file": "testcases/test_note.py", "description": "备忘录应用测试" + }, + { + "case_file": "testcases/test_hap.py", + "description": "hap包测试" } ] \ No newline at end of file diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_hap.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_hap.py new file mode 100644 index 0000000000000000000000000000000000000000..7140237df089793a47d919bd12f84498f6ac48b3 --- /dev/null +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_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.example.helloworld') + except: + pass + + +class Test: + ability_name = 'EntryAbility' + bundle_name = 'com.example.helloworld' + + @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))), 'entry-default-signed.hap') + device.install_hap(hap_path) + time.sleep(1) + 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=72, x2=297, y2=290) + stand_pic = os.path.join(device.resource_path, 'hap.jpeg') + + similarity = compare_image_similarity(main_page, stand_pic) + assert similarity > 0.8, '截图对比失败'