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 Mms(ITestCase): 11 ability_name = 'com.ohos.mms.MainAbility' 12 bundle_name = 'com.ohos.mms' 13 14 def __init__(self, controllers): 15 super().__init__(controllers) 16 17 def setup(self): 18 self.step('前置条件1:回到桌面') 19 self.common_oh.goHome(self.Phone1) 20 self.step('前置条件2:检查当前界面是否在桌面') 21 self.common_oh.checkIfTextExist(self.Phone1, '相机') 22 23 24 def process(self): 25 self.step('步骤1:启动短信应用') 26 self.common_oh.startAbility(self.Phone1, self.ability_name, self.bundle_name) 27 # self.common_oh.wait(self.Phone1, 5) 28 self.step('步骤2:检查"信息"是否存在') 29 # 控件检查 30 self.common_oh.checkIfTextExist(self.Phone1, '信息') 31 # 截图对比 32 self.step('步骤2:短信截图对比') 33 mms_pic = 'mms.jpeg' 34 self.take_picture_to_local(picture_name=mms_pic) 35 self.crop_picture(mms_pic) 36 similarity = self.compare_image_similarity(mms_pic) 37 print_info('相似度为:{}%'.format(similarity)) 38 self.asserts.assert_greater_equal(similarity, self.STANDARD_SIMILARITY) 39 40 def teardown(self): 41 self.step('收尾1:停掉短信应用') 42 self.common_oh.forceStopAbility(self.Phone1, self.bundle_name) 43