diff --git a/frameworks/ability_lite/BUILD.gn b/frameworks/ability_lite/BUILD.gn index c57d37864fc1216b076af26420261bd48b5ddcee..eeccdb8718202fcd11c94bfac677ddca4a90a7a6 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 0000000000000000000000000000000000000000..667564698d22a29eb24a613338cdb8e637505547 --- /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 f49098daba923f10f14598d2b9756dfe4887926e..afa96c400945e7c490302f16eb03c8cb1b087588 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" @@ -36,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", @@ -53,6 +55,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 0000000000000000000000000000000000000000..3b34e9a969612fba37929d9d641d133a9f051c8f --- /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