• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright (C) 2025 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15import pytest
16from utils import GP, check_app_install, check_app_uninstall, check_cmd_block, \
17    check_hdc_cmd, check_shell, get_shell_result, load_gp, get_end_symbol
18
19
20class TestHdcTrackJpid:
21    bundle_name = "com.example.aacommand07"
22
23    @classmethod
24    def setup_class(self):
25        package_hap = "AACommand07.hap"
26        assert check_app_install(package_hap, self.bundle_name)
27        assert check_shell(f"shell aa start -b {self.bundle_name} -a MainAbility")
28
29    @classmethod
30    def teardown_class(self):
31        assert check_shell(f"shell aa force-stop {self.bundle_name}")
32        assert check_app_uninstall(self.bundle_name)
33
34    @pytest.mark.L0
35    def test_hdc_jpid(self):
36        pidstr = get_shell_result(f'shell "pidof {self.bundle_name}"').split(get_end_symbol())[0]
37        assert check_hdc_cmd(f"jpid", pidstr)
38
39    @pytest.mark.L0
40    def test_hdc_track_jpid(self):
41        pidstr = get_shell_result(f'shell "pidof {self.bundle_name}"').split(get_end_symbol())[0]
42        track_cmd_p = f"{GP.hdc_exe} -t {GP.device_name} track-jpid -p"
43        pattern_p = f"{pidstr} {self.bundle_name}"
44        assert check_cmd_block(track_cmd_p, pattern_p, timeout=2)
45        track_cmd_a = f"{GP.hdc_exe} -t {GP.device_name} track-jpid -a"
46        pattern_a = f"{pidstr} {self.bundle_name} release"
47        assert check_cmd_block(track_cmd_a, pattern_a, timeout=2)
48