• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#-*- coding: utf-8 -*-
3
4# Copyright (c) 2024 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17from devicetest.utils.file_util import get_resource_path
18from devicetest.core.test_case import TestCase, Step, CheckPoint, get_report_dir
19from hypium import UiDriver
20import time
21from hypium import *
22from hypium.action.os_hypium.device_logger import DeviceLogger
23from hypium.action.host import host
24from hypium.model import UiParam
25
26
27class SUB_RUNNINGLOCK_TEST(TestCase):
28
29    def __init__(self, configs):
30        self.TAG = self.__class__.__name__
31        TestCase.__init__(self, self.TAG, configs)
32        self.tests = [
33            "test_step"
34        ]
35        self.driver = UiDriver(self.device1)
36        self.driver_width, self.driver_height = self.driver.get_display_size()
37        self.sn = self.device1.device_sn
38
39    def setup(self):
40        self.log.info("SUB_RUNNINGLOCK_TEST start")
41        #处理可能会弹出的USB连接方式弹窗
42        self.driver.touch(BY.text("确定"), EXCEPTION=False)
43
44
45        Step("预置条件1:设置休眠时长30s")
46        self.driver.Screen.set_sleep_time(30)
47
48        #清除日志
49        host.shell("hdc -t {} shell rm -r /data/log/hilog".format(self.sn))
50        host.shell("hdc -t {} shell hilog -d /system/bin/samgr".format(self.sn))
51
52        #回到桌面
53        self.driver.go_home()
54
55    def test_step(self):
56        Step("启动华为视频应用")
57        self.driver.start_app("com.huawei.hmsapp.himovie")
58        self.driver.wait(0.5)
59
60        #处理第一次弹出的同意使用app的选项
61        self.driver.touch(BY.text("同意").type("Button"), EXCEPTION=False)
62        self.driver.wait(0.5)
63
64
65        #点击免费专区
66        self.driver.touch(BY.key('PafSubTabBars.Text.text').text('免费专区'))
67
68        #通过相对位置点击控件,开始播放视频
69        self.driver.touch(BY.isAfter(BY.key('3560')).isBefore(BY.type('RelativeContainer')).key('ImageTextCard.Image.imageUrl').type('Image'))
70        self.driver.wait(0.5)
71
72
73        self.driver.wait(30)
74        Step("检查是否为亮屏状态")
75        self.driver.Screen.check_on()
76
77
78    def teardown(self):
79        Step("收尾工作")
80        self.log.info("SUB_RUNNINGLOCK_TEST down")
81        self.driver.stop_app("com.huawei.hmsapp.himovie")
82        #回到桌面
83        self.driver.go_home()