diff --git a/services/dtbschedmgr/test/BUILD.gn b/services/dtbschedmgr/test/BUILD.gn index d426e9f0..b150555b 100644 --- a/services/dtbschedmgr/test/BUILD.gn +++ b/services/dtbschedmgr/test/BUILD.gn @@ -126,18 +126,92 @@ distributed_event_sources = [ "${dms_path}/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp", ] -ohos_unittest("distributedschedsvrtest") { +ohos_unittest("distributedschedcallbacktest") { + module_out_path = module_output_path + + sources = [ + "unittest/dms_callback_task_test.cpp", + "unittest/dms_token_callback_test.cpp", + "unittest/mock_remote_stub.cpp", + ] + sources += dtbschedmgr_sources + + configs = [ + ":test_config", + "${distributed_service}/dtbschedmgr/test/resource:coverage_flags", + ] + configs += dsched_configs + if (is_standard_system) { + external_deps = dsched_external_deps + public_deps = dsched_public_deps + } + + if (dmsfwk_report_memmgr || dmsfwk_report_memmgr_plugins) { + defines = [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ] + } + + part_name = "dmsfwk" + subsystem_name = "ability" +} + +ohos_unittest("distributedschedservicetest") { + module_out_path = module_output_path + + sources = [ + "unittest/distributed_sched_service_first_test.cpp", + "unittest/distributed_sched_service_second_test.cpp", + "unittest/mock_distributed_sched.cpp", + ] + sources += dtbschedmgr_sources + + configs = [ + ":test_config", + "${distributed_service}/dtbschedmgr/test/resource:coverage_flags", + ] + configs += dsched_configs + if (is_standard_system) { + external_deps = dsched_external_deps + public_deps = dsched_public_deps + } + + if (dmsfwk_report_memmgr || dmsfwk_report_memmgr_plugins) { + defines = [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ] + } + + part_name = "dmsfwk" + subsystem_name = "ability" +} + +ohos_unittest("distributedschedstubtest") { + module_out_path = module_output_path + + sources = [ "unittest/distributed_sched_stub_test.cpp" ] + sources += dtbschedmgr_sources + + configs = [ + ":test_config", + "${distributed_service}/dtbschedmgr/test/resource:coverage_flags", + ] + configs += dsched_configs + if (is_standard_system) { + external_deps = dsched_external_deps + public_deps = dsched_public_deps + } + + if (dmsfwk_report_memmgr || dmsfwk_report_memmgr_plugins) { + defines = [ "SUPPORT_DISTRIBUTEDCOMPONENT_TO_MEMMGR" ] + } + + part_name = "dmsfwk" + subsystem_name = "ability" +} + +ohos_unittest("distributedschedadaptertest") { module_out_path = module_output_path sources = [ "unittest/continue_scene_session_handler_test.cpp", "unittest/distributed_sched_adapter_test.cpp", - "unittest/distributed_sched_service_first_test.cpp", - "unittest/distributed_sched_service_second_test.cpp", - "unittest/distributed_sched_stub_test.cpp", - "unittest/dms_callback_task_test.cpp", - "unittest/dms_token_callback_test.cpp", - "unittest/mock_distributed_sched.cpp", "unittest/mock_remote_stub.cpp", ] sources += dtbschedmgr_sources @@ -303,7 +377,7 @@ ohos_unittest("dschedpermissiontest") { subsystem_name = "ability" } -ohos_unittest("dschedmissionmanagertest") { +ohos_unittest("distributedmissionmanagertest") { sanitize = { cfi = true cfi_cross_dso = true @@ -313,11 +387,7 @@ ohos_unittest("dschedmissionmanagertest") { cflags = [ "-Dprivate=public" ] sources = [ "unittest/mission/distributed_bm_storage_test.cpp", - "unittest/mission/distributed_data_storage_test.cpp", "unittest/mission/distributed_mission_info_test.cpp", - "unittest/mission/dms_continue_manager_test.cpp", - "unittest/mission/dms_mission_manager_test.cpp", - "unittest/mission/dsched_sync_e2e_test.cpp", "unittest/mission/mission_info_converter_test.cpp", "unittest/mission/snapshot_test.cpp", "unittest/mock_remote_stub.cpp", @@ -339,6 +409,65 @@ ohos_unittest("dschedmissionmanagertest") { subsystem_name = "ability" } +ohos_unittest("dmscontinuemanagertest") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path + cflags = [ "-Dprivate=public" ] + sources = [ + "unittest/mission/dms_continue_manager_test.cpp", + "unittest/mission/dsched_sync_e2e_test.cpp", + ] + sources += dtbschedmgr_sources + + configs = [ + ":test_config", + "${distributed_service}/dtbschedmgr/test/resource:coverage_flags", + ] + configs += dsched_configs + + if (is_standard_system) { + external_deps = dsched_external_deps + external_deps += [ "config_policy:configpolicy_util" ] + public_deps = dsched_public_deps + } + part_name = "dmsfwk" + subsystem_name = "ability" +} + +ohos_unittest("dmsmissionmanagertest") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path + cflags = [ "-Dprivate=public" ] + sources = [ + "unittest/mission/distributed_data_storage_test.cpp", + "unittest/mission/dms_mission_manager_test.cpp", + "unittest/mission/mock_image_packer.cpp", + ] + sources += dtbschedmgr_sources + + configs = [ + ":test_config", + "${distributed_service}/dtbschedmgr/test/resource:coverage_flags", + ] + configs += dsched_configs + + if (is_standard_system) { + external_deps = dsched_external_deps + external_deps += [ "config_policy:configpolicy_util" ] + public_deps = dsched_public_deps + } + part_name = "dmsfwk" + subsystem_name = "ability" +} + ohos_unittest("bundlemanagerinternaltest") { sanitize = { cfi = true @@ -613,7 +742,10 @@ group("unittest") { ":distributedadaptertest", ":distributedcalltest", ":distributedeventtest", - ":distributedschedsvrtest", + ":distributedschedadaptertest", + ":distributedschedcallbacktest", + ":distributedschedservicetest", + ":distributedschedstubtest", ":distributeduidtest", ":distributedwanttest", ":dmsbasetest", @@ -628,7 +760,9 @@ group("unittest") { ] if (dmsfwk_mission_manager) { deps += [ - ":dschedmissionmanagertest", + ":distributedmissionmanagertest", + ":dmscontinuemanagertest", + ":dmsmissionmanagertest", ":dschedpermissiontest", ] } diff --git a/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp b/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp index 251dfe27..64ee3dab 100644 --- a/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp +++ b/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp @@ -220,6 +220,7 @@ HWTEST_F(DMSContinueManagerTest, testRegisterOnListener001, TestSize.Level1) sptr obj02(new RemoteOnListenerStubTest()); ret = DMSContinueRecvMgr::GetInstance().RegisterOnListener(TYPE, obj02); EXPECT_EQ(ret, ERR_OK); + DMSContinueRecvMgr::GetInstance().UnInit(); DTEST_LOG << "DMSContinueManagerTest testRegisterOnListener001 end" << std::endl; } @@ -279,7 +280,7 @@ HWTEST_F(DMSContinueManagerTest, testGetMissionId001, TestSize.Level1) EXPECT_EQ(ret, ERR_OK); ret = DMSContinueSendMgr::GetInstance().GetMissionIdByBundleName(BUNDLENAME_02, missionId); - EXPECT_EQ(ret, INVALID_PARAMETERS_ERR); + EXPECT_EQ(ret, MISSION_NOT_FOCUSED); DTEST_LOG << "DMSContinueManagerTest testGetMissionId001 end" << std::endl; } @@ -661,14 +662,12 @@ HWTEST_F(DMSContinueManagerTest, testOnDeviceScreenOff001, TestSize.Level1) HWTEST_F(DMSContinueManagerTest, testNotifyDeviceOffline001, TestSize.Level1) { DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline001 start" << std::endl; + DMSContinueRecvMgr::GetInstance().iconInfo_.senderNetworkId = NETWORKID_01; + DMSContinueRecvMgr::GetInstance().NotifyDeviceOffline(NETWORKID_01); + sptr obj01(new RemoteOnListenerStubTest()); DMSContinueRecvMgr::GetInstance().RegisterOnListener(TYPE, obj01); EXPECT_NE(DMSContinueRecvMgr::GetInstance().registerOnListener_.size(), 0); - - DMSContinueRecvMgr::GetInstance().iconInfo_.senderNetworkId = NETWORKID_01; - DMSContinueRecvMgr::GetInstance().NotifyDeviceOffline(NETWORKID_01); - EXPECT_EQ(DMSContinueRecvMgr::GetInstance().iconInfo_.senderNetworkId, ""); - DTEST_LOG << "DMSContinueManagerTest testNotifyDeviceOffline001 end" << std::endl; } diff --git a/services/dtbschedmgr/test/unittest/mission/mock_image_packer.cpp b/services/dtbschedmgr/test/unittest/mission/mock_image_packer.cpp new file mode 100644 index 00000000..f508a0a0 --- /dev/null +++ b/services/dtbschedmgr/test/unittest/mission/mock_image_packer.cpp @@ -0,0 +1,41 @@ +/* + * 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 "mock_image_packer.h" +#include + +namespace OHOS { +namespace DistributedSchedule { +ImagePacker::ImagePacker() +{} + +ImagePacker::~ImagePacker() +{} + +uint32_t ImagePacker::StartPacking(std::ostream &outputStream, const PackOption &option) +{ + return 0; +} + +uint32_t ImagePacker::AddImage(PixelMap &pixelMap) +{ + return 0; +} + +uint32_t ImagePacker::FinalizePacking() +{ + return 0; +} +} // namespace DistributedSchedule +} // namespace OHOS diff --git a/services/dtbschedmgr/test/unittest/mission/mock_image_packer.h b/services/dtbschedmgr/test/unittest/mission/mock_image_packer.h new file mode 100644 index 00000000..885bf5ab --- /dev/null +++ b/services/dtbschedmgr/test/unittest/mission/mock_image_packer.h @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#ifndef MOCK_IMAGE_PACKER_H +#define MOCK_IMAGE_PACKER_H + +#include +#include + +namespace OHOS { +namespace DistributedSchedule { +struct PackOption { +}; + +class PixelMap { +public: + PixelMap() = default; + ~PixelMap() = default; +}; + +class ImagePacker { +public: + ImagePacker(); + ~ImagePacker(); + uint32_t StartPacking(std::ostream &outputStream, const PackOption &option); + uint32_t AddImage(PixelMap &pixelMap); + uint32_t FinalizePacking(); +}; +} // namespace DistributedSchedule +} // namespace OHOS +#endif //MOCK_IMAGE_PACKER_H