• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MOCK_NOTIFICATION_SLOT_H
17 #define MOCK_NOTIFICATION_SLOT_H
18 
19 #include "mock_fuzz_object.h"
20 #include "notification_slot.h"
21 namespace OHOS {
22 namespace Notification {
23 
24 constexpr uint32_t MAX_SLOT_TYPE = 5;
25 constexpr uint32_t MAX_STR_LENGTH = 20;
26 constexpr uint32_t MAX_FLAGS = 63;
27 
28 template <>
Build(FuzzedDataProvider * fdp)29 NotificationSlot* ObjectBuilder<NotificationSlot>::Build(FuzzedDataProvider *fdp)
30 {
31     NotificationSlot* slot = new NotificationSlot(static_cast<OHOS::Notification::NotificationConstant::SlotType>(
32         fdp->ConsumeIntegralInRange<int>(0, MAX_SLOT_TYPE)));
33     slot->SetEnableLight(fdp->ConsumeBool());
34     slot->SetEnableVibration(fdp->ConsumeBool());
35     slot->SetDescription(fdp->ConsumeRandomLengthString(MAX_STR_LENGTH));
36     slot->SetLedLightColor(fdp->ConsumeIntegral<int32_t>());
37     slot->SetLevel(static_cast<OHOS::Notification::NotificationSlot::NotificationLevel>(
38         fdp->ConsumeIntegralInRange<int32_t>(0, MAX_SLOT_TYPE)));
39     slot->SetSlotFlags(fdp->ConsumeIntegralInRange<int32_t>(0, MAX_FLAGS));
40     slot->EnableBypassDnd(fdp->ConsumeBool());
41     slot->EnableBadge(fdp->ConsumeBool());
42     slot->SetEnable(fdp->ConsumeBool());
43     slot->SetForceControl(fdp->ConsumeBool());
44     slot->SetAuthorizedStatus(fdp->ConsumeIntegralInRange<int32_t>(0, 1));
45     slot->SetAuthHintCnt(fdp->ConsumeIntegralInRange<int32_t>(0, 1));
46     slot->SetReminderMode(fdp->ConsumeIntegralInRange<int32_t>(0, MAX_FLAGS));
47 
48     ANS_LOGE("Build mock veriables");
49     return slot;
50 }
51 
52 }  // namespace Notification
53 }  // namespace OHOS
54 #endif  // MOCK_NOTIFICATION_SLOT_H