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_ACTION_BUTTON_BUILDER_H
17 #define MOCK_NOTIFICATION_ACTION_BUTTON_BUILDER_H
18
19 #include "mock_fuzz_object.h"
20 #include "notification_action_button.h"
21 #include "mock_notification_user_input.h"
22 #include "mock_pixel_map.h"
23
24 namespace OHOS {
25 namespace Notification {
26
27 template <>
BuildSharedPtr(FuzzedDataProvider * fdp)28 std::shared_ptr<NotificationActionButton> ObjectBuilder<NotificationActionButton>::BuildSharedPtr(
29 FuzzedDataProvider *fdp)
30 {
31 std::string title = fdp->ConsumeRandomLengthString(50);
32 auto icon = fdp->ConsumeBool() ? ObjectBuilder<Media::PixelMap>::BuildSharedPtr(fdp) : nullptr;
33
34 auto semanticAction = static_cast<NotificationConstant::SemanticActionButton>(
35 fdp->ConsumeIntegralInRange<uint8_t>(0, 3));
36 bool autoReplies = fdp->ConsumeBool();
37 std::vector<std::shared_ptr<NotificationUserInput>> mimeInputs;
38 for (size_t i = 0; i < fdp->ConsumeIntegralInRange<size_t>(0, 5); ++i) {
39 mimeInputs.push_back(ObjectBuilder<NotificationUserInput>::BuildSharedPtr(fdp));
40 }
41 auto userInput = fdp->ConsumeBool() ? ObjectBuilder<NotificationUserInput>::BuildSharedPtr(fdp) : nullptr;
42 bool isContextual = fdp->ConsumeBool();
43
44 ANS_LOGE("Build mock veriables");
45 return NotificationActionButton::Create(
46 icon, title, nullptr, nullptr, semanticAction, autoReplies, mimeInputs, userInput, isContextual);
47 }
48
49 } // namespace Notification
50 } // namespace OHOS
51
52 #endif // MOCK_NOTIFICATION_ACTION_BUTTON_BUILDER_H
53