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_CHECK_REQUEST_BUILDER_H 17 #define MOCK_NOTIFICATION_CHECK_REQUEST_BUILDER_H 18 19 #include "mock_fuzz_object.h" 20 #include "notification_check_request.h" 21 22 namespace OHOS { 23 namespace Notification { 24 25 const int MAX_SLOT_TYPE = 8; 26 const int MAX_CONTENT_TYPE = 10; 27 const int MAX_ARRAY_SIZE = 10; 28 const int MAX_STRING_SIZE = 20; 29 30 template <> Build(FuzzedDataProvider * fdp)31NotificationCheckRequest* ObjectBuilder<NotificationCheckRequest>::Build(FuzzedDataProvider *fdp) 32 { 33 auto checkRequest = new NotificationCheckRequest(); 34 35 checkRequest->SetContentType(static_cast<NotificationContent::Type>( 36 fdp->ConsumeIntegralInRange<int>(0, MAX_CONTENT_TYPE))); 37 38 checkRequest->SetSlotType(static_cast<OHOS::Notification::NotificationConstant::SlotType>( 39 fdp->ConsumeIntegralInRange<int>(0, MAX_SLOT_TYPE))); 40 std::vector<std::string> extraKeys; 41 for (int i = 0; i < fdp->ConsumeIntegralInRange(0, MAX_ARRAY_SIZE); i++) { 42 extraKeys.push_back(fdp->ConsumeRandomLengthString(MAX_STRING_SIZE)); 43 } 44 checkRequest->SetExtraKeys(extraKeys); 45 checkRequest->SetUid(fdp->ConsumeIntegral<int32_t>()); 46 47 ANS_LOGE("Build mock veriables"); 48 return checkRequest; 49 } 50 } // namespace Notification 51 } // namespace OHOS 52 53 #endif // MOCK_NOTIFICATION_CHECK_REQUEST_BUILDER_H