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