From 3a4cc712cf32a008f9e37fb71be4192289b83de8 Mon Sep 17 00:00:00 2001 From: caochufeng Date: Fri, 25 Oct 2024 21:56:46 +0800 Subject: [PATCH] add unittest Signed-off-by: caochufeng --- .../test/unittest/standby_utils_unit_test.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/services/test/unittest/standby_utils_unit_test.cpp b/services/test/unittest/standby_utils_unit_test.cpp index 684e5a5..137a27a 100644 --- a/services/test/unittest/standby_utils_unit_test.cpp +++ b/services/test/unittest/standby_utils_unit_test.cpp @@ -33,6 +33,7 @@ namespace { const std::string JSON_KEY = "key"; const std::string JSON_ERROR_KEY = "error_key"; const std::string TAG_APPS_LIMIT = "apps_limit"; + const std::string TAG_BATTERY_THRESHOLD = "battery_threshold"; } class StandbyUtilsUnitTest : public testing::Test { public: @@ -522,5 +523,23 @@ HWTEST_F(StandbyUtilsUnitTest, StandbyUtilsUnitTest_027, TestSize.Level1) int result = StandbyConfigManager::GetInstance()->CompareVersion(configVerA, configVerB); EXPECT_EQ(result, 1); } + +/** + * @tc.name: StandbyUtilsUnitTest_028 + * @tc.desc: test GetStandbyLadderBatteryList of StandbyConfigManager. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(StandbyUtilsUnitTest, StandbyUtilsUnitTest_028, TestSize.Level1) +{ + StandbyConfigManager::GetInstance()->ladderBatteryListMap_ = { + {"battery_threshold", {90, 40}} + }; + auto result = StandbyConfigManager::GetInstance()->GetStandbyLadderBatteryList(TAG_BATTERY_THRESHOLD); + EXPECT_EQ(result.size(), 2); + StandbyConfigManager::GetInstance()->ladderBatteryListMap_.clear(); + result = StandbyConfigManager::GetInstance()->GetStandbyLadderBatteryList(TAG_BATTERY_THRESHOLD); + EXPECT_EQ(result.size(), 0); +} } // namespace DevStandbyMgr } // namespace OHOS -- Gitee