1 /* 2 * Copyright (c) 2021-2023 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_CAMERA_OPERATOR_H 17 #define OHOS_MOCK_CAMERA_OPERATOR_H 18 19 #include "distributed_camera_errno.h" 20 #include "icamera_operator.h" 21 22 namespace OHOS { 23 namespace DistributedHardware { 24 extern std::string g_operatorStr; 25 class MockCameraOperator : public ICameraOperator { 26 public: MockCameraOperator()27 explicit MockCameraOperator() 28 { 29 } 30 ~MockCameraOperator()31 ~MockCameraOperator() 32 { 33 } 34 Init()35 int32_t Init() 36 { 37 return DCAMERA_OK; 38 } 39 UnInit()40 int32_t UnInit() 41 { 42 if (g_operatorStr == "test020") { 43 return DCAMERA_BAD_VALUE; 44 } 45 return DCAMERA_OK; 46 } 47 UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>> & settings)48 int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) 49 { 50 if (g_operatorStr == "test015") { 51 return DCAMERA_BAD_VALUE; 52 } 53 return DCAMERA_OK; 54 } 55 OpenCamera(std::vector<std::shared_ptr<DCameraCaptureInfo>> & captureInfos)56 int32_t OpenCamera(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) 57 { 58 return DCAMERA_OK; 59 } 60 CloseCamera()61 int32_t CloseCamera() 62 { 63 return DCAMERA_OK; 64 } 65 StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>> & captureInfos,sptr<Surface> & surface)66 int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos, 67 sptr<Surface>& surface) 68 { 69 if (g_operatorStr == "test022") { 70 return DCAMERA_ALLOC_ERROR; 71 } else if (g_operatorStr == "test023") { 72 return DCAMERA_DEVICE_BUSY; 73 } 74 return DCAMERA_OK; 75 } 76 StopCapture()77 int32_t StopCapture() 78 { 79 return DCAMERA_OK; 80 } 81 SetStateCallback(std::shared_ptr<StateCallback> & callback)82 int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback) 83 { 84 return DCAMERA_OK; 85 } 86 SetResultCallback(std::shared_ptr<ResultCallback> & callback)87 int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback) 88 { 89 return DCAMERA_OK; 90 } 91 PauseCapture()92 int32_t PauseCapture() 93 { 94 return DCAMERA_OK; 95 } 96 ResumeCapture()97 int32_t ResumeCapture() 98 { 99 return DCAMERA_OK; 100 } 101 }; 102 } // namespace DistributedHardware 103 } // namespace OHOS 104 #endif // OHOS_MOCK_CAMERA_OPERATOR_H