diff --git a/aafwk_lite/ability_hal/BUILD.gn b/aafwk_lite/ability_hal/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..4dd11af791cbfcf769b33bdec72c99e2573a951f --- /dev/null +++ b/aafwk_lite/ability_hal/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2021-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. + +import("//test/xts/tools/lite/build/suite_lite.gni") +hctest_suite("ActsAbilityMgrTest") { + suite_name = "acts" + sources = [ "src/ability_mgr_test.c" ] + + include_dirs = [ + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${aafwk_lite_path}/interfaces/kits/ability_lite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + "//foundation/communication/ipc_lite/interfaces/kits", + ] + cflags = [ "-Wno-error" ] +} diff --git a/aafwk_lite/ability_hal/Test.tmpl b/aafwk_lite/ability_hal/Test.tmpl new file mode 100755 index 0000000000000000000000000000000000000000..be8407e1286041a5af2bdc75a15633337376eb9d --- /dev/null +++ b/aafwk_lite/ability_hal/Test.tmpl @@ -0,0 +1,19 @@ +{ + "description": "Config for $module test cases", + "environment": [ + { + "type": "device", + "label": "wifiiot" + } + ], + "kits": [ + { + "type": "DeployKit", + "timeout": "20000", + "burn_file": "$subsystem/$module.bin" + } + ], + "driver": { + "type": "CTestLite" + } +} \ No newline at end of file diff --git a/aafwk_lite/ability_hal/src/ability_mgr_test.c b/aafwk_lite/ability_hal/src/ability_mgr_test.c new file mode 100755 index 0000000000000000000000000000000000000000..6e04857af61cdfab196965d5811e6e3f6ce8588f --- /dev/null +++ b/aafwk_lite/ability_hal/src/ability_mgr_test.c @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2021-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 + +#include "hctest.h" +#include "ohos_types.h" + +#include "ability_manager.h" +#include "want.h" + + +/** +* @brief register a test suit named AbilityMgrTestSuite +* @param subsystem name is aafwk +* @param module name is abilitymgr +* @param test suit name is AbilityMgrTestSuite +*/ +LITE_TEST_SUIT(aafwk, abilitymgr, AbilityMgrTestSuite); + +static BOOL AbilityMgrTestSuiteSetUp(void) +{ + printf("----------test case with AbilityMgrTest start-------------\n"); + return TRUE; +} + +static BOOL AbilityMgrTestSuiteTearDown(void) +{ + printf("----------test case with AbilityMgrTest end-------------\n"); + return TRUE; +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0001 + * @tc.name : testClearElement parameter legal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testClearElement, Function | MediumTest | Level0) +{ + printf("------start testClearElement------\n"); + ElementName element = { 0 }; + bool ret = SetElementAbilityName(&element, "SecondAbility"); + if (ret) { + char aName[] = "SecondAbility"; + TEST_ASSERT_EQUAL_STRING(element.abilityName, aName); + ClearElement(&element); + TEST_ASSERT_EQUAL_STRING(element.abilityName, NULL); + } + printf("------end testClearElement------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0002 + * @tc.name : testClearElement parameter illegal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testClearElementIllegal, Function | MediumTest | Level0) +{ + printf("------start testClearElementIllegal------\n"); + ElementName element = { 0 }; + bool ret = SetElementAbilityName(&element, "SecondAbility"); + if (ret) { + char aName[] = "SecondAbility"; + TEST_ASSERT_EQUAL_STRING(element.abilityName, aName); + ClearElement(NULL); + TEST_ASSERT_EQUAL_STRING(element.abilityName, aName); + } + printf("------end testClearElementIllegal------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0003 + * @tc.name : testSetWantElement parameter legal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantElement, Function | MediumTest | Level0) +{ + printf("------start testSetWantElement------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementDeviceID(&element, "0001000"); + SetElementBundleName(&element, "com.openharmony.testnative"); + SetElementAbilityName(&element, "SecondAbility"); + if (element.abilityName != NULL) { + bool ret = SetWantElement(&want, element); + if (ret) { + TEST_ASSERT_EQUAL_STRING(want.element->deviceId, "0001000"); + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, "SecondAbility"); + TEST_ASSERT_EQUAL_STRING(want.element->bundleName, "com.openharmony.testnative"); + } + } + ClearElement(&element); + ClearWant(&want); + printf("------end testSetWantElement------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0004 + * @tc.name : testSetWantElement parameter illegal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantElementIllegal, Function | MediumTest | Level2) +{ + printf("------start testSetWantElementIllegal------\n"); + Want want= { 0 }; + ElementName element = { 0 }; + bool ret = SetWantElement(&want, element); + if (ret) { + TEST_ASSERT_EQUAL_STRING(want.element->deviceId, NULL); + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, NULL); + TEST_ASSERT_EQUAL_STRING(want.element->bundleName, NULL); + } + ClearElement(&element); + TEST_ASSERT_EQUAL_STRING(element.abilityName, NULL); + ClearWant(&want); + TEST_ASSERT_EQUAL_STRING(want.element, NULL); + printf("------end testSetWantElementIllegal------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0005 + * @tc.name : testClearWant parameter illegal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testClearWantIllegal, Function | MediumTest | Level2) +{ + printf("------start testClearWantIllegal------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + bool ret = SetElementAbilityName(&element, "SecondAbility"); + if (ret) { + ret = SetWantElement(&want, element); + if (ret) { + char aName[] = "SecondAbility"; + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, aName); + ClearWant(NULL); + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, aName); + } + } + ClearElement(&element); + ClearWant(&want); + printf("------end testClearWantIllegal------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0006 + * @tc.name : testSetWantDate parameter legal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantDate, Function | MediumTest | Level0) +{ + printf("------start testSetWantDate------\n"); + Want want = { 0 }; + SetWantData(&want, "test", 5); + if (want.data != NULL) { + TEST_ASSERT_EQUAL_STRING((char*)(want.data), "test"); + TEST_ASSERT_TRUE(want.dataLength == 5); + } + ClearWant(&want); + printf("------end testSetWantDate------\n"); +} + +/** + * @tc.number : SUB_AAFWK_ABILITY_0007 + * @tc.name : testSetWantDate parameter illegal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(AbilityMgrTestSuite, testSetWantDateIllegal, Function | MediumTest | Level2) +{ + printf("------start testSetWantDateIllegal------\n"); + Want want = { 0 }; + SetWantData(&want, "test", -1); + TEST_ASSERT_EQUAL_STRING((char*)(want.data), NULL); + TEST_ASSERT_FALSE(want.dataLength); + SetWantData(&want, NULL, 0); + TEST_ASSERT_EQUAL_STRING((char*)(want.data), NULL); + TEST_ASSERT_FALSE(want.dataLength); + printf("------end testSetWantDateIllegal------\n"); +} + +RUN_TEST_SUITE(AbilityMgrTestSuite); diff --git a/appexecfwk_lite/appexecfwk_hal/BUILD.gn b/appexecfwk_lite/appexecfwk_hal/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..2fb385cc4dffaefad52407b8a0107a52c1827151 --- /dev/null +++ b/appexecfwk_lite/appexecfwk_hal/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021-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. + +import("//test/xts/tools/lite/build/suite_lite.gni") +hctest_suite("ActsBundleMgrTest") { + suite_name = "acts" + sources = [ "src/bundle_mgr_test.c" ] + + include_dirs = [ + "${aafwk_lite_path}/interfaces/kits/want_lite", + "${appexecfwk_lite_path}/interfaces/kits/bundle_lite", + ] + cflags = [ "-Wno-error" ] +} diff --git a/appexecfwk_lite/appexecfwk_hal/Test.tmpl b/appexecfwk_lite/appexecfwk_hal/Test.tmpl new file mode 100755 index 0000000000000000000000000000000000000000..be8407e1286041a5af2bdc75a15633337376eb9d --- /dev/null +++ b/appexecfwk_lite/appexecfwk_hal/Test.tmpl @@ -0,0 +1,19 @@ +{ + "description": "Config for $module test cases", + "environment": [ + { + "type": "device", + "label": "wifiiot" + } + ], + "kits": [ + { + "type": "DeployKit", + "timeout": "20000", + "burn_file": "$subsystem/$module.bin" + } + ], + "driver": { + "type": "CTestLite" + } +} \ No newline at end of file diff --git a/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c b/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c new file mode 100755 index 0000000000000000000000000000000000000000..0bad2856d957aaa91a0f3591edaa2b3eeb556df1 --- /dev/null +++ b/appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c @@ -0,0 +1,199 @@ +/** + * Copyright (c) 2021-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 + +#include "hctest.h" +#include "securec.h" +#include "bundle_info.h" +#include "bundle_manager.h" +#include "want.h" + +/** +* @brief register a test suit named BundleMgrTestSuite +* @param subsystem name is appexecfwk +* @param module name is bundlemgr +* @param test suit name is BundleMgrTestSuite +*/ +LITE_TEST_SUIT(appexecfwk, bundlemgr, BundleMgrTestSuite); + +static BOOL BundleMgrTestSuiteSetUp(void) +{ + printf("----------test case with BundleMgrTest start-------------\n"); + return TRUE; +} + +static BOOL BundleMgrTestSuiteTearDown(void) +{ + printf("----------test case with BundleMgrTest end-------------\n"); + return TRUE; +} + +/** + * @tc.number : SUB_APPEXECFWK_0001 + * @tc.name : testClearAbilityInfo parameter illegal test + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | MediumTest | Level2) +{ + printf("------start testClearAbilityInfoIllegal------\n"); + AbilityInfo abilityInfo = { 0 }; + memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo)); + abilityInfo.bundleName = "com.openharmony.testjsdemo"; + ClearAbilityInfo(NULL); + TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, "com.openharmony.testjsdemo"); + printf("------end testClearAbilityInfoIllegal------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0002 + * @tc.name : testClearBundleInfo parameter legal test with bundle name + * @tc.desc : [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | MediumTest | Level2) +{ + printf("------start testClearBundleInfoIllegal------\n"); + BundleInfo bundleInfo = { 0 }; + memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo)); + bundleInfo.bundleName = "com.openharmony.testjsdemo"; + ClearBundleInfo(NULL); + TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, "com.openharmony.testjsdemo"); + printf("------end testClearBundleInfoIllegal------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0003 + * @tc.name : testSetElementAbilityName parameter legal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementAbilityName, Function | MediumTest | Level0) +{ + printf("------start testSetElementAbilityName------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementAbilityName(&element, "SecondAbility"); + SetWantElement(&want, element); + char *aName = "SecondAbility"; + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, aName); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementAbilityName------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0004 + * @tc.name : testSetElementAbilityName parameter illegal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementAbilityNameIllegal, Function | MediumTest | Level2) +{ + printf("------start testSetElementAbilityNameIllegal------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + char *aName = ""; + SetElementAbilityName(&element, aName); + SetWantElement(&want, element); + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, ""); + SetElementAbilityName(&element, NULL); + SetWantElement(&want, element); + TEST_ASSERT_EQUAL_STRING(want.element->abilityName, NULL); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementAbilityNameIllegal------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0005 + * @tc.name : testSetElementBundleName parameter legal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementBundleName, Function | MediumTest | Level0) +{ + printf("------start testSetElementBundleName------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementBundleName(&element, "com.openharmony.testjsdemo"); + SetWantElement(&want, element); + char *bName = "com.openharmony.testjsdemo"; + TEST_ASSERT_EQUAL_STRING(want.element->bundleName, bName); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementBundleName------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0006 + * @tc.name : testSetElementBundleName parameter illegal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementBundleNameIllegal, Function | MediumTest | Level2) +{ + printf("------start testSetElementBundleNameIllegal------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementBundleName(&element, ""); + SetWantElement(&want, element); + char *bName = ""; + TEST_ASSERT_EQUAL_STRING(want.element->bundleName, bName); + SetElementBundleName(&element, NULL); + SetWantElement(&want, element); + TEST_ASSERT_EQUAL_STRING(want.element->bundleName, NULL); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementBundleNameIllegal------\n"); +} +/** + * @tc.number : SUB_APPEXECFWK_0007 + * @tc.name : testSetElementDeviceID parameter legal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementDeviceID, Function | MediumTest | Level0) +{ + printf("------start testSetElementDeviceID------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementDeviceID(&element, "0001000"); + SetWantElement(&want, element); + char *dID = "0001000"; + TEST_ASSERT_EQUAL_STRING(want.element->deviceId, dID); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementDeviceID------\n"); +} + +/** + * @tc.number : SUB_APPEXECFWK_0008 + * @tc.name : testSetElementDeviceID parameter illegal test + * @tc.desc : [C- SOFTWARE -0100] + */ +LITE_TEST_CASE(BundleMgrTestSuite, testSetElementDeviceIDIllegal, Function | MediumTest | Level2) +{ + printf("------start testSetElementDeviceIDIllegal------\n"); + Want want = { 0 }; + ElementName element = { 0 }; + SetElementDeviceID(&element, ""); + SetWantElement(&want, element); + char *dID = ""; + TEST_ASSERT_EQUAL_STRING(want.element->deviceId, dID); + SetElementDeviceID(&element, NULL); + SetWantElement(&want, element); + TEST_ASSERT_EQUAL_STRING(want.element->deviceId, NULL); + ClearElement(&element); + ClearWant(&want); + printf("------end testSetElementDeviceIDIllegal------\n"); +} + +RUN_TEST_SUITE(BundleMgrTestSuite); diff --git a/build_lite/BUILD.gn b/build_lite/BUILD.gn index 2a736bbf5b9d7fb523b112e39593ef3295e86458..00248832b448c464fd5f0794337636edd192d73c 100644 --- a/build_lite/BUILD.gn +++ b/build_lite/BUILD.gn @@ -32,6 +32,8 @@ lite_component("acts_component") { } else { if (ohos_kernel_type == "liteos_m") { all_features += [ + "//test/xts/acts/aafwk_lite/ability_hal:ActsAbilityMgrTest", + "//test/xts/acts/appexecfwk_lite/appexecfwk_hal:ActsBundleMgrTest", "//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest", "//test/xts/acts/communication_lite/wifiservice_hal:ActsWifiServiceTest", "//test/xts/acts/utils_lite/file_hal:ActsUtilsFileTest",