diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp index 3dace1401ca5763efd1e26264fc382573ba79676..41ce3f2db76ce5b666b598954f9cba6be348c59e 100644 --- a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp @@ -23,6 +23,12 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + int32_t notificationId = fuzzData->ConsumeIntegral(); + std::string label = fuzzData->ConsumeRandomLengthString(); + std::string instanceKey = fuzzData->ConsumeRandomLengthString(); + service->Cancel(notificationId, label, instanceKey); return true; } } @@ -33,6 +39,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp index b3c136406cc135c53a97465c933ea9623917d845..37a8ee07130db3d7820c074a59bf1ad2069e9a83 100644 --- a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp @@ -23,6 +23,10 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + sptr notificationDisable = ObjectBuilder::Build(fuzzData); + service->DisableNotificationFeature(notificationDisable); return true; } } @@ -33,6 +37,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp index d3fd0620db86e0ad04a02cf56325e094f44bb248..d1a1e0fd42830dd8cd2e2d1adbd027680f434888 100644 --- a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp @@ -23,6 +23,10 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + std::vector bundleOption; + service->GetAllLiveViewEnabledBundles(bundleOption); return true; } } @@ -33,6 +37,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp index 3718993e6927cced1a647e51d55b26b644c64857..fed9e36b5e653a24280a52958ada2494add17e97 100644 --- a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp @@ -23,6 +23,10 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + int32_t importance = 0; + service->GetBundleImportance(importance); return true; } } @@ -33,6 +37,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp index 275c98fc8c62770c28f48efa423767a7d213dc3e..c8234283e3ffcb341460a283590f4c18c0d8efe0 100644 --- a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp @@ -23,6 +23,10 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + sptr date; + service->GetDoNotDisturbDate(date); return true; } } @@ -33,6 +37,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp index ff9661159d7e40677cf346da2761a11f973848e9..2f46a5c61106760067ebba113aa48c39c33cfe12 100644 --- a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp @@ -23,6 +23,14 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + std::vector key; + key.push_back(fuzzData->ConsumeRandomLengthString()); + key.push_back(fuzzData->ConsumeRandomLengthString()); + key.push_back(fuzzData->ConsumeRandomLengthString()); + std::vector> notifications; + service->GetSpecialActiveNotifications(key, notifications); return true; } } @@ -33,6 +41,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp index e8692ec1107efec075c159f6b5245514246a1cd7..a42ca49a47dc5da2995d064e3e9ebc7937def8b6 100644 --- a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp @@ -23,6 +23,16 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + std::vector> profiles; + sptr profile1 = + ObjectBuilder::Build(fuzzData); + profiles.push_back(profile1); + sptr profile2 = + ObjectBuilder::Build(fuzzData); + profiles.push_back(profile2); + service->RemoveDoNotDisturbProfiles(profiles); return true; } } @@ -33,6 +43,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp index 63d4ccdf0952236a0af66da9268a07a95bbf0013..103a24590edf54a719b554b12217922d0f50b6e4 100644 --- a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp @@ -23,6 +23,11 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + int32_t result = fuzzData->ConsumeIntegral(); + std::string hashCode = fuzzData->ConsumeRandomLengthString(); + service->ReplyDistributeOperation(hashCode, result); return true; } } @@ -33,6 +38,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp index 2d69fed755988add6d55ea3b5de11eb4a5a27321..f51efc5d931b33e2fb3c45de97cccf658fc85306 100644 --- a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp @@ -23,6 +23,13 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + bool enabled = fuzzData->ConsumeBool(); + bool isForceControl = fuzzData->ConsumeBool(); + int32_t slotTypeInt = fuzzData->ConsumeIntegral(); + sptr bundleOption = ObjectBuilder::Build(fuzzData); + service->SetEnabledForBundleSlot(bundleOption, slotTypeInt, enabled, isForceControl); return true; } } @@ -33,6 +40,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp index 3c1f6ccd66aa8dd22070c2b94f5e6a68cc1d4f8f..74a547c07877936e813e6b3731a4cf9d0f238300 100644 --- a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp @@ -23,6 +23,11 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + bool enabled = fuzzData->ConsumeBool(); + sptr bundleOption = ObjectBuilder::Build(fuzzData); + service->SetShowBadgeEnabledForBundle(bundleOption, enabled); return true; } } @@ -33,6 +38,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp index 0fdfc728ab6dd22c667ec8b9eeeafa30d32658de..8ac418b9ee79966771f66203dbf9b395f6ebc862 100644 --- a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp @@ -23,6 +23,14 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + std::string deviceType = fuzzData->ConsumeRandomLengthString(); + std::string deviceId = fuzzData->ConsumeRandomLengthString(); + uint32_t status = fuzzData->ConsumeIntegral(); + uint32_t controlFlag = fuzzData->ConsumeIntegral(); + int32_t userId = fuzzData->ConsumeIntegral(); + service->SetTargetDeviceStatus(deviceType, status, controlFlag, deviceId, userId); return true; } } @@ -33,6 +41,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp index 02c33df2739e58ed55f88d1830ceec2043efe388..39f49e9fe8ce7a52dc8009ae2be9a6e09728d7fc 100644 --- a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp @@ -23,6 +23,15 @@ namespace OHOS { namespace Notification { bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) { + auto service = AdvancedNotificationService::GetInstance(); + + std::string cmd = fuzzData->ConsumeRandomLengthString(); + std::string bundle = fuzzData->ConsumeRandomLengthString(); + int32_t userId = fuzzData->ConsumeIntegral(); + int32_t recvUserId = fuzzData->ConsumeIntegral(); + + std::vector dumpInfo; + service->ShellDump(cmd, bundle, userId, recvUserId, dumpInfo); return true; } } @@ -33,6 +42,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ FuzzedDataProvider fdp(data, size); + std::vector requestPermission = { + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_NOTIFICATION_AGENT_CONTROLLER, + OHOS::Notification::OHOS_PERMISSION_SET_UNREMOVABLE_NOTIFICATION + }; + MockRandomToken(&fdp, requestPermission); OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); return 0; } diff --git a/test/fuzztest/fuzz_common_base/mock/mock_notification_disable.h b/test/fuzztest/fuzz_common_base/mock/mock_notification_disable.h new file mode 100644 index 0000000000000000000000000000000000000000..1a0ba5354350109d870ffa36ec0564bea78829f9 --- /dev/null +++ b/test/fuzztest/fuzz_common_base/mock/mock_notification_disable.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 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_NOTIFICATION_DISABLE_BUILDER_H +#define MOCK_NOTIFICATION_DISABLE_BUILDER_H + +#include "mock_fuzz_object.h" +#include "mock_notification_content.h" +#include "mock_notification_distributed_options.h" +#include "mock_notification_template.h" +#include "mock_notification_flags.h" +#include "mock_notification_bundle_option.h" +#include "mock_notification_action_button.h" +#include "notification_request.h" + +namespace OHOS { +namespace Notification { +template <> +NotificationSlot* ObjectBuilder::Build(FuzzedDataProvider *fdp) +{ + auto disable = new NotificationDisable(); + slot->SetDisabled(fdp->ConsumeBool()); + std::vector bundleList; + bundleList.push_back(fdp->ConsumeRandomLengthString()); + bundleList.push_back(fdp->ConsumeRandomLengthString()); + bundleList.push_back(fdp->ConsumeRandomLengthString()); + slot->SetBundleList(bundleList); + return slot; +} +} // namespace Notification +} // namespace OHOS +#endif // MOCK_NOTIFICATION_DISABLE_BUILDER_H diff --git a/test/fuzztest/fuzz_common_base/mock/mock_notification_donotdisturbdate.h b/test/fuzztest/fuzz_common_base/mock/mock_notification_donotdisturbdate.h new file mode 100644 index 0000000000000000000000000000000000000000..3a2e96b5bf2d1826fb921846af4322b000a34d14 --- /dev/null +++ b/test/fuzztest/fuzz_common_base/mock/mock_notification_donotdisturbdate.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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_NOTIFICATION_DISABLE_BUILDER_H +#define MOCK_NOTIFICATION_DISABLE_BUILDER_H + +#include "mock_fuzz_object.h" +#include "mock_notification_content.h" +#include "mock_notification_distributed_options.h" +#include "mock_notification_template.h" +#include "mock_notification_flags.h" +#include "mock_notification_bundle_option.h" +#include "mock_notification_action_button.h" +#include "notification_request.h" + +namespace OHOS { +namespace Notification { +constexpr int32_t DONOTDISTURB_TYPE_LENGTH = 3; +template <> +NotificationSlot* ObjectBuilder::Build(FuzzedDataProvider *fdp) +{ + auto disturbDate = new NotificationDoNotDisturbDate(); + disturbDate->SetBeginDate(fdp->ConsumeIntegral()); + disturbDate->SetEndDate(fdp->ConsumeIntegral()); + disturbDate->SetDoNotDisturbType(static_cast( + fdp->ConsumeIntegralInRange(0, DONOTDISTURB_TYPE_LENGTH))); + return slot; +} +} // namespace Notification +} // namespace OHOS +#endif // MOCK_NOTIFICATION_DISABLE_BUILDER_H