• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "hdi_func_test.h"
16 
SetUpTestCase(void)17 void UtestHdiFuncTest::SetUpTestCase(void)
18 {}
TearDownTestCase(void)19 void UtestHdiFuncTest::TearDownTestCase(void)
20 {}
SetUp(void)21 void UtestHdiFuncTest::SetUp(void)
22 {
23     if (display_ == nullptr)
24     display_ = std::make_shared<TestDisplay>();
25     display_->FBInit();
26     display_->Init();
27 }
TearDown(void)28 void UtestHdiFuncTest::TearDown(void)
29 {
30     display_->Close();
31 }
32 
33 /**
34   * @tc.name: Capture
35   * @tc.desc: Capture, input normal.
36   * @tc.level: Level1
37   * @tc.size: MediumTest
38   * @tc.type: Function
39   */
40 HWTEST_F(UtestHdiFuncTest, camera_hdi_0190, TestSize.Level1)
41 {
42     std::cout << "==========[test log] Capture, input normal." << std::endl;
43     // Create and get streamOperator information
44     display_->AchieveStreamOperator();
45     // Create data stream
46     display_->intents = {PREVIEW};
47     display_->StartStream(display_->intents);
48     // Get preview
49     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, false, true);
50     // release stream
51     display_->captureIds = {display_->captureId_preview};
52     display_->streamIds = {display_->streamId_preview};
53     display_->StopStream(display_->captureIds, display_->streamIds);
54 }
55 
56 /**
57   * @tc.name: Capture
58   * @tc.desc: Preview, Capture->captureInfo->streamID = -1 ,return error.
59   * @tc.level: Level2
60   * @tc.size: MediumTest
61   * @tc.type: Function
62   */
63 HWTEST_F(UtestHdiFuncTest, camera_hdi_0191, TestSize.Level1)
64 {
65     std::cout << "==========[test log] Preview, Capture->captureInfo->streamID = -1 ,return error." << std::endl;
66     display_->OpenCamera();
67     // Create and get streamOperator information
68     display_->AchieveStreamOperator();
69     // start stream
70     display_->intents = {PREVIEW};
71     display_->StartStream(display_->intents);
72     // Get preview
73     int captureId = 2001;
74     std::shared_ptr<CaptureInfo> captureInfo = std::make_shared<CaptureInfo>();
75     captureInfo->streamIds_ = {-1};
76     captureInfo->enableShutterCallback_ = true;
77     display_->rc = display_->streamOperator->Capture(captureId, captureInfo, true);
78     EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
79     if (display_->rc == INVALID_ARGUMENT)
80     {
81         std::cout << "==========[test log] Capture fail." << std::endl;
82     } else {
83         std::cout << "==========[test log] Capture success." << std::endl;
84     }
85     sleep(3);
86 }
87 
88 /**
89   * @tc.name: Capture
90   * @tc.desc: Preview, Capture->captureInfo->streamID = 2147483647 ,return success.
91   * @tc.level: Level2
92   * @tc.size: MediumTest
93   * @tc.type: Function
94   */
95 HWTEST_F(UtestHdiFuncTest, camera_hdi_0192, TestSize.Level1)
96 {
97     std::cout << "==========[test log] Preview,";
98     std::cout << "Capture->captureInfo->streamID = 2147483647 ,return success." << std::endl;
99     // Create and get streamOperator information
100     display_->AchieveStreamOperator();
101     // start stream
102     display_->intents = {PREVIEW};
103     display_->StartStream(display_->intents);
104     // Get preview
105     int captureId = 2001;
106     std::shared_ptr<CaptureInfo> captureInfo = std::make_shared<CaptureInfo>();
107     captureInfo->streamIds_ = {2147483647};
108     captureInfo->enableShutterCallback_ = true;
109     bool isStreaming = true;
110     display_->rc = display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
111     EXPECT_EQ(true, display_->rc == NO_ERROR);
112     if (display_->rc == NO_ERROR) {
113         std::cout << "==========[test log] Capture success." << std::endl;
114     } else {
115         std::cout << "==========[test log] Capture fail, rc = " << display_->rc << std::endl;
116     }
117     sleep(5);
118     display_->rc = display_->streamOperator->CancelCapture(captureId);
119     EXPECT_EQ(true, display_->rc == NO_ERROR);
120     if (display_->rc == NO_ERROR) {
121         std::cout << "==========[test log] CancelCapture success." << std::endl;
122     } else {
123         std::cout << "==========[test log] CancelCapture fail, rc = " << display_->rc << std::endl;
124     }
125     display_->cameraDevice->Close();
126     std::cout << "cameraDevice->Close" << std::endl;
127 }
128 
129 /**
130   * @tc.name: Capture
131   * @tc.desc: Preview, Capture->captureInfo->enableShutterCallback = false ,return success.
132   * @tc.level: Level2
133   * @tc.size: MediumTest
134   * @tc.type: Function
135   */
136 HWTEST_F(UtestHdiFuncTest, camera_hdi_0193, TestSize.Level1)
137 {
138     std::cout << "==========[test log] Preview,";
139     std::cout << "Capture->captureInfo->enableShutterCallback = false ,return success." << std::endl;
140     // Create and get streamOperator information
141     display_->AchieveStreamOperator();
142     // start stream
143     display_->intents = {PREVIEW};
144     display_->StartStream(display_->intents);
145     // Get preview
146     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, false, true);
147     // release stream
148     display_->captureIds = {display_->captureId_preview};
149     display_->streamIds = {display_->streamId_preview};
150     display_->StopStream(display_->captureIds, display_->streamIds);
151 }
152 
153 /**
154   * @tc.name: Capture
155   * @tc.desc: Preview, Capture->isStreaming = false ,expected success.
156   * @tc.level: Level2
157   * @tc.size: MediumTest
158   * @tc.type: Function
159   */
160 HWTEST_F(UtestHdiFuncTest, camera_hdi_0194, TestSize.Level1)
161 {
162     std::cout << "==========[test log] Preview, Capture->isStreaming = false ,expected success." << std::endl;
163     std::cout << "==========[test log] Preview, Capture->isStreaming = false ,expected success." << std::endl;
164     // Create and get streamOperator information
165     display_->AchieveStreamOperator();
166     // start stream
167     display_->intents = {PREVIEW};
168     display_->StartStream(display_->intents);
169     // Get preview
170     int captureId = 2001;
171     std::shared_ptr<CaptureInfo> captureInfo = std::make_shared<CaptureInfo>();
172     captureInfo->streamIds_ = {display_->streamId_preview};
173     captureInfo->enableShutterCallback_ = true;
174     display_->rc = display_->streamOperator->Capture(captureId, captureInfo, false);
175     EXPECT_EQ(true, display_->rc == NO_ERROR);
176     sleep(5);
177     display_->streamOperator->CancelCapture(captureId);
178     EXPECT_EQ(true, display_->rc == NO_ERROR);
179     if (display_->rc == NO_ERROR) {
180         std::cout << "==========[test log] CancelCapture success." << std::endl;
181     } else {
182         std::cout << "==========[test log] CancelCapture fail, rc = " << display_->rc << std::endl;
183     }
184     // release stream
185     display_->rc = display_->streamOperator->ReleaseStreams(captureInfo->streamIds_);
186     EXPECT_EQ(true, display_->rc == NO_ERROR);
187     if (display_->rc == NO_ERROR) {
188         std::cout << "==========[test log] ReleaseStreams success." << std::endl;
189     } else {
190         std::cout << "==========[test log] ReleaseStreams fail, rc = " << display_->rc << std::endl;
191     }
192 }
193 
194 /**
195   * @tc.name: Capture
196   * @tc.desc: Preview, Capture->captureId = -1 ,return error.
197   * @tc.level: Level2
198   * @tc.size: MediumTest
199   * @tc.type: Function
200   */
201 HWTEST_F(UtestHdiFuncTest, camera_hdi_0195, TestSize.Level1)
202 {
203     std::cout << "==========[test log] Preview, Capture->captureId = -1 ,return error." << std::endl;
204     display_->OpenCamera();
205     // Create and get streamOperator information
206     display_->AchieveStreamOperator();
207     // start stream
208     display_->intents = {PREVIEW};
209     display_->StartStream(display_->intents);
210     // Get preview
211     int captureId = -1;
212     std::shared_ptr<CaptureInfo> captureInfo = std::make_shared<CaptureInfo>();
213     captureInfo->streamIds_ = {display_->streamId_preview};
214     captureInfo->enableShutterCallback_ = false;
215     bool isStreaming = true;
216     display_->rc = display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
217     EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
218     if (display_->rc == NO_ERROR) {
219         std::cout << "==========[test log] Capture success." << std::endl;
220     } else {
221         std::cout << "==========[test log] Capture fail, rc = " << display_->rc << std::endl;
222     }
223     sleep(3);
224 }
225 
226 /**
227   * @tc.name: Capture
228   * @tc.desc: Preview, Capture->captureInfo->enableShutterCallback = true ,return success.
229   * @tc.level: Level2
230   * @tc.size: MediumTest
231   * @tc.type: Function
232   */
233 HWTEST_F(UtestHdiFuncTest, camera_hdi_0196, TestSize.Level1)
234 {
235     std::cout << "==========[test log] Preview,";
236     std::cout << "Capture->captureInfo->enableShutterCallback = true ,return success." << std::endl;
237     // Create and get streamOperator information
238     display_->AchieveStreamOperator();
239     // start stream
240     display_->intents = {PREVIEW};
241     display_->StartStream(display_->intents);
242     // Get preview
243     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, true, true);
244     // release stream
245     display_->captureIds = {display_->captureId_preview};
246     display_->streamIds = {display_->streamId_preview};
247     display_->StopStream(display_->captureIds, display_->streamIds);
248 }
249 
250 /**
251   * @tc.name: CancelCapture
252   * @tc.desc: CancelCapture, success.
253   * @tc.level: Level2
254   * @tc.size: MediumTest
255   * @tc.type: Function
256   */
257 HWTEST_F(UtestHdiFuncTest, camera_hdi_0200, TestSize.Level1)
258 {
259     std::cout << "==========[test log] CancelCapture, success." << std::endl;
260     // Create and get streamOperator information
261     display_->AchieveStreamOperator();
262     // start stream
263     display_->intents = {PREVIEW};
264     display_->StartStream(display_->intents);
265     // Get preview
266     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, false, true);
267     // release stream
268     display_->captureIds = {display_->captureId_preview};
269     display_->streamIds = {display_->streamId_preview};
270     display_->StopStream(display_->captureIds, display_->streamIds);
271 }
272 
273 /**
274   * @tc.name: CancelCapture
275   * @tc.desc: CancelCapture captureID = -1.
276   * @tc.level: Level2
277   * @tc.size: MediumTest
278   * @tc.type: Function
279   */
280 HWTEST_F(UtestHdiFuncTest, camera_hdi_0201, TestSize.Level1)
281 {
282     std::cout << "==========[test log] CancelCapture captureID = -1, expected fail." << std::endl;
283     // Create and get streamOperator information
284     display_->AchieveStreamOperator();
285     // start stream
286     display_->intents = {PREVIEW};
287     display_->StartStream(display_->intents);
288     // Get preview
289     int captureId = 100;
290     std::shared_ptr<CaptureInfo> captureInfo = std::make_shared<CaptureInfo>();
291     captureInfo->streamIds_ = {display_->streamId_preview};
292     captureInfo->enableShutterCallback_ = false;
293     bool isStreaming = true;
294     display_->rc = display_->streamOperator->Capture(captureId, captureInfo, isStreaming);
295     EXPECT_EQ(true, display_->rc == NO_ERROR);
296     sleep(5);
297     display_->rc = display_->streamOperator->CancelCapture(-1);
298     EXPECT_EQ(INVALID_ARGUMENT, display_->rc);
299     display_->rc = display_->streamOperator->CancelCapture(captureId);
300     EXPECT_EQ(true, display_->rc == NO_ERROR);
301     if (display_->rc == NO_ERROR) {
302         std::cout << "==========[test log] CancelCapture success." << std::endl;
303     } else {
304         std::cout << "==========[test log] CancelCapture fail, rc = " << display_->rc << std::endl;
305     }
306     // release stream
307     display_->rc = display_->streamOperator->ReleaseStreams(captureInfo->streamIds_);
308     EXPECT_EQ(true, display_->rc == NO_ERROR);
309     if (display_->rc == NO_ERROR) {
310         std::cout << "==========[test log] ReleaseStreams success." << std::endl;
311     } else {
312         std::cout << "==========[test log] ReleaseStreams fail, rc = " << display_->rc << std::endl;
313     }
314 }
315 
316 /**
317   * @tc.name: AttachBufferQueue
318   * @tc.desc: AttachBufferQueue, normal input.
319   * @tc.level: Level1
320   * @tc.size: MediumTest
321   * @tc.type: Function
322   // */
323 HWTEST_F(UtestHdiFuncTest, camera_hdi_0210, TestSize.Level1)
324 {
325     std::cout << "==========[test log] AttachBufferQueue, normal input." << std::endl;
326     display_->AchieveStreamOperator();
327     // Create data stream
328     std::shared_ptr<IBufferProducer> producer = IBufferProducer::CreateBufferQueue();
329     producer->SetQueueSize(8); // 8:set bufferQueue size
330     if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
331         std::cout << "~~~~~~~" << std::endl;
332     }
__anon3ef5f2dd0102(std::shared_ptr<SurfaceBuffer> b) 333     auto callback = [this](std::shared_ptr<SurfaceBuffer> b) {
334         display_->BufferCallback(b, display_->preview_mode);
335         return;
336     };
337     producer->SetCallback(callback);
338 
339     display_->streamInfo = std::make_shared<StreamInfo>();
340     display_->streamInfo->streamId_ = 1001;
341     display_->streamInfo->width_ = 640; // 640:picture width
342     display_->streamInfo->height_ = 480; // 480:picture height
343     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
344     display_->streamInfo->dataspace_ = 8; // 8:picture dataspace
345     display_->streamInfo->intent_ = PREVIEW;
346     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode
347     display_->streamInfos.push_back(display_->streamInfo);
348     display_->rc = display_->streamOperator->CreateStreams(display_->streamInfos);
349     std::cout << "==========[test log] streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
350     EXPECT_EQ(true, display_->rc == NO_ERROR);
351     if (display_->rc == NO_ERROR) {
352         std::cout << "==========[test log] CreateStreams success." << std::endl;
353     } else {
354         std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
355     }
356     display_->rc = display_->streamOperator->AttachBufferQueue(display_->streamInfo->streamId_, producer);
357     EXPECT_EQ(true, display_->rc == NO_ERROR);
358     if (display_->rc == NO_ERROR) {
359         std::cout << "==========[test log] AttachBufferQueue success. " << std::endl;
360     } else {
361         std::cout << "==========[test log] AttachBufferQueue fail, rc = " << display_->rc << std::endl;
362     }
363     sleep(3);
364     // release stream
365     display_->streamIds = {1001};
366     display_->StopStream(display_->captureIds, display_->streamIds);
367 }
368 
369 /**
370   * @tc.name: AttachBufferQueue
371   * @tc.desc: AttachBufferQueue, streamID is not exist.
372   * @tc.level: Level2
373   * @tc.size: MediumTest
374   * @tc.type: Function
375   */
376 HWTEST_F(UtestHdiFuncTest, camera_hdi_0211, TestSize.Level1)
377 {
378     std::cout << "==========[test log] AttachBufferQueue, streamID is not exist.." << std::endl;
379     display_->AchieveStreamOperator();
380     // Create data stream
381     display_->streamInfo = std::make_shared<StreamInfo>();
382     std::shared_ptr<IBufferProducer> producer = IBufferProducer::CreateBufferQueue();
383     producer->SetQueueSize(8); // 8:set bufferQueue size
384     if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
385         std::cout << "~~~~~~~" << std::endl;
386     }
__anon3ef5f2dd0202(std::shared_ptr<SurfaceBuffer> b) 387     auto callback = [this](std::shared_ptr<SurfaceBuffer> b) {
388         display_->BufferCallback(b, display_->preview_mode);
389         return;
390     };
391     producer->SetCallback(callback);
392     display_->streamInfo->streamId_ = 1001;
393     display_->streamInfo->width_ = 640; // 640:picture width
394     display_->streamInfo->height_ = 480; // 480:picture height
395     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
396     display_->streamInfo->dataspace_ = 8; // 8:picture dataspace
397     display_->streamInfo->intent_ = PREVIEW;
398     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode
399     display_->streamInfos.push_back(display_->streamInfo);
400     display_->rc = display_->streamOperator->CreateStreams(display_->streamInfos);
401     std::cout << "==========[test log] streamOperator->CreateStreams's RetCode = " << display_->rc << std::endl;
402     EXPECT_EQ(true, display_->rc == NO_ERROR);
403     if (display_->rc == NO_ERROR) {
404         std::cout << "==========[test log] CreateStreams success." << std::endl;
405     } else {
406         std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
407     }
408     display_->rc = display_->streamOperator->AttachBufferQueue(0, producer);
409     EXPECT_EQ(true, display_->rc != NO_ERROR);
410     if (display_->rc == NO_ERROR) {
411         std::cout << "==========[test log] AttachBufferQueue success. " << std::endl;
412     } else {
413         std::cout << "==========[test log] AttachBufferQueue fail, rc = " << display_->rc << std::endl;
414     }
415     sleep(3);
416     // Release the stream
417     display_->streamIds = {1001};
418     display_->StopStream(display_->captureIds, display_->streamIds);
419 }
420 
421 /**
422   * @tc.name: AttachBufferQueue
423   * @tc.desc: AttachBufferQueue, producer is nullptr.
424   * @tc.level: Level2
425   * @tc.size: MediumTest
426   * @tc.type: Function
427   */
428 HWTEST_F(UtestHdiFuncTest, camera_hdi_0212, TestSize.Level1)
429 {
430     std::cout << "==========[test log] AttachBufferQueue, producer is nullptr." << std::endl;
431     display_->AchieveStreamOperator();
432     if (display_->rc == NO_ERROR) {
433         std::cout << "==========[test log] GetStreamOperator success. " << std::endl;
434     } else {
435         std::cout << "==========[test log] GetStreamOperator fail, rc = " << display_->rc << std::endl;
436     }
437     std::shared_ptr<IBufferProducer> producer = nullptr;
438     // Create data stream
439     display_->streamInfo = std::make_shared<StreamInfo>();
440     display_->streamInfo->streamId_ = 1001;
441     display_->streamInfo->width_ = 640; // 640:picture width
442     display_->streamInfo->height_ = 480; // 480:picture height
443     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
444     display_->streamInfo->dataspace_ = 8; // 8:picture dataspace
445     display_->streamInfo->intent_ = PREVIEW;
446     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode
447     display_->streamInfos.push_back(display_->streamInfo);
448     display_->rc = display_->streamOperator->CreateStreams(display_->streamInfos);
449     std::cout << "==========[test log] streamOperator->CreateStreams's RetCode = ";
450     std::cout << display_->rc << std::endl;
451     EXPECT_EQ(true, display_->rc == NO_ERROR);
452     if (display_->rc == NO_ERROR) {
453         std::cout << "==========[test log] CreateStreams success. " << std::endl;
454     } else {
455         std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
456     }
457     display_->rc = display_->streamOperator->AttachBufferQueue(display_->streamInfo->streamId_, nullptr);
458     EXPECT_EQ(true, display_->rc != NO_ERROR);
459     if (display_->rc == NO_ERROR) {
460         std::cout << "==========[test log] AttachBufferQueue success. " << std::endl;
461     } else {
462         std::cout << "==========[test log] AttachBufferQueue fail, rc = " << display_->rc << std::endl;
463     }
464     sleep(3);
465     // release stream
466     display_->streamIds = {1001};
467     display_->StopStream(display_->captureIds, display_->streamIds);
468 }
469 
470 /**
471   * @tc.name: DetachBufferQueue
472   * @tc.desc: DetachBufferQueue, normal input.
473   * @tc.level: Level1
474   * @tc.size: MediumTest
475   * @tc.type: Function
476   */
477 HWTEST_F(UtestHdiFuncTest, camera_hdi_0220, TestSize.Level1)
478 {
479     std::cout << "==========[test log] DetachBufferQueue, normal input." << std::endl;
480     display_->AchieveStreamOperator();
481     // Create data stream
482     std::shared_ptr<IBufferProducer> producer = IBufferProducer::CreateBufferQueue();
483     producer->SetQueueSize(8); // 8:set bufferQueue size
484     if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
485         std::cout << "~~~~~~~" << std::endl;
486     }
__anon3ef5f2dd0302(std::shared_ptr<SurfaceBuffer> b) 487     auto callback = [this](std::shared_ptr<SurfaceBuffer> b) {
488         display_->BufferCallback(b, display_->preview_mode);
489         return;
490     };
491     producer->SetCallback(callback);
492     display_->streamInfo = std::make_shared<StreamInfo>();
493     display_->streamInfo->streamId_ = 1001;
494     display_->streamInfo->width_ = 640; // 640:picture width
495     display_->streamInfo->height_ = 480; // 480:picture height
496     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
497     display_->streamInfo->dataspace_ = 8; // 8:picture dataspace
498     display_->streamInfo->intent_ = PREVIEW;
499     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode
500     display_->streamInfos.push_back(display_->streamInfo);
501     display_->rc = display_->streamOperator->CreateStreams(display_->streamInfos);
502     std::cout << "==========[test log] streamOperator->CreateStreams's RetCode = ";
503     std::cout << display_->rc << std::endl;
504     EXPECT_EQ(true, display_->rc == NO_ERROR);
505     std::cout << "==========[test log] CreateStreams success. " << std::endl;
506     display_->rc = display_->streamOperator->AttachBufferQueue(display_->streamInfo->streamId_, producer);
507     std::cout << "==========[test log] streamOperator->AttachBufferQueue's RetCode = ";
508     std::cout << display_->rc << std::endl;
509     EXPECT_EQ(true, display_->rc == NO_ERROR);
510     sleep(3);
511     std::cout << "==========[test log] AttachBufferQueue success. " << std::endl;
512     display_->rc = display_->streamOperator->DetachBufferQueue(display_->streamInfo->streamId_);
513     std::cout << "==========[test log] streamOperator->DetachBufferQueue's RetCode = ";
514     std::cout << display_->rc << std::endl;
515     EXPECT_EQ(true, display_->rc == NO_ERROR);
516     if (display_->rc == NO_ERROR) {
517         std::cout << "==========[test log] DetachBufferQueue success. " << std::endl;
518     } else {
519         std::cout << "==========[test log] DetachBufferQueue fail, rc = " << display_->rc << std::endl;
520     }
521     // release stream
522     display_->streamIds = {1001};
523     display_->StopStream(display_->captureIds, display_->streamIds);
524 }
525 
526 /**
527   * @tc.name: DetachBufferQueue
528   * @tc.desc: DetachBufferQueue, streamID is not exist.
529   * @tc.level: Level2
530   * @tc.size: MediumTest
531   * @tc.type: Function
532   */
533 HWTEST_F(UtestHdiFuncTest, camera_hdi_0221, TestSize.Level1)
534 {
535     std::cout << "==========[test log] DetachBufferQueue, streamID is not exist." << std::endl;
536     display_->AchieveStreamOperator();
537     // Create data stream
538     std::shared_ptr<IBufferProducer> producer = IBufferProducer::CreateBufferQueue();
539     producer->SetQueueSize(8); // 8:set bufferQueue size
540     if (producer->GetQueueSize() != 8) { // 8:get bufferQueue size
541         std::cout << "~~~~~~~" << std::endl;
542     }
__anon3ef5f2dd0402(std::shared_ptr<SurfaceBuffer> b) 543     auto callback = [this](std::shared_ptr<SurfaceBuffer> b) {
544         display_->BufferCallback(b, display_->preview_mode);
545         return;
546     };
547     producer->SetCallback(callback);
548     display_->streamInfo = std::make_shared<StreamInfo>();
549     display_->streamInfo->streamId_ = 1001;
550     display_->streamInfo->width_ = 640; // 640:picture width
551     display_->streamInfo->height_ = 480; // 480:picture height
552     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
553     display_->streamInfo->dataspace_ = 8; // 8:picture dataspace
554     display_->streamInfo->intent_ = PREVIEW;
555     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode
556     display_->streamInfos.push_back(display_->streamInfo);
557     display_->rc = display_->streamOperator->CreateStreams(display_->streamInfos);
558     std::cout << "==========[test log] streamOperator->CreateStreams's RetCode = ";
559     std::cout << display_->rc << std::endl;
560     EXPECT_EQ(true, display_->rc == NO_ERROR);
561     std::cout << "==========[test log] CreateStreams success. " << std::endl;
562     display_->rc = display_->streamOperator->AttachBufferQueue(display_->streamInfo->streamId_, producer);
563     std::cout << "==========[test log] streamOperator->AttachBufferQueue's RetCode = " << display_->rc << std::endl;
564     EXPECT_EQ(true, display_->rc == NO_ERROR);
565     std::cout << "==========[test log] AttachBufferQueue success. " << std::endl;
566     sleep(3);
567 
568     display_->rc = display_->streamOperator->DetachBufferQueue(0);
569     std::cout << "==========[test log] streamOperator->DetachBufferQueue's RetCode = " << display_->rc << std::endl;
570     EXPECT_EQ(true, display_->rc != NO_ERROR);
571     if (display_->rc == NO_ERROR) {
572         std::cout << "==========[test log] DetachBufferQueue success. " << std::endl;
573     } else {
574         std::cout << "==========[test log] DetachBufferQueue fail, rc = " << display_->rc << std::endl;
575     }
576     // release stream
577     display_->streamIds = {1001};
578     display_->StopStream(display_->captureIds, display_->streamIds);
579 }