• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import logging
2import os
3import time
4
5import pytest
6
7from utils.images import compare_image_similarity
8
9
10class Test:
11
12
13    @pytest.mark.parametrize('setup_teardown', [None], indirect=True)
14    def test(self, setup_teardown, device):
15        logging.info('compare image similarity')
16        # usb弹窗
17        device.unlock()
18        time.sleep(2)
19        device.click(360, 800)
20        #time.sleep(10)
21        #device.click(360, 1245)
22        #device.unlock()
23        #time.sleep(2)
24
25        #if device.get_focus_window() == 'SystemDialog1':
26        #    device.click(595, 555)
27        #    time.sleep(10)
28        #if device.get_focus_window() == 'SystemDialog1':
29        #    device.click(360, 800)
30        #    time.sleep(10)
31        standard_pic = os.path.join(device.resource_path, 'launcher.jpeg')
32        launcher_pic = device.save_snapshot_to_local('{}_launcher.jpeg'.format(device.sn))
33        similarity = compare_image_similarity(launcher_pic, standard_pic)
34        assert similarity > 0.5, 'compare similarity failed'
35
36        # logging.info('检查桌面图标控件是否存在')
37        # device.refresh_layout()
38        # device.assert_type_exist('Badge')
39