From 8af6aef74a3d7904e4a23a16a01b7b9cf70e4ebe Mon Sep 17 00:00:00 2001 From: wendel Date: Mon, 5 Jan 2026 11:14:54 +0800 Subject: [PATCH] add ut Signed-off-by: wendel --- test/unittest/BUILD.gn | 1 + .../start_params_by_SCB_test/BUILD.gn | 40 +++++++++ .../start_params_by_SCB_test.cpp | 86 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 test/unittest/start_params_by_SCB_test/BUILD.gn create mode 100644 test/unittest/start_params_by_SCB_test/start_params_by_SCB_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 08beab03c4..bd6d1cc80b 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -476,6 +476,7 @@ group("unittest") { "start_options_test:unittest", "start_options_utils_test:unittest", "start_other_app_interceptor_test:unittest", + "start_params_by_SCB_test:unittest", "startup_util_test:unittest", "state_utils_test:unittest", "stop_user_callback_proxy_test:unittest", diff --git a/test/unittest/start_params_by_SCB_test/BUILD.gn b/test/unittest/start_params_by_SCB_test/BUILD.gn new file mode 100644 index 0000000000..dd2c3e87fd --- /dev/null +++ b/test/unittest/start_params_by_SCB_test/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2026 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/ability_runtime/abilitymgr" + +ohos_unittest("start_params_by_SCB_test") { + module_out_path = module_output_path + + sources = [ "start_params_by_SCB_test.cpp" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager" ] + + external_deps = [ + "c_utils:utils", + "googletest:gtest_main", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":start_params_by_SCB_test" ] +} diff --git a/test/unittest/start_params_by_SCB_test/start_params_by_SCB_test.cpp b/test/unittest/start_params_by_SCB_test/start_params_by_SCB_test.cpp new file mode 100644 index 0000000000..682e7a1389 --- /dev/null +++ b/test/unittest/start_params_by_SCB_test/start_params_by_SCB_test.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2026 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 + +#include "parcel.h" +#define private public +#include "start_params_by_SCB.h" +#undef private + +using namespace testing::ext; +namespace OHOS { +namespace AbilityRuntime { +class StartParamsBySCBTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void StartParamsBySCBTest::SetUpTestCase() +{} + +void StartParamsBySCBTest::TearDownTestCase() +{} + +void StartParamsBySCBTest::SetUp() +{} + +void StartParamsBySCBTest::TearDown() +{} + +/** + * @tc.name: start_params_by_SCB_test_001 + * @tc.desc: test class StartParamsBySCB marshalling function + * @tc.type: FUNC + */ +HWTEST_F(StartParamsBySCBTest, start_params_by_SCB_test_001, TestSize.Level1) +{ + StartParamsBySCB params; + Parcel parcel; + bool marshallResult = params.Marshalling(parcel); + EXPECT_EQ(marshallResult, true); +} + +/** + * @tc.name: start_params_by_SCB_test_002 + * @tc.desc: test class StartOptions Unmarshalling function + * @tc.type: FUNC + */ +HWTEST_F(StartParamsBySCBTest, start_params_by_SCB_test_002, TestSize.Level1) +{ + StartParamsBySCB params; + Parcel parcel; + auto unmarshallResult = params.Unmarshalling(parcel); + EXPECT_NE(unmarshallResult, nullptr); + ASSERT_FALSE(unmarshallResult->isRestart); +} + +/** + * @tc.name: start_params_by_SCB_test_003 + * @tc.desc: test class StartOptions Unmarshalling function + * @tc.type: FUNC + */ +HWTEST_F(StartParamsBySCBTest, start_params_by_SCB_test_003, TestSize.Level1) +{ + StartParamsBySCB params; + Parcel parcel; + bool result = params.ReadFromParcel(parcel); + ASSERT_TRUE(result); +} +} // namespace AbilityRuntime +} // namespace OHOS