• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2import os
3
4from devicetest.api import Asserts
5from devicetest.log.logger import print_info
6
7from test_case import ITestCase
8
9
10class NotificationBar(ITestCase):
11
12    def __init__(self, controllers):
13        super().__init__(controllers)
14
15    def setup(self):
16        self.step('前置条件1:回到桌面')
17        self.common_oh.goHome(self.Phone1)
18        self.step('前置条件2:检查当前界面是否在桌面')
19        self.common_oh.checkIfTextExist(self.Phone1, '相机')
20
21    def process(self):
22        for i in range(2):
23            try:
24                self.step('步骤1:第 {} 次下拉控制中心'.format(i))
25                self.common_oh.swipe(self.Phone1, x1=500, y1=0, x2=500, y2=80)
26                self.common_oh.wait(self.Phone1, 2)
27                # 控件检查
28                #self.step('步骤2:检查文本"控制中心"是否存在')
29                #self.common_oh.checkIfTextExist(self.Phone1, '控制中心')
30                #self.common_oh.checkIfTextExist(self.Phone1, 'WLAN')
31                #break
32            except:
33                if i == 1:
34                    raise
35        # 截图对比
36        self.step('步骤3:控制中心截图对比')
37        notification_pic = 'notification_bar.jpeg'
38        self.take_picture_to_local(notification_pic)
39        self.crop_picture(notification_pic)
40        similarity = self.compare_image_similarity(notification_pic)
41        print_info('相似度为:{}%'.format(similarity))
42        self.asserts.assert_greater_equal(similarity, self.STANDARD_SIMILARITY)
43
44    def teardown(self):
45        self.step('收尾1:上滑收回控制中心')
46        for i in range(2):
47            self.step('第 {} 次上滑收起控制中心'.format(i))
48            self.common_oh.swipe(self.Phone1, x1=500, y1=500, x2=500, y2=300)
49            self.common_oh.wait(self.Phone1, 1)
50