• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#-*- coding: utf-8 -*-
3
4# Copyright (c) 2025 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
17import os
18import sys
19
20current_dir = os.path.abspath(os.path.dirname(__file__))
21rootPath = os.path.split(current_dir)[0]
22awPath = os.path.split(rootPath)[0]
23sys.path.append(rootPath)
24sys.path.append(os.path.join(awPath, "aw"))
25
26import os.path
27import time
28from devicetest.core.test_case import TestCase, Step, CheckPoint, get_report_dir
29from hypium import UiDriver
30import disk_drop_log
31from get_source_path import get_source_path
32from push_remove_source import push_source, remove_source
33from hypium.action.os_hypium.device_logger import DeviceLogger
34
35
36class case24_sub001(TestCase):
37
38    def __init__(self, configs):
39        self.TAG = self.__class__.__name__
40        TestCase.__init__(self, self.TAG, configs)
41        self.tests = [
42            "test_step"
43        ]
44        self.driver = UiDriver(self.device1)
45        self.sn = self.device1.device_sn
46        self.source_path = {}
47
48    def setup(self):
49        self.log.info("case24_sub001 start")
50        need_source = {"cfg": True, "listen_test": False, "audio_ability": False, "ondemand": False,
51                       "proxy": False, "para": False}
52        self.source_path = get_source_path(need_source=need_source, casename="level0/case24_sub001")
53        push_source(source_path=self.source_path, driver=self.driver, sn=self.sn)
54
55    def test_step(self):
56        driver = self.driver
57        device_logger = DeviceLogger(driver).set_filter_string("01800")
58        device_logger.start_log(get_report_dir() + "//case024_sub001.txt")
59        driver.System.execute_command("ondemand sa load 1494")
60        result = driver.System.execute_command("hidumper -ls")
61        max_wait_time = 10
62        wait_time = 0
63        while ("1494" not in result and wait_time <= max_wait_time):
64            wait_time += 1
65            time.sleep(1)
66            result = driver.System.execute_command("hidumper -ls")
67        CheckPoint("1494 is loaded after booting up")
68        assert "1494" in result
69
70        time.sleep(5)
71        device_logger.stop_log()
72        CheckPoint("The log contains 'ListenAbility: OnAddSystemAbility systemAbilityId:1901 added!'")
73        device_logger.check_log("OnAddSystemAbility systemAbilityId:1901 added!", EXCEPTION=True)
74        CheckPoint("The log contains 'ListenAbility: OnAddSystemAbility systemAbilityId:4700 added!'")
75        device_logger.check_log("OnAddSystemAbility systemAbilityId:4700 added!", EXCEPTION=True)
76
77    def teardown(self):
78        remove_source(source_path=self.source_path, driver=self.driver, sn=self.sn)
79        self.log.info("case24_sub001 down")
80