1 /*
2 * Copyright (c) 2022 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 #include "camera_preview_test.h"
16
17 using namespace testing::ext;
18
SetUpTestCase(void)19 void CameraPreviewTest::SetUpTestCase(void)
20 {
21 }
22
TearDownTestCase(void)23 void CameraPreviewTest::TearDownTestCase(void)
24 {
25 }
26
SetUp(void)27 void CameraPreviewTest::SetUp(void)
28 {
29 if (display_ == nullptr)
30 display_ = std::make_shared<TestDisplay>();
31 display_->Init();
32 }
33
TearDown(void)34 void CameraPreviewTest::TearDown(void)
35 {
36 display_->Close();
37 }
38
39 /**
40 * @tc.name: Preview
41 * @tc.desc: Preview stream, expected success.
42 * @tc.level: Level1
43 * @tc.size: MediumTest
44 * @tc.type: Function
45 */
46 HWTEST_F(CameraPreviewTest, camera_preview_001, TestSize.Level1)
47 {
48 std::cout << "==========[test log] Preview stream, expected success." << std::endl;
49 // Get the stream manager
50 display_->AchieveStreamOperator();
51 // start stream
52 display_->intents = {PREVIEW};
53 display_->StartStream(display_->intents);
54 // Get preview
55 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
56 // release stream
57 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
58 display_->streamIds = {display_->STREAM_ID_PREVIEW};
59 display_->StopStream(display_->captureIds, display_->streamIds);
60 }
61
62 /**
63 * @tc.name: Preview
64 * @tc.desc: Preview, format error, expected return errorCode.
65 * @tc.level: Level2
66 * @tc.size: MediumTest
67 * @tc.type: Function
68 */
69 HWTEST_F(CameraPreviewTest, camera_preview_003, TestSize.Level2)
70 {
71 std::cout << "==========[test log] Preview, format error, expected return errorCode." << std::endl;
72 // Create and get streamOperator information
73 display_->AchieveStreamOperator();
74 // Create data stream
75 if (display_->streamCustomerPreview_ == nullptr) {
76 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
77 }
78 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
79 producer->SetQueueSize(8); // 8:set bufferQueue size
80 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
81 std::cout << "~~~~~~~" << std::endl;
82 }
83 std::vector<StreamInfo> streamInfos;
84 StreamInfo streamInfo = {};
85 streamInfo.streamId_ = 1001;
86 streamInfo.width_ = 640; // 640:picture width
87 streamInfo.height_ = 480; // 480:picture height
88 streamInfo.format_ = -1;
89 streamInfo.dataspace_ = 10; // 10:picture dataspace
90 streamInfo.intent_ = PREVIEW;
91 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
92 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
93 streamInfos.push_back(streamInfo);
94 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
95 EXPECT_EQ(true, display_->rc != HDI::Camera::V1_0::NO_ERROR);
96 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
97 std::cout << "==========[test log] CreateStreams success." << std::endl;
98 } else {
99 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
100 }
101 }
102
103 /**
104 * @tc.name: Preview
105 * @tc.desc: GetStreamOperator success.
106 * @tc.level: Level1
107 * @tc.size: MediumTest
108 * @tc.type: Function
109 */
110 HWTEST_F(CameraPreviewTest, camera_preview_010, TestSize.Level1)
111 {
112 std::cout << "==========[test log] GetStreamOperator success." << std::endl;
113 // Get the configured cameraId
114 display_->cameraHost->GetCameraIds(display_->cameraIds);
115 std::cout << "cameraIds.front() = " << display_->cameraIds.front() << std::endl;
116 // Open the camera device and get the device
117 const OHOS::sptr<ICameraDeviceCallback> callback = new DemoCameraDeviceCallback();
118 display_->rc = (CamRetCode)display_->cameraHost->OpenCamera(display_->cameraIds.front(),
119 callback, display_->cameraDevice);
120 std::cout << "OpenCamera's RetCode = " << display_->rc << std::endl;
121 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
122 display_->AchieveStreamOperator();
123 }
124
125 /**
126 * @tc.name: Preview
127 * @tc.desc: GetStreamOperator, input nullptr.
128 * @tc.level: Level2
129 * @tc.size: MediumTest
130 * @tc.type: Function
131 */
132 HWTEST_F(CameraPreviewTest, camera_preview_011, TestSize.Level2)
133 {
134 std::cout << "==========[test log] GetStreamOperator, input nullptr." << std::endl;
135 // Get the configured cameraId
136 display_->cameraHost->GetCameraIds(display_->cameraIds);
137 std::cout << "cameraIds.front() = " << display_->cameraIds.front() << std::endl;
138 // Open the camera device and get the device
139 const OHOS::sptr<ICameraDeviceCallback> callback = new DemoCameraDeviceCallback();
140 display_->rc = (CamRetCode)display_->cameraHost->OpenCamera(display_->cameraIds.front(),
141 callback, display_->cameraDevice);
142 std::cout << "OpenCamera's RetCode = " << display_->rc << std::endl;
143 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
144 // Create and get streamOperator information
145 OHOS::sptr<IStreamOperatorCallback> streamOperatorCallback = nullptr;
146 display_->rc = (CamRetCode)display_->cameraDevice->GetStreamOperator(streamOperatorCallback,
147 display_->streamOperator);
148 std::cout << "GetStreamOperator's RetCode = " << display_->rc << std::endl;
149 EXPECT_EQ(CamRetCode::INVALID_ARGUMENT, display_->rc);
150 }
151
152 /**
153 * @tc.name: Preview
154 * @tc.desc: CreateStreams, success.
155 * @tc.level: Level1
156 * @tc.size: MediumTest
157 * @tc.type: Function
158 */
159 HWTEST_F(CameraPreviewTest, camera_preview_020, TestSize.Level1)
160 {
161 std::cout << "==========[test log] CreateStreams, success." << std::endl;
162 // Create and get streamOperator information
163 display_->AchieveStreamOperator();
164 // Create data stream
165 if (display_->streamCustomerPreview_ == nullptr) {
166 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
167 }
168 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
169 producer->SetQueueSize(8); // 8:set bufferQueue size
170 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
171 std::cout << "~~~~~~~" << std::endl;
172 }
173
174 std::vector<StreamInfo> streamInfos;
175 StreamInfo streamInfo = {};
176 streamInfo.streamId_ = 1001;
177 streamInfo.width_ = 640; // 640:picture width
178 streamInfo.height_ = 480; // 480:picture height
179 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
180 streamInfo.dataspace_ = 8; // 8:picture dataspace
181 streamInfo.intent_ = PREVIEW;
182 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
183 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
184 std::vector<StreamInfo>().swap(streamInfos);
185 streamInfos.push_back(streamInfo);
186 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
187 std::cout << "CreateStreams's RetCode = " << display_->rc << std::endl;
188 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
189 std::cout << "==========[test log] CreateStreams, success." << std::endl;
190 // Submit stream information
191 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
192 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
193 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
194 std::cout << "==========[test log] CommitStreams success." << std::endl;
195 } else {
196 std::cout << "==========[test log] CommitStreams fail, rc = " << display_->rc << std::endl;
197 }
198 // capture
199 display_->StartCapture(1001, display_->CAPTURE_ID_PREVIEW, false, true);
200 // release stream
201 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
202 display_->streamIds = {1001};
203 display_->StopStream(display_->captureIds, display_->streamIds);
204 }
205
206 /**
207 * @tc.name: Preview
208 * @tc.desc: CreateStreams, StreamInfo->streamId = -1, return error.
209 * @tc.level: Level2
210 * @tc.size: MediumTest
211 * @tc.type: Function
212 */
213 HWTEST_F(CameraPreviewTest, camera_preview_021, TestSize.Level2)
214 {
215 std::cout << "==========[test log] CreateStreams, success." << std::endl;
216 // Create and get streamOperator information
217 display_->AchieveStreamOperator();
218 // Create data stream
219 if (display_->streamCustomerPreview_ == nullptr) {
220 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
221 }
222 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
223 producer->SetQueueSize(8); // 8:set bufferQueue size
224 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
225 std::cout << "~~~~~~~" << std::endl;
226 }
227 std::vector<StreamInfo> streamInfos;
228 StreamInfo streamInfo = {};
229 streamInfo.streamId_ = -1;
230 streamInfo.width_ = 640; // 640:picture width
231 streamInfo.height_ = 480; // 480:picture height
232 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
233 streamInfo.dataspace_ = 8; // 8:picture dataspace
234 streamInfo.intent_ = PREVIEW;
235 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
236 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
237 streamInfos.push_back(streamInfo);
238 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
239 std::cout << "CreateStreams's RetCode = " << display_->rc << std::endl;
240 EXPECT_EQ(false, display_->rc == HDI::Camera::V1_0::NO_ERROR);
241 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
242 std::cout << "==========[test log] CreateStreams success." << std::endl;
243 } else {
244 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
245 }
246 }
247
248 /**
249 * @tc.name: Preview
250 * @tc.desc: CreateStreams, StreamInfo->streamId = 2147483647, return success.
251 * @tc.level: Level2
252 * @tc.size: MediumTest
253 * @tc.type: Function
254 */
255 HWTEST_F(CameraPreviewTest, camera_preview_022, TestSize.Level2)
256 {
257 std::cout << "==========[test log] CreateStreams, StreamInfo->streamId = 2147483647,";
258 std::cout << "return success." << std::endl;
259 display_->AchieveStreamOperator();
260 // Create data stream
261 if (display_->streamCustomerPreview_ == nullptr) {
262 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
263 }
264 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
265 producer->SetQueueSize(8); // 8:set bufferQueue size
266 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
267 std::cout << "~~~~~~~" << std::endl;
268 }
269 std::vector<StreamInfo> streamInfos;
270 StreamInfo streamInfo = {};
271 streamInfo.streamId_ = 2147483647;
272 streamInfo.width_ = 640; // 640:picture width
273 streamInfo.height_ = 480; // 480:picture height
274 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
275 streamInfo.dataspace_ = 8; // 8:picture dataspace
276 streamInfo.intent_ = PREVIEW;
277 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
278 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
279 std::vector<StreamInfo>().swap(streamInfos);
280 streamInfos.push_back(streamInfo);
281 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
282 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
283 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
284 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
285 std::cout << "==========[test log] CreateStreams success." << std::endl;
286 } else {
287 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
288 }
289 // Submit stream information
290 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
291 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
292 std::cout << "==========[test log] CommitStreams success." << std::endl;
293 // capture
294 display_->StartCapture(2147483647, display_->CAPTURE_ID_PREVIEW, false, true);
295 // release stream
296 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
297 display_->streamIds = {2147483647};
298 display_->StopStream(display_->captureIds, display_->streamIds);
299 }
300
301 /**
302 * @tc.name: Preview
303 * @tc.desc: CreateStreams, StreamInfo->width = -1, return error.
304 * @tc.level: Level2
305 * @tc.size: MediumTest
306 * @tc.type: Function
307 */
308 HWTEST_F(CameraPreviewTest, camera_preview_023, TestSize.Level2)
309 {
310 std::cout << "==========[test log] CreateStreams, StreamInfo->width = -1, return error." << std::endl;
311 // Create and get streamOperator information
312 display_->AchieveStreamOperator();
313 // Create data stream
314 if (display_->streamCustomerPreview_ == nullptr) {
315 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
316 }
317 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
318 producer->SetQueueSize(8); // 8:set bufferQueue size
319 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
320 std::cout << "~~~~~~~" << std::endl;
321 }
322 std::vector<StreamInfo> streamInfos;
323 StreamInfo streamInfo = {};
324 streamInfo.streamId_ = 1001;
325 streamInfo.width_ = -1;
326 streamInfo.height_ = 480; // 480:picture height
327 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
328 streamInfo.dataspace_ = 8; // 8:picture dataspace
329 streamInfo.intent_ = PREVIEW;
330 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
331 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
332 std::vector<StreamInfo>().swap(streamInfos);
333 streamInfos.push_back(streamInfo);
334 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
335 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
336 EXPECT_EQ(true, display_->rc == INVALID_ARGUMENT);
337 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
338 std::cout << "==========[test log] CreateStreams success." << std::endl;
339 } else {
340 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
341 }
342 }
343
344 /**
345 * @tc.name: Preview
346 * @tc.desc: CreateStreams, StreamInfo->height = -1, return error.
347 * @tc.level: Level2
348 * @tc.size: MediumTest
349 * @tc.type: Function
350 */
351 HWTEST_F(CameraPreviewTest, camera_preview_025, TestSize.Level2)
352 {
353 std::cout << "==========[test log] CreateStreams, StreamInfo->height = -1, return error." << std::endl;
354 // Create and get streamOperator information
355 display_->AchieveStreamOperator();
356 // Create data stream
357 if (display_->streamCustomerPreview_ == nullptr) {
358 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
359 }
360 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
361 producer->SetQueueSize(8); // 8:set bufferQueue size
362 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
363 std::cout << "~~~~~~~" << std::endl;
364 }
365 std::vector<StreamInfo> streamInfos;
366 StreamInfo streamInfo = {};
367 streamInfo.streamId_ = 1001;
368 streamInfo.width_ = 640; // 640:picture width
369 streamInfo.height_ = -1;
370 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
371 streamInfo.dataspace_ = 8; // 8:picture dataspace
372 streamInfo.intent_ = PREVIEW;
373 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
374 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
375 std::vector<StreamInfo>().swap(streamInfos);
376 streamInfos.push_back(streamInfo);
377 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
378 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
379 EXPECT_EQ(CamRetCode::INVALID_ARGUMENT, display_->rc);
380 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
381 std::cout << "==========[test log] CreateStreams success." << std::endl;
382 } else {
383 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
384 }
385 }
386
387 /**
388 * @tc.name: Preview
389 * @tc.desc: CreateStreams, StreamInfo->format = -1, return error.
390 * @tc.level: Level2
391 * @tc.size: MediumTest
392 * @tc.type: Function
393 */
394 HWTEST_F(CameraPreviewTest, camera_preview_027, TestSize.Level2)
395 {
396 std::cout << "==========[test log] CreateStreams, StreamInfo->format = -1, return error." << std::endl;
397 display_->AchieveStreamOperator();
398 // Create data stream
399 if (display_->streamCustomerPreview_ == nullptr) {
400 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
401 }
402 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
403 producer->SetQueueSize(8); // 8:set bufferQueue size
404 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
405 std::cout << "~~~~~~~" << std::endl;
406 }
407 std::vector<StreamInfo> streamInfos;
408 StreamInfo streamInfo = {};
409 streamInfo.streamId_ = 1001;
410 streamInfo.width_ = 640; // 640:picture width
411 streamInfo.height_ = 480; // 480:picture height
412 streamInfo.format_ = -1;
413 streamInfo.dataspace_ = 8; // 8:picture dataspace
414 streamInfo.intent_ = PREVIEW;
415 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
416 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
417 std::vector<StreamInfo>().swap(streamInfos);
418 streamInfos.push_back(streamInfo);
419 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
420 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
421 EXPECT_EQ(CamRetCode::INVALID_ARGUMENT, display_->rc);
422 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
423 std::cout << "==========[test log] CreateStreams success." << std::endl;
424 } else {
425 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
426 }
427 }
428
429 /**
430 * @tc.name: Preview
431 * @tc.desc: CreateStreams, StreamInfo->dataspace = 2147483647, success.
432 * @tc.level: Level2
433 * @tc.size: MediumTest
434 * @tc.type: Function
435 */
436 HWTEST_F(CameraPreviewTest, camera_preview_030, TestSize.Level2)
437 {
438 std::cout << "==========[test log] CreateStreams, StreamInfo->dataspace = 2147483647, success." << std::endl;
439 // Create and get streamOperator information
440 display_->AchieveStreamOperator();
441 // Create data stream
442 if (display_->streamCustomerPreview_ == nullptr) {
443 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
444 }
445 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
446 producer->SetQueueSize(8); // 8:set bufferQueue size
447 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
448 std::cout << "~~~~~~~" << std::endl;
449 }
450 std::vector<StreamInfo> streamInfos;
451 StreamInfo streamInfo = {};
452 streamInfo.streamId_ = 1001;
453 streamInfo.width_ = 640; // 640:picture width
454 streamInfo.height_ = 480; // 480:picture height
455 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
456 streamInfo.dataspace_ = 2147483647;
457 streamInfo.intent_ = PREVIEW;
458 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
459 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
460 std::vector<StreamInfo>().swap(streamInfos);
461 streamInfos.push_back(streamInfo);
462 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
463 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
464 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
465 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
466 std::cout << "==========[test log] CreateStreams success." << std::endl;
467 } else {
468 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
469 }
470 // Submit stream information
471 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
472 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
473 std::cout << "==========[test log] CommitStreams success." << std::endl;
474 // capture
475 display_->StartCapture(1001, display_->CAPTURE_ID_PREVIEW, false, true);
476 // release stream
477 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
478 display_->streamIds = {1001};
479 display_->StopStream(display_->captureIds, display_->streamIds);
480 }
481
482 /**
483 * @tc.name: Preview
484 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = PREVIEW, success.
485 * @tc.level: Level2
486 * @tc.size: MediumTest
487 * @tc.type: Function
488 */
489 HWTEST_F(CameraPreviewTest, camera_preview_031, TestSize.Level2)
490 {
491 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = ";
492 std::cout << "PREVIEW, success." << std::endl;
493 // Get the stream manager
494 display_->AchieveStreamOperator();
495 // start stream
496 display_->intents = {PREVIEW};
497 display_->StartStream(display_->intents);
498 // capture
499 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
500 // release stream
501 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
502 display_->streamIds = {display_->STREAM_ID_PREVIEW};
503 display_->StopStream(display_->captureIds, display_->streamIds);
504 }
505
506 /**
507 * @tc.name: Preview
508 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = VIDEO, success.
509 * @tc.level: Level2
510 * @tc.size: MediumTest
511 * @tc.type: Function
512 */
513 HWTEST_F(CameraPreviewTest, camera_preview_032, TestSize.Level2)
514 {
515 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = VIDEO, success." << std::endl;
516 // Create and get streamOperator information
517 display_->AchieveStreamOperator();
518 // start stream
519 display_->intents = {PREVIEW, VIDEO};
520 display_->StartStream(display_->intents);
521 // Get preview
522 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
523 display_->StartCapture(display_->STREAM_ID_VIDEO, display_->CAPTURE_ID_VIDEO, false, true);
524 // release stream
525 display_->captureIds = {display_->CAPTURE_ID_PREVIEW, display_->CAPTURE_ID_VIDEO};
526 display_->streamIds = {display_->STREAM_ID_PREVIEW, display_->STREAM_ID_VIDEO};
527 display_->StopStream(display_->captureIds, display_->streamIds);
528 }
529
530 /**
531 * @tc.name: Preview
532 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = STILL_CAPTURE, success.
533 * @tc.level: Level2
534 * @tc.size: MediumTest
535 * @tc.type: Function
536 */
537 HWTEST_F(CameraPreviewTest, camera_preview_033, TestSize.Level2)
538 {
539 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = ";
540 std::cout << "STILL_CAPTURE, success." << std::endl;
541 // Get the stream manager
542 display_->AchieveStreamOperator();
543 // start stream
544 display_->intents = {PREVIEW, STILL_CAPTURE};
545 display_->StartStream(display_->intents);
546 // Get preview
547 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
548 display_->StartCapture(display_->STREAM_ID_CAPTURE, display_->CAPTURE_ID_CAPTURE, false, true);
549 // release stream
550 display_->captureIds = {display_->CAPTURE_ID_PREVIEW, display_->CAPTURE_ID_CAPTURE};
551 display_->streamIds = {display_->STREAM_ID_PREVIEW, display_->STREAM_ID_CAPTURE};
552 display_->StopStream(display_->captureIds, display_->streamIds);
553 }
554
555 /**
556 * @tc.name: Preview
557 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = OHOS::POST_VIEW;, success.
558 * @tc.level: Level2
559 * @tc.size: MediumTest
560 * @tc.type: Function
561 */
562 HWTEST_F(CameraPreviewTest, camera_preview_034, TestSize.Level2)
563 {
564 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = ";
565 std::cout << "POST_VIEW;, success." << std::endl;
566 // Create and get streamOperator information
567 display_->AchieveStreamOperator();
568 // Create preview stream
569 // std::shared_ptr<OHOS::IBufferProducer> producer = OHOS::IBufferProducer::CreateBufferQueue();
570 if (display_->streamCustomerPreview_ == nullptr) {
571 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
572 }
573 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
574 producer->SetQueueSize(8); // 8:set bufferQueue size
575 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
576 std::cout << "~~~~~~~" << std::endl;
577 }
578 std::vector<StreamInfo> streamInfos;
579 StreamInfo streamInfo = {};
580 streamInfo.streamId_ = 1001;
581 streamInfo.width_ = 640; // 640:picture width
582 streamInfo.height_ = 480; // 480:picture height
583 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
584 streamInfo.dataspace_ = 8; // 8:picture dataspace
585 streamInfo.intent_ = POST_VIEW;
586 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
587 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
588 std::vector<StreamInfo>().swap(streamInfos);
589 streamInfos.push_back(streamInfo);
590 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
591 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
592 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
593 std::cout << "==========[test log] CreateStreams success." << std::endl;
594 } else {
595 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
596 }
597 // release stream
598 std::vector<int> streamIds;
599 streamIds.push_back(streamInfo.streamId_);
600 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(streamIds);
601 std::cout << "ReleaseStreams's RetCode = " << display_->rc << std::endl;
602 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
603 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
604 std::cout << "==========[test log] ReleaseStreams success." << std::endl;
605 } else {
606 std::cout << "==========[test log] ReleaseStreams fail, rc = " << display_->rc << std::endl;
607 }
608 }
609
610 /**
611 * @tc.name: Preview
612 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = OHOS::ANALYZE;, success.
613 * @tc.level: Level2
614 * @tc.size: MediumTest
615 * @tc.type: Function
616 */
617 HWTEST_F(CameraPreviewTest, camera_preview_035, TestSize.Level2)
618 {
619 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = ";
620 std::cout << "ANALYZE;, success." << std::endl;
621 // Create and get streamOperator information
622 display_->AchieveStreamOperator();
623 // Create data stream
624 if (display_->streamCustomerPreview_ == nullptr) {
625 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
626 }
627 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
628 producer->SetQueueSize(8); // 8:set bufferQueue size
629 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
630 std::cout << "~~~~~~~" << std::endl;
631 }
632 std::vector<StreamInfo> streamInfos;
633 StreamInfo streamInfo = {};
634 streamInfo.streamId_ = 1001;
635 streamInfo.width_ = 640; // 640:picture width
636 streamInfo.height_ = 480; // 480:picture height
637 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
638 streamInfo.dataspace_ = 8; // 8:picture dataspace
639 streamInfo.intent_ = ANALYZE;
640 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
641 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
642 std::vector<StreamInfo>().swap(streamInfos);
643 streamInfos.push_back(streamInfo);
644 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
645 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
646 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
647 std::cout << "==========[test log] CreateStreams success." << std::endl;
648 // release stream
649 std::vector<int> streamIds;
650 streamIds.push_back(streamInfo.streamId_);
651 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(streamIds);
652 std::cout << "ReleaseStreams RetCode = " << display_->rc << std::endl;
653 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
654 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
655 std::cout << "==========[test log] ReleaseStreams success." << std::endl;
656 }
657 else {
658 std::cout << "==========[test log] ReleaseStreams fail, rc = " << display_->rc << std::endl;
659 }
660 }
661
662 /**
663 * @tc.name: Preview
664 * @tc.desc: CreateStreams, StreamInfo->StreamIntent = CUSTOM, not support.
665 * @tc.level: Level2
666 * @tc.size: MediumTest
667 * @tc.type: Function
668 */
669 HWTEST_F(CameraPreviewTest, camera_preview_036, TestSize.Level2)
670 {
671 std::cout << "==========[test log] CreateStreams, StreamInfo->StreamIntent = ";
672 std::cout << "Camera::CUSTOM, not support." << std::endl;
673 // Create and get streamOperator information
674 display_->AchieveStreamOperator();
675 // Create data stream
676 if (display_->streamCustomerPreview_ == nullptr) {
677 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
678 }
679 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
680 producer->SetQueueSize(8); // 8:set bufferQueue size
681 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
682 std::cout << "~~~~~~~" << std::endl;
683 }
684 std::vector<StreamInfo> streamInfos;
685 StreamInfo streamInfo = {};
686 streamInfo.streamId_ = 1001;
687 streamInfo.width_ = 640; // 640:picture width
688 streamInfo.height_ = 480; // 480:picture height
689 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
690 streamInfo.dataspace_ = 8; // 8:picture dataspace
691 streamInfo.intent_ = CUSTOM;
692 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
693 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
694 std::vector<StreamInfo>().swap(streamInfos);
695 streamInfos.push_back(streamInfo);
696 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
697 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
698 EXPECT_EQ(true, display_->rc != HDI::Camera::V1_0::NO_ERROR);
699 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
700 std::cout << "==========[test log] CreateStreams success." << std::endl;
701 } else {
702 std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
703 }
704 }
705
706 /**
707 * @tc.name: Preview
708 * @tc.desc: CreateStreams, StreamInfo->tunneledMode = false, success.
709 * @tc.level: Level2
710 * @tc.size: MediumTest
711 * @tc.type: Function
712 */
713 HWTEST_F(CameraPreviewTest, camera_preview_037, TestSize.Level2)
714 {
715 std::cout << "==========[test log] CreateStreams, StreamInfo->tunneledMode = false, success." << std::endl;
716 // Create and get streamOperator information
717 display_->AchieveStreamOperator();
718 // Create data stream
719 if (display_->streamCustomerPreview_ == nullptr) {
720 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
721 }
722 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
723 producer->SetQueueSize(8); // 8:set bufferQueue size
724 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
725 std::cout << "~~~~~~~" << std::endl;
726 }
727 std::vector<StreamInfo> streamInfos;
728 StreamInfo streamInfo = {};
729 streamInfo.streamId_ = 1001;
730 streamInfo.width_ = 640; // 640:picture width
731 streamInfo.height_ = 480; // 480:picture height
732 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
733 streamInfo.dataspace_ = 8; // 8:picture dataspace
734 streamInfo.intent_ = PREVIEW;
735 streamInfo.tunneledMode_ = false;
736 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
737 std::vector<StreamInfo>().swap(streamInfos);
738 streamInfos.push_back(streamInfo);
739 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
740 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
741 EXPECT_EQ(true, display_->rc == INVALID_ARGUMENT);
742 if (display_->rc == INVALID_ARGUMENT) {
743 std::cout << "==========[test log] CreateStreams fail." << std::endl;
744 } else {
745 std::cout << "==========[test log] CreateStreams success"<< std::endl;
746 }
747 }
748
749 /**
750 * @tc.name: Preview
751 * @tc.desc: CreateStreams, StreamInfo->minFrameDuration = -1, return error.
752 * @tc.level: Level2
753 * @tc.size: MediumTest
754 * @tc.type: Function
755 */
756 HWTEST_F(CameraPreviewTest, camera_preview_038, TestSize.Level2)
757 {
758 std::cout << "==========[test log] CreateStreams, StreamInfo->minFrameDuration = -1, ";
759 std::cout << "return error." << std::endl;
760 // Create and get streamOperator information
761 display_->AchieveStreamOperator();
762 // Create data stream
763 if (display_->streamCustomerPreview_ == nullptr) {
764 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
765 }
766 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
767 producer->SetQueueSize(8); // 8:set bufferQueue size
768 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
769 std::cout << "~~~~~~~" << std::endl;
770 }
771 std::vector<StreamInfo> streamInfos;
772 StreamInfo streamInfo = {};
773 streamInfo.streamId_ = 1001;
774 streamInfo.width_ = 640; // 640:picture width
775 streamInfo.height_ = 480; // 480:picture height
776 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
777 streamInfo.dataspace_ = 8; // 8:picture dataspace
778 streamInfo.intent_ = PREVIEW;
779 streamInfo.tunneledMode_ = 0;
780 streamInfo.minFrameDuration_ = -1;
781 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
782 std::vector<StreamInfo>().swap(streamInfos);
783 streamInfos.push_back(streamInfo);
784 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
785 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
786 EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
787 std::cout << "==========[test log] CreateStreams, failed." << std::endl;
788 }
789
790 /**
791 * @tc.name: Preview
792 * @tc.desc: CreateStreams, StreamInfo->minFrameDuration = 2147483647, success.
793 * @tc.level: Level2
794 * @tc.size: MediumTest
795 * @tc.type: Function
796 */
797 HWTEST_F(CameraPreviewTest, camera_preview_039, TestSize.Level2)
798 {
799 std::cout << "==========[test log] CreateStreams, StreamInfo->minFrameDuration = 2147483647, ";
800 std::cout << "success." << std::endl;
801 // Create and get streamOperator information
802 display_->AchieveStreamOperator();
803 // Create data stream
804 if (display_->streamCustomerPreview_ == nullptr) {
805 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
806 }
807 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
808 producer->SetQueueSize(8); // 8:set bufferQueue size
809 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
810 std::cout << "~~~~~~~" << std::endl; }
811
812 std::vector<StreamInfo> streamInfos;
813 StreamInfo streamInfo = {};
814 streamInfo.streamId_ = 1001;
815 streamInfo.width_ = 640; // 640:picture width
816 streamInfo.height_ = 480; // 480:picture height
817 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
818 streamInfo.dataspace_ = 8; // 8:picture dataspace
819 streamInfo.intent_ = PREVIEW;
820 streamInfo.tunneledMode_ = 0;
821 streamInfo.minFrameDuration_ = 2147483647;
822 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
823 std::vector<StreamInfo>().swap(streamInfos);
824 streamInfos.push_back(streamInfo);
825 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
826 std::cout << "streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
827 EXPECT_EQ(false, display_->rc == HDI::Camera::V1_0::NO_ERROR);
828 std::cout << "==========[test log] CreateStreams, success." << std::endl;
829 }
830
831 /**
832 * @tc.name: Preview
833 * @tc.desc: Preview, CommitStreams Metadata = nullptr.
834 * @tc.level: Level2
835 * @tc.size: MediumTest
836 * @tc.type: Function
837 */
838 HWTEST_F(CameraPreviewTest, camera_preview_040, TestSize.Level2)
839 {
840 std::cout << "==========[test log] Preview, CommitStreams Metadata = nullptr." << std::endl;
841 // Create and get streamOperator information
842 display_->AchieveStreamOperator();
843 if (display_->streamCustomerPreview_ == nullptr) {
844 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
845 }
846 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
847 producer->SetQueueSize(8); // 8:set bufferQueue size
848 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
849 std::cout << "~~~~~~~" << std::endl; }
850
851 std::vector<StreamInfo> streamInfos;
852 StreamInfo streamInfo = {};
853 streamInfo.streamId_ = 1001;
854 streamInfo.width_ = 640; // 640:picture width
855 streamInfo.height_ = 480; // 480:picture height
856 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
857 streamInfo.dataspace_ = 8; // 8:picture dataspace
858 streamInfo.intent_ = PREVIEW;
859 streamInfo.tunneledMode_ = 0;
860 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
861 std::vector<StreamInfo>().swap(streamInfos);
862 streamInfos.push_back(streamInfo);
863 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
864 // Distribution stream
865 std::vector<uint8_t> modeSetting = {};
866 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, modeSetting);
867 std::cout << "streamOperator->CommitStreams's RetCode = " << display_->rc << std::endl;
868 EXPECT_EQ(true, display_->rc != HDI::Camera::V1_0::NO_ERROR);
869 // release stream
870 std::vector<int> streamIds;
871 streamIds.push_back(-1);
872 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(streamIds);
873 }
874
875 /**
876 * @tc.name: Preview
877 * @tc.desc: Preview, CommitStreams without CreateStreams, expected fail.
878 * @tc.level: Level2
879 * @tc.size: MediumTest
880 * @tc.type: Function
881 */
882 HWTEST_F(CameraPreviewTest, camera_preview_050, TestSize.Level2)
883 {
884 std::cout << "==========[test log] Preview, CommitStreams without CreateStreams, expected fail." << std::endl;
885 // Create and get streamOperator information
886 display_->AchieveStreamOperator();
887 // Distribution stream
888 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
889 std::cout << "streamOperator->CommitStreams's RetCode = " << display_->rc << std::endl;
890 EXPECT_EQ(true, display_->rc == INVALID_ARGUMENT);
891 // release stream
892 std::vector<int> streamIds;
893 streamIds.push_back(-1);
894 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(streamIds);
895 }
896
897 /**
898 * @tc.name: Preview
899 * @tc.desc: Preview and release streams, success.
900 * @tc.level: Level1
901 * @tc.size: MediumTest
902 * @tc.type: Function
903 */
904 HWTEST_F(CameraPreviewTest, camera_preview_060, TestSize.Level1)
905 {
906 std::cout << "==========[test log] Preview and release streams, success." << std::endl;
907 // Create and get streamOperator information
908 display_->AchieveStreamOperator();
909 // Create data stream
910 if (display_->streamCustomerPreview_ == nullptr) {
911 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
912 }
913 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
914 producer->SetQueueSize(8); // 8:set bufferQueue size
915 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
916 std::cout << "~~~~~~~" << std::endl;
917 }
918 std::vector<StreamInfo> streamInfos;
919 StreamInfo streamInfo = {};
920 streamInfo.streamId_ = 1001;
921 streamInfo.width_ = 640; // 640:picture width
922 streamInfo.height_ = 480; // 480:picture height
923 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
924 streamInfo.dataspace_ = 8; // 8:picture dataspace
925 streamInfo.intent_ = PREVIEW;
926 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
927 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
928 std::vector<StreamInfo>().swap(streamInfos);
929 streamInfos.push_back(streamInfo);
930 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
931 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
932 // Distribution stream
933 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
934 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
935 // Get preview
936 int captureId = 2001;
937 CaptureInfo captureInfo = {};
938 captureInfo.streamIds_ = {1001};
939 captureInfo.captureSetting_ = display_->ability_;
940 captureInfo.enableShutterCallback_ = false;
941 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, true);
942 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
943 sleep(5);
944 display_->streamOperator->CancelCapture(captureId);
945 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
946 // release stream
947 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
948 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
949 }
950
951 /**
952 * @tc.name: Preview
953 * @tc.desc: ReleaseStreams-> streamID = -1, expected INVALID_ARGUMENT.
954 * @tc.level: Level2
955 * @tc.size: MediumTest
956 * @tc.type: Function
957 */
958 HWTEST_F(CameraPreviewTest, camera_preview_061, TestSize.Level2)
959 {
960 std::cout << "==========[test log] ReleaseStreams-> streamID = -1, expected success." << std::endl;
961 // Create and get streamOperator information
962 display_->AchieveStreamOperator();
963 // Create preview stream
964 // std::shared_ptr<OHOS::IBufferProducer> producer = OHOS::IBufferProducer::CreateBufferQueue();
965 if (display_->streamCustomerPreview_ == nullptr) {
966 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
967 }
968 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
969 producer->SetQueueSize(8); // 8:set bufferQueue size
970 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
971 std::cout << "~~~~~~~" << std::endl;
972 }
973 std::vector<StreamInfo> streamInfos;
974 StreamInfo streamInfo = {};
975 streamInfo.streamId_ = 1001;
976 streamInfo.width_ = 640; // 640:picture width
977 streamInfo.height_ = 480; // 480:picture height
978 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
979 streamInfo.dataspace_ = 8; // 8:picture dataspace
980 streamInfo.intent_ = PREVIEW;
981 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
982 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
983 std::vector<StreamInfo>().swap(streamInfos);
984 streamInfos.push_back(streamInfo);
985 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
986 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
987 // Distribution stream
988 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
989 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
990 // Get preview
991 int captureId = 2001;
992 CaptureInfo captureInfo = {};
993 captureInfo.streamIds_ = {1001};
994 captureInfo.captureSetting_ = display_->ability_;
995 captureInfo.enableShutterCallback_ = false;
996 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, true);
997 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
998 sleep(5);
999 display_->streamOperator->CancelCapture(captureId);
1000 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1001 // release stream
1002 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(
1003 {-1});
1004 std::cout << "streamOperator->ReleaseStreams's rc = " << display_->rc << std::endl;
1005 EXPECT_EQ(true, display_->rc == INVALID_ARGUMENT);
1006 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(
1007 {1001});
1008 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1009 std::cout << "streamOperator->ReleaseStreams's RetCode = " << display_->rc << std::endl;
1010 }
1011
1012 /**
1013 * @tc.name: Preview
1014 * @tc.desc: ReleaseStreams no exist streamID, expect success.
1015 * @tc.level: Level2
1016 * @tc.size: MediumTest
1017 * @tc.type: Function
1018 */
1019 HWTEST_F(CameraPreviewTest, camera_preview_062, TestSize.Level2)
1020 {
1021 std::cout << "==========[test log] ReleaseStreams no exist streamID, expect success." << std::endl;
1022 // Create and get streamOperator information
1023 display_->AchieveStreamOperator();
1024 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(
1025 {9999});
1026 std::cout << "streamOperator->ReleaseStreams's RetCode = " << display_->rc << std::endl;
1027 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1028 }
1029
1030 /**
1031 * @tc.name: Preview
1032 * @tc.desc: Preview, Capture->captureInfo->streamID = -1 ,return error.
1033 * @tc.level: Level2
1034 * @tc.size: MediumTest
1035 * @tc.type: Function
1036 */
1037 HWTEST_F(CameraPreviewTest, camera_preview_070, TestSize.Level2)
1038 {
1039 std::cout << "==========[test log] Preview, Capture->captureInfo->streamID = -1 ,return error." << std::endl;
1040 // Create and get streamOperator information
1041 display_->AchieveStreamOperator();
1042 // Create preview stream
1043 // std::shared_ptr<OHOS::IBufferProducer> producer = OHOS::IBufferProducer::CreateBufferQueue();
1044 if (display_->streamCustomerPreview_ == nullptr) {
1045 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
1046 }
1047 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
1048 producer->SetQueueSize(8); // 8:set bufferQueue size
1049 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
1050 std::cout << "~~~~~~~" << std::endl;
1051 }
1052
1053 std::vector<StreamInfo> streamInfos;
1054 StreamInfo streamInfo = {};
1055 streamInfo.streamId_ = 1001;
1056 streamInfo.width_ = 640; // 640:picture width
1057 streamInfo.height_ = 480; // 480:picture height
1058 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
1059 streamInfo.dataspace_ = 8; // 8:picture dataspace
1060 streamInfo.intent_ = PREVIEW;
1061 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
1062 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
1063 std::vector<StreamInfo>().swap(streamInfos);
1064 streamInfos.push_back(streamInfo);
1065 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
1066 if (display_->rc != HDI::Camera::V1_0::NO_ERROR) {
1067 std::cout << "==============[test log]CreateStreams failed!" << std::endl;
1068 }
1069 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1070 // Distribution stream
1071 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
1072 if (display_->rc != HDI::Camera::V1_0::NO_ERROR) {
1073 std::cout << "==============[test log]CommitStreams failed!" << std::endl;
1074 }
1075 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1076 // Get preview
1077 int captureId = 2001;
1078 CaptureInfo captureInfo = {};
1079 captureInfo.streamIds_ = {-1};
1080 captureInfo.captureSetting_ = display_->ability_;
1081 captureInfo.enableShutterCallback_ = true;
1082 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, true);
1083 std::cout << "streamOperator->Capture rc = " << display_->rc << std::endl;
1084 if (display_->rc == INVALID_ARGUMENT) {
1085 std::cout << "============[test log]Capture failed " << std::endl;
1086 }
1087 EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
1088 }
1089
1090 /**
1091 * @tc.name: Preview
1092 * @tc.desc: Preview, Capture->captureInfo->streamID = 2147483647 ,return success.
1093 * @tc.level: Level2
1094 * @tc.size: MediumTest
1095 * @tc.type: Function
1096 */
1097 HWTEST_F(CameraPreviewTest, camera_preview_071, TestSize.Level2)
1098 {
1099 std::cout << "==========[test log] Preview, Capture->captureInfo->streamID = 2147483647 ,";
1100 std::cout << "return success." << std::endl;
1101 // Create and get streamOperator information
1102 display_->AchieveStreamOperator();
1103 // Create data stream
1104 if (display_->streamCustomerPreview_ == nullptr) {
1105 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
1106 }
1107 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
1108 producer->SetQueueSize(8); // 8:set bufferQueue size
1109 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
1110 std::cout << "~~~~~~~" << std::endl;
1111 }
1112
1113 std::vector<StreamInfo> streamInfos;
1114 StreamInfo streamInfo = {};
1115 streamInfo.streamId_ = 2147483647;
1116 streamInfo.width_ = 640; // 640:picture width
1117 streamInfo.height_ = 480; // 480:picture height
1118 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
1119 streamInfo.dataspace_ = 8; // 8:picture dataspace
1120 streamInfo.intent_ = PREVIEW;
1121 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
1122 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
1123 std::vector<StreamInfo>().swap(streamInfos);
1124 streamInfos.push_back(streamInfo);
1125 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
1126 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1127 // Distribution stream
1128 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
1129 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1130 // Get preview
1131 int captureId = 2001;
1132 CaptureInfo captureInfo = {};
1133 captureInfo.streamIds_ = {2147483647};
1134 captureInfo.captureSetting_ = display_->ability_;
1135 captureInfo.enableShutterCallback_ = true;
1136 bool isStreaming = true;
1137 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1138 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1139 sleep(5);
1140 display_->streamOperator->CancelCapture(captureId);
1141 // release stream
1142 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
1143 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1144 }
1145
1146 /**
1147 * @tc.name: Preview
1148 * @tc.desc: Preview, Capture->captureInfo->enableShutterCallback = false ,return success.
1149 * @tc.level: Level2
1150 * @tc.size: MediumTest
1151 * @tc.type: Function
1152 */
1153 HWTEST_F(CameraPreviewTest, camera_preview_072, TestSize.Level2)
1154 {
1155 std::cout << "==========[test log] Preview, Capture->captureInfo->enableShutterCallback = false ,";
1156 std::cout << "return success." << std::endl;
1157 // Create and get streamOperator information
1158 display_->AchieveStreamOperator();
1159 // Create data stream
1160 display_->intents = {PREVIEW};
1161 display_->StartStream(display_->intents);
1162 // Get preview
1163 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
1164 // release stream
1165 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
1166 display_->streamIds = {display_->STREAM_ID_PREVIEW};
1167 display_->StopStream(display_->captureIds, display_->streamIds);
1168 }
1169
1170 /**
1171 * @tc.name: Preview
1172 * @tc.desc: Preview, Capture->isStreaming = false ,expected success.
1173 * @tc.level: Level2
1174 * @tc.size: MediumTest
1175 * @tc.type: Function
1176 */
1177 HWTEST_F(CameraPreviewTest, camera_preview_073, TestSize.Level2)
1178 {
1179 std::cout << "==========[test log] Preview, Capture->isStreaming = false ,expected success." << std::endl;
1180 // Create and get streamOperator information
1181 display_->AchieveStreamOperator();
1182 // Create data stream
1183 display_->intents = {PREVIEW};
1184 display_->StartStream(display_->intents);
1185 // Get preview
1186 int captureId = 2001;
1187 CaptureInfo captureInfo = {};
1188 captureInfo.streamIds_ = {display_->STREAM_ID_PREVIEW};
1189 captureInfo.captureSetting_ = display_->ability_;
1190 captureInfo.enableShutterCallback_ = true;
1191 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, false);
1192 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1193 sleep(5);
1194 display_->streamOperator->CancelCapture(captureId);
1195 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1196 // release stream
1197 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
1198 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1199 }
1200
1201 /**
1202 * @tc.name: Preview
1203 * @tc.desc: Preview, Capture->captureId = -1 ,return error.
1204 * @tc.level: Level2
1205 * @tc.size: MediumTest
1206 * @tc.type: Function
1207 */
1208 HWTEST_F(CameraPreviewTest, camera_preview_074, TestSize.Level2)
1209 {
1210 std::cout << "==========[test log] Preview, Capture->captureId = -1 ,return error." << std::endl;
1211 // Create and get streamOperator information
1212 display_->AchieveStreamOperator();
1213 // Create data stream
1214 display_->intents = {PREVIEW};
1215 display_->StartStream(display_->intents);
1216 // Get preview
1217 int captureId = -1;
1218 CaptureInfo captureInfo = {};
1219 captureInfo.streamIds_ = {display_->STREAM_ID_PREVIEW};
1220 captureInfo.captureSetting_ = display_->ability_;
1221 captureInfo.enableShutterCallback_ = false;
1222 bool isStreaming = true;
1223 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1224 EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
1225 }
1226
1227 /**
1228 * @tc.name: Preview
1229 * @tc.desc: Preview, Capture->captureInfo->enableShutterCallback = true ,return success.
1230 * @tc.level: Level2
1231 * @tc.size: MediumTest
1232 * @tc.type: Function
1233 */
1234 HWTEST_F(CameraPreviewTest, camera_preview_075, TestSize.Level2)
1235 {
1236 std::cout << "==========[test log] Preview, Capture->captureInfo->enableShutterCallback = true ,";
1237 std::cout << "return success." << std::endl;
1238 // Create and get streamOperator information
1239 display_->AchieveStreamOperator();
1240 // Create data stream
1241 display_->intents = {PREVIEW};
1242 display_->StartStream(display_->intents);
1243 // Get preview
1244 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, true, true);
1245 // release stream
1246 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
1247 display_->streamIds = {display_->STREAM_ID_PREVIEW};
1248 display_->StopStream(display_->captureIds, display_->streamIds);
1249 }
1250
1251 /**
1252 * @tc.name: Preview
1253 * @tc.desc: CancelCapture captureID = -1.
1254 * @tc.level: Level2
1255 * @tc.size: MediumTest
1256 * @tc.type: Function
1257 */
1258 HWTEST_F(CameraPreviewTest, camera_preview_080, TestSize.Level2)
1259 {
1260 std::cout << "==========[test log] CancelCapture captureID = -1, expected fail." << std::endl;
1261 // Create and get streamOperator information
1262 display_->AchieveStreamOperator();
1263 // Create data stream
1264 if (display_->streamCustomerPreview_ == nullptr) {
1265 display_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
1266 }
1267 OHOS::sptr<OHOS::IBufferProducer> producer = display_->streamCustomerPreview_->CreateProducer();
1268 producer->SetQueueSize(8); // 8:set bufferQueue size
1269 if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
1270 std::cout << "~~~~~~~" << std::endl;
1271 }
1272
1273 std::vector<StreamInfo> streamInfos;
1274 StreamInfo streamInfo = {};
1275 streamInfo.streamId_ = 1001;
1276 streamInfo.width_ = 640; // 640:picture width
1277 streamInfo.height_ = 480; // 480:picture height
1278 streamInfo.format_ = PIXEL_FMT_RGBA_8888;
1279 streamInfo.dataspace_ = 8; // 8:picture dataspace
1280 streamInfo.intent_ = PREVIEW;
1281 streamInfo.tunneledMode_ = 5; // 5:tunnel mode
1282 streamInfo.bufferQueue_ = new BufferProducerSequenceable(producer);
1283 std::vector<StreamInfo>().swap(streamInfos);
1284 streamInfos.push_back(streamInfo);
1285 display_->rc = (CamRetCode)display_->streamOperator->CreateStreams(streamInfos);
1286 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1287 // Distribution stream
1288 display_->rc = (CamRetCode)display_->streamOperator->CommitStreams(NORMAL, display_->ability_);
1289 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1290 // Get preview
1291 int captureId = 100;
1292 CaptureInfo captureInfo = {};
1293 captureInfo.streamIds_ = {1001};
1294 captureInfo.captureSetting_ = display_->ability_;
1295 captureInfo.enableShutterCallback_ = false;
1296 bool isStreaming = true;
1297 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1298 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1299 sleep(5);
1300 display_->rc = (CamRetCode)display_->streamOperator->CancelCapture(-1);
1301 EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
1302 display_->rc = (CamRetCode)display_->streamOperator->CancelCapture(captureId);
1303 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1304 // release stream
1305 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
1306 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1307 }
1308
1309 /**
1310 * @tc.name: Preview
1311 * @tc.desc: CancelCapture without Create capture.
1312 * @tc.level: Level2
1313 * @tc.size: MediumTest
1314 * @tc.type: Function
1315 */
1316 HWTEST_F(CameraPreviewTest, camera_preview_090, TestSize.Level2)
1317 {
1318 std::cout << "==========[test log] CancelCapture without Create capture ." << std::endl;
1319 // Create and get streamOperator information
1320 display_->AchieveStreamOperator();
1321 // Create data stream
1322 display_->intents = {PREVIEW};
1323 display_->StartStream(display_->intents);
1324 // Get preview
1325 int captureId = 100;
1326 display_->rc = (CamRetCode)display_->streamOperator->CancelCapture(captureId);
1327 if (display_->rc == HDI::Camera::V1_0::NO_ERROR) {
1328 std::cout << "==========[test log] CancelCapture success." << std::endl;
1329 }
1330 else {
1331 std::cout << "==========[test log] CancelCapture fail, rc = " << display_->rc << std::endl;
1332 }
1333 }
1334
1335 /**
1336 * @tc.name: Preview
1337 * @tc.desc: Release streams, then createCapture.
1338 * @tc.level: Level2
1339 * @tc.size: MediumTest
1340 * @tc.type: Function
1341 */
1342 HWTEST_F(CameraPreviewTest, camera_preview_091, TestSize.Level2)
1343 {
1344 std::cout << "==========[test log] Create capture, then release streams." << std::endl;
1345 // Create and get streamOperator information
1346 display_->AchieveStreamOperator();
1347 // start stream
1348 display_->intents = {PREVIEW};
1349 display_->StartStream(display_->intents);
1350 // Get preview
1351 display_->StartCapture(display_->STREAM_ID_PREVIEW, display_->CAPTURE_ID_PREVIEW, false, true);
1352 // release stream
1353 display_->captureIds = {display_->CAPTURE_ID_PREVIEW};
1354 display_->streamIds = {display_->STREAM_ID_PREVIEW};
1355 display_->StopStream(display_->captureIds, display_->streamIds);
1356 }
1357
1358 /**
1359 * @tc.name: Preview
1360 * @tc.desc: The same CaptureID, Create capture twice, expected fail.
1361 * @tc.level: Level2
1362 * @tc.size: MediumTest
1363 * @tc.type: Function
1364 */
1365 HWTEST_F(CameraPreviewTest, camera_preview_092, TestSize.Level2)
1366 {
1367 std::cout << "==========[test log] The same CaptureID, Create capture twice, expected fail." << std::endl;
1368 // Create and get streamOperator information
1369 display_->AchieveStreamOperator();
1370 // start stream
1371 display_->intents = {PREVIEW};
1372 display_->StartStream(display_->intents);
1373
1374 int captureId = display_->CAPTURE_ID_PREVIEW;
1375 CaptureInfo captureInfo = {};
1376 captureInfo.streamIds_ = {display_->STREAM_ID_PREVIEW};
1377 captureInfo.captureSetting_ = display_->ability_;
1378 captureInfo.enableShutterCallback_ = false;
1379 bool isStreaming = true;
1380 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1381 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1382
1383 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1384 EXPECT_EQ(false, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1385
1386 sleep(2);
1387 // cancel capture
1388 display_->rc = (CamRetCode)display_->streamOperator->CancelCapture(captureId);
1389 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1390
1391 // release stream
1392 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
1393 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1394 }
1395
1396 /**
1397 * @tc.name: Preview
1398 * @tc.desc: Different captureIDs, Create capture,expected success.
1399 * @tc.level: Level2
1400 * @tc.size: MediumTest
1401 * @tc.type: Function
1402 */
1403 HWTEST_F(CameraPreviewTest, camera_preview_093, TestSize.Level2)
1404 {
1405 std::cout << "==========[test log] Different captureIDs, Create capture,expected success." << std::endl;
1406 // Create and get streamOperator information
1407 display_->AchieveStreamOperator();
1408 // Create data stream
1409 display_->intents = {PREVIEW};
1410 display_->StartStream(display_->intents);
1411 // Get preview
1412 int captureId = display_->CAPTURE_ID_PREVIEW;
1413 CaptureInfo captureInfo = {};
1414 captureInfo.streamIds_ = {display_->STREAM_ID_PREVIEW};
1415 captureInfo.captureSetting_ = display_->ability_;
1416 captureInfo.enableShutterCallback_ = false;
1417 bool isStreaming = true;
1418 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
1419 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1420 display_->rc = (CamRetCode)display_->streamOperator->Capture(captureId + 1, captureInfo, isStreaming);
1421 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1422
1423 sleep(2);
1424 // cancel capture
1425 display_->streamOperator->CancelCapture(captureId);
1426 display_->streamOperator->CancelCapture(captureId + 1);
1427 // release stream
1428 display_->rc = (CamRetCode)display_->streamOperator->ReleaseStreams(captureInfo.streamIds_);
1429 EXPECT_EQ(true, display_->rc == HDI::Camera::V1_0::NO_ERROR);
1430 }