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_install_multi, check_app_uninstall, \ 17 check_app_uninstall_multi, check_hdc_cmd, get_local_path, load_gp 18 19 20class TestInstallBase: 21 hap_tables = { 22 "AACommand07.hap" : "com.example.aacommand07", 23 "AACommand08.hap" : "com.example.aacommand08" 24 } 25 hsp_tables = { 26 "libA_v10001.hsp" : "com.example.liba", 27 "libB_v10001.hsp" : "com.example.libb", 28 } 29 hsp_hap_tables = { 30 "AACommandpackage.hap" : "com.example.actsaacommandtestatest", 31 "libB_v10001.hsp" : "com.example.libb", 32 } 33 34 # 来自原hdc_normal_test.py的基础install 用例 35 @pytest.mark.L0 36 @pytest.mark.repeat(2) 37 @pytest.mark.parametrize("package_hap, hap_name_default", hap_tables.items()) 38 def test_hap_install(self, package_hap, hap_name_default): 39 assert check_hdc_cmd(f"install -r {get_local_path(f'{package_hap}')}", 40 bundle=f"{hap_name_default}") 41 assert check_app_uninstall(f"{hap_name_default}") 42 43 @pytest.mark.L1 44 @pytest.mark.repeat(2) 45 @pytest.mark.parametrize("package_hap, hap_name_default", hap_tables.items()) 46 def test_install_hap(self, package_hap, hap_name_default): 47 48 # default 49 assert check_app_install(package_hap, hap_name_default) 50 assert check_app_uninstall(hap_name_default) 51 52 # -r 53 assert check_app_install(package_hap, hap_name_default, "-r") 54 assert check_app_uninstall(hap_name_default) 55 56 # -k 57 assert check_app_install(package_hap, hap_name_default, "-r") 58 assert check_app_uninstall(hap_name_default, "-k") 59 60 # -s 61 assert check_app_install(package_hap, hap_name_default, "-s") 62 63 @pytest.mark.L0 64 @pytest.mark.repeat(2) 65 @pytest.mark.parametrize("package_hsp, hsp_name_default", hsp_tables.items()) 66 def test_install_hsp(self, package_hsp, hsp_name_default): 67 assert check_app_install(package_hsp, hsp_name_default, "-s") 68 assert check_app_uninstall(hsp_name_default, "-s") 69 assert check_app_install(package_hsp, hsp_name_default) 70 71 @pytest.mark.L0 72 @pytest.mark.repeat(2) 73 def test_install_multi_hap(self): 74 # default multi hap 75 assert check_app_install_multi(self.hap_tables) 76 assert check_app_uninstall_multi(self.hap_tables) 77 assert check_app_install_multi(self.hap_tables, "-s") 78 assert check_app_install_multi(self.hap_tables, "-r") 79 assert check_app_uninstall_multi(self.hap_tables, "-k") 80 81 82 @pytest.mark.L0 83 @pytest.mark.repeat(2) 84 def test_install_multi_hsp(self): 85 # default multi hsp -s 86 assert check_app_install_multi(self.hsp_tables, "-s") 87 assert check_app_uninstall_multi(self.hsp_tables, "-s") 88 assert check_app_install_multi(self.hsp_tables) 89 90 @pytest.mark.L0 91 @pytest.mark.repeat(2) 92 def test_install_hsp_and_hap(self): 93 #default multi hsp and hsp 94 assert check_app_install_multi(self.hsp_hap_tables) 95 assert check_app_install_multi(self.hsp_hap_tables, "-s") 96 97 @pytest.mark.L0 98 @pytest.mark.repeat(2) 99 def test_install_dir(self): 100 package_haps_dir = "app_dir" 101 hap_name_default_default = "com.example.aacommand07" 102 assert check_app_install(package_haps_dir, hap_name_default_default) 103 assert check_app_uninstall(hap_name_default_default)