• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import logging
2import os.path
3import time
4
5import pytest
6
7from utils.images import compare_image_similarity, crop_picture
8
9
10class Test:
11    ability_name = 'com.ohos.settings.MainAbility'
12    bundle_name = 'com.ohos.settings'
13
14    @pytest.mark.parametrize('setup_teardown', [bundle_name], indirect=True)
15    def test(self, setup_teardown, device):
16        logging.info('start setting app')
17        device.start_ability(self.bundle_name, self.ability_name)
18
19        logging.info('compare image similarity')
20        standard_pic = os.path.join(device.resource_path, 'settings.jpeg')
21        settings_page_pic = device.save_snapshot_to_local('{}_settings.jpeg'.format(device.sn))
22        crop_picture(settings_page_pic)
23        similarity = compare_image_similarity(settings_page_pic, standard_pic)
24        # assert similarity > 0.5, 'compare similarity failed'
25
26        logging.info('enter wlan page')
27        device.click(160, 306)
28        time.sleep(2)
29        device.save_snapshot_to_local('{}_before_click.jpeg'.format(device.sn))
30        before_click = device.get_wifi_status().get('active')
31
32        logging.info('turn on/off wlan swith')
33        device.click(646, 210)
34        #device.hdc_shell(f'uitest uiInput click 646 210')
35        time.sleep(15)
36        device.save_snapshot_to_local('{}_after_click.jpeg'.format(device.sn))
37        after_click = device.get_wifi_status().get('active')
38        logging.info('wlan switch changes from [{}] to [{}]'.format(before_click, after_click))
39        assert before_click != after_click, 'wlan switch turn on/off failed'
40