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