From d6f2c553220816bbb4672c0b6f774780d192f4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=8F=9E=E9=A3=8E?= Date: Tue, 8 Mar 2022 01:44:34 +0000 Subject: [PATCH 1/2] Description:TDD testing case. Sig:aafwk Feature or Bugfix:Bugfix Binary Source:No #I4WRWM; Signed-off-by: wuluofeng --- frameworks/ability_lite/BUILD.gn | 10 ++ .../unittest/ability_main_test.cpp | 46 ++++++ frameworks/abilitymgr_lite/BUILD.gn | 8 + .../unittest/ability_manager_inner_test.cpp | 143 ++++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 frameworks/ability_lite/unittest/ability_main_test.cpp create mode 100644 frameworks/abilitymgr_lite/unittest/ability_manager_inner_test.cpp diff --git a/frameworks/ability_lite/BUILD.gn b/frameworks/ability_lite/BUILD.gn index c57d378..eeccdb8 100755 --- a/frameworks/ability_lite/BUILD.gn +++ b/frameworks/ability_lite/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/lite/config/component/lite_component.gni") import("//build/lite/config/subsystem/aafwk/config.gni") +import("//build/lite/config/test.gni") import("//build/lite/ndk/ndk.gni") generate_notice_file("ability_notice_file") { @@ -106,6 +107,15 @@ lite_component("aafwk_abilitykit_lite") { features = [ ":ability" ] } +unittest("ability_main_test_lv0") { + output_extension = "bin" + output_dir = "$root_out_dir/test/unittest/MainTest_lv0" + + sources = [ "//foundation/aafwk/aafwk_lite/frameworks/ability_lite/unittest/ability_main_test.cpp" ] + + include_dirs = [ "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite" ] +} + config("abilitykit_config") { ldflags = [ "-lstdc++", diff --git a/frameworks/ability_lite/unittest/ability_main_test.cpp b/frameworks/ability_lite/unittest/ability_main_test.cpp new file mode 100644 index 0000000..6675646 --- /dev/null +++ b/frameworks/ability_lite/unittest/ability_main_test.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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 "../../../interfaces/innerkits/abilitymgr_lite/ability_main.h" + +using namespace testing::ext; + +namespace OHOS { + class AbilityMainTest : public testing::Test { + public: + void SetUp() override + { + printf("AbilityMainTest setup"); + } + + void TearDown() override + { + printf("AbilityMainTest TearDown"); + } + void AbilityMainTest001(); + }; + + void AbilityMainTest::AbilityMainTest001() + { + printf("AbilityMainTest setup"); + SetUp(); + const char *token = "launcher"; + auto ret = AbilityMain(token); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityMainTest001 end--------"); + } +} \ No newline at end of file diff --git a/frameworks/abilitymgr_lite/BUILD.gn b/frameworks/abilitymgr_lite/BUILD.gn index f49098d..9e4cc95 100755 --- a/frameworks/abilitymgr_lite/BUILD.gn +++ b/frameworks/abilitymgr_lite/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/lite/config/component/lite_component.gni") import("//build/lite/config/subsystem/aafwk/config.gni") +import("//build/lite/config/test.gni") lite_library("abilitymanager") { target_type = "shared_library" @@ -53,6 +54,13 @@ lite_library("abilitymanager") { defines = [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ] } +unittest("ability_manager_inner_test") { + output_extension = "bin" + output_dir = "$root_out_dir/test/unittest/ManagerInnerTest_lv0" + + sources = [ "//foundation/aafwk/aafwk_lite/frameworks/abilitymgr_lite/unittest/ability_manager_inner_test.cpp" ] +} + lite_component("aafwk_abilityManager_lite") { features = [ ":abilitymanager" ] } diff --git a/frameworks/abilitymgr_lite/unittest/ability_manager_inner_test.cpp b/frameworks/abilitymgr_lite/unittest/ability_manager_inner_test.cpp new file mode 100644 index 0000000..3b34e9a --- /dev/null +++ b/frameworks/abilitymgr_lite/unittest/ability_manager_inner_test.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2022 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 "../../../interfaces/innerkits/abilitymgr_lite/slite/ability_manager_inner.h" + +using namespace testing::ext; + +using int (*StartCheckFunc)(const char *bundleName); + +namespace OHOS { + class AbilityManagerInnerTest : public testing::Test { + public: + void SetUp() override + { + printf("AbilityManagerInnerTest setup"); + } + + void TearDown() override + { + printf("AbilityManagerInnerTest TearDown"); + } + + void AbilityManagerInnerTest001(); + void AbilityManagerInnerTest002(); + void AbilityManagerInnerTest003(); + void AbilityManagerInnerTest004(); + void AbilityManagerInnerTest005(); + void AbilityManagerInnerTest006(); + void AbilityManagerInnerTest007(); + void AbilityManagerInnerTest008(); + void RunTests(); + }; + + void AbilityManagerInnerTest::AbilityManagerInnerTest001() + { + printf("AbilityManagerInnerTest setup"); + SetUp(); + StartCheckFunc startChecktCallback = getAbilityCallback(); + auto ret = RegAbilityCallback(startChecktCallback); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityManagerInnerTest001 RegAbilityCallback end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest002() + { + printf("--------AbilityManagerInnerTest002 SchedulerLifecycleDone begin--------"); + SetUp(); + int state = 2; + auto token = 0; + auto ret = SchedulerLifecycleDone(token, state); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityManagerInnerTest002 SchedulerLifecycleDone end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest003() + { + printf("--------AbilityManagerInnerTest003 ForceStopBundle begin--------"); + SetUp(); + auto token = 0; + auto ret = ForceStopBundle(token); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityManagerInnerTest003 ForceStopBundle end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest004() + { + printf("--------AbilityManagerInnerTest004 GetTopAbility begin--------"); + SetUp(); + auto ret = GetTopAbility(); + EXPECT_TRUE(ret == nullptr); + TearDown(); + printf("--------AbilityManagerInnerTest004 GetTopAbility end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest005() + { + printf("--------AbilityManagerInnerTest005 ForceStop begin--------"); + SetUp(); + char *bundlename = "bundletest"; + auto ret = ForceStop(bundlename); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityManagerInnerTest005 ForceStop end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest006() + { + printf("--------AbilityManagerInnerTest006 getAbilityCallback begin--------"); + SetUp(); + auto ret = getAbilityCallback(); + EXPECT_TRUE(ret == nullptr); + TearDown(); + printf("--------AbilityManagerInnerTest006 getAbilityCallback end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest007() + { + printf("--------AbilityManagerInnerTest007 setCleanAbilityDataFlag begin--------"); + SetUp(); + bool cleanFlag = true; + setCleanAbilityDataFlag(cleanFlag); + TearDown(); + printf("--------AbilityManagerInnerTest007 setCleanAbilityDataFlag end--------"); + } + + void AbilityManagerInnerTest::AbilityManagerInnerTest008() + { + printf("--------AbilityManagerInnerTest008 getCleanAbilityDataFlag begin--------"); + SetUp(); + auto ret = getCleanAbilityDataFlag(); + EXPECT_TRUE(ret == 0); + TearDown(); + printf("--------AbilityManagerInnerTest008 getCleanAbilityDataFlag end--------"); + } + + void AbilityManagerInnerTest::RunTests() + { + void AbilityManagerInnerTest001(); + void AbilityManagerInnerTest002(); + void AbilityManagerInnerTest003(); + void AbilityManagerInnerTest004(); + void AbilityManagerInnerTest005(); + void AbilityManagerInnerTest006(); + void AbilityManagerInnerTest007(); + void AbilityManagerInnerTest008(); + } +} \ No newline at end of file -- Gitee From ed895b290440413898fcdcb42991373a253b7a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=8F=9E=E9=A3=8E?= Date: Tue, 8 Mar 2022 02:07:46 +0000 Subject: [PATCH 2/2] Description:TDD testing case. Sig:aafwk Feature or Bugfix:Bugfix Binary Source:No #I4WRWM; Signed-off-by: wuluofeng --- frameworks/abilitymgr_lite/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/abilitymgr_lite/BUILD.gn b/frameworks/abilitymgr_lite/BUILD.gn index 9e4cc95..afa96c4 100755 --- a/frameworks/abilitymgr_lite/BUILD.gn +++ b/frameworks/abilitymgr_lite/BUILD.gn @@ -37,6 +37,7 @@ lite_library("abilitymanager") { "${aafwk_lite_path}/frameworks/abilitymgr_lite/include", "${aafwk_lite_path}/frameworks/want_lite/include", "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite", + "${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite/slite", "${aafwk_lite_path}/interfaces/kits/want_lite", "${aafwk_lite_path}/interfaces/kits/ability_lite", "${appexecfwk_lite_path}/utils/bundle_lite", -- Gitee