• 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 expected 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 "pipeline_test.h"
16 
SetUpTestCase(void)17 void UtestPipelineTest::SetUpTestCase(void)
18 {}
TearDownTestCase(void)19 void UtestPipelineTest::TearDownTestCase(void)
20 {}
SetUp(void)21 void UtestPipelineTest::SetUp(void)
22 {
23     if (display_ == nullptr)
24     display_ = std::make_shared<TestDisplay>();
25     display_->FBInit();
26     display_->Init();
27 }
TearDown(void)28 void UtestPipelineTest::TearDown(void)
29 {
30     display_->Close();
31 }
32 
33 /**
34   * @tc.name: Check ppl
35   * @tc.desc: preview success.
36   * @tc.level: Level0
37   * @tc.size: MediumTest
38   * @tc.type: Function
39   */
TEST_F(UtestPipelineTest,camera_ppl_0001)40 TEST_F(UtestPipelineTest, camera_ppl_0001)
41 {
42     std::cout << "==========[test log] Check ppl: preview success." << std::endl;
43     // Get the stream manager
44     display_->AchieveStreamOperator();
45     // start 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: Check ppl
58   * @tc.desc: preview + capture success.
59   * @tc.level: Level1
60   * @tc.size: MediumTest
61   * @tc.type: Function
62   */
TEST_F(UtestPipelineTest,camera_ppl_0002)63 TEST_F(UtestPipelineTest, camera_ppl_0002)
64 {
65     std::cout << "==========[test log] Check ppl: preview + capture success." << std::endl;
66     // Get the stream manager
67     display_->AchieveStreamOperator();
68     // start stream
69     display_->intents = {PREVIEW, STILL_CAPTURE};
70     display_->StartStream(display_->intents);
71     // Get preview
72     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, false, true);
73     display_->StartCapture(display_->streamId_capture, display_->captureId_capture, false, true);
74     // release stream
75     display_->captureIds = {display_->captureId_preview, display_->captureId_capture};
76     display_->streamIds = {display_->streamId_preview, display_->streamId_capture};
77     display_->StopStream(display_->captureIds, display_->streamIds);
78 }
79 
80 /**
81   * @tc.name: Check ppl
82   * @tc.desc: preview + video success.
83   * @tc.level: Level1
84   * @tc.size: MediumTest
85   * @tc.type: Function
86   */
TEST_F(UtestPipelineTest,camera_ppl_0003)87 TEST_F(UtestPipelineTest, camera_ppl_0003)
88 {
89     std::cout << "==========[test log] Check ppl: preview + video success." << std::endl;
90     // Get the stream manager
91     display_->AchieveStreamOperator();
92     // start stream
93     display_->intents = {PREVIEW, VIDEO};
94     display_->StartStream(display_->intents);
95     // Get preview
96     display_->StartCapture(display_->streamId_preview, display_->captureId_preview, false, true);
97     display_->StartCapture(display_->streamId_video, display_->captureId_video, false, true);
98     // release stream
99     display_->captureIds = {display_->captureId_preview, display_->captureId_video};
100     display_->streamIds = {display_->streamId_preview, display_->streamId_video};
101     display_->StopStream(display_->captureIds, display_->streamIds);
102 }
103 
104 /**
105   * @tc.name: Check ppl
106   * @tc.desc: video mode without preview, system not support, expected return fail.
107   * @tc.level: Level2
108   * @tc.size: MediumTest
109   * @tc.type: Function
110   */
TEST_F(UtestPipelineTest,camera_ppl_0004)111 TEST_F(UtestPipelineTest, camera_ppl_0004)
112 {
113     std::cout << "==========[test log] Video mode without preview, system not support, ";
114     std::cout << "expected return fail." << std::endl;
115 
116     EXPECT_EQ(true, display_->cameraDevice != nullptr);
117     display_->AchieveStreamOperator();
118     // Create video stream
119     std::vector<std::shared_ptr<StreamInfo>> streamInfos;
120     std::shared_ptr<IBufferProducer> producer = IBufferProducer::CreateBufferQueue();
121     producer->SetQueueSize(8); // 8:set bufferqueue size
122     if (producer->GetQueueSize() != 8) { // 8:get bufferqueue size
123         std::cout << "~~~~~~~" << std::endl;
124     }
125     auto callback = [this](std::shared_ptr<SurfaceBuffer> b) {
126         display_->BufferCallback(b, display_->video_mode);
127         return;
128     };
129     producer->SetCallback(callback);
130     display_->streamInfo = std::make_shared<StreamInfo>();
131     display_->streamInfo->streamId_ = display_->streamId_video;
132     display_->streamInfo->width_ = 640; // 640:picture width // 640:picture width
133     display_->streamInfo->height_ = 480; // 480:picture height // 480:picture height
134     display_->streamInfo->format_ = CAMERA_FORMAT_YUYV_422_PKG;
135     display_->streamInfo->dataspace_ = 10; // 10:picture dataspace
136     display_->streamInfo->intent_ = VIDEO;
137     display_->streamInfo->tunneledMode_ = 5; // 5:tunnel mode // 5:tunnel mode
138     display_->streamInfo->bufferQueue_ = producer;
139     std::vector<std::shared_ptr<StreamInfo>>().swap(streamInfos);
140     streamInfos.push_back(display_->streamInfo);
141     display_->rc = display_->streamOperator->CreateStreams(streamInfos);
142     EXPECT_EQ(false, display_->rc == Camera::METHOD_NOT_SUPPORTED);
143     if (display_->rc == Camera::METHOD_NOT_SUPPORTED) {
144         std::cout << "==========[test log] CreateStreams METHOD_NOT_SUPPORTED, streamId = ";
145         std::cout << display_->streamId_video <<", intent = VIDEO" << std::endl;
146     } else {
147         std::cout << "==========[test log] CreateStreams fail, rc = " << display_->rc << std::endl;
148     }
149 
150     display_->rc = display_->streamOperator->CommitStreams(Camera::NORMAL, nullptr);
151     EXPECT_EQ(false, display_->rc == NO_ERROR);
152     if (display_->rc == NO_ERROR) {
153         std::cout << "==========[test log] CommitStreams success." << std::endl;
154     } else {
155         std::cout << "==========[test log] CommitStreams fail, rc = ." << display_->rc << std::endl;
156     }
157 }