• 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 METADATA_OUTPUT_FUZZER_H
17 #define METADATA_OUTPUT_FUZZER_H
18 
19 #include "metadata_output.h"
20 #include "iservice_registry.h"
21 #include "system_ability_definition.h"
22 #include "deferred_processing_service.h"
23 #include "camera_log.h"
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 using namespace DeferredProcessing;
28 class IDeferredPhotoProcessingSessionCallbackFuzz : public IDeferredPhotoProcessingSessionCallback {
29 public:
30     explicit IDeferredPhotoProcessingSessionCallbackFuzz() = default;
31     virtual ~IDeferredPhotoProcessingSessionCallbackFuzz() = default;
OnProcessImageDone(const std::string & imageId,sptr<IPCFileDescriptor> ipcFd,const long bytes,uint32_t cloudImageEnhanceFlag)32     inline int32_t OnProcessImageDone(const std::string &imageId,
33         sptr<IPCFileDescriptor> ipcFd, const long bytes, uint32_t cloudImageEnhanceFlag) override
34     {
35         return 0;
36     }
OnProcessImageDone(const std::string & imageId,std::shared_ptr<PictureIntf> picture,uint32_t cloudImageEnhanceFlag)37     inline int32_t OnProcessImageDone(const std::string &imageId, std::shared_ptr<PictureIntf> picture,
38         uint32_t cloudImageEnhanceFlag) override
39     {
40         return 0;
41     }
OnDeliveryLowQualityImage(const std::string & imageId,std::shared_ptr<PictureIntf> picture)42     inline int32_t OnDeliveryLowQualityImage(const std::string &imageId,
43         std::shared_ptr<PictureIntf> picture) override
44     {
45         return 0;
46     }
OnError(const std::string & imageId,const ErrorCode errorCode)47     inline int32_t OnError(const std::string &imageId, const ErrorCode errorCode) override
48     {
49         return 0;
50     }
OnStateChanged(const StatusCode status)51     inline int32_t OnStateChanged(const StatusCode status) override
52     {
53         return 0;
54     }
AsObject()55     sptr<IRemoteObject> AsObject() override
56     {
57         auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
58         if (samgr == nullptr) {
59             return nullptr;
60         }
61         sptr<IRemoteObject> object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
62         return object;
63     }
64 };
65 
66 class AppMetadataCallback : public MetadataObjectCallback, public MetadataStateCallback {
67 public:
OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects)68     void OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const
69     {
70         MEDIA_INFO_LOG("AppMetadataCallback::OnMetadataObjectsAvailable received");
71     }
OnError(int32_t errorCode)72     void OnError(int32_t errorCode) const
73     {
74         MEDIA_INFO_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
75     }
76 };
77 
78 class MetadataStateCallbackTest : public MetadataStateCallback {
79 public:
80     MetadataStateCallbackTest() = default;
81     virtual ~MetadataStateCallbackTest() = default;
OnError(int32_t errorCode)82     virtual void OnError(int32_t errorCode) const {};
83 };
84 
85 class MetadataOutputFuzzer {
86 public:
87 static std::shared_ptr<MetadataOutput> fuzz_;
88 static void MetadataOutputFuzzTest();
89 static void MetadataOutputFuzzTest1();
90 };
91 } //CameraStandard
92 } //OHOS
93 #endif //METADATA_OUTPUT_FUZZER_H