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_CONTENT_BUILDER_H 17 #define MOCK_NOTIFICATION_CONTENT_BUILDER_H 18 19 #include "mock_fuzz_object.h" 20 #include "notification_content.h" 21 #include "mock_notification_conversational_content.h" 22 #include "mock_notification_media_content.h" 23 #include "mock_notification_live_view_content.h" 24 #include "mock_notification_multiline_content.h" 25 #include "mock_notification_normal_content.h" 26 27 namespace OHOS { 28 namespace Notification { 29 30 const int INDEX_ZERO = 0; 31 const int INDEX_ONE = 1; 32 const int INDEX_TWO = 2; 33 const int INDEX_THREE = 3; 34 35 template <> Build(FuzzedDataProvider * fdp)36NotificationContent* ObjectBuilder<NotificationContent>::Build(FuzzedDataProvider *fdp) 37 { 38 int caseNum = fdp->ConsumeIntegralInRange(0, 4); 39 ANS_LOGE("Build mock veriables"); 40 switch (caseNum) { 41 case INDEX_ZERO: { 42 std::shared_ptr<NotificationConversationalContent> conversationalContent ( 43 ObjectBuilder<NotificationConversationalContent>::Build(fdp)); 44 return new NotificationContent(conversationalContent); 45 break; 46 } 47 case INDEX_ONE: { 48 std::shared_ptr<NotificationMediaContent> mediaContent ( 49 ObjectBuilder<NotificationMediaContent>::Build(fdp)); 50 return new NotificationContent(mediaContent); 51 break; 52 } 53 case INDEX_TWO: { 54 std::shared_ptr<NotificationMultiLineContent> multiContent ( 55 ObjectBuilder<NotificationMultiLineContent>::Build(fdp)); 56 return new NotificationContent(multiContent); 57 break; 58 } 59 case INDEX_THREE: { 60 std::shared_ptr<NotificationNormalContent> normalContent ( 61 ObjectBuilder<NotificationNormalContent>::Build(fdp)); 62 return new NotificationContent(normalContent); 63 break; 64 } 65 default: { 66 std::shared_ptr<NotificationNormalContent> defaultNormalContent ( 67 ObjectBuilder<NotificationNormalContent>::Build(fdp)); 68 return new NotificationContent(defaultNormalContent); 69 break; 70 } 71 } 72 } 73 74 } // namespace Notification 75 } // namespace OHOS 76 77 #endif // MOCK_NOTIFICATION_CONTENT_BUILDER_H 78