From e34831d973eda91f0572648e851ef5cacbabb861 Mon Sep 17 00:00:00 2001 From: mengyiping <1091773127@qq.com> Date: Fri, 19 Jul 2024 10:39:33 +0800 Subject: [PATCH] Feature Signed-off-by: mengyiping <1091773127@qq.com> --- test/BUILD.gn | 30 +++++++++++ test/unittest/phone/set_rate_test.cpp | 71 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 test/unittest/phone/set_rate_test.cpp diff --git a/test/BUILD.gn b/test/BUILD.gn index bbd8565..22334b3 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -279,6 +279,35 @@ ohos_unittest("config_reader_test") { part_name = "qos_manager" } +ohos_unittest("set_rate_test") { + module_out_path = module_output_path + + configs = [ ":test_config" ] + + sources = [ "unittest/phone/set_rate_test.cpp" ] + deps = [ + "../etc/param:ffrt_etc", + "../frameworks/concurrent_task_client:concurrent_task_client", + "../services:concurrentsvc", + "//third_party/jsoncpp:jsoncpp", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "init:libbegetutil", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (is_standard_system) { + public_deps = gtest_public_deps + } + + subsystem_name = "resourceschedule" + part_name = "qos_manager" +} + group("concurrent_unittest") { testonly = true deps = [] @@ -294,6 +323,7 @@ group("concurrent_unittest") { ":qos_ndk_test", ":qos_policy_test", ":qos_test", + ":set_rate_test", ] } } diff --git a/test/unittest/phone/set_rate_test.cpp b/test/unittest/phone/set_rate_test.cpp new file mode 100644 index 0000000..3618a9e --- /dev/null +++ b/test/unittest/phone/set_rate_test.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "parameters.h" +#define private public +#include "concurrent_task_controller.h" +#undef private + +namespace OHOS { +namespace FFRT_TEST { +using namespace testing; +using namespace testing::ext; +using namespace OHOS::ConcurrentTask; +using namespace std; + + +class SetRateTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void SetRateTest::SetUpTestCase() +{ +} + +void SetRateTest::TearDownTestCase() +{ +} + +void SetRateTest::SetUp() +{ +} + +void SetRateTest::TearDown() +{ +} + +/** + * @tc.name: SetRenderServiceRate + * @tc.desc: Test whether the SetRenderServiceRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(SetRateTest, SetRenderServiceRateTest, TestSize.Level1) +{ + Json::Value payload; + payload["758"] = "144"; + TaskController::GetInstance().renderServiceMainTid_ = 758; + TaskController::GetInstance().systemRate_ = 0; + TaskController::GetInstance().renderServiceMainGrpId_ = 1; + TaskController::GetInstance().SetRenderServiceRate(payload); + EXPECT_EQ(TaskController::GetInstance().systemRate_, 144); + EXPECT_EQ(OHOS::system::GetIntParameter("persist.ffrt.interval.rsRate", 0), 144); +} +} +} \ No newline at end of file -- Gitee