1 /* 2 * Copyright (c) 2021 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 OHOS_MOCK_DCAMERA_SINK_OUTPUT_H 17 #define OHOS_MOCK_DCAMERA_SINK_OUTPUT_H 18 19 #include "distributed_camera_errno.h" 20 #include "icamera_operator.h" 21 #include "icamera_sink_output.h" 22 23 namespace OHOS { 24 namespace DistributedHardware { 25 extern std::string g_outputStr; 26 class MockDCameraSinkOutput : public ICameraSinkOutput { 27 public: MockDCameraSinkOutput(const std::string & dhId,const std::shared_ptr<ICameraOperator> & cameraOperator)28 explicit MockDCameraSinkOutput(const std::string& dhId, const std::shared_ptr<ICameraOperator>& cameraOperator) 29 { 30 } 31 ~MockDCameraSinkOutput()32 ~MockDCameraSinkOutput() 33 { 34 } 35 Init()36 int32_t Init() 37 { 38 if (g_outputStr == "test026") { 39 return DCAMERA_BAD_VALUE; 40 } 41 return DCAMERA_OK; 42 } UnInit()43 int32_t UnInit() 44 { 45 if (g_outputStr == "test019") { 46 return DCAMERA_BAD_VALUE; 47 } 48 return DCAMERA_OK; 49 } StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>> & captureInfos)50 int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) 51 { 52 if (g_outputStr == "test021" || g_outputStr == "test_025") { 53 return DCAMERA_BAD_VALUE; 54 } 55 return DCAMERA_OK; 56 } StopCapture()57 int32_t StopCapture() 58 { 59 return DCAMERA_OK; 60 } OpenChannel(std::shared_ptr<DCameraChannelInfo> & info)61 int32_t OpenChannel(std::shared_ptr<DCameraChannelInfo>& info) 62 { 63 return DCAMERA_OK; 64 } CloseChannel()65 int32_t CloseChannel() 66 { 67 if (g_outputStr == "test018") { 68 return DCAMERA_BAD_VALUE; 69 } 70 return DCAMERA_OK; 71 } GetProperty(const std::string & propertyName,PropertyCarrier & propertyCarrier)72 int32_t GetProperty(const std::string& propertyName, PropertyCarrier& propertyCarrier) 73 { 74 if (g_outputStr == "test_025") { 75 return DCAMERA_BAD_VALUE; 76 } 77 return DCAMERA_OK; 78 } 79 }; 80 } // namespace DistributedHardware 81 } // namespace OHOS 82 #endif // OHOS_MOCK_DCAMERA_SINK_OUTPUT_H 83