• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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         if (g_operatorStr == "test026") {
38             return DCAMERA_BAD_VALUE;
39         }
40         return DCAMERA_OK;
41     }
42 
UnInit()43     int32_t UnInit()
44     {
45         if (g_operatorStr == "test020") {
46             return DCAMERA_BAD_VALUE;
47         }
48         return DCAMERA_OK;
49     }
50 
UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>> & settings)51     int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings)
52     {
53         if (g_operatorStr == "test015") {
54             return DCAMERA_BAD_VALUE;
55         }
56         return DCAMERA_OK;
57     }
58 
OpenCamera(std::vector<std::shared_ptr<DCameraCaptureInfo>> & captureInfos)59     int32_t OpenCamera(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos)
60     {
61         return DCAMERA_OK;
62     }
63 
CloseCamera()64     int32_t CloseCamera()
65     {
66         return DCAMERA_OK;
67     }
68 
StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>> & captureInfos,sptr<Surface> & surface,int32_t sceneMode)69     int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos,
70         sptr<Surface>& surface, int32_t sceneMode)
71     {
72         if (g_operatorStr == "test022") {
73             return DCAMERA_ALLOC_ERROR;
74         } else if (g_operatorStr == "test023") {
75             return DCAMERA_DEVICE_BUSY;
76         }
77         return DCAMERA_OK;
78     }
79 
StopCapture()80     int32_t StopCapture()
81     {
82         if (g_operatorStr == "test027") {
83             return DCAMERA_BAD_VALUE;
84         }
85         return DCAMERA_OK;
86     }
87 
SetStateCallback(std::shared_ptr<StateCallback> & callback)88     int32_t SetStateCallback(std::shared_ptr<StateCallback>& callback)
89     {
90         return DCAMERA_OK;
91     }
92 
SetResultCallback(std::shared_ptr<ResultCallback> & callback)93     int32_t SetResultCallback(std::shared_ptr<ResultCallback>& callback)
94     {
95         return DCAMERA_OK;
96     }
97 
PauseCapture()98     int32_t PauseCapture()
99     {
100         if (g_operatorStr == "test029") {
101             return DCAMERA_BAD_VALUE;
102         }
103         return DCAMERA_OK;
104     }
105 
ResumeCapture()106     int32_t ResumeCapture()
107     {
108         if (g_operatorStr == "test030") {
109             return DCAMERA_BAD_VALUE;
110         }
111         return DCAMERA_OK;
112     }
113 };
114 } // namespace DistributedHardware
115 } // namespace OHOS
116 #endif // OHOS_MOCK_CAMERA_OPERATOR_H
117