1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 #include <limits> 18 #include <test_header.h> 19 20 #include "hgm_hfbc_config.h" 21 #include <parameters.h> 22 23 using namespace testing; 24 using namespace testing::ext; 25 26 namespace OHOS { 27 namespace Rosen { 28 namespace { 29 constexpr const char* VDEC_HFBC_SWITCH = "vendor.vdec.hfbc.disable.fromuser"; 30 } 31 32 class HgmHfbcConfigTest : public testing::Test { 33 public: SetUpTestCase()34 static void SetUpTestCase() {} TearDownTestCase()35 static void TearDownTestCase() {} SetUp()36 void SetUp() {} TearDown()37 void TearDown() {} 38 }; 39 40 /** 41 * @tc.name: HandleHfbcConfig 42 * @tc.desc: Verify the execution process of HandleHfbcConfig function 43 * @tc.type: FUNC 44 * @tc.require: 45 */ 46 HWTEST_F(HgmHfbcConfigTest, HandleHfbcConfig01, Function | SmallTest | Level1) 47 { 48 std::vector<std::string> packageList; 49 packageList.emplace_back("com.test.banapp"); 50 packageList.emplace_back("com.test.allowapp"); 51 ASSERT_NO_FATAL_FAILURE({HgmHfbcConfig::HandleHfbcConfig(packageList);}); 52 std::string hfbcStatus = system::GetParameter(VDEC_HFBC_SWITCH, "0"); 53 bool ret = hfbcStatus == "-1"; 54 ASSERT_EQ(ret, 0); 55 } 56 57 /** 58 * @tc.name: HandleHfbcConfig 59 * @tc.desc: Verify the execution process of HandleHfbcConfig function 60 * @tc.type: FUNC 61 * @tc.require: 62 */ 63 HWTEST_F(HgmHfbcConfigTest, HandleHfbcConfig02, Function | SmallTest | Level1) 64 { 65 std::vector<std::string> packageList; 66 packageList.emplace_back("com.test.allowapp"); 67 ASSERT_NO_FATAL_FAILURE({HgmHfbcConfig::HandleHfbcConfig(packageList);}); 68 // hfbc can be enabled now 69 std::string hfbcStatus = system::GetParameter(VDEC_HFBC_SWITCH, "0"); 70 bool ret = hfbcStatus == "0"; 71 ASSERT_EQ(ret, 1); 72 } 73 74 } // namespace Rosen 75 } // namespace OHOS 76