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