1 /* 2 * Copyright (c) 2024 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 CAMERA_INPUT_FUZZER_H 17 #define CAMERA_INPUT_FUZZER_H 18 19 #include "hcamera_device_stub.h" 20 #include "hcamera_device.h" 21 22 namespace OHOS { 23 namespace CameraStandard { 24 25 class FoldScreenListener; 26 27 class IRemoteObjectMock : public IRemoteObject { 28 public: GetObjectRefCount()29 inline int32_t GetObjectRefCount() override 30 { 31 return 0; 32 } SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)33 inline int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override 34 { 35 return 0; 36 } AddDeathRecipient(const sptr<DeathRecipient> & recipient)37 inline bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override 38 { 39 return true; 40 } RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)41 inline bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override 42 { 43 return true; 44 } Dump(int fd,const std::vector<std::u16string> & args)45 inline int Dump(int fd, const std::vector<std::u16string> &args) override 46 { 47 return 0; 48 } 49 }; 50 51 class ICameraDeviceServiceCallbackMock : public ICameraDeviceServiceCallback, public IRemoteObjectMock { 52 public: OnError(const int32_t errorType,const int32_t errorMsg)53 inline int32_t OnError(const int32_t errorType, const int32_t errorMsg) override 54 { 55 return 0; 56 } OnResult(const uint64_t timestamp,const std::shared_ptr<OHOS::Camera::CameraMetadata> & result)57 inline int32_t OnResult(const uint64_t timestamp, 58 const std::shared_ptr<OHOS::Camera::CameraMetadata> &result) override 59 { 60 return 0; 61 } AsObject()62 sptr<IRemoteObject> AsObject() override 63 { 64 return this; 65 } 66 }; 67 68 class HCameraDeviceFuzzer { 69 public: 70 static bool hasPermission; 71 static sptr<HCameraDevice> fuzz_; 72 static void HCameraDeviceFuzzTest1(); 73 static void HCameraDeviceFuzzTest2(); 74 static void HCameraDeviceFuzzTest3(); 75 static void HCameraDeviceFuzzTest4(); 76 }; 77 } //CameraStandard 78 } //OHOS 79 #endif //CAMERA_INPUT_FUZZER_H