1 /*
2 * Copyright (c) 2022-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 #include <gtest/gtest.h>
17 #define private public
18 #include "dcamera_source_controller.h"
19 #undef private
20
21 #include "dcamera_source_state.h"
22 #include "dcamera_utils_tools.h"
23 #include "mock_camera_channel.h"
24 #include "distributed_hardware_log.h"
25 #include "icamera_state_listener.h"
26 #include "dcamera_source_controller_channel_listener.h"
27 #include "distributed_camera_errno.h"
28 #include "mock_dcamera_source_dev.h"
29 #include "mock_dcamera_source_state_listener.h"
30
31 using namespace testing::ext;
32
33 namespace OHOS {
34 namespace DistributedHardware {
35 std::string g_channelStr = "";
36 class DCameraSourceControllerTest : public testing::Test {
37 public:
38 static void SetUpTestCase(void);
39 static void TearDownTestCase(void);
40 void SetUp();
41 void TearDown();
42
43 std::shared_ptr<DCameraSourceDev> camDev_;
44 std::shared_ptr<ICameraStateListener> stateListener_;
45 std::shared_ptr<DCameraSourceStateMachine> stateMachine_;
46 std::shared_ptr<DCameraSourceController> controller_;
47 std::vector<DCameraIndex> indexs_;
48 };
49
50 namespace {
51 const std::string TEST_DEVICE_ID = "bb536a637105409e904d4da83790a4a7";
52 const std::string TEST_CAMERA_DH_ID_0 = "camera_0";
53 const int32_t TEST_WIDTH = 1920;
54 const int32_t TEST_HEIGTH = 1080;
55 const int32_t TEST_FORMAT = 4;
56 const int32_t TEST_DATASPACE = 8;
57 const int32_t TEST_ISCAPTURE = 0;
58 const int32_t TEST_SLEEP_SEC = 200000;
59 }
60
SetUpTestCase(void)61 void DCameraSourceControllerTest::SetUpTestCase(void)
62 {
63 }
64
TearDownTestCase(void)65 void DCameraSourceControllerTest::TearDownTestCase(void)
66 {
67 }
68
SetUp(void)69 void DCameraSourceControllerTest::SetUp(void)
70 {
71 stateListener_ = std::make_shared<MockDCameraSourceStateListener>();
72 camDev_ = std::make_shared<MockDCameraSourceDev>(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, stateListener_);
73 stateMachine_ = std::make_shared<DCameraSourceStateMachine>(camDev_);
74 controller_ = std::make_shared<DCameraSourceController>(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, stateMachine_,
75 camDev_);
76 controller_->channel_ = std::make_shared<MockCameraChannel>();
77 DCameraIndex index;
78 index.devId_ = TEST_DEVICE_ID;
79 index.dhId_ = TEST_CAMERA_DH_ID_0;
80 indexs_.push_back(index);
81 }
82
TearDown(void)83 void DCameraSourceControllerTest::TearDown(void)
84 {
85 usleep(TEST_SLEEP_SEC);
86 stateMachine_ = nullptr;
87 camDev_ = nullptr;
88 stateListener_ = nullptr;
89 controller_ = nullptr;
90 }
91
92 /**
93 * @tc.name: dcamera_source_controller_test_001
94 * @tc.desc: Verify source controller Init.
95 * @tc.type: FUNC
96 * @tc.require: Issue Number
97 */
98 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_001, TestSize.Level1)
99 {
100 int32_t ret = controller_->Init(indexs_);
101 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
102 }
103 /**
104 * @tc.name: dcamera_source_controller_test_002
105 * @tc.desc: Verify source controller UnInit.
106 * @tc.type: FUNC
107 * @tc.require: Issue Number
108 */
109 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_002, TestSize.Level1)
110 {
111 int32_t ret = controller_->Init(indexs_);
112 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
113 ret = controller_->UnInit();
114 EXPECT_EQ(ret, DCAMERA_OK);
115 }
116 /**
117 * @tc.name: dcamera_source_controller_test_003
118 * @tc.desc: Verify source controller StartCapture.
119 * @tc.type: FUNC
120 * @tc.require: Issue Number
121 */
122 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_003, TestSize.Level1)
123 {
124 std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfos;
125 std::shared_ptr<DCameraCaptureInfo> capture = std::make_shared<DCameraCaptureInfo>();
126 capture->width_ = TEST_WIDTH;
127 capture->height_ = TEST_HEIGTH;
128 capture->format_ = TEST_FORMAT;
129 capture->dataspace_ = TEST_DATASPACE;
130 capture->isCapture_ = TEST_ISCAPTURE;
131 capture->encodeType_ = DCEncodeType::ENCODE_TYPE_H264;
132 capture->streamType_ = DCStreamType::SNAPSHOT_FRAME;
133 captureInfos.push_back(capture);
134
135 int32_t ret = controller_->Init(indexs_);
136 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
137 DCameraIndex index1;
138 index1.devId_ = TEST_DEVICE_ID;
139 index1.dhId_ = TEST_CAMERA_DH_ID_0;
140 controller_->indexs_.push_back(index1);
141 int32_t mode = 0;
142 ret = controller_->StartCapture(captureInfos, mode);
143 controller_->UnInit();
144 EXPECT_EQ(ret, DCAMERA_OK);
145 }
146 /**
147 * @tc.name: dcamera_source_controller_test_004
148 * @tc.desc: Verify source controller StartCapture and StopCapture.
149 * @tc.type: FUNC
150 * @tc.require: Issue Number
151 */
152 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_004, TestSize.Level1)
153 {
154 std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfos;
155 std::shared_ptr<DCameraCaptureInfo> capture = std::make_shared<DCameraCaptureInfo>();
156 capture->width_ = TEST_WIDTH;
157 capture->height_ = TEST_HEIGTH;
158 capture->format_ = TEST_FORMAT;
159 capture->dataspace_ = TEST_DATASPACE;
160 capture->isCapture_ = TEST_ISCAPTURE;
161 capture->encodeType_ = DCEncodeType::ENCODE_TYPE_H264;
162 capture->streamType_ = DCStreamType::SNAPSHOT_FRAME;
163 captureInfos.push_back(capture);
164 int32_t ret = controller_->Init(indexs_);
165 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
166 DCameraIndex index1;
167 index1.devId_ = TEST_DEVICE_ID;
168 index1.dhId_ = TEST_CAMERA_DH_ID_0;
169 controller_->indexs_.push_back(index1);
170 int32_t mode = 0;
171 ret = controller_->StartCapture(captureInfos, mode);
172
173 ret = controller_->StopCapture();
174 controller_->UnInit();
175 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
176 }
177
178 /**
179 * @tc.name: dcamera_source_controller_test_005
180 * @tc.desc: Verify source controller ChannelNeg.
181 * @tc.type: FUNC
182 * @tc.require: Issue Number
183 */
184 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_005, TestSize.Level1)
185 {
186 DHLOGI("start execute dcamera_source_controller_test_005");
187 std::shared_ptr<DCameraChannelInfo> chanInfo = std::make_shared<DCameraChannelInfo>();
188 int32_t ret = GetLocalDeviceNetworkId(chanInfo->sourceDevId_);
189 DCameraChannelDetail continueChInfo(CONTINUE_SESSION_FLAG, CONTINUOUS_FRAME);
190 DCameraChannelDetail snapShotChInfo(SNAP_SHOT_SESSION_FLAG, SNAPSHOT_FRAME);
191 chanInfo->detail_.push_back(continueChInfo);
192 chanInfo->detail_.push_back(snapShotChInfo);
193 ret = controller_->Init(indexs_);
194 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
195 DCameraIndex index1;
196 index1.devId_ = TEST_DEVICE_ID;
197 index1.dhId_ = TEST_CAMERA_DH_ID_0;
198 controller_->indexs_.push_back(index1);
199 ret = controller_->ChannelNeg(chanInfo);
200 controller_->UnInit();
201 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
202 }
203
204 /**
205 * @tc.name: dcamera_source_controller_test_006
206 * @tc.desc: Verify source controller UpdateSettings.
207 * @tc.type: FUNC
208 * @tc.require: Issue Number
209 */
210 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_006, TestSize.Level1)
211 {
212 DHLOGI("start execute dcamera_source_controller_test_006");
213 std::shared_ptr<DCameraChannelInfo> chanInfo = std::make_shared<DCameraChannelInfo>();
214 std::vector<std::shared_ptr<DCameraSettings>> settings;
215 std::shared_ptr<DCameraSettings> setting = std::make_shared<DCameraSettings>();
216 setting->type_ = DCSettingsType::DISABLE_METADATA;
217 setting->value_ = "UpdateSettingsTest";
218 settings.push_back(setting);
219
220 int32_t ret = controller_->Init(indexs_);
221 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
222 DCameraIndex index1;
223 index1.devId_ = TEST_DEVICE_ID;
224 index1.dhId_ = TEST_CAMERA_DH_ID_0;
225 controller_->indexs_.push_back(index1);
226 ret = controller_->UpdateSettings(settings);
227 controller_->UnInit();
228 EXPECT_EQ(ret, DCAMERA_OK);
229 }
230
231 /**
232 * @tc.name: dcamera_source_controller_test_007
233 * @tc.desc: Verify source controller GetCameraInfo.
234 * @tc.type: FUNC
235 * @tc.require: Issue Number
236 */
237 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_007, TestSize.Level1)
238 {
239 DHLOGI("start execute dcamera_source_controller_test_006");
240 int32_t ret = controller_->Init(indexs_);
241 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
242 DCameraIndex index1;
243 index1.devId_ = TEST_DEVICE_ID;
244 index1.dhId_ = TEST_CAMERA_DH_ID_0;
245 controller_->indexs_.push_back(index1);
246 std::shared_ptr<DCameraInfo> camInfo = std::make_shared<DCameraInfo>();
247 camInfo->state_ = 1;
248 ret = controller_->GetCameraInfo(camInfo);
249 controller_->UnInit();
250 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
251 }
252
253 /**
254 * @tc.name: dcamera_source_controller_test_008
255 * @tc.desc: Verify source controller OpenChannel.
256 * @tc.type: FUNC
257 * @tc.require: Issue Number
258 */
259 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_008, TestSize.Level1)
260 {
261 int32_t ret = controller_->Init(indexs_);
262 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
263 DCameraIndex index1;
264 index1.devId_ = TEST_DEVICE_ID;
265 index1.dhId_ = TEST_CAMERA_DH_ID_0;
266 controller_->indexs_.push_back(index1);
267 std::shared_ptr<DCameraOpenInfo> openInfo = std::make_shared<DCameraOpenInfo>();
268 ret = GetLocalDeviceNetworkId(openInfo->sourceDevId_);
269 ret = controller_->OpenChannel(openInfo);
270 controller_->UnInit();
271 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
272 }
273
274 /**
275 * @tc.name: dcamera_source_controller_test_009
276 * @tc.desc: Verify source controller OpenChannel and CloseChannel.
277 * @tc.type: FUNC
278 * @tc.require: Issue Number
279 */
280 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_009, TestSize.Level1)
281 {
282 int32_t ret = controller_->Init(indexs_);
283 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
284 DCameraIndex index1;
285 index1.devId_ = TEST_DEVICE_ID;
286 index1.dhId_ = TEST_CAMERA_DH_ID_0;
287 controller_->indexs_.push_back(index1);
288 std::shared_ptr<DCameraOpenInfo> openInfo = std::make_shared<DCameraOpenInfo>();
289 ret = GetLocalDeviceNetworkId(openInfo->sourceDevId_);
290 controller_->OpenChannel(openInfo);
291 ret = controller_->CloseChannel();
292 controller_->UnInit();
293 EXPECT_EQ(ret, DCAMERA_OK);
294 }
295
296 /**
297 * @tc.name: dcamera_source_controller_test_010
298 * @tc.desc: Verify source controller OnDataReceived.
299 * @tc.type: FUNC
300 * @tc.require: Issue Number
301 */
302 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_010, TestSize.Level1)
303 {
304 int32_t ret = controller_->Init(indexs_);
305 ret = camDev_->InitDCameraSourceDev();
306 std::shared_ptr<ICameraChannelListener> listener =
307 std::make_shared<DCameraSourceControllerChannelListener>(controller_);
308 int32_t state = 0;
309 listener->OnSessionState(state);
310 int32_t eventType = 1;
311 int32_t eventReason = 1;
312 std::string detail = "OnSessionErrorTest";
313 listener->OnSessionError(eventType, eventReason, detail);
314 std::vector<std::shared_ptr<DataBuffer>> buffers;
315 listener->OnDataReceived(buffers);
316 ret = controller_->UnInit();
317 EXPECT_EQ(ret, DCAMERA_OK);
318 }
319
320 /**
321 * @tc.name: dcamera_source_controller_test_011
322 * @tc.desc: Verify source controller ChannelNeg.
323 * @tc.type: FUNC
324 * @tc.require: Issue Number
325 */
326 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_011, TestSize.Level1)
327 {
328 std::shared_ptr<DCameraChannelInfo> chanInfo = std::make_shared<DCameraChannelInfo>();
329 int32_t ret = GetLocalDeviceNetworkId(chanInfo->sourceDevId_);
330 DCameraChannelDetail continueChInfo(CONTINUE_SESSION_FLAG, CONTINUOUS_FRAME);
331 DCameraChannelDetail snapShotChInfo(SNAP_SHOT_SESSION_FLAG, SNAPSHOT_FRAME);
332 chanInfo->detail_.push_back(continueChInfo);
333 chanInfo->detail_.push_back(snapShotChInfo);
334 DCameraIndex index1;
335 index1.devId_ = TEST_DEVICE_ID;
336 index1.dhId_ = TEST_CAMERA_DH_ID_0;
337 DCameraIndex index2;
338 index2.devId_ = TEST_DEVICE_ID;
339 index2.dhId_ = TEST_CAMERA_DH_ID_0;
340 controller_->Init(indexs_);
341
342 controller_->indexs_.push_back(index1);
343 controller_->indexs_.push_back(index2);
344 ret = controller_->ChannelNeg(chanInfo);
345 controller_->UnInit();
346 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
347 }
348
349 /**
350 * @tc.name: dcamera_source_controller_test_012
351 * @tc.desc: Verify source controller DCameraNotify.
352 * @tc.type: FUNC
353 * @tc.require: Issue Number
354 */
355 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_012, TestSize.Level1)
356 {
357 std::shared_ptr<DCameraEvent> events = std::make_shared<DCameraEvent>();
358 events->eventType_ = 1;
359 events->eventResult_ = DCAMERA_EVENT_CAMERA_ERROR;
360 events->eventContent_ = "controllerTest012";
361 int32_t ret = controller_->DCameraNotify(events);
362 controller_->UnInit();
363 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
364 }
365
366 /**
367 * @tc.name: dcamera_source_controller_test_013
368 * @tc.desc: Verify source controller UpdateSettings.
369 * @tc.type: FUNC
370 * @tc.require: Issue Number
371 */
372 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_013, TestSize.Level1)
373 {
374 std::shared_ptr<DCameraChannelInfo> chanInfo = std::make_shared<DCameraChannelInfo>();
375 std::vector<std::shared_ptr<DCameraSettings>> settings;
376 std::shared_ptr<DCameraSettings> setting = std::make_shared<DCameraSettings>();
377 setting->type_ = DCSettingsType::DISABLE_METADATA;
378 setting->value_ = "UpdateSettingsTest";
379 settings.push_back(setting);
380 DCameraIndex index1;
381 index1.devId_ = TEST_DEVICE_ID;
382 index1.dhId_ = TEST_CAMERA_DH_ID_0;
383 DCameraIndex index2;
384 index2.devId_ = TEST_DEVICE_ID;
385 index2.dhId_ = TEST_CAMERA_DH_ID_0;
386 controller_->indexs_.push_back(index1);
387 controller_->indexs_.push_back(index2);
388 int32_t ret = controller_->UpdateSettings(settings);
389 controller_->UnInit();
390 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
391 }
392
393 /**
394 * @tc.name: dcamera_source_controller_test_014
395 * @tc.desc: Verify source controller GetCameraInfo.
396 * @tc.type: FUNC
397 * @tc.require: Issue Number
398 */
399 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_014, TestSize.Level1)
400 {
401 DCameraIndex index1;
402 index1.devId_ = TEST_DEVICE_ID;
403 index1.dhId_ = TEST_CAMERA_DH_ID_0;
404 DCameraIndex index2;
405 index2.devId_ = TEST_DEVICE_ID;
406 index2.dhId_ = TEST_CAMERA_DH_ID_0;
407 controller_->indexs_.push_back(index1);
408 controller_->indexs_.push_back(index2);
409 indexs_.push_back(index1);
410
411 std::shared_ptr<DCameraInfo> camInfo = std::make_shared<DCameraInfo>();
412 camInfo->state_ = 1;
413 int32_t ret = controller_->GetCameraInfo(camInfo);
414 controller_->UnInit();
415 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
416 }
417
418 /**
419 * @tc.name: dcamera_source_controller_test_015
420 * @tc.desc: Verify source controller OpenChannel.
421 * @tc.type: FUNC
422 * @tc.require: Issue Number
423 */
424 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_015, TestSize.Level1)
425 {
426 DCameraIndex index1;
427 index1.devId_ = TEST_DEVICE_ID;
428 index1.dhId_ = TEST_CAMERA_DH_ID_0;
429 DCameraIndex index2;
430 index2.devId_ = TEST_DEVICE_ID;
431 index2.dhId_ = TEST_CAMERA_DH_ID_0;
432 controller_->indexs_.push_back(index1);
433 controller_->indexs_.push_back(index2);
434 indexs_.push_back(index1);
435
436 std::shared_ptr<DCameraOpenInfo> openInfo = std::make_shared<DCameraOpenInfo>();
437 int32_t ret = GetLocalDeviceNetworkId(openInfo->sourceDevId_);
438 ret = controller_->OpenChannel(openInfo);
439 controller_->UnInit();
440 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
441 }
442
443 /**
444 * @tc.name: dcamera_source_controller_test_016
445 * @tc.desc: Verify source controller OpenChannel and CloseChannel.
446 * @tc.type: FUNC
447 * @tc.require: Issue Number
448 */
449 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_016, TestSize.Level1)
450 {
451 DCameraIndex index1;
452 index1.devId_ = TEST_DEVICE_ID;
453 index1.dhId_ = TEST_CAMERA_DH_ID_0;
454 DCameraIndex index2;
455 index2.devId_ = TEST_DEVICE_ID;
456 index2.dhId_ = TEST_CAMERA_DH_ID_0;
457 controller_->indexs_.push_back(index1);
458 controller_->indexs_.push_back(index2);
459 controller_->CloseChannel();
460 int32_t ret = controller_->UnInit();
461 EXPECT_EQ(ret, DCAMERA_OK);
462 }
463
464 /**
465 * @tc.name: dcamera_source_controller_test_017
466 * @tc.desc: Verify source controller OpenChannel and HandleMetaDataResult.
467 * @tc.type: FUNC
468 * @tc.require: Issue Number
469 */
470 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_017, TestSize.Level1)
471 {
472 int32_t ret = controller_->Init(indexs_);
473 std::string jsonStr = "controllerTest17";
474 controller_->HandleMetaDataResult(jsonStr);
475 ret = controller_->UnInit();
476 EXPECT_EQ(ret, DCAMERA_OK);
477 }
478
479 /**
480 * @tc.name: dcamera_source_controller_test_018
481 * @tc.desc: Verify source controller OpenChannel and WaitforSessionResult.
482 * @tc.type: FUNC
483 * @tc.require: Issue Number
484 */
485 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_018, TestSize.Level1)
486 {
487 int32_t ret = camDev_->InitDCameraSourceDev();
488 controller_->PublishEnableLatencyMsg(TEST_DEVICE_ID);
489 ret = controller_->UnInit();
490 EXPECT_EQ(ret, DCAMERA_OK);
491 }
492
493 /**
494 * @tc.name: dcamera_source_controller_test_019
495 * @tc.desc: Verify source controller OnSessionError.
496 * @tc.type: FUNC
497 * @tc.require: Issue Number
498 */
499 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_019, TestSize.Level1)
500 {
501 int32_t ret = controller_->Init(indexs_);
502 std::shared_ptr<DCameraSourceController> controller = nullptr;
503 std::shared_ptr<ICameraChannelListener> listener_ =
504 std::make_shared<DCameraSourceControllerChannelListener>(controller);
505 int32_t state = 0;
506 listener_->OnSessionState(state);
507 int32_t eventType = 1;
508 int32_t eventReason = 1;
509 std::string detail = "OnSessionErrorTest";
510 listener_->OnSessionError(eventType, eventReason, detail);
511 std::vector<std::shared_ptr<DataBuffer>> buffers;
512 listener_->OnDataReceived(buffers);
513 ret = controller_->UnInit();
514 EXPECT_EQ(ret, DCAMERA_OK);
515 }
516
517 /**
518 * @tc.name: dcamera_source_controller_test_020
519 * @tc.desc: Verify source controller OpenChannel and CloseChannel.
520 * @tc.type: FUNC
521 * @tc.require: Issue Number
522 */
523 HWTEST_F(DCameraSourceControllerTest, dcamera_source_controller_test_020, TestSize.Level1)
524 {
525 std::vector<std::shared_ptr<DCameraCaptureInfo>> captureInfos;
526 std::shared_ptr<DCameraCaptureInfo> capture = std::make_shared<DCameraCaptureInfo>();
527 capture->width_ = TEST_WIDTH;
528 capture->height_ = TEST_HEIGTH;
529 capture->format_ = TEST_FORMAT;
530 capture->dataspace_ = TEST_DATASPACE;
531 capture->isCapture_ = TEST_ISCAPTURE;
532 capture->encodeType_ = DCEncodeType::ENCODE_TYPE_H264;
533 capture->streamType_ = DCStreamType::SNAPSHOT_FRAME;
534 captureInfos.push_back(capture);
535 DCameraIndex index1;
536 index1.devId_ = TEST_DEVICE_ID;
537 index1.dhId_ = TEST_CAMERA_DH_ID_0;
538 DCameraIndex index2;
539 index2.devId_ = TEST_DEVICE_ID;
540 index2.dhId_ = TEST_CAMERA_DH_ID_0;
541 controller_->indexs_.push_back(index1);
542 controller_->indexs_.push_back(index2);
543 indexs_.push_back(index1);
544
545 int32_t ret = controller_->Init(indexs_);
546 EXPECT_EQ(ret, DCAMERA_INIT_ERR);
547 int32_t mode = 0;
548 ret = controller_->StartCapture(captureInfos, mode);
549 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
550 ret = controller_->StopCapture();
551 EXPECT_EQ(ret, DCAMERA_BAD_OPERATE);
552 }
553 }
554 }