1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file expected in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci#include "performance_func_test.h" 16094332d3Sopenharmony_ci#include <fstream> 17094332d3Sopenharmony_cinamespace { 18094332d3Sopenharmony_ci static const int TIME_TRANSFORMATION_US = 1000000; // 1000000:1000000 microseconds 19094332d3Sopenharmony_ci static const int CYCLE_TIMES = 1000; // 1000:Cycle 1000 times 20094332d3Sopenharmony_ci std::ofstream g_writeIntoFile; 21094332d3Sopenharmony_ci} 22094332d3Sopenharmony_ci 23094332d3Sopenharmony_ciusing namespace OHOS; 24094332d3Sopenharmony_ciusing namespace std; 25094332d3Sopenharmony_ciusing namespace testing::ext; 26094332d3Sopenharmony_ciusing namespace OHOS::Camera; 27094332d3Sopenharmony_cifloat PerformanceFuncTest::calTime(struct timeval start, struct timeval end) 28094332d3Sopenharmony_ci{ 29094332d3Sopenharmony_ci float time_use = 0; 30094332d3Sopenharmony_ci time_use = (end.tv_sec - start.tv_sec) * TIME_TRANSFORMATION_US + (end.tv_usec - start.tv_usec); 31094332d3Sopenharmony_ci return time_use; 32094332d3Sopenharmony_ci} 33094332d3Sopenharmony_civoid PerformanceFuncTest::SetUpTestCase(void) {} 34094332d3Sopenharmony_civoid PerformanceFuncTest::TearDownTestCase(void) {} 35094332d3Sopenharmony_civoid PerformanceFuncTest::SetUp(void) {} 36094332d3Sopenharmony_civoid PerformanceFuncTest::TearDown(void) 37094332d3Sopenharmony_ci{ 38094332d3Sopenharmony_ci Test_->Close(); 39094332d3Sopenharmony_ci} 40094332d3Sopenharmony_ci 41094332d3Sopenharmony_ci/** 42094332d3Sopenharmony_ci * @tc.name: Check Open camera's time consuming. 43094332d3Sopenharmony_ci * @tc.desc: Check Open camera's time consuming. 44094332d3Sopenharmony_ci * @tc.size: MediumTest 45094332d3Sopenharmony_ci * @tc.type: Function 46094332d3Sopenharmony_ci */ 47094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0001, TestSize.Level3) 48094332d3Sopenharmony_ci{ 49094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Check Open camera's time consuming."<< std::endl; 50094332d3Sopenharmony_ci struct timeval start; 51094332d3Sopenharmony_ci struct timeval end; 52094332d3Sopenharmony_ci float totle_time_use = 0; 53094332d3Sopenharmony_ci g_writeIntoFile.open("TimeConsuming.txt", ios::app); 54094332d3Sopenharmony_ci for (int i= 0; i < CYCLE_TIMES; i++) { 55094332d3Sopenharmony_ci float time_use; 56094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 57094332d3Sopenharmony_ci gettimeofday(&start, NULL); 58094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 59094332d3Sopenharmony_ci Test_->Init(); 60094332d3Sopenharmony_ci Test_->Open(); 61094332d3Sopenharmony_ci gettimeofday(&end, NULL); 62094332d3Sopenharmony_ci time_use = calTime(start, end); 63094332d3Sopenharmony_ci totle_time_use = totle_time_use + time_use; 64094332d3Sopenharmony_ci // Post-processing, turn off the camera 65094332d3Sopenharmony_ci Test_->Close(); 66094332d3Sopenharmony_ci } 67094332d3Sopenharmony_ci float avrg_time = totle_time_use / CYCLE_TIMES; 68094332d3Sopenharmony_ci EXPECT_LT(avrg_time, 80000); 69094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Open camera's average time consuming: "; 70094332d3Sopenharmony_ci std::cout << avrg_time << "us." << std::endl; 71094332d3Sopenharmony_ci g_writeIntoFile << "==========[test log] Performance: Open camera's average time consuming: "; 72094332d3Sopenharmony_ci g_writeIntoFile << avrg_time << "us." << std::endl; 73094332d3Sopenharmony_ci} 74094332d3Sopenharmony_ci 75094332d3Sopenharmony_ci/** 76094332d3Sopenharmony_ci * @tc.name: Check Start Streams's time consuming. 77094332d3Sopenharmony_ci * @tc.desc: Check Start Streams's time consuming. 78094332d3Sopenharmony_ci * @tc.size: MediumTest 79094332d3Sopenharmony_ci * @tc.type: Function 80094332d3Sopenharmony_ci */ 81094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0002, TestSize.Level3) 82094332d3Sopenharmony_ci{ 83094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Check Start Streams's time consuming." << std::endl; 84094332d3Sopenharmony_ci struct timeval start; 85094332d3Sopenharmony_ci struct timeval end; 86094332d3Sopenharmony_ci float time_use; 87094332d3Sopenharmony_ci float totle_time_use = 0; 88094332d3Sopenharmony_ci g_writeIntoFile.open("TimeConsuming.txt", ios::app); 89094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 90094332d3Sopenharmony_ci Test_->Init(); 91094332d3Sopenharmony_ci Test_->Open(); 92094332d3Sopenharmony_ci for (int i = 0; i < CYCLE_TIMES; i++) { 93094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 94094332d3Sopenharmony_ci // Create and get streamOperator information 95094332d3Sopenharmony_ci Test_->CreateStreamOperatorCallback(); 96094332d3Sopenharmony_ci Test_->rc = Test_->cameraDevice->GetStreamOperator(Test_->streamOperatorCallback, Test_->streamOperator); 97094332d3Sopenharmony_ci EXPECT_EQ(false, Test_->rc != Camera::NO_ERROR || Test_->streamOperator == nullptr); 98094332d3Sopenharmony_ci // Create data flow 99094332d3Sopenharmony_ci Test_->streamInfo = std::make_shared<Camera::StreamInfo>(); 100094332d3Sopenharmony_ci Test_->streamInfo->streamId_ = 1001; 101094332d3Sopenharmony_ci Test_->streamInfo->width_ = 1920; 102094332d3Sopenharmony_ci Test_->streamInfo->height_ = 1080; 103094332d3Sopenharmony_ci Test_->StreamInfoFormat(); 104094332d3Sopenharmony_ci Test_->streamInfo->dataspace_ = 10; 105094332d3Sopenharmony_ci Test_->streamInfo->intent_ = Camera::PREVIEW; 106094332d3Sopenharmony_ci Test_->streamInfo->tunneledMode_ = 5; 107094332d3Sopenharmony_ci std::shared_ptr<OHOS::Camera::Test::StreamConsumer> preview_consumer = 108094332d3Sopenharmony_ci std::make_shared<OHOS::Camera::Test::StreamConsumer>(); 109094332d3Sopenharmony_ci#ifdef CAMERA_BUILT_ON_OHOS_LITE 110094332d3Sopenharmony_ci Test_->streamInfo->bufferQueue_ = preview_consumer->CreateProducer([this](OHOS::SurfaceBuffer* buffer) { 111094332d3Sopenharmony_ci Test_->SaveYUV("preview", buffer->GetVirAddr(), buffer->GetSize()); 112094332d3Sopenharmony_ci }); 113094332d3Sopenharmony_ci#else 114094332d3Sopenharmony_ci Test_->streamInfo->bufferQueue_ = preview_consumer->CreateProducer([this](void* addr, uint32_t size) { 115094332d3Sopenharmony_ci Test_->SaveYUV("preview", addr, size); 116094332d3Sopenharmony_ci }); 117094332d3Sopenharmony_ci#endif 118094332d3Sopenharmony_ci Test_->streamInfo->bufferQueue_->SetQueueSize(8); 119094332d3Sopenharmony_ci Test_->consumerMap_[Camera::PREVIEW] = preview_consumer; 120094332d3Sopenharmony_ci std::vector<std::shared_ptr<Camera::StreamInfo>>().swap(Test_->streamInfos); 121094332d3Sopenharmony_ci Test_->streamInfos.push_back(Test_->streamInfo); 122094332d3Sopenharmony_ci gettimeofday(&start, NULL); 123094332d3Sopenharmony_ci Test_->rc = Test_->streamOperator->CreateStreams(Test_->streamInfos); 124094332d3Sopenharmony_ci EXPECT_EQ(Test_->rc, Camera::NO_ERROR); 125094332d3Sopenharmony_ci // Flow distribution 126094332d3Sopenharmony_ci Test_->rc = Test_->streamOperator->CommitStreams(Camera::NORMAL, Test_->ability); 127094332d3Sopenharmony_ci gettimeofday(&end, NULL); 128094332d3Sopenharmony_ci EXPECT_EQ(Test_->rc, Camera::NO_ERROR); 129094332d3Sopenharmony_ci time_use = calTime(start, end); 130094332d3Sopenharmony_ci totle_time_use = totle_time_use + time_use; 131094332d3Sopenharmony_ci // Release stream 132094332d3Sopenharmony_ci Test_->rc = Test_->streamOperator->ReleaseStreams({1001}); 133094332d3Sopenharmony_ci EXPECT_EQ(Test_->rc, Camera::NO_ERROR); 134094332d3Sopenharmony_ci } 135094332d3Sopenharmony_ci float avrg_time = totle_time_use / CYCLE_TIMES; 136094332d3Sopenharmony_ci EXPECT_LT(avrg_time, 100000); 137094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Start Streams's average time consuming: "; 138094332d3Sopenharmony_ci std::cout << avrg_time << "us." << std::endl; 139094332d3Sopenharmony_ci g_writeIntoFile << "==========[test log] Performance: Start Streams's average time consuming: "; 140094332d3Sopenharmony_ci g_writeIntoFile << avrg_time << "us. " << std::endl; 141094332d3Sopenharmony_ci} 142094332d3Sopenharmony_ci 143094332d3Sopenharmony_ci/** 144094332d3Sopenharmony_ci * @tc.name: Check Close camera's time consuming. 145094332d3Sopenharmony_ci * @tc.desc: Check Close camera's time consuming. 146094332d3Sopenharmony_ci * @tc.size: MediumTest 147094332d3Sopenharmony_ci * @tc.type: Function 148094332d3Sopenharmony_ci */ 149094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0003, TestSize.Level3) 150094332d3Sopenharmony_ci{ 151094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Check Close camera's time consuming."<< std::endl; 152094332d3Sopenharmony_ci struct timeval start; 153094332d3Sopenharmony_ci struct timeval end; 154094332d3Sopenharmony_ci float totle_time_use = 0; 155094332d3Sopenharmony_ci g_writeIntoFile.open("TimeConsuming.txt", ios::app); 156094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 157094332d3Sopenharmony_ci Test_->Init(); 158094332d3Sopenharmony_ci for (int i= 0; i < CYCLE_TIMES; i++) { 159094332d3Sopenharmony_ci float time_use; 160094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 161094332d3Sopenharmony_ci Test_->Open(); 162094332d3Sopenharmony_ci gettimeofday(&start, NULL); 163094332d3Sopenharmony_ci Test_->Close(); 164094332d3Sopenharmony_ci gettimeofday(&end, NULL); 165094332d3Sopenharmony_ci time_use = calTime(start, end); 166094332d3Sopenharmony_ci totle_time_use = totle_time_use + time_use; 167094332d3Sopenharmony_ci } 168094332d3Sopenharmony_ci float avrg_time = totle_time_use / CYCLE_TIMES; 169094332d3Sopenharmony_ci EXPECT_LT(avrg_time, 100000); 170094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Close camera's average time consuming: "; 171094332d3Sopenharmony_ci std::cout << avrg_time << "us." << std::endl; 172094332d3Sopenharmony_ci g_writeIntoFile << "==========[test log] Performance: Close camera's average time consuming: "; 173094332d3Sopenharmony_ci g_writeIntoFile << avrg_time << "us." << std::endl; 174094332d3Sopenharmony_ci} 175094332d3Sopenharmony_ci 176094332d3Sopenharmony_ci/** 177094332d3Sopenharmony_ci * @tc.name: Continuous startup streams and shutdown streams. 178094332d3Sopenharmony_ci * @tc.desc: Continuous startup streams and shutdown streams. 179094332d3Sopenharmony_ci * @tc.size: MediumTest 180094332d3Sopenharmony_ci * @tc.type: Function 181094332d3Sopenharmony_ci */ 182094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0004, TestSize.Level3) 183094332d3Sopenharmony_ci{ 184094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Continuous startup streams and shutdown streams." << std::endl; 185094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 186094332d3Sopenharmony_ci Test_->Init(); 187094332d3Sopenharmony_ci Test_->Open(); 188094332d3Sopenharmony_ci for (int i = 0; i < 100; i++) { // 100:Cycle 100 times 189094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 190094332d3Sopenharmony_ci // Start stream 191094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW}; 192094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 193094332d3Sopenharmony_ci // Get preview 194094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 195094332d3Sopenharmony_ci // Release stream 196094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview}; 197094332d3Sopenharmony_ci Test_->streamIds.push_back(Test_->streamId_preview); 198094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 199094332d3Sopenharmony_ci } 200094332d3Sopenharmony_ci} 201094332d3Sopenharmony_ci 202094332d3Sopenharmony_ci/** 203094332d3Sopenharmony_ci * @tc.name: Preview and Capture, then start one Preview 204094332d3Sopenharmony_ci * @tc.desc: Preview and Capture, then start one Preview 205094332d3Sopenharmony_ci * @tc.size: MediumTest 206094332d3Sopenharmony_ci * @tc.type: Function 207094332d3Sopenharmony_ci */ 208094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0005, TestSize.Level3) 209094332d3Sopenharmony_ci{ 210094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Preview and Capture then start one Preview" << std::endl; 211094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 212094332d3Sopenharmony_ci Test_->Init(); 213094332d3Sopenharmony_ci Test_->Open(); 214094332d3Sopenharmony_ci for (int i = 0; i < 100; i++) { // 100:Cycle 100 times 215094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 216094332d3Sopenharmony_ci // Configure two stream information 217094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::STILL_CAPTURE}; 218094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 219094332d3Sopenharmony_ci // Capture preview stream 220094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 221094332d3Sopenharmony_ci // Capture camera stream, single capture 222094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_capture, Test_->captureId_capture, false, true); 223094332d3Sopenharmony_ci // Post-processing 224094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_capture}; 225094332d3Sopenharmony_ci Test_->streamIds.push_back(Test_->streamId_preview); 226094332d3Sopenharmony_ci Test_->streamIds.push_back(Test_->streamId_capture); 227094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 228094332d3Sopenharmony_ci // Configure preview stream 229094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW}; 230094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 231094332d3Sopenharmony_ci // Capture preview stream 232094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 233094332d3Sopenharmony_ci // Release preview stream 234094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview}; 235094332d3Sopenharmony_ci Test_->streamIds.push_back(Test_->streamId_preview); 236094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 237094332d3Sopenharmony_ci } 238094332d3Sopenharmony_ci} 239094332d3Sopenharmony_ci 240094332d3Sopenharmony_ci/** 241094332d3Sopenharmony_ci * @tc.name: Preview and Video, then start one Preview 242094332d3Sopenharmony_ci * @tc.desc: Preview and Video, then start one Preview 243094332d3Sopenharmony_ci * @tc.size: MediumTest 244094332d3Sopenharmony_ci * @tc.type: Function 245094332d3Sopenharmony_ci */ 246094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0006, TestSize.Level3) 247094332d3Sopenharmony_ci{ 248094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Preview and Video, then start one Preview" << std::endl; 249094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 250094332d3Sopenharmony_ci Test_->Init(); 251094332d3Sopenharmony_ci Test_->Open(); 252094332d3Sopenharmony_ci for (int i = 0; i < 100; i++) { // 100:Cycle 100 times 253094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 254094332d3Sopenharmony_ci // Configure two stream information 255094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::VIDEO}; 256094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 257094332d3Sopenharmony_ci // Capture preview stream 258094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 259094332d3Sopenharmony_ci // Capture video stream 260094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_video, Test_->captureId_video, false, true); 261094332d3Sopenharmony_ci // Post-processing 262094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_video}; 263094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_video}; 264094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 265094332d3Sopenharmony_ci // Configure preview stream 266094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW}; 267094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 268094332d3Sopenharmony_ci // Capture preview stream 269094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 270094332d3Sopenharmony_ci // Release preview stream 271094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview}; 272094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview}; 273094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 274094332d3Sopenharmony_ci } 275094332d3Sopenharmony_ci} 276094332d3Sopenharmony_ci 277094332d3Sopenharmony_ci/** 278094332d3Sopenharmony_ci * @tc.name: Preview and Video, then Preview and Capture, then Preview and Video 279094332d3Sopenharmony_ci * @tc.desc: Preview and Video, then Preview and Capture, then Preview and Video 280094332d3Sopenharmony_ci * @tc.size: MediumTest 281094332d3Sopenharmony_ci * @tc.type: Function 282094332d3Sopenharmony_ci */ 283094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0007, TestSize.Level3) 284094332d3Sopenharmony_ci{ 285094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Preview and Video, then Preview and Capture,"; 286094332d3Sopenharmony_ci std::cout << "then Preview and Video" << std::endl; 287094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 288094332d3Sopenharmony_ci Test_->Init(); 289094332d3Sopenharmony_ci Test_->Open(); 290094332d3Sopenharmony_ci for (int i = 0; i < 100; i++) { // 100:Cycle 100 times 291094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 292094332d3Sopenharmony_ci // Configure two stream information 293094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::VIDEO}; 294094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 295094332d3Sopenharmony_ci // Capture preview stream 296094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 297094332d3Sopenharmony_ci // Capture video stream 298094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_video, Test_->captureId_video, false, true); 299094332d3Sopenharmony_ci // Post-processing 300094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_video}; 301094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_video}; 302094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 303094332d3Sopenharmony_ci Test_->consumerMap_.clear(); 304094332d3Sopenharmony_ci // Configure two stream information 305094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::STILL_CAPTURE}; 306094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 307094332d3Sopenharmony_ci // Capture preview stream 308094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 309094332d3Sopenharmony_ci // Capture camera stream, continuous capture 310094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_capture, Test_->captureId_capture, false, true); 311094332d3Sopenharmony_ci // Post-processing 312094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_capture}; 313094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_capture}; 314094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 315094332d3Sopenharmony_ci Test_->consumerMap_.clear(); 316094332d3Sopenharmony_ci // Configure two stream information 317094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::VIDEO}; 318094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 319094332d3Sopenharmony_ci // Capture preview stream 320094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 321094332d3Sopenharmony_ci // Capture video stream 322094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_video, Test_->captureId_video, false, true); 323094332d3Sopenharmony_ci // Post-processing 324094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_video}; 325094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_video}; 326094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 327094332d3Sopenharmony_ci } 328094332d3Sopenharmony_ci} 329094332d3Sopenharmony_ci 330094332d3Sopenharmony_ci/** 331094332d3Sopenharmony_ci * @tc.name: Preview and Capture, then Preview and Video, then Preview and Capture 332094332d3Sopenharmony_ci * @tc.desc: Preview and Capture, then Preview and Video, then Preview and Capture 333094332d3Sopenharmony_ci * @tc.size: MediumTest 334094332d3Sopenharmony_ci * @tc.type: Function 335094332d3Sopenharmony_ci */ 336094332d3Sopenharmony_ciHWTEST_F(PerformanceFuncTest, Camera_Performance_0008, TestSize.Level3) 337094332d3Sopenharmony_ci{ 338094332d3Sopenharmony_ci std::cout << "==========[test log] Performance: Preview and Capture, then Preview and Video,"; 339094332d3Sopenharmony_ci std::cout << "then Preview and Capture" << std::endl; 340094332d3Sopenharmony_ci Test_ = std::make_shared<OHOS::Camera::Test>(); 341094332d3Sopenharmony_ci Test_->Init(); 342094332d3Sopenharmony_ci Test_->Open(); 343094332d3Sopenharmony_ci for (int i = 0; i < 100; i++) { // 100:Cycle 100 times 344094332d3Sopenharmony_ci std::cout << "Running " << i << " time" << std::endl; 345094332d3Sopenharmony_ci // Configure two stream information 346094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::STILL_CAPTURE}; 347094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 348094332d3Sopenharmony_ci // Capture preview stream 349094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 350094332d3Sopenharmony_ci // Capture camera stream, continuous capture 351094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_capture, Test_->captureId_capture, false, true); 352094332d3Sopenharmony_ci // Post-processing 353094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_capture}; 354094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_capture}; 355094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 356094332d3Sopenharmony_ci Test_->consumerMap_.clear(); 357094332d3Sopenharmony_ci // Configure two stream information 358094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::VIDEO}; 359094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 360094332d3Sopenharmony_ci // Capture preview stream 361094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 362094332d3Sopenharmony_ci // Capture video stream 363094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_video, Test_->captureId_video, false, true); 364094332d3Sopenharmony_ci // Post-processing 365094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_video}; 366094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_video}; 367094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 368094332d3Sopenharmony_ci Test_->consumerMap_.clear(); 369094332d3Sopenharmony_ci // Configure two stream information 370094332d3Sopenharmony_ci Test_->intents = {Camera::PREVIEW, Camera::STILL_CAPTURE}; 371094332d3Sopenharmony_ci Test_->StartStream(Test_->intents); 372094332d3Sopenharmony_ci // Capture preview stream 373094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_preview, Test_->captureId_preview, false, true); 374094332d3Sopenharmony_ci // Capture camera stream, continuous capture 375094332d3Sopenharmony_ci Test_->StartCapture(Test_->streamId_capture, Test_->captureId_capture, false, true); 376094332d3Sopenharmony_ci // Post-processing 377094332d3Sopenharmony_ci Test_->captureIds = {Test_->captureId_preview, Test_->captureId_capture}; 378094332d3Sopenharmony_ci Test_->streamIds = {Test_->streamId_preview, Test_->streamId_capture}; 379094332d3Sopenharmony_ci Test_->StopStream(Test_->captureIds, Test_->streamIds); 380094332d3Sopenharmony_ci Test_->consumerMap_.clear(); 381094332d3Sopenharmony_ci } 382094332d3Sopenharmony_ci}