• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "camera_framework_moduletest.h"
17 #include <cinttypes>
18 #include "input/camera_input.h"
19 #include "input/camera_manager.h"
20 #include "camera_error_code.h"
21 #include "camera_log.h"
22 #include "surface.h"
23 #include "test_common.h"
24 
25 #include "parameter.h"
26 #include "ipc_skeleton.h"
27 #include "access_token.h"
28 #include "hap_token_info.h"
29 #include "accesstoken_kit.h"
30 #include "token_setproc.h"
31 #include "camera_util.h"
32 #include "nativetoken_kit.h"
33 
34 #include "iservice_registry.h"
35 #include "system_ability_definition.h"
36 
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace CameraStandard {
41 namespace {
42     enum class CAM_PHOTO_EVENTS {
43         CAM_PHOTO_CAPTURE_START = 0,
44         CAM_PHOTO_CAPTURE_END,
45         CAM_PHOTO_CAPTURE_ERR,
46         CAM_PHOTO_FRAME_SHUTTER,
47         CAM_PHOTO_MAX_EVENT
48     };
49 
50     enum class CAM_PREVIEW_EVENTS {
51         CAM_PREVIEW_FRAME_START = 0,
52         CAM_PREVIEW_FRAME_END,
53         CAM_PREVIEW_FRAME_ERR,
54         CAM_PREVIEW_MAX_EVENT
55     };
56 
57     enum class CAM_VIDEO_EVENTS {
58         CAM_VIDEO_FRAME_START = 0,
59         CAM_VIDEO_FRAME_END,
60         CAM_VIDEO_FRAME_ERR,
61         CAM_VIDEO_MAX_EVENT
62     };
63 
64 
65     const int32_t WAIT_TIME_AFTER_CAPTURE = 1;
66     const int32_t WAIT_TIME_AFTER_START = 2;
67     const int32_t WAIT_TIME_BEFORE_STOP = 1;
68     const int32_t CAMERA_NUMBER = 2;
69 
70     bool g_camInputOnError = false;
71     bool g_sessionclosed = false;
72     std::shared_ptr<Camera::CameraMetadata> g_metaResult = nullptr;
73     int32_t g_videoFd = -1;
74     int32_t g_previewFd = -1;
75     std::bitset<static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_MAX_EVENT)> g_photoEvents;
76     std::bitset<static_cast<unsigned int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_MAX_EVENT)> g_previewEvents;
77     std::bitset<static_cast<unsigned int>(CAM_VIDEO_EVENTS::CAM_VIDEO_MAX_EVENT)> g_videoEvents;
78     std::unordered_map<std::string, int> g_camStatusMap;
79     std::unordered_map<std::string, bool> g_camFlashMap;
80 
81 
82     class AppCallback : public CameraManagerCallback, public ErrorCallback, public PhotoStateCallback,
83                         public PreviewStateCallback, public ResultCallback {
84     public:
OnCameraStatusChanged(const CameraStatusInfo & cameraDeviceInfo) const85         void OnCameraStatusChanged(const CameraStatusInfo &cameraDeviceInfo) const override
86         {
87             const std::string cameraID = cameraDeviceInfo.cameraDevice->GetID();
88             const CameraStatus cameraStatus = cameraDeviceInfo.cameraStatus;
89 
90             switch (cameraStatus) {
91                 case CAMERA_STATUS_UNAVAILABLE: {
92                     MEDIA_DEBUG_LOG("AppCallback::OnCameraStatusChanged %{public}s: CAMERA_STATUS_UNAVAILABLE",
93                                     cameraID.c_str());
94                     g_camStatusMap[cameraID] = CAMERA_STATUS_UNAVAILABLE;
95                     break;
96                 }
97                 case CAMERA_STATUS_AVAILABLE: {
98                     MEDIA_DEBUG_LOG("AppCallback::OnCameraStatusChanged %{public}s: CAMERA_STATUS_AVAILABLE",
99                                     cameraID.c_str());
100                     g_camStatusMap[cameraID] = CAMERA_STATUS_AVAILABLE;
101                     break;
102                 }
103                 default: {
104                     MEDIA_DEBUG_LOG("AppCallback::OnCameraStatusChanged %{public}s: unknown", cameraID.c_str());
105                     EXPECT_TRUE(false);
106                 }
107             }
108             return;
109         }
110 
OnFlashlightStatusChanged(const std::string & cameraID,const FlashStatus flashStatus) const111         void OnFlashlightStatusChanged(const std::string &cameraID, const FlashStatus flashStatus) const override
112         {
113             switch (flashStatus) {
114                 case FLASH_STATUS_OFF: {
115                     MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_OFF",
116                                     cameraID.c_str());
117                     g_camFlashMap[cameraID] = false;
118                     break;
119                 }
120                 case FLASH_STATUS_ON: {
121                     MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_ON",
122                                     cameraID.c_str());
123                     g_camFlashMap[cameraID] = true;
124                     break;
125                 }
126                 case FLASH_STATUS_UNAVAILABLE: {
127                     MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_UNAVAILABLE",
128                                     cameraID.c_str());
129                     g_camFlashMap.erase(cameraID);
130                     break;
131                 }
132                 default: {
133                     MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: unknown", cameraID.c_str());
134                     EXPECT_TRUE(false);
135                 }
136             }
137             return;
138         }
139 
OnError(const int32_t errorType,const int32_t errorMsg) const140         void OnError(const int32_t errorType, const int32_t errorMsg) const override
141         {
142             MEDIA_DEBUG_LOG("AppCallback::OnError errorType: %{public}d, errorMsg: %{public}d", errorType, errorMsg);
143             g_camInputOnError = true;
144             if (errorType == CAMERA_DEVICE_PREEMPTED) {
145                 g_sessionclosed = true;
146             }
147             return;
148         }
149 
OnResult(const uint64_t timestamp,const std::shared_ptr<Camera::CameraMetadata> & result) const150         void OnResult(const uint64_t timestamp, const std::shared_ptr<Camera::CameraMetadata> &result) const override
151         {
152             MEDIA_INFO_LOG("CameraDeviceServiceCallback::OnResult() is called!");
153 
154             if (result != nullptr) {
155                 g_metaResult = result;
156                 common_metadata_header_t* data = result->get();
157                 std::vector<int32_t>  fpsRange;
158                 camera_metadata_item_t entry;
159                 int ret = OHOS::Camera::FindCameraMetadataItem(data, OHOS_ABILITY_FPS_RANGES, &entry);
160                 MEDIA_INFO_LOG("CameraDeviceServiceCallback::FindCameraMetadataItem() %{public}d", ret);
161                 if (ret != 0) {
162                     MEDIA_INFO_LOG("demo test: get OHOS_ABILITY_FPS_RANGES error");
163                 }
164                 uint32_t count = entry.count;
165                 MEDIA_INFO_LOG("demo test: fpsRange count  %{public}d",  count);
166                 for (uint32_t i = 0 ; i < count; i++) {
167                     fpsRange.push_back(*(entry.data.i32 + i));
168                 }
169                 for (auto it = fpsRange.begin(); it != fpsRange.end(); it++) {
170                     MEDIA_INFO_LOG("demo test: fpsRange %{public}d ", *it);
171                 }
172             }
173         }
174 
OnCaptureStarted(const int32_t captureId) const175         void OnCaptureStarted(const int32_t captureId) const override
176         {
177             MEDIA_DEBUG_LOG("AppCallback::OnCaptureStarted captureId: %{public}d", captureId);
178             g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] = 1;
179             return;
180         }
181 
OnCaptureEnded(const int32_t captureId,const int32_t frameCount) const182         void OnCaptureEnded(const int32_t captureId, const int32_t frameCount) const override
183         {
184             MEDIA_DEBUG_LOG("AppCallback::OnCaptureEnded captureId: %{public}d, frameCount: %{public}d",
185                             captureId, frameCount);
186             g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_END)] = 1;
187             return;
188         }
189 
OnFrameShutter(const int32_t captureId,const uint64_t timestamp) const190         void OnFrameShutter(const int32_t captureId, const uint64_t timestamp) const override
191         {
192             MEDIA_DEBUG_LOG("AppCallback::OnFrameShutter captureId: %{public}d, timestamp: %{public}"
193                             PRIu64, captureId, timestamp);
194             g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_FRAME_SHUTTER)] = 1;
195             return;
196         }
197 
OnCaptureError(const int32_t captureId,const int32_t errorCode) const198         void OnCaptureError(const int32_t captureId, const int32_t errorCode) const override
199         {
200             MEDIA_DEBUG_LOG("AppCallback::OnCaptureError captureId: %{public}d, errorCode: %{public}d",
201                             captureId, errorCode);
202             g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_ERR)] = 1;
203             return;
204         }
205 
OnFrameStarted() const206         void OnFrameStarted() const override
207         {
208             MEDIA_DEBUG_LOG("AppCallback::OnFrameStarted");
209             g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_START)] = 1;
210             return;
211         }
OnFrameEnded(const int32_t frameCount) const212         void OnFrameEnded(const int32_t frameCount) const override
213         {
214             MEDIA_DEBUG_LOG("AppCallback::OnFrameEnded frameCount: %{public}d", frameCount);
215             g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_END)] = 1;
216             return;
217         }
OnError(const int32_t errorCode) const218         void OnError(const int32_t errorCode) const override
219         {
220             MEDIA_DEBUG_LOG("AppCallback::OnError errorCode: %{public}d", errorCode);
221             g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_ERR)] = 1;
222             return;
223         }
224     };
225 
226     class AppVideoCallback : public VideoStateCallback {
OnFrameStarted() const227         void OnFrameStarted() const override
228         {
229             MEDIA_DEBUG_LOG("AppVideoCallback::OnFrameStarted");
230             g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_START)] = 1;
231             return;
232         }
OnFrameEnded(const int32_t frameCount) const233         void OnFrameEnded(const int32_t frameCount) const override
234         {
235             MEDIA_DEBUG_LOG("AppVideoCallback::OnFrameEnded frameCount: %{public}d", frameCount);
236             g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_END)] = 1;
237             return;
238         }
OnError(const int32_t errorCode) const239         void OnError(const int32_t errorCode) const override
240         {
241             MEDIA_DEBUG_LOG("AppVideoCallback::OnError errorCode: %{public}d", errorCode);
242             g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_ERR)] = 1;
243             return;
244         }
245     };
246 
247     class AppMetadataCallback : public MetadataObjectCallback, public MetadataStateCallback {
248     public:
OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const249         void OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const
250         {
251             MEDIA_DEBUG_LOG("AppMetadataCallback::OnMetadataObjectsAvailable received");
252         }
OnError(int32_t errorCode) const253         void OnError(int32_t errorCode) const
254         {
255             MEDIA_DEBUG_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
256         }
257     };
258 
259     class AppSessionCallback : public SessionCallback {
260     public:
OnError(int32_t errorCode)261         void OnError(int32_t errorCode)
262         {
263             MEDIA_DEBUG_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
264             return;
265         }
266     };
267 } // namespace
268 
CreatePhotoOutput(int32_t width,int32_t height)269 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput(int32_t width, int32_t height)
270 {
271     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
272     CameraFormat photoFormat = photoFormat_;
273     Size photoSize;
274     photoSize.width = width;
275     photoSize.height = height;
276     Profile photoProfile = Profile(photoFormat, photoSize);
277     sptr<CaptureOutput> photoOutput = nullptr;
278     sptr<IBufferProducer> surfaceProducer = surface->GetProducer();
279     manager_->CreatePhotoOutput(surfaceProducer);
280     photoOutput = manager_->CreatePhotoOutput(photoProfile, surfaceProducer);
281     return photoOutput;
282 }
283 
CreatePhotoOutput()284 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput()
285 {
286     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(photoWidth_, photoHeight_);
287     return photoOutput;
288 }
289 
CreatePreviewOutput(int32_t width,int32_t height)290 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput(int32_t width, int32_t height)
291 {
292     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
293     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
294     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)listener);
295     Size previewSize;
296     previewSize.width = previewProfiles[0].GetSize().width;
297     previewSize.height = previewProfiles[0].GetSize().height;
298     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewProfiles[0].GetCameraFormat()));
299     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
300 
301     sptr<IBufferProducer> bp = previewSurface->GetProducer();
302     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(bp);
303 
304     sptr<CaptureOutput> previewOutput = nullptr;
305     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
306     return previewOutput;
307 }
308 
CreatePreviewOutput()309 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput()
310 {
311     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(previewWidth_, previewHeight_);
312     return previewOutput;
313 }
314 
CreateVideoOutput(int32_t width,int32_t height)315 sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput(int32_t width, int32_t height)
316 {
317     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
318     sptr<SurfaceListener> videoSurfaceListener =
319         new(std::nothrow) SurfaceListener("Video", SurfaceType::VIDEO, g_videoFd, surface);
320     surface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)videoSurfaceListener);
321     if (videoSurfaceListener == nullptr) {
322         MEDIA_ERR_LOG("Failed to create new SurfaceListener");
323         return nullptr;
324     }
325     sptr<IBufferProducer> videoProducer = surface->GetProducer();
326     sptr<Surface> videoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
327     VideoProfile videoProfile = videoProfiles[0];
328     sptr<CaptureOutput> videoOutput = nullptr;
329     videoOutput = manager_->CreateVideoOutput(videoProfile, videoSurface);
330     return videoOutput;
331 }
332 
CreateVideoOutput()333 sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput()
334 {
335     sptr<CaptureOutput> videoOutput = CreateVideoOutput(videoWidth_, videoHeight_);
336     return videoOutput;
337 }
338 
CreatePhotoOutput(Profile profile)339 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput(Profile profile)
340 {
341     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
342     Size photoSize;
343     photoSize.width = profile.GetSize().width;
344     photoSize.height = profile.GetSize().height;
345     sptr<CaptureOutput> photoOutput = nullptr;
346     sptr<IBufferProducer> surfaceProducer = surface->GetProducer();
347     photoOutput = manager_->CreatePhotoOutput(profile, surfaceProducer);
348     return photoOutput;
349 }
350 
GetSupportedOutputCapability()351 void CameraFrameworkModuleTest::GetSupportedOutputCapability()
352 {
353     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
354     std::vector<sptr<CameraDevice>> cameraObjList = camManagerObj->GetSupportedCameras();
355     ASSERT_GE(cameraObjList.size(), CAMERA_NUMBER);
356     sptr<CameraOutputCapability> outputcapability =  camManagerObj->GetSupportedOutputCapability(cameraObjList[1]);
357     previewProfiles = outputcapability->GetPreviewProfiles();
358     ASSERT_TRUE(!previewProfiles.empty());
359     photoProfiles = outputcapability->GetPhotoProfiles();
360     ASSERT_TRUE(!photoProfiles.empty());
361     videoProfiles = outputcapability->GetVideoProfiles();
362     ASSERT_TRUE(!videoProfiles.empty());
363     return;
364 }
365 
ReleaseInput()366 void CameraFrameworkModuleTest::ReleaseInput()
367 {
368     if (input_) {
369         sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
370         camInput->Close();
371         input_->Release();
372     }
373     return;
374 }
375 
SetCameraParameters(sptr<CaptureSession> & session,bool video)376 void CameraFrameworkModuleTest::SetCameraParameters(sptr<CaptureSession> &session, bool video)
377 {
378     session->LockForControl();
379 
380     std::vector<float> zoomRatioRange = session->GetZoomRatioRange();
381     if (!zoomRatioRange.empty()) {
382         session->SetZoomRatio(zoomRatioRange[0]);
383     }
384 
385     // GetExposureBiasRange
386     std::vector<float> exposureBiasRange = session->GetExposureBiasRange();
387     if (!exposureBiasRange.empty()) {
388         session->SetExposureBias(exposureBiasRange[0]);
389     }
390 
391     // Get/Set Exposurepoint
392     Point exposurePoint = {1, 2};
393     session->SetMeteringPoint(exposurePoint);
394 
395     // GetFocalLength
396     float focalLength = session->GetFocalLength();
397     EXPECT_NE(focalLength, 0);
398 
399     // Get/Set focuspoint
400     Point focusPoint = {1, 2};
401     session->SetFocusPoint(focusPoint);
402 
403     FlashMode flash = FLASH_MODE_OPEN;
404     if (video) {
405         flash = FLASH_MODE_ALWAYS_OPEN;
406     }
407     session->SetFlashMode(flash);
408 
409     FocusMode focus = FOCUS_MODE_AUTO;
410     session->SetFocusMode(focus);
411 
412     ExposureMode exposure = EXPOSURE_MODE_AUTO;
413     session->SetExposureMode(exposure);
414 
415     session->UnlockForControl();
416 
417     Point exposurePointGet = session->GetMeteringPoint();
418     EXPECT_EQ(exposurePointGet.x, exposurePoint.x > 1 ? 1 : exposurePoint.x);
419     EXPECT_EQ(exposurePointGet.y, exposurePoint.y > 1 ? 1 : exposurePoint.y);
420 
421     Point focusPointGet = session->GetFocusPoint();
422     EXPECT_EQ(focusPointGet.x, focusPoint.x > 1 ? 1 : focusPoint.x);
423     EXPECT_EQ(focusPointGet.y, focusPoint.y > 1 ? 1 : focusPoint.y);
424 
425     if (!zoomRatioRange.empty()) {
426         EXPECT_EQ(session->GetZoomRatio(), zoomRatioRange[0]);
427     }
428 
429     // exposureBiasRange
430     if (!exposureBiasRange.empty()) {
431         EXPECT_EQ(session->GetExposureValue(), exposureBiasRange[0]);
432     }
433 
434     EXPECT_EQ(session->GetFlashMode(), flash);
435     EXPECT_EQ(session->GetFocusMode(), focus);
436     EXPECT_EQ(session->GetExposureMode(), exposure);
437 }
438 
TestCallbacksSession(sptr<CaptureOutput> photoOutput,sptr<CaptureOutput> videoOutput)439 void CameraFrameworkModuleTest::TestCallbacksSession(sptr<CaptureOutput> photoOutput,
440     sptr<CaptureOutput> videoOutput)
441 {
442     int32_t intResult;
443 
444     if (videoOutput != nullptr) {
445         intResult = session_->Start();
446         EXPECT_EQ(intResult, 0);
447 
448         intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
449         EXPECT_EQ(intResult, 0);
450         sleep(WAIT_TIME_AFTER_START);
451     }
452 
453     if (photoOutput != nullptr) {
454         intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
455         EXPECT_EQ(intResult, 0);
456     }
457 
458     if (videoOutput != nullptr) {
459         intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
460         EXPECT_EQ(intResult, 0);
461     }
462 
463     sleep(WAIT_TIME_BEFORE_STOP);
464     session_->Stop();
465 }
466 
TestCallbacks(sptr<CameraDevice> & cameraInfo,bool video)467 void CameraFrameworkModuleTest::TestCallbacks(sptr<CameraDevice> &cameraInfo, bool video)
468 {
469     int32_t intResult = session_->BeginConfig();
470     EXPECT_EQ(intResult, 0);
471 
472     // Register error callback
473     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
474     sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
475     camInput->SetErrorCallback(callback);
476 
477     EXPECT_EQ(g_camInputOnError, false);
478 
479     intResult = session_->AddInput(input_);
480     EXPECT_EQ(intResult, 0);
481 
482     sptr<CaptureOutput> photoOutput = nullptr;
483     sptr<CaptureOutput> videoOutput = nullptr;
484     if (!video) {
485         photoOutput = CreatePhotoOutput();
486         ASSERT_NE(photoOutput, nullptr);
487 
488         // Register photo callback
489         ((sptr<PhotoOutput> &)photoOutput)->SetCallback(std::make_shared<AppCallback>());
490         intResult = session_->AddOutput(photoOutput);
491     } else {
492         videoOutput = CreateVideoOutput();
493         ASSERT_NE(videoOutput, nullptr);
494 
495         // Register video callback
496         ((sptr<VideoOutput> &)videoOutput)->SetCallback(std::make_shared<AppVideoCallback>());
497         intResult = session_->AddOutput(videoOutput);
498     }
499 
500     EXPECT_EQ(intResult, 0);
501 
502     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
503     ASSERT_NE(previewOutput, nullptr);
504 
505     // Register preview callback
506     ((sptr<PreviewOutput> &)previewOutput)->SetCallback(std::make_shared<AppCallback>());
507     intResult = session_->AddOutput(previewOutput);
508     EXPECT_EQ(intResult, 0);
509 
510     intResult = session_->CommitConfig();
511     EXPECT_EQ(intResult, 0);
512 
513     SetCameraParameters(session_, video);
514 
515     /* In case of wagner device, once commit config is done with flash on
516     it is not giving the flash status callback, removing it */
517     EXPECT_TRUE(g_photoEvents.none());
518     EXPECT_TRUE(g_previewEvents.none());
519     EXPECT_TRUE(g_videoEvents.none());
520 
521     TestCallbacksSession(photoOutput, videoOutput);
522 
523     if (photoOutput != nullptr) {
524         EXPECT_TRUE(g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] == 1);
525         /* In case of wagner device, frame shutter callback not working,
526         hence removed. Once supported by hdi, the same needs to be
527         enabled */
528         ((sptr<PhotoOutput> &)photoOutput)->Release();
529     }
530 
531     if (videoOutput != nullptr) {
532         EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_START)], 1);
533 
534         TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
535 
536         EXPECT_EQ(g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_START)], 1);
537         EXPECT_EQ(g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_END)], 1);
538 
539         ((sptr<VideoOutput> &)videoOutput)->Release();
540     }
541 
542     ((sptr<PreviewOutput> &)previewOutput)->Release();
543 }
544 
IsSupportNow()545 bool CameraFrameworkModuleTest::IsSupportNow()
546 {
547     const char *deviveTypeString = GetDeviceType();
548     std::string deviveType = std::string(deviveTypeString);
549     if (deviveType.compare("default") == 0 ||
550         (cameras_[0] != nullptr && cameras_[0]->GetConnectionType() == CAMERA_CONNECTION_USB_PLUGIN)) {
551         return false;
552     }
553     return true;
554 }
555 
SetUpTestCase(void)556 void CameraFrameworkModuleTest::SetUpTestCase(void) {}
TearDownTestCase(void)557 void CameraFrameworkModuleTest::TearDownTestCase(void) {}
558 
SetUpInit()559 void CameraFrameworkModuleTest::SetUpInit()
560 {
561     MEDIA_DEBUG_LOG("Beginning of camera test case!");
562     g_photoEvents.reset();
563     g_previewEvents.reset();
564     g_videoEvents.reset();
565     g_camStatusMap.clear();
566     g_camFlashMap.clear();
567     g_camInputOnError = false;
568     g_videoFd = -1;
569     g_previewFd = -1;
570     previewFormat_ = CAMERA_FORMAT_YUV_420_SP;
571     videoFormat_ = CAMERA_FORMAT_YUV_420_SP;
572     photoFormat_ = CAMERA_FORMAT_JPEG;
573     previewWidth_ = PREVIEW_DEFAULT_WIDTH;
574     previewHeight_ = PREVIEW_DEFAULT_HEIGHT;
575     photoWidth_ = PHOTO_DEFAULT_WIDTH;
576     photoHeight_ = PHOTO_DEFAULT_HEIGHT;
577     videoWidth_ = VIDEO_DEFAULT_WIDTH;
578     videoHeight_ = VIDEO_DEFAULT_HEIGHT;
579 }
580 
SetUp()581 void CameraFrameworkModuleTest::SetUp()
582 {
583     SetUpInit();
584     // set native token
585     uint64_t tokenId;
586     const char *perms[2];
587     perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC";
588     perms[1] = "ohos.permission.CAMERA";
589     NativeTokenInfoParams infoInstance = {
590         .dcapsNum = 0,
591         .permsNum = 2,
592         .aclsNum = 0,
593         .dcaps = NULL,
594         .perms = perms,
595         .acls = NULL,
596         .processName = "native_camera_tdd",
597         .aplStr = "system_basic",
598     };
599     tokenId = GetAccessTokenId(&infoInstance);
600     SetSelfTokenID(tokenId);
601     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
602 
603     manager_ = CameraManager::GetInstance();
604     ASSERT_NE(manager_, nullptr);
605     manager_->SetCallback(std::make_shared<AppCallback>());
606 
607     cameras_ = manager_->GetSupportedCameras();
608     ASSERT_TRUE(cameras_.size() != 0);
609 
610     input_ = manager_->CreateCameraInput(cameras_[0]);
611     ASSERT_NE(input_, nullptr);
612 
613     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
614     std::vector<sptr<CameraDevice>> cameraObjList = camManagerObj->GetSupportedCameras();
615     sptr<CameraOutputCapability> outputcapability =  camManagerObj->GetSupportedOutputCapability(cameraObjList[0]);
616     previewProfiles = outputcapability->GetPreviewProfiles();
617     for (auto i : previewProfiles) {
618         previewFormats_.push_back(i.GetCameraFormat());
619         previewSizes_.push_back(i.GetSize());
620     }
621     ASSERT_TRUE(!previewFormats_.empty());
622     ASSERT_TRUE(!previewSizes_.empty());
623     if (std::find(previewFormats_.begin(), previewFormats_.end(), CAMERA_FORMAT_YUV_420_SP)
624         != previewFormats_.end()) {
625         previewFormat_ = CAMERA_FORMAT_YUV_420_SP;
626     } else {
627         previewFormat_ = previewFormats_[0];
628     }
629     photoProfiles =  outputcapability->GetPhotoProfiles();
630         for (auto i : photoProfiles) {
631             photoFormats_.push_back(i.GetCameraFormat());
632             photoSizes_.push_back(i.GetSize());
633         }
634     ASSERT_TRUE(!photoFormats_.empty());
635     ASSERT_TRUE(!photoSizes_.empty());
636     photoFormat_ = photoFormats_[0];
637     videoProfiles = outputcapability->GetVideoProfiles();
638 
639     for (auto i : videoProfiles) {
640         videoFormats_.push_back(i.GetCameraFormat());
641         videoSizes_.push_back(i.GetSize());
642         videoFrameRates_ = i.GetFrameRates();
643     }
644     ASSERT_TRUE(!videoFormats_.empty());
645     ASSERT_TRUE(!videoSizes_.empty());
646     ASSERT_TRUE(!videoFrameRates_.empty());
647     if (std::find(videoFormats_.begin(), videoFormats_.end(), CAMERA_FORMAT_YUV_420_SP)
648         != videoFormats_.end()) {
649         videoFormat_ = CAMERA_FORMAT_YUV_420_SP;
650     } else {
651         videoFormat_ = videoFormats_[0];
652     }
653     Size size = previewSizes_.back();
654     previewWidth_ = size.width;
655     previewHeight_ = size.height;
656     size = photoSizes_.back();
657     photoWidth_ = size.width;
658     photoHeight_ = size.height;
659     size = videoSizes_.back();
660     videoWidth_ = size.width;
661     videoHeight_ = size.height;
662 
663     sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
664     camInput->Open();
665 
666     session_ = manager_->CreateCaptureSession();
667     ASSERT_NE(session_, nullptr);
668 }
669 
TearDown()670 void CameraFrameworkModuleTest::TearDown()
671 {
672     if (session_) {
673         session_->Release();
674     }
675     if (input_) {
676         sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
677         camInput->Close();
678         input_->Release();
679     }
680     MEDIA_DEBUG_LOG("End of camera test case");
681 }
682 
683 /*
684  * Feature: Framework
685  * Function: Test get distributed camera hostname
686  * SubFunction: NA
687  * FunctionPoints: NA
688  * EnvConditions: NA
689  * CaseDescription: Test get distributed camera hostname
690  */
691 HWTEST_F(CameraFrameworkModuleTest, Camera_fwInfoManager_moduletest_001, TestSize.Level0)
692 {
693     std::string hostName;
694     for (int i = 0; i < cameras_.size(); i++) {
695         hostName = cameras_[i]->GetHostName();
696         std::string cameraId = cameras_[i]->GetID();
697         std::string networkId = cameras_[i]->GetNetWorkId();
698         if (networkId != "") {
699             ASSERT_NE(hostName, "");
700         } else {
701             ASSERT_EQ(hostName, "");
702         }
703     }
704 }
705 /*
706  * Feature: Framework
707  * Function: Test get DeviceType
708  * SubFunction: NA
709  * FunctionPoints: NA
710  * EnvConditions: NA
711  * CaseDescription: Test get DeviceType
712  */
713 HWTEST_F(CameraFrameworkModuleTest, Camera_fwInfoManager_moduletest_002, TestSize.Level0)
714 {
715     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
__anon8ed7da120202() 716     auto judgeDeviceType = [&cameras] () -> bool {
717         bool isOk = false;
718         for (int i = 0; i < cameras.size(); i++) {
719             uint16_t deviceType = cameras[i]->GetDeviceType();
720             switch (deviceType) {
721                 case HostDeviceType::UNKNOWN:
722                 case HostDeviceType::PHONE:
723                 case HostDeviceType::TABLET:
724                     isOk = true;
725                     break;
726                 default:
727                     isOk = false;
728                     break;
729             }
730             if (isOk == false) {
731                 break;
732             }
733         }
734         return isOk;
735     };
736     ASSERT_NE(judgeDeviceType(), false);
737 }
738 /*
739  * Feature: Framework
740  * Function: Test Result Callback
741  * SubFunction: NA
742  * FunctionPoints: NA
743  * EnvConditions: NA
744  * CaseDescription: Test Result Callback
745  */
746 
747 HWTEST_F(CameraFrameworkModuleTest, Camera_ResultCallback_moduletest, TestSize.Level0)
748 {
749     int32_t intResult = session_->BeginConfig();
750     EXPECT_EQ(intResult, 0);
751 
752     intResult = session_->AddInput(input_);
753     EXPECT_EQ(intResult, 0);
754 
755     // Register error callback
756     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
757     sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
758     camInput->SetResultCallback(callback);
759     EXPECT_EQ(g_camInputOnError, false);
760 
761     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
762     ASSERT_NE(previewOutput, nullptr);
763 
764     intResult = session_->AddOutput(previewOutput);
765     EXPECT_EQ(intResult, 0);
766 
767     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
768     ASSERT_NE(videoOutput, nullptr);
769 
770     intResult = session_->AddOutput(videoOutput);
771     EXPECT_EQ(intResult, 0);
772 
773     intResult = session_->CommitConfig();
774     EXPECT_EQ(intResult, 0);
775 
776     sleep(WAIT_TIME_AFTER_START);
777     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
778     EXPECT_EQ(intResult, 0);
779 
780     sleep(WAIT_TIME_AFTER_START);
781 
782     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
783     EXPECT_EQ(intResult, 0);
784 
785     sleep(WAIT_TIME_AFTER_START);
786     EXPECT_NE(g_metaResult, nullptr);
787 
788     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
789     EXPECT_EQ(intResult, 0);
790 
791     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
792 
793     sleep(WAIT_TIME_BEFORE_STOP);
794     ((sptr<PreviewOutput> &)previewOutput)->Stop();
795     session_->Stop();
796 }
797 
798 /*
799  * Feature: Framework
800  * Function: Test Capture
801  * SubFunction: NA
802  * FunctionPoints: NA
803  * EnvConditions: NA
804  * CaseDescription: Test Capture
805  */
806 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_001, TestSize.Level0)
807 {
808     int32_t intResult = session_->BeginConfig();
809     EXPECT_EQ(intResult, 0);
810 
811     intResult = session_->AddInput(input_);
812     EXPECT_EQ(intResult, 0);
813 
814     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
815     ASSERT_NE(photoOutput, nullptr);
816 
817     intResult = session_->AddOutput(photoOutput);
818     EXPECT_EQ(intResult, 0);
819 
820     intResult = session_->CommitConfig();
821     EXPECT_EQ(intResult, 0);
822 
823     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
824     EXPECT_EQ(intResult, 0);
825     sleep(WAIT_TIME_AFTER_CAPTURE);
826 
827     ((sptr<PhotoOutput> &)photoOutput)->Release();
828 }
829 /*
830  * Feature: Framework
831  * Function: Test Capture + Preview
832  * SubFunction: NA
833  * FunctionPoints: NA
834  * EnvConditions: NA
835  * CaseDescription: Test Capture + Preview
836  */
837 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_002, TestSize.Level0)
838 {
839     int32_t intResult = session_->BeginConfig();
840     EXPECT_EQ(intResult, 0);
841 
842     intResult = session_->AddInput(input_);
843     EXPECT_EQ(intResult, 0);
844 
845     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
846     ASSERT_NE(photoOutput, nullptr);
847 
848     intResult = session_->AddOutput(photoOutput);
849     EXPECT_EQ(intResult, 0);
850 
851     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
852     ASSERT_NE(previewOutput, nullptr);
853 
854     intResult = session_->AddOutput(previewOutput);
855     EXPECT_EQ(intResult, 0);
856 
857     intResult = session_->CommitConfig();
858     EXPECT_EQ(intResult, 0);
859 
860     sleep(WAIT_TIME_AFTER_START);
861     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
862     EXPECT_EQ(intResult, 0);
863 
864     sleep(WAIT_TIME_AFTER_START);
865     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
866     EXPECT_EQ(intResult, 0);
867     sleep(WAIT_TIME_AFTER_CAPTURE);
868 
869     ((sptr<PreviewOutput> &)previewOutput)->Stop();
870     session_->Stop();
871 }
872 
873 /*
874  * Feature: Framework
875  * Function: Test Preview + Video
876  * SubFunction: NA
877  * FunctionPoints: NA
878  * EnvConditions: NA
879  * CaseDescription: Test Preview + Video
880  */
881 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_003, TestSize.Level0)
882 {
883     int32_t intResult = session_->BeginConfig();
884     EXPECT_EQ(intResult, 0);
885 
886     intResult = session_->AddInput(input_);
887     EXPECT_EQ(intResult, 0);
888 
889     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
890     ASSERT_NE(previewOutput, nullptr);
891 
892     intResult = session_->AddOutput(previewOutput);
893     EXPECT_EQ(intResult, 0);
894 
895     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
896     ASSERT_NE(videoOutput, nullptr);
897 
898     intResult = session_->AddOutput(videoOutput);
899     EXPECT_EQ(intResult, 0);
900 
901     intResult = session_->CommitConfig();
902     EXPECT_EQ(intResult, 0);
903 
904     sleep(WAIT_TIME_AFTER_START);
905     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
906     EXPECT_EQ(intResult, 0);
907 
908     sleep(WAIT_TIME_AFTER_START);
909 
910     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
911     EXPECT_EQ(intResult, 0);
912 
913     sleep(WAIT_TIME_AFTER_START);
914 
915     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
916     EXPECT_EQ(intResult, 0);
917 
918     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
919 
920     sleep(WAIT_TIME_BEFORE_STOP);
921     ((sptr<PreviewOutput> &)previewOutput)->Stop();
922     session_->Stop();
923 }
924 
925 /*
926  * Feature: Framework
927  * Function: Test camera status, flash, camera input, photo output and preview output callbacks
928  * SubFunction: NA
929  * FunctionPoints: NA
930  * EnvConditions: NA
931  * CaseDescription: Test callbacks
932  */
933 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_004, TestSize.Level0)
934 {
935     TestCallbacks(cameras_[0], false);
936 }
937 
938 /*
939  * Feature: Framework
940  * Function: Test camera status, flash, camera input, preview output and video output callbacks
941  * SubFunction: NA
942  * FunctionPoints: NA
943  * EnvConditions: NA
944  * CaseDescription: Test callbacks
945  */
946 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_005, TestSize.Level0)
947 {
948     TestCallbacks(cameras_[0], true);
949 }
950 
951 /*
952  * Feature: Framework
953  * Function: Test Preview
954  * SubFunction: NA
955  * FunctionPoints: NA
956  * EnvConditions: NA
957  * CaseDescription: Test Preview
958  */
959 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_006, TestSize.Level0)
960 {
961     int32_t intResult = session_->BeginConfig();
962     EXPECT_EQ(intResult, 0);
963 
964     intResult = session_->AddInput(input_);
965     EXPECT_EQ(intResult, 0);
966 
967     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
968     ASSERT_NE(previewOutput, nullptr);
969 
970     intResult = session_->AddOutput(previewOutput);
971     EXPECT_EQ(intResult, 0);
972 
973     intResult = session_->CommitConfig();
974     EXPECT_EQ(intResult, 0);
975 
976     sleep(WAIT_TIME_AFTER_START);
977     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
978     EXPECT_EQ(intResult, 0);
979 
980     sleep(WAIT_TIME_AFTER_START);
981 
982     ((sptr<PreviewOutput> &)previewOutput)->Stop();
983     session_->Stop();
984 }
985 
986 /*
987  * Feature: Framework
988  * Function: Test Video
989  * SubFunction: NA
990  * FunctionPoints: NA
991  * EnvConditions: NA
992  * CaseDescription: Test Video
993  */
994 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_007, TestSize.Level0)
995 {
996     int32_t intResult = session_->BeginConfig();
997     EXPECT_EQ(intResult, 0);
998 
999     intResult = session_->AddInput(input_);
1000     EXPECT_EQ(intResult, 0);
1001 
1002     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1003     ASSERT_NE(previewOutput, nullptr);
1004 
1005     intResult = session_->AddOutput(previewOutput);
1006     EXPECT_EQ(intResult, 0);
1007 
1008     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1009     ASSERT_NE(videoOutput, nullptr);
1010 
1011     intResult = session_->AddOutput(videoOutput);
1012     EXPECT_EQ(intResult, 0);
1013 
1014     intResult = session_->CommitConfig();
1015     EXPECT_EQ(intResult, 0);
1016     // Video mode without preview is not supported
1017 }
1018 
1019 /*
1020  * Feature: Framework
1021  * Function: Test Custom Preview with invalid resolutions
1022  * SubFunction: NA
1023  * FunctionPoints: NA
1024  * EnvConditions: NA
1025  * CaseDescription: Test Custom Preview with invalid resolution(0 * 0)
1026  */
1027 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_011, TestSize.Level0)
1028 {
1029     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1030     ASSERT_NE(previewOutput, nullptr);
1031 }
1032 
1033 /*
1034  * Feature: Framework
1035  * Function: Test capture session with commit config multiple times
1036  * SubFunction: NA
1037  * FunctionPoints: NA
1038  * EnvConditions: NA
1039  * CaseDescription: Test capture session with commit config multiple times
1040  */
1041 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_017, TestSize.Level0)
1042 {
1043     int32_t intResult = session_->BeginConfig();
1044     EXPECT_EQ(intResult, 0);
1045 
1046     intResult = session_->AddInput(input_);
1047     EXPECT_EQ(intResult, 0);
1048 
1049     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1050     ASSERT_NE(previewOutput, nullptr);
1051 
1052     intResult = session_->AddOutput(previewOutput);
1053     EXPECT_EQ(intResult, 0);
1054 
1055     intResult = session_->CommitConfig();
1056     EXPECT_EQ(intResult, 0);
1057 
1058     sleep(WAIT_TIME_AFTER_START);
1059 
1060     intResult = session_->CommitConfig();
1061     EXPECT_NE(intResult, 0);
1062 }
1063 
1064 /*
1065  * Feature: Framework
1066  * Function: Test capture session add input with invalid value
1067  * SubFunction: NA
1068  * FunctionPoints: NA
1069  * EnvConditions: NA
1070  * CaseDescription: Test capture session add input with invalid value
1071  */
1072 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_018, TestSize.Level0)
1073 {
1074     int32_t intResult = session_->BeginConfig();
1075     EXPECT_EQ(intResult, 0);
1076 
1077     sptr<CaptureInput> input1 = nullptr;
1078     intResult = session_->AddInput(input1);
1079     EXPECT_NE(intResult, 0);
1080 
1081     session_->Stop();
1082 }
1083 
1084 /*
1085  * Feature: Framework
1086  * Function: Test capture session add output with invalid value
1087  * SubFunction: NA
1088  * FunctionPoints: NA
1089  * EnvConditions: NA
1090  * CaseDescription: Test capture session add output with invalid value
1091  */
1092 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_019, TestSize.Level0)
1093 {
1094     int32_t intResult = session_->BeginConfig();
1095     EXPECT_EQ(intResult, 0);
1096 
1097     sptr<CaptureOutput> previewOutput = nullptr;
1098     intResult = session_->AddOutput(previewOutput);
1099     EXPECT_NE(intResult, 0);
1100 
1101     session_->Stop();
1102 }
1103 
1104 /*
1105  * Feature: Framework
1106  * Function: Test capture session commit config without adding input
1107  * SubFunction: NA
1108  * FunctionPoints: NA
1109  * EnvConditions: NA
1110  * CaseDescription: Test capture session commit config without adding input
1111  */
1112 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_020, TestSize.Level0)
1113 {
1114     int32_t intResult = session_->BeginConfig();
1115     EXPECT_EQ(intResult, 0);
1116 
1117     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1118     ASSERT_NE(previewOutput, nullptr);
1119 
1120     intResult = session_->AddOutput(previewOutput);
1121     EXPECT_EQ(intResult, 0);
1122 
1123     intResult = session_->CommitConfig();
1124     EXPECT_NE(intResult, 0);
1125 
1126     session_->Stop();
1127 }
1128 
1129 /*
1130  * Feature: Framework
1131  * Function: Test capture session commit config without adding output
1132  * SubFunction: NA
1133  * FunctionPoints: NA
1134  * EnvConditions: NA
1135  * CaseDescription: Test capture session commit config without adding output
1136  */
1137 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_021, TestSize.Level0)
1138 {
1139     int32_t intResult = session_->BeginConfig();
1140     EXPECT_EQ(intResult, 0);
1141 
1142     intResult = session_->AddInput(input_);
1143     EXPECT_EQ(intResult, 0);
1144 
1145     intResult = session_->CommitConfig();
1146     EXPECT_NE(intResult, 0);
1147 
1148     session_->Stop();
1149 }
1150 
1151 /*
1152  * Feature: Framework
1153  * Function: Test capture session start and stop without adding preview output
1154  * SubFunction: NA
1155  * FunctionPoints: NA
1156  * EnvConditions: NA
1157  * CaseDescription: Test capture session start and stop without adding preview output
1158  */
1159 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_022, TestSize.Level0)
1160 {
1161     int32_t intResult = session_->BeginConfig();
1162     EXPECT_EQ(intResult, 0);
1163 
1164     intResult = session_->AddInput(input_);
1165     EXPECT_EQ(intResult, 0);
1166 
1167     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1168     ASSERT_NE(photoOutput, nullptr);
1169 
1170     intResult = session_->AddOutput(photoOutput);
1171     EXPECT_EQ(intResult, 0);
1172 
1173     intResult = session_->CommitConfig();
1174     EXPECT_EQ(intResult, 0);
1175 
1176     intResult = session_->Start();
1177     EXPECT_EQ(intResult, 0);
1178 
1179     intResult = session_->Stop();
1180     EXPECT_EQ(intResult, 0);
1181 }
1182 
1183 /*
1184  * Feature: Framework
1185  * Function: Test capture session without begin config
1186  * SubFunction: NA
1187  * FunctionPoints: NA
1188  * EnvConditions: NA
1189  * CaseDescription: Test capture session without begin config
1190  */
1191 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_023, TestSize.Level0)
1192 {
1193     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1194     ASSERT_NE(photoOutput, nullptr);
1195 
1196     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1197     ASSERT_NE(previewOutput, nullptr);
1198 
1199     int32_t intResult = session_->AddInput(input_);
1200     EXPECT_NE(intResult, 0);
1201 
1202     intResult = session_->AddOutput(photoOutput);
1203     EXPECT_NE(intResult, 0);
1204 
1205     intResult = session_->AddOutput(previewOutput);
1206     EXPECT_NE(intResult, 0);
1207 
1208     intResult = session_->CommitConfig();
1209     EXPECT_NE(intResult, 0);
1210 
1211     intResult = session_->Start();
1212     EXPECT_NE(intResult, 0);
1213 
1214     sleep(WAIT_TIME_AFTER_START);
1215     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
1216     EXPECT_NE(intResult, 0);
1217 
1218     sleep(WAIT_TIME_AFTER_START);
1219     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
1220     EXPECT_NE(intResult, 0);
1221     sleep(WAIT_TIME_AFTER_CAPTURE);
1222 
1223     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1224     session_->Stop();
1225 }
1226 
1227 /*
1228  * Feature: Framework
1229  * Function: Test capture session with multiple photo outputs
1230  * SubFunction: NA
1231  * FunctionPoints: NA
1232  * EnvConditions: NA
1233  * CaseDescription: Test capture session with multiple photo outputs
1234  */
1235 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_024, TestSize.Level0)
1236 {
1237     if (!IsSupportNow()) {
1238         return;
1239     }
1240     int32_t intResult = session_->BeginConfig();
1241     EXPECT_EQ(intResult, 0);
1242 
1243     intResult = session_->AddInput(input_);
1244     EXPECT_EQ(intResult, 0);
1245 
1246     sptr<CaptureOutput> photoOutput1 = CreatePhotoOutput();
1247     ASSERT_NE(photoOutput1, nullptr);
1248 
1249     intResult = session_->AddOutput(photoOutput1);
1250     EXPECT_EQ(intResult, 0);
1251 
1252     sptr<CaptureOutput> photoOutput2 = CreatePhotoOutput();
1253     ASSERT_NE(photoOutput2, nullptr);
1254 
1255     intResult = session_->AddOutput(photoOutput2);
1256     EXPECT_EQ(intResult, 0);
1257 
1258     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1259     ASSERT_NE(previewOutput, nullptr);
1260 
1261     intResult = session_->AddOutput(previewOutput);
1262     EXPECT_EQ(intResult, 0);
1263 
1264     intResult = session_->CommitConfig();
1265     EXPECT_EQ(intResult, 0);
1266 
1267     intResult = session_->Start();
1268     EXPECT_EQ(intResult, 0);
1269 
1270     sleep(WAIT_TIME_AFTER_START);
1271     intResult = ((sptr<PhotoOutput> &)photoOutput1)->Capture();
1272     EXPECT_EQ(intResult, 0);
1273     sleep(WAIT_TIME_AFTER_CAPTURE);
1274 
1275     intResult = ((sptr<PhotoOutput> &)photoOutput2)->Capture();
1276     EXPECT_EQ(intResult, 0);
1277     sleep(WAIT_TIME_AFTER_CAPTURE);
1278 
1279     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1280     session_->Stop();
1281 
1282     ((sptr<PhotoOutput> &)photoOutput1)->Release();
1283     ((sptr<PhotoOutput> &)photoOutput2)->Release();
1284 }
1285 
1286 /*
1287  * Feature: Framework
1288  * Function: Test capture session with multiple preview outputs
1289  * SubFunction: NA
1290  * FunctionPoints: NA
1291  * EnvConditions: NA
1292  * CaseDescription: Test capture session with multiple preview ouputs
1293  */
1294 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_025, TestSize.Level0)
1295 {
1296     int32_t intResult = session_->BeginConfig();
1297     EXPECT_EQ(intResult, 0);
1298 
1299     intResult = session_->AddInput(input_);
1300     EXPECT_EQ(intResult, 0);
1301 
1302     sptr<CaptureOutput> previewOutput1 = CreatePreviewOutput();
1303     ASSERT_NE(previewOutput1, nullptr);
1304 
1305     intResult = session_->AddOutput(previewOutput1);
1306     EXPECT_EQ(intResult, 0);
1307 
1308     sptr<CaptureOutput> previewOutput2 = CreatePreviewOutput();
1309     ASSERT_NE(previewOutput2, nullptr);
1310 
1311     intResult = session_->AddOutput(previewOutput2);
1312     EXPECT_EQ(intResult, 0);
1313 
1314     intResult = session_->CommitConfig();
1315     EXPECT_EQ(intResult, 0);
1316 
1317     sleep(WAIT_TIME_AFTER_START);
1318     intResult = ((sptr<PreviewOutput> &)previewOutput1)->Start();
1319     EXPECT_EQ(intResult, 0);
1320 
1321     sleep(WAIT_TIME_AFTER_START);
1322     intResult = ((sptr<PreviewOutput> &)previewOutput2)->Start();
1323     EXPECT_EQ(intResult, 0);
1324 
1325     sleep(WAIT_TIME_AFTER_START);
1326 
1327     ((sptr<PhotoOutput> &)previewOutput1)->Release();
1328     ((sptr<PhotoOutput> &)previewOutput2)->Release();
1329 }
1330 
1331 /*
1332  * Feature: Framework
1333  * Function: Test capture session with multiple video outputs
1334  * SubFunction: NA
1335  * FunctionPoints: NA
1336  * EnvConditions: NA
1337  * CaseDescription: Test capture session with multiple video ouputs
1338  */
1339 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_026, TestSize.Level0)
1340 {
1341     if (!IsSupportNow()) {
1342         return;
1343     }
1344     int32_t intResult = session_->BeginConfig();
1345     EXPECT_EQ(intResult, 0);
1346 
1347     intResult = session_->AddInput(input_);
1348     EXPECT_EQ(intResult, 0);
1349 
1350     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1351     ASSERT_NE(previewOutput, nullptr);
1352 
1353     intResult = session_->AddOutput(previewOutput);
1354     EXPECT_EQ(intResult, 0);
1355 
1356     sptr<CaptureOutput> videoOutput1 = CreateVideoOutput();
1357     ASSERT_NE(videoOutput1, nullptr);
1358 
1359     intResult = session_->AddOutput(videoOutput1);
1360     EXPECT_EQ(intResult, 0);
1361 
1362     sptr<CaptureOutput> videoOutput2 = CreateVideoOutput();
1363     ASSERT_NE(videoOutput2, nullptr);
1364 
1365     intResult = session_->AddOutput(videoOutput2);
1366     EXPECT_EQ(intResult, 0);
1367 
1368     intResult = session_->CommitConfig();
1369     EXPECT_EQ(intResult, 0);
1370 
1371     intResult = session_->Start();
1372     EXPECT_EQ(intResult, 0);
1373     sleep(WAIT_TIME_AFTER_START);
1374     intResult = ((sptr<VideoOutput> &)videoOutput1)->Start();
1375     EXPECT_EQ(intResult, 0);
1376 
1377     intResult = ((sptr<VideoOutput> &)videoOutput2)->Start();
1378     EXPECT_EQ(intResult, 0);
1379 
1380     sleep(WAIT_TIME_AFTER_START);
1381 
1382     intResult = ((sptr<VideoOutput> &)videoOutput1)->Stop();
1383     EXPECT_EQ(intResult, 0);
1384 
1385     intResult = ((sptr<VideoOutput> &)videoOutput2)->Stop();
1386     EXPECT_EQ(intResult, 0);
1387 
1388     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1389 
1390     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1391     session_->Stop();
1392 
1393     ((sptr<PhotoOutput> &)videoOutput1)->Release();
1394     ((sptr<PhotoOutput> &)videoOutput2)->Release();
1395 }
1396 
1397 /*
1398  * Feature: Framework
1399  * Function: Test capture session start and stop preview multiple times
1400  * SubFunction: NA
1401  * FunctionPoints: NA
1402  * EnvConditions: NA
1403  * CaseDescription: Test capture session start and stop preview multiple times
1404  */
1405 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_027, TestSize.Level0)
1406 {
1407     int32_t intResult = session_->BeginConfig();
1408     EXPECT_EQ(intResult, 0);
1409 
1410     intResult = session_->AddInput(input_);
1411     EXPECT_EQ(intResult, 0);
1412 
1413     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1414     ASSERT_NE(previewOutput, nullptr);
1415 
1416     intResult = session_->AddOutput(previewOutput);
1417     EXPECT_EQ(intResult, 0);
1418 
1419     intResult = session_->CommitConfig();
1420     EXPECT_EQ(intResult, 0);
1421 
1422     sleep(WAIT_TIME_AFTER_START);
1423     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
1424     EXPECT_EQ(intResult, 0);
1425 
1426     sleep(WAIT_TIME_AFTER_START);
1427 
1428     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1429 
1430     sleep(WAIT_TIME_AFTER_START);
1431 
1432     sleep(WAIT_TIME_AFTER_START);
1433     intResult = ((sptr<PreviewOutput> &)previewOutput)->Start();
1434     EXPECT_EQ(intResult, 0);
1435 
1436     sleep(WAIT_TIME_AFTER_START);
1437 
1438     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1439 }
1440 
1441 /*
1442  * Feature: Framework
1443  * Function: Test capture session start and stop video multiple times
1444  * SubFunction: NA
1445  * FunctionPoints: NA
1446  * EnvConditions: NA
1447  * CaseDescription: Test capture session start and stop video multiple times
1448  */
1449 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_028, TestSize.Level0)
1450 {
1451     int32_t intResult = session_->BeginConfig();
1452     EXPECT_EQ(intResult, 0);
1453 
1454     intResult = session_->AddInput(input_);
1455     EXPECT_EQ(intResult, 0);
1456 
1457     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1458     ASSERT_NE(previewOutput, nullptr);
1459 
1460     intResult = session_->AddOutput(previewOutput);
1461     EXPECT_EQ(intResult, 0);
1462 
1463     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1464     ASSERT_NE(videoOutput, nullptr);
1465 
1466     intResult = session_->AddOutput(videoOutput);
1467     EXPECT_EQ(intResult, 0);
1468 
1469     intResult = session_->CommitConfig();
1470     EXPECT_EQ(intResult, 0);
1471 
1472     intResult = session_->Start();
1473     EXPECT_EQ(intResult, 0);
1474 
1475     sleep(WAIT_TIME_AFTER_START);
1476 
1477     sleep(WAIT_TIME_AFTER_START);
1478 
1479     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
1480     EXPECT_EQ(intResult, 0);
1481 
1482     sleep(WAIT_TIME_AFTER_START);
1483 
1484     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
1485     EXPECT_EQ(intResult, 0);
1486 
1487     sleep(WAIT_TIME_AFTER_START);
1488 
1489     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
1490     EXPECT_EQ(intResult, 0);
1491 
1492     sleep(WAIT_TIME_AFTER_START);
1493 
1494     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
1495     EXPECT_EQ(intResult, 0);
1496 
1497     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1498 
1499     sleep(WAIT_TIME_BEFORE_STOP);
1500 
1501     ((sptr<PreviewOutput> &)previewOutput)->Stop();
1502     session_->Stop();
1503 }
1504 
1505 /*
1506  * Feature: Framework
1507  * Function: Test remove video output and commit when preview + video outputs were committed
1508  * SubFunction: NA
1509  * FunctionPoints: NA
1510  * EnvConditions: NA
1511  * CaseDescription: Test remove video output and commit when preview + video outputs were committed
1512  */
1513 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_029, TestSize.Level0)
1514 {
1515     if (!IsSupportNow()) {
1516         return;
1517     }
1518     int32_t intResult = session_->BeginConfig();
1519     EXPECT_EQ(intResult, 0);
1520 
1521     intResult = session_->AddInput(input_);
1522     EXPECT_EQ(intResult, 0);
1523 
1524     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1525     ASSERT_NE(previewOutput, nullptr);
1526 
1527     intResult = session_->AddOutput(previewOutput);
1528     EXPECT_EQ(intResult, 0);
1529 
1530     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1531     ASSERT_NE(videoOutput, nullptr);
1532 
1533     intResult = session_->AddOutput(videoOutput);
1534     EXPECT_EQ(intResult, 0);
1535 
1536     intResult = session_->CommitConfig();
1537     EXPECT_EQ(intResult, 0);
1538 
1539     intResult = session_->BeginConfig();
1540     EXPECT_EQ(intResult, 0);
1541 
1542     intResult = session_->RemoveOutput(videoOutput);
1543     EXPECT_EQ(intResult, 0);
1544 
1545     intResult = session_->CommitConfig();
1546     EXPECT_EQ(intResult, 0);
1547 
1548     intResult = session_->Start();
1549     EXPECT_EQ(intResult, 0);
1550 
1551     sleep(WAIT_TIME_AFTER_START);
1552     session_->Stop();
1553 }
1554 
1555 /*
1556  * Feature: Framework
1557  * Function: Test remove video output, add photo output and commit when preview + video outputs were committed
1558  * SubFunction: NA
1559  * FunctionPoints: NA
1560  * EnvConditions: NA
1561  * CaseDescription: Test remove video output, add photo output and commit when preview + video outputs were committed
1562  */
1563 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_030, TestSize.Level0)
1564 {
1565     int32_t intResult = session_->BeginConfig();
1566     EXPECT_EQ(intResult, 0);
1567 
1568     intResult = session_->AddInput(input_);
1569     EXPECT_EQ(intResult, 0);
1570 
1571     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1572     ASSERT_NE(previewOutput, nullptr);
1573 
1574     intResult = session_->AddOutput(previewOutput);
1575     EXPECT_EQ(intResult, 0);
1576 
1577     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1578     ASSERT_NE(videoOutput, nullptr);
1579 
1580     intResult = session_->AddOutput(videoOutput);
1581     EXPECT_EQ(intResult, 0);
1582 
1583     intResult = session_->CommitConfig();
1584     EXPECT_EQ(intResult, 0);
1585 
1586     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1587     ASSERT_NE(photoOutput, nullptr);
1588 
1589     intResult = session_->BeginConfig();
1590     EXPECT_EQ(intResult, 0);
1591 
1592     intResult = session_->RemoveOutput(videoOutput);
1593     EXPECT_EQ(intResult, 0);
1594 
1595     intResult = session_->AddOutput(photoOutput);
1596     EXPECT_EQ(intResult, 0);
1597 
1598     intResult = session_->CommitConfig();
1599     EXPECT_EQ(intResult, 0);
1600 
1601     intResult = session_->Start();
1602     EXPECT_EQ(intResult, 0);
1603 
1604     sleep(WAIT_TIME_AFTER_START);
1605     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
1606     EXPECT_EQ(intResult, 0);
1607     sleep(WAIT_TIME_AFTER_CAPTURE);
1608 
1609     session_->Stop();
1610 }
1611 
1612 /*
1613  * Feature: Framework
1614  * Function: Test remove photo output and commit when preview + photo outputs were committed
1615  * SubFunction: NA
1616  * FunctionPoints: NA
1617  * EnvConditions: NA
1618  * CaseDescription: Test remove photo output and commit when preview + photo outputs were committed
1619  */
1620 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_031, TestSize.Level0)
1621 {
1622     if (!IsSupportNow()) {
1623         return;
1624     }
1625     int32_t intResult = session_->BeginConfig();
1626     EXPECT_EQ(intResult, 0);
1627 
1628     intResult = session_->AddInput(input_);
1629     EXPECT_EQ(intResult, 0);
1630 
1631     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1632     ASSERT_NE(previewOutput, nullptr);
1633 
1634     intResult = session_->AddOutput(previewOutput);
1635     EXPECT_EQ(intResult, 0);
1636 
1637     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1638     ASSERT_NE(photoOutput, nullptr);
1639 
1640     intResult = session_->AddOutput(photoOutput);
1641     EXPECT_EQ(intResult, 0);
1642 
1643     intResult = session_->CommitConfig();
1644     EXPECT_EQ(intResult, 0);
1645 
1646     intResult = session_->BeginConfig();
1647     EXPECT_EQ(intResult, 0);
1648 
1649     intResult = session_->RemoveOutput(photoOutput);
1650     EXPECT_EQ(intResult, 0);
1651 
1652     intResult = session_->CommitConfig();
1653     EXPECT_EQ(intResult, 0);
1654 
1655     intResult = session_->Start();
1656     EXPECT_EQ(intResult, 0);
1657 
1658     sleep(WAIT_TIME_AFTER_START);
1659 
1660     session_->Stop();
1661 }
1662 
1663 /*
1664  * Feature: Framework
1665  * Function: Test remove photo output, add video output and commit when preview + photo outputs were committed
1666  * SubFunction: NA
1667  * FunctionPoints: NA
1668  * EnvConditions: NA
1669  * CaseDescription: Test remove photo output, add video output and commit when preview + photo outputs were committed
1670  */
1671 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_032, TestSize.Level0)
1672 {
1673     int32_t intResult = session_->BeginConfig();
1674     EXPECT_EQ(intResult, 0);
1675 
1676     intResult = session_->AddInput(input_);
1677     EXPECT_EQ(intResult, 0);
1678 
1679     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1680     ASSERT_NE(previewOutput, nullptr);
1681 
1682     intResult = session_->AddOutput(previewOutput);
1683     EXPECT_EQ(intResult, 0);
1684 
1685     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1686     ASSERT_NE(photoOutput, nullptr);
1687 
1688     intResult = session_->AddOutput(photoOutput);
1689     EXPECT_EQ(intResult, 0);
1690 
1691     intResult = session_->CommitConfig();
1692     EXPECT_EQ(intResult, 0);
1693 
1694     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1695     ASSERT_NE(videoOutput, nullptr);
1696 
1697     intResult = session_->BeginConfig();
1698     EXPECT_EQ(intResult, 0);
1699 
1700     intResult = session_->RemoveOutput(photoOutput);
1701     EXPECT_EQ(intResult, 0);
1702 
1703     intResult = session_->AddOutput(videoOutput);
1704     EXPECT_EQ(intResult, 0);
1705 
1706     intResult = session_->CommitConfig();
1707     EXPECT_EQ(intResult, 0);
1708 
1709     intResult = session_->Start();
1710     EXPECT_EQ(intResult, 0);
1711 
1712     sleep(WAIT_TIME_AFTER_START);
1713 
1714     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
1715     EXPECT_EQ(intResult, 0);
1716 
1717     sleep(WAIT_TIME_AFTER_START);
1718 
1719     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
1720     EXPECT_EQ(intResult, 0);
1721 
1722     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1723 
1724     sleep(WAIT_TIME_BEFORE_STOP);
1725 
1726     session_->Stop();
1727 }
1728 
1729 /*
1730  * Feature: Framework
1731  * Function: Test capture session remove output with null
1732  * SubFunction: NA
1733  * FunctionPoints: NA
1734  * EnvConditions: NA
1735  * CaseDescription: Test capture session remove output with null
1736  */
1737 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_033, TestSize.Level0)
1738 {
1739     int32_t intResult = session_->BeginConfig();
1740     EXPECT_EQ(intResult, 0);
1741 
1742     sptr<CaptureOutput> output = nullptr;
1743     intResult = session_->RemoveOutput(output);
1744     EXPECT_NE(intResult, 0);
1745 }
1746 
1747 /*
1748  * Feature: Framework
1749  * Function: Test capture session remove input with null
1750  * SubFunction: NA
1751  * FunctionPoints: NA
1752  * EnvConditions: NA
1753  * CaseDescription: Test capture session remove input with null
1754  */
1755 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_034, TestSize.Level0)
1756 {
1757     int32_t intResult = session_->BeginConfig();
1758     EXPECT_EQ(intResult, 0);
1759 
1760     sptr<CaptureInput> input = nullptr;
1761     intResult = session_->RemoveInput(input);
1762     EXPECT_NE(intResult, 0);
1763 }
1764 
1765 /*
1766  * Feature: Framework
1767  * Function: Test Capture with location setting [lat:1 ,long:1 ,alt:1]
1768  * SubFunction: NA
1769  * FunctionPoints: NA
1770  * EnvConditions: NA
1771  * CaseDescription: Test Capture with location setting
1772  */
1773 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_035, TestSize.Level0)
1774 {
1775     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
1776     std::unique_ptr<Location> location = std::make_unique<Location>();
1777     location->latitude = 1;
1778     location->longitude = 1;
1779     location->altitude = 1;
1780 
1781     photoSetting->SetLocation(location);
1782 
1783     int32_t intResult = session_->BeginConfig();
1784     EXPECT_EQ(intResult, 0);
1785 
1786     intResult = session_->AddInput(input_);
1787     EXPECT_EQ(intResult, 0);
1788 
1789     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1790     ASSERT_NE(photoOutput, nullptr);
1791 
1792     intResult = session_->AddOutput(photoOutput);
1793     EXPECT_EQ(intResult, 0);
1794 
1795     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1796     ASSERT_NE(previewOutput, nullptr);
1797 
1798     intResult = session_->AddOutput(previewOutput);
1799     EXPECT_EQ(intResult, 0);
1800 
1801     intResult = session_->CommitConfig();
1802     EXPECT_EQ(intResult, 0);
1803 
1804     intResult = session_->Start();
1805     EXPECT_EQ(intResult, 0);
1806 
1807     sleep(WAIT_TIME_AFTER_START);
1808     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture(photoSetting);
1809     EXPECT_EQ(intResult, 0);
1810     sleep(WAIT_TIME_AFTER_CAPTURE);
1811 
1812     session_->Stop();
1813 }
1814 
1815 /*
1816  * Feature: Framework
1817  * Function: Test Capture with location setting [lat:0.0 ,long:0.0 ,alt:0.0]
1818  * SubFunction: NA
1819  * FunctionPoints: NA
1820  * EnvConditions: NA
1821  * CaseDescription: Test Capture with location setting
1822  */
1823 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_036, TestSize.Level0)
1824 {
1825     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
1826     std::unique_ptr<Location> location = std::make_unique<Location>();
1827     location->latitude = 0.0;
1828     location->longitude = 0.0;
1829     location->altitude = 0.0;
1830 
1831     photoSetting->SetLocation(location);
1832 
1833     int32_t intResult = session_->BeginConfig();
1834     EXPECT_EQ(intResult, 0);
1835 
1836     intResult = session_->AddInput(input_);
1837     EXPECT_EQ(intResult, 0);
1838 
1839     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1840     ASSERT_NE(photoOutput, nullptr);
1841 
1842     intResult = session_->AddOutput(photoOutput);
1843     EXPECT_EQ(intResult, 0);
1844 
1845     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1846     ASSERT_NE(previewOutput, nullptr);
1847 
1848     intResult = session_->AddOutput(previewOutput);
1849     EXPECT_EQ(intResult, 0);
1850 
1851     intResult = session_->CommitConfig();
1852     EXPECT_EQ(intResult, 0);
1853 
1854     intResult = session_->Start();
1855     EXPECT_EQ(intResult, 0);
1856 
1857     sleep(WAIT_TIME_AFTER_START);
1858     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture(photoSetting);
1859     EXPECT_EQ(intResult, 0);
1860     sleep(WAIT_TIME_AFTER_CAPTURE);
1861 
1862     session_->Stop();
1863 }
1864 
1865 /*
1866  * Feature: Framework
1867  * Function: Test Capture with location setting [lat:-1 ,long:-1 ,alt:-1]
1868  * SubFunction: NA
1869  * FunctionPoints: NA
1870  * EnvConditions: NA
1871  * CaseDescription: Test Capture with location setting
1872  */
1873 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_037, TestSize.Level0)
1874 {
1875     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
1876     std::unique_ptr<Location> location = std::make_unique<Location>();
1877     location->latitude = -1;
1878     location->longitude = -1;
1879     location->altitude = -1;
1880 
1881     photoSetting->SetLocation(location);
1882 
1883     int32_t intResult = session_->BeginConfig();
1884     EXPECT_EQ(intResult, 0);
1885 
1886     intResult = session_->AddInput(input_);
1887     EXPECT_EQ(intResult, 0);
1888 
1889     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1890     ASSERT_NE(photoOutput, nullptr);
1891 
1892     intResult = session_->AddOutput(photoOutput);
1893     EXPECT_EQ(intResult, 0);
1894 
1895     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1896     ASSERT_NE(previewOutput, nullptr);
1897 
1898     intResult = session_->AddOutput(previewOutput);
1899     EXPECT_EQ(intResult, 0);
1900 
1901     intResult = session_->CommitConfig();
1902     EXPECT_EQ(intResult, 0);
1903 
1904     intResult = session_->Start();
1905     EXPECT_EQ(intResult, 0);
1906 
1907     sleep(WAIT_TIME_AFTER_START);
1908     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture(photoSetting);
1909     EXPECT_EQ(intResult, 0);
1910     sleep(WAIT_TIME_AFTER_CAPTURE);
1911 
1912     session_->Stop();
1913 }
1914 
1915 /*
1916  * Feature: Framework
1917  * Function: Test snapshot
1918  * SubFunction: NA
1919  * FunctionPoints: NA
1920  * EnvConditions: NA
1921  * CaseDescription: Test snapshot
1922  */
1923 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_038, TestSize.Level0)
1924 {
1925     int32_t intResult = session_->BeginConfig();
1926     EXPECT_EQ(intResult, 0);
1927 
1928     intResult = session_->AddInput(input_);
1929     EXPECT_EQ(intResult, 0);
1930 
1931     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1932     ASSERT_NE(photoOutput, nullptr);
1933 
1934     intResult = session_->AddOutput(photoOutput);
1935     EXPECT_EQ(intResult, 0);
1936 
1937     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1938     ASSERT_NE(previewOutput, nullptr);
1939 
1940     intResult = session_->AddOutput(previewOutput);
1941     EXPECT_EQ(intResult, 0);
1942 
1943     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1944     ASSERT_NE(videoOutput, nullptr);
1945 
1946     intResult = session_->AddOutput(videoOutput);
1947     EXPECT_EQ(intResult, 0);
1948 
1949     intResult = session_->CommitConfig();
1950     EXPECT_EQ(intResult, 0);
1951 
1952     intResult = session_->Start();
1953     EXPECT_EQ(intResult, 0);
1954 
1955     sleep(WAIT_TIME_AFTER_START);
1956 
1957     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
1958     EXPECT_EQ(intResult, 0);
1959 
1960     sleep(WAIT_TIME_AFTER_START);
1961     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture();
1962     EXPECT_EQ(intResult, 0);
1963     sleep(WAIT_TIME_AFTER_CAPTURE);
1964 
1965     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
1966     EXPECT_EQ(intResult, 0);
1967 
1968     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1969 
1970     sleep(WAIT_TIME_BEFORE_STOP);
1971 
1972     session_->Stop();
1973 }
1974 
1975 /*
1976  * Feature: Framework
1977  * Function: Test snapshot with location setting
1978  * SubFunction: NA
1979  * FunctionPoints: NA
1980  * EnvConditions: NA
1981  * CaseDescription: Test snapshot with location setting
1982  */
1983 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_039, TestSize.Level0)
1984 {
1985     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
1986     std::unique_ptr<Location> location = std::make_unique<Location>();
1987     location->latitude = 12.972442;
1988     location->longitude = 77.580643;
1989     location->altitude = 0;
1990 
1991     int32_t intResult = session_->BeginConfig();
1992     EXPECT_EQ(intResult, 0);
1993 
1994     intResult = session_->AddInput(input_);
1995     EXPECT_EQ(intResult, 0);
1996 
1997     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1998     ASSERT_NE(photoOutput, nullptr);
1999 
2000     intResult = session_->AddOutput(photoOutput);
2001     EXPECT_EQ(intResult, 0);
2002 
2003     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2004     ASSERT_NE(previewOutput, nullptr);
2005 
2006     intResult = session_->AddOutput(previewOutput);
2007     EXPECT_EQ(intResult, 0);
2008 
2009     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2010     ASSERT_NE(videoOutput, nullptr);
2011 
2012     intResult = session_->AddOutput(videoOutput);
2013     EXPECT_EQ(intResult, 0);
2014 
2015     intResult = session_->CommitConfig();
2016     EXPECT_EQ(intResult, 0);
2017 
2018     intResult = session_->Start();
2019     EXPECT_EQ(intResult, 0);
2020 
2021     sleep(WAIT_TIME_AFTER_START);
2022 
2023     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
2024     EXPECT_EQ(intResult, 0);
2025 
2026     sleep(WAIT_TIME_AFTER_START);
2027     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture(photoSetting);
2028     EXPECT_EQ(intResult, 0);
2029     sleep(WAIT_TIME_AFTER_CAPTURE);
2030 
2031     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
2032     EXPECT_EQ(intResult, 0);
2033 
2034     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2035 
2036     sleep(WAIT_TIME_BEFORE_STOP);
2037 
2038     session_->Stop();
2039 }
2040 
2041 /*
2042  * Feature: Framework
2043  * Function: Test snapshot with mirror setting
2044  * SubFunction: NA
2045  * FunctionPoints: NA
2046  * EnvConditions: NA
2047  * CaseDescription: Test snapshot with mirror setting
2048  */
2049 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_040, TestSize.Level0)
2050 {
2051     ReleaseInput();
2052     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2053     photoSetting->SetMirror(true);
2054 
2055     int32_t intResult = session_->BeginConfig();
2056     EXPECT_EQ(intResult, 0);
2057 
2058     if (cameras_.size() < 2) {
2059         return;
2060     }
2061 
2062     sptr<CaptureInput> input = manager_->CreateCameraInput(cameras_[1]);
2063     ASSERT_NE(input, nullptr);
2064 
2065     sptr<CameraInput> camInput = (sptr<CameraInput> &)input;
2066     camInput->Open();
2067 
2068     intResult = session_->AddInput(input);
2069     EXPECT_EQ(intResult, 0);
2070 
2071     GetSupportedOutputCapability();
2072 
2073     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(photoProfiles[0]);
2074     ASSERT_NE(photoOutput, nullptr);
2075 
2076     intResult = session_->AddOutput(photoOutput);
2077     EXPECT_EQ(intResult, 0);
2078 
2079     if (!(((sptr<PhotoOutput> &)photoOutput)->IsMirrorSupported())) {
2080         return;
2081     }
2082 
2083     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2084     ASSERT_NE(previewOutput, nullptr);
2085 
2086     intResult = session_->AddOutput(previewOutput);
2087     EXPECT_EQ(intResult, 0);
2088 
2089     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2090     ASSERT_NE(videoOutput, nullptr);
2091 
2092     intResult = session_->AddOutput(videoOutput);
2093     EXPECT_EQ(intResult, 0);
2094 
2095     intResult = session_->CommitConfig();
2096     EXPECT_EQ(intResult, 0);
2097 
2098     intResult = session_->Start();
2099     EXPECT_EQ(intResult, 0);
2100 
2101     sleep(WAIT_TIME_AFTER_START);
2102 
2103     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
2104     EXPECT_EQ(intResult, 0);
2105 
2106     sleep(WAIT_TIME_AFTER_START);
2107     intResult = ((sptr<PhotoOutput> &)photoOutput)->Capture(photoSetting);
2108     EXPECT_EQ(intResult, 0);
2109     sleep(WAIT_TIME_AFTER_CAPTURE);
2110 
2111     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
2112     EXPECT_EQ(intResult, 0);
2113 
2114     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2115 
2116     sleep(WAIT_TIME_BEFORE_STOP);
2117 
2118     session_->Stop();
2119 }
2120 
2121 /*
2122  * Feature: Framework
2123  * Function: Test capture session with Video Stabilization Mode
2124  * SubFunction: NA
2125  * FunctionPoints: NA
2126  * EnvConditions: NA
2127  * CaseDescription: Test capture session with Video Stabilization Mode
2128  */
2129 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_042, TestSize.Level0)
2130 {
2131     int32_t intResult = session_->BeginConfig();
2132     EXPECT_EQ(intResult, 0);
2133 
2134     intResult = session_->AddInput(input_);
2135     EXPECT_EQ(intResult, 0);
2136 
2137     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2138     ASSERT_NE(previewOutput, nullptr);
2139 
2140     intResult = session_->AddOutput(previewOutput);
2141     EXPECT_EQ(intResult, 0);
2142 
2143     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2144     ASSERT_NE(videoOutput, nullptr);
2145 
2146     intResult = session_->AddOutput(videoOutput);
2147     EXPECT_EQ(intResult, 0);
2148 
2149     intResult = session_->CommitConfig();
2150     EXPECT_EQ(intResult, 0);
2151 
2152     std::vector<VideoStabilizationMode> stabilizationmodes = session_->GetSupportedStabilizationMode();
2153     if (stabilizationmodes.empty()) {
2154         return;
2155     }
2156     ASSERT_EQ(stabilizationmodes.empty(), false);
2157 
2158     VideoStabilizationMode stabilizationMode = stabilizationmodes.back();
2159     if (session_->IsVideoStabilizationModeSupported(stabilizationMode)) {
2160         session_->SetVideoStabilizationMode(stabilizationMode);
2161         EXPECT_EQ(session_->GetActiveVideoStabilizationMode(), stabilizationMode);
2162     }
2163 
2164     intResult = session_->Start();
2165     EXPECT_EQ(intResult, 0);
2166 
2167     sleep(WAIT_TIME_AFTER_START);
2168 
2169     intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
2170     EXPECT_EQ(intResult, 0);
2171 
2172     sleep(WAIT_TIME_AFTER_START);
2173 
2174     intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
2175     EXPECT_EQ(intResult, 0);
2176 
2177     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2178 
2179     sleep(WAIT_TIME_BEFORE_STOP);
2180     session_->Stop();
2181 }
2182 
2183 /*
2184  * Feature: Framework
2185  * Function: Test Preview + Metadata
2186  * SubFunction: NA
2187  * FunctionPoints: NA
2188  * EnvConditions: NA
2189  * CaseDescription: Test Preview + Metadata
2190  * @tc.require: SR000GVK5P SR000GVO5O
2191  */
2192 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_043, TestSize.Level0)
2193 {
2194     int32_t intResult = session_->BeginConfig();
2195     EXPECT_EQ(intResult, 0);
2196 
2197     intResult = session_->AddInput(input_);
2198     EXPECT_EQ(intResult, 0);
2199 
2200     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2201     ASSERT_NE(previewOutput, nullptr);
2202 
2203     intResult = session_->AddOutput(previewOutput);
2204     EXPECT_EQ(intResult, 0);
2205 
2206     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
2207     ASSERT_NE(metadatOutput, nullptr);
2208 
2209     intResult = session_->AddOutput(metadatOutput);
2210     EXPECT_EQ(intResult, 0);
2211 
2212     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput> &)metadatOutput;
2213     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
2214     if (metadataObjectTypes.size() == 0) {
2215         return;
2216     }
2217 
2218     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::FACE});
2219 
2220     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
2221     metaOutput->SetCallback(metadataObjectCallback);
2222     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
2223     metaOutput->SetCallback(metadataStateCallback);
2224 
2225     intResult = session_->CommitConfig();
2226     EXPECT_EQ(intResult, 0);
2227 
2228     intResult = session_->Start();
2229     EXPECT_EQ(intResult, 0);
2230 
2231     sleep(WAIT_TIME_AFTER_START);
2232 
2233     intResult = metaOutput->Start();
2234     EXPECT_EQ(intResult, 0);
2235 
2236     sleep(WAIT_TIME_AFTER_START);
2237 
2238     intResult = metaOutput->Stop();
2239     EXPECT_EQ(intResult, 0);
2240 
2241     session_->Stop();
2242     metaOutput->Release();
2243 }
2244 
2245 /*
2246  * Feature: Framework
2247  * Function: Test camera preempted.
2248  * SubFunction: NA
2249  * FunctionPoints: NA
2250  * EnvConditions: NA
2251  * CaseDescription: Test camera preempted.
2252  * @tc.require: SR000GVTU0
2253  */
2254 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_044, TestSize.Level0)
2255 {
2256     if (!IsSupportNow()) {
2257         return;
2258     }
2259     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
2260     sptr<CameraInput> camInput_2 = (sptr<CameraInput> &)input_;
2261     camInput_2->Open();
2262 
2263     camInput_2->SetErrorCallback(callback);
2264 
2265 
2266     sptr<CaptureSession> session_2 = manager_->CreateCaptureSession();
2267     ASSERT_NE(session_2, nullptr);
2268 
2269     int32_t intResult = session_2->BeginConfig();
2270     EXPECT_EQ(intResult, 0);
2271 
2272     intResult = session_2->AddInput(input_);
2273     EXPECT_EQ(intResult, 0);
2274 
2275     sptr<CaptureOutput> previewOutput_2 = CreatePreviewOutput();
2276     ASSERT_NE(previewOutput_2, nullptr);
2277 
2278     intResult = session_2->AddOutput(previewOutput_2);
2279     EXPECT_EQ(intResult, 0);
2280 
2281     intResult = session_2->CommitConfig();
2282     EXPECT_EQ(intResult, 0);
2283 
2284     intResult = session_2->Start();
2285     EXPECT_EQ(intResult, 0);
2286 
2287     sleep(WAIT_TIME_AFTER_START);
2288     camInput_2->Close();
2289 
2290     if (cameras_.size() < 2) {
2291         return;
2292     }
2293 
2294     sptr<CaptureInput> input_3 = manager_->CreateCameraInput(cameras_[1]);
2295     ASSERT_NE(input_3, nullptr);
2296 
2297     sptr<CameraInput> camInput_3 = (sptr<CameraInput> &)input_3;
2298     camInput_3->Open();
2299 
2300     sptr<CaptureSession> session_3 = manager_->CreateCaptureSession();
2301     ASSERT_NE(session_3, nullptr);
2302 
2303     intResult = session_3->BeginConfig();
2304     EXPECT_EQ(intResult, 0);
2305 
2306     intResult = session_3->AddInput(input_3);
2307     EXPECT_EQ(intResult, 0);
2308 
2309     sptr<CaptureOutput> previewOutput_3 = CreatePreviewOutput();
2310     ASSERT_NE(previewOutput_3, nullptr);
2311 
2312     intResult = session_3->AddOutput(previewOutput_3);
2313     EXPECT_EQ(intResult, 0);
2314 
2315     intResult = session_3->CommitConfig();
2316     EXPECT_EQ(intResult, 0);
2317 
2318     session_3->Stop();
2319 }
2320 
2321 /*
2322  * Feature: Framework
2323  * Function: Test anomalous branch.
2324  * SubFunction: NA
2325  * FunctionPoints: NA
2326  * EnvConditions: NA
2327  * CaseDescription: Test capture session video stabilization mode with anomalous branch.
2328  */
2329 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_045, TestSize.Level0)
2330 {
2331     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2332     ASSERT_NE(camSession, nullptr);
2333 
2334     VideoStabilizationMode stabilizationMode = camSession->GetActiveVideoStabilizationMode();
2335     EXPECT_EQ(stabilizationMode, OFF);
2336 
2337     int32_t actVideoStaMode = camSession->SetVideoStabilizationMode(stabilizationMode);
2338     EXPECT_EQ(actVideoStaMode, 7400103);
2339 
2340     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
2341     EXPECT_EQ(actVideoStaMode, 7400103);
2342 
2343     bool isSupported = true;
2344 
2345     int32_t videoStaModeSupported = camSession->IsVideoStabilizationModeSupported(stabilizationMode, isSupported);
2346     EXPECT_EQ(videoStaModeSupported, 7400103);
2347 
2348     std::vector<VideoStabilizationMode> videoStabilizationMode = camSession->GetSupportedStabilizationMode();
2349     EXPECT_EQ(videoStabilizationMode.empty(), true);
2350 
2351     int32_t supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
2352     EXPECT_EQ(supportedVideoStaMode, 7400103);
2353 
2354     int32_t intResult = camSession->BeginConfig();
2355     EXPECT_EQ(intResult, 0);
2356 
2357     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2358     ASSERT_NE(input, nullptr);
2359 
2360     intResult = camSession->AddInput(input);
2361     EXPECT_EQ(intResult, 0);
2362 
2363     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2364     ASSERT_NE(previewOutput, nullptr);
2365 
2366     intResult = camSession->AddOutput(previewOutput);
2367     EXPECT_EQ(intResult, 0);
2368 
2369     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2370     ASSERT_NE(videoOutput, nullptr);
2371 
2372     intResult = camSession->AddOutput(videoOutput);
2373     EXPECT_EQ(intResult, 0);
2374 
2375     intResult = camSession->CommitConfig();
2376     EXPECT_EQ(intResult, 0);
2377 
2378     videoStaModeSupported = camSession->IsVideoStabilizationModeSupported(stabilizationMode, isSupported);
2379     EXPECT_EQ(videoStaModeSupported, 0);
2380 
2381     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
2382     EXPECT_EQ(actVideoStaMode, 0);
2383 
2384     supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
2385     EXPECT_EQ(supportedVideoStaMode, 0);
2386 
2387     ReleaseInput();
2388 
2389     stabilizationMode = camSession->GetActiveVideoStabilizationMode();
2390     EXPECT_EQ(stabilizationMode, OFF);
2391 
2392     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
2393     EXPECT_EQ(actVideoStaMode, 0);
2394 
2395     videoStabilizationMode = camSession->GetSupportedStabilizationMode();
2396     EXPECT_EQ(videoStabilizationMode.empty(), true);
2397 
2398     supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
2399     EXPECT_EQ(supportedVideoStaMode, 0);
2400 }
2401 
2402 /*
2403  * Feature: Framework
2404  * Function: Test anomalous branch.
2405  * SubFunction: NA
2406  * FunctionPoints: NA
2407  * EnvConditions: NA
2408  * CaseDescription: Test capture session exposure mode with anomalous branch.
2409  */
2410 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_046, TestSize.Level0)
2411 {
2412     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2413     ASSERT_NE(camSession, nullptr);
2414 
2415     ExposureMode exposureMode = camSession->GetExposureMode();
2416     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
2417 
2418     int32_t getExposureMode = camSession->GetExposureMode(exposureMode);
2419     EXPECT_EQ(getExposureMode, 7400103);
2420 
2421     int32_t setExposureMode = camSession->SetExposureMode(exposureMode);
2422     EXPECT_EQ(setExposureMode, 7400103);
2423 
2424     bool isExposureModeSupported = camSession->IsExposureModeSupported(exposureMode);
2425     EXPECT_EQ(isExposureModeSupported, false);
2426 
2427     bool isSupported = true;
2428 
2429     int32_t exposureModeSupported = camSession->IsExposureModeSupported(exposureMode, isSupported);
2430     EXPECT_EQ(exposureModeSupported, 7400103);
2431 
2432     std::vector<ExposureMode> getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
2433     EXPECT_EQ(getSupportedExpModes_1.empty(), true);
2434 
2435     int32_t getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
2436     EXPECT_EQ(getSupportedExpModes_2, 7400103);
2437 
2438     int32_t intResult = camSession->BeginConfig();
2439     EXPECT_EQ(intResult, 0);
2440 
2441     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2442     ASSERT_NE(input, nullptr);
2443 
2444     intResult = camSession->AddInput(input);
2445     EXPECT_EQ(intResult, 0);
2446 
2447     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2448     ASSERT_NE(previewOutput, nullptr);
2449 
2450     intResult = camSession->AddOutput(previewOutput);
2451     EXPECT_EQ(intResult, 0);
2452 
2453     intResult = camSession->CommitConfig();
2454     EXPECT_EQ(intResult, 0);
2455 
2456     setExposureMode = camSession->SetExposureMode(exposureMode);
2457     EXPECT_EQ(setExposureMode, 0);
2458 
2459     getExposureMode = camSession->GetExposureMode(exposureMode);
2460     EXPECT_EQ(getExposureMode, 0);
2461 
2462     exposureModeSupported = camSession->IsExposureModeSupported(exposureMode, isSupported);
2463     EXPECT_EQ(exposureModeSupported, 0);
2464 
2465     getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
2466     EXPECT_EQ(getSupportedExpModes_1.empty(), false);
2467 
2468     getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
2469     EXPECT_EQ(getSupportedExpModes_2, 0);
2470 
2471     ReleaseInput();
2472 
2473     getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
2474     EXPECT_EQ(getSupportedExpModes_1.empty(), true);
2475 
2476     getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
2477     EXPECT_EQ(getSupportedExpModes_2, 0);
2478 
2479     exposureMode = camSession->GetExposureMode();
2480     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
2481 
2482     getExposureMode = camSession->GetExposureMode(exposureMode);
2483     EXPECT_EQ(getExposureMode, 0);
2484 }
2485 
2486 /*
2487  * Feature: Framework
2488  * Function: Test anomalous branch.
2489  * SubFunction: NA
2490  * FunctionPoints: NA
2491  * EnvConditions: NA
2492  * CaseDescription: Test capture session metering point with anomalous branch.
2493  */
2494 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_047, TestSize.Level0)
2495 {
2496     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2497     ASSERT_NE(camSession, nullptr);
2498 
2499     Point exposurePointGet = camSession->GetMeteringPoint();
2500     EXPECT_EQ(exposurePointGet.x, 0);
2501     EXPECT_EQ(exposurePointGet.y, 0);
2502 
2503     int32_t setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
2504     EXPECT_EQ(setMeteringPoint, 7400103);
2505 
2506     int32_t getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
2507     EXPECT_EQ(getMeteringPoint, 7400103);
2508 
2509     int32_t intResult = camSession->BeginConfig();
2510     EXPECT_EQ(intResult, 0);
2511 
2512     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2513     ASSERT_NE(input, nullptr);
2514 
2515     intResult = camSession->AddInput(input);
2516     EXPECT_EQ(intResult, 0);
2517 
2518     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2519     ASSERT_NE(previewOutput, nullptr);
2520 
2521     intResult = camSession->AddOutput(previewOutput);
2522     EXPECT_EQ(intResult, 0);
2523 
2524     intResult = camSession->CommitConfig();
2525     EXPECT_EQ(intResult, 0);
2526 
2527     setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
2528     EXPECT_EQ(setMeteringPoint, 0);
2529 
2530     getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
2531     EXPECT_EQ(getMeteringPoint, 0);
2532 
2533     ReleaseInput();
2534 
2535     exposurePointGet = camSession->GetMeteringPoint();
2536     EXPECT_EQ(exposurePointGet.x, 0);
2537     EXPECT_EQ(exposurePointGet.y, 0);
2538 
2539     getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
2540     EXPECT_EQ(getMeteringPoint, 0);
2541 
2542     camSession->LockForControl();
2543 
2544     setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
2545     EXPECT_EQ(setMeteringPoint, 0);
2546 }
2547 
2548 /*
2549  * Feature: Framework
2550  * Function: Test anomalous branch.
2551  * SubFunction: NA
2552  * FunctionPoints: NA
2553  * EnvConditions: NA
2554  * CaseDescription: Test capture session exposure value and range with anomalous branch.
2555  */
2556 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_048, TestSize.Level0)
2557 {
2558     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2559     ASSERT_NE(camSession, nullptr);
2560 
2561     std::shared_ptr<Camera::CameraMetadata> metadata = cameras_[0]->GetMetadata();
2562     ASSERT_NE(metadata, nullptr);
2563 
2564     camSession->ProcessAutoExposureUpdates(metadata);
2565 
2566     float exposureValue = camSession->GetExposureValue();
2567     EXPECT_EQ(exposureValue, 0);
2568 
2569     int32_t exposureValueGet = camSession->GetExposureValue(exposureValue);
2570     EXPECT_EQ(exposureValueGet, 7400103);
2571 
2572     int32_t setExposureBias = camSession->SetExposureBias(exposureValue);
2573     EXPECT_EQ(setExposureBias, 7400103);
2574 
2575     std::vector<float> getExposureBiasRange = camSession->GetExposureBiasRange();
2576     EXPECT_EQ(getExposureBiasRange.empty(), true);
2577 
2578     int32_t exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
2579     EXPECT_EQ(exposureBiasRangeGet, 7400103);
2580 
2581     int32_t intResult = camSession->BeginConfig();
2582     EXPECT_EQ(intResult, 0);
2583 
2584     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2585     ASSERT_NE(input, nullptr);
2586 
2587     intResult = camSession->AddInput(input);
2588     EXPECT_EQ(intResult, 0);
2589 
2590     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2591     ASSERT_NE(previewOutput, nullptr);
2592 
2593     intResult = camSession->AddOutput(previewOutput);
2594     EXPECT_EQ(intResult, 0);
2595 
2596     intResult = camSession->CommitConfig();
2597     EXPECT_EQ(intResult, 0);
2598 
2599     setExposureBias = camSession->SetExposureBias(exposureValue);
2600     EXPECT_EQ(setExposureBias, 0);
2601 
2602     exposureValueGet = camSession->GetExposureValue(exposureValue);
2603     EXPECT_EQ(exposureValueGet, 0);
2604 
2605     exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
2606     EXPECT_EQ(exposureBiasRangeGet, 0);
2607 
2608     ReleaseInput();
2609 
2610     getExposureBiasRange = camSession->GetExposureBiasRange();
2611     EXPECT_EQ(getExposureBiasRange.empty(), true);
2612 
2613     exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
2614     EXPECT_EQ(exposureBiasRangeGet, 0);
2615 
2616     exposureValue = camSession->GetExposureValue();
2617     EXPECT_EQ(exposureValue, 0);
2618 
2619     exposureValueGet = camSession->GetExposureValue(exposureValue);
2620     EXPECT_EQ(exposureValueGet, 0);
2621 
2622     camSession->LockForControl();
2623 
2624     setExposureBias = camSession->SetExposureBias(exposureValue);
2625     EXPECT_EQ(setExposureBias, 7400102);
2626 }
2627 
2628 /*
2629  * Feature: Framework
2630  * Function: Test anomalous branch.
2631  * SubFunction: NA
2632  * FunctionPoints: NA
2633  * EnvConditions: NA
2634  * CaseDescription: Test capture session focus mode with anomalous branch.
2635  */
2636 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_049, TestSize.Level0)
2637 {
2638     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2639     ASSERT_NE(camSession, nullptr);
2640 
2641     FocusMode focusMode = camSession->GetFocusMode();
2642     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
2643 
2644     int32_t getFocusMode = camSession->GetFocusMode(focusMode);
2645     EXPECT_EQ(getFocusMode, 7400103);
2646 
2647     int32_t setFocusMode = camSession->SetFocusMode(focusMode);
2648     EXPECT_EQ(setFocusMode, 7400103);
2649 
2650     bool isFocusModeSupported = camSession->IsFocusModeSupported(focusMode);
2651     EXPECT_EQ(isFocusModeSupported, false);
2652 
2653     bool isSupported = true;
2654 
2655     int32_t focusModeSupported = camSession->IsFocusModeSupported(focusMode, isSupported);
2656     EXPECT_EQ(focusModeSupported, 7400103);
2657 
2658     std::vector<FocusMode> getSupportedFocusModes = camSession->GetSupportedFocusModes();
2659     EXPECT_EQ(getSupportedFocusModes.empty(), true);
2660 
2661     int32_t supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
2662     EXPECT_EQ(supportedFocusModesGet, 7400103);
2663 
2664     int32_t intResult = camSession->BeginConfig();
2665     EXPECT_EQ(intResult, 0);
2666 
2667     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2668     ASSERT_NE(input, nullptr);
2669 
2670     intResult = camSession->AddInput(input);
2671     EXPECT_EQ(intResult, 0);
2672 
2673     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2674     ASSERT_NE(previewOutput, nullptr);
2675 
2676     intResult = camSession->AddOutput(previewOutput);
2677     EXPECT_EQ(intResult, 0);
2678 
2679     intResult = camSession->CommitConfig();
2680     EXPECT_EQ(intResult, 0);
2681 
2682     setFocusMode = camSession->SetFocusMode(focusMode);
2683     EXPECT_EQ(setFocusMode, 0);
2684 
2685     getFocusMode = camSession->GetFocusMode(focusMode);
2686     EXPECT_EQ(getFocusMode, 0);
2687 
2688     focusModeSupported = camSession->IsFocusModeSupported(focusMode, isSupported);
2689     EXPECT_EQ(focusModeSupported, 0);
2690 
2691     getSupportedFocusModes = camSession->GetSupportedFocusModes();
2692     EXPECT_EQ(getSupportedFocusModes.empty(), false);
2693 
2694     supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
2695     EXPECT_EQ(supportedFocusModesGet, 0);
2696 
2697     ReleaseInput();
2698 
2699     getSupportedFocusModes = camSession->GetSupportedFocusModes();
2700     EXPECT_EQ(getSupportedFocusModes.empty(), true);
2701 
2702     supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
2703     EXPECT_EQ(supportedFocusModesGet, 0);
2704 
2705     focusMode = camSession->GetFocusMode();
2706     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
2707 
2708     getFocusMode = camSession->GetFocusMode(focusMode);
2709     EXPECT_EQ(getFocusMode, 0);
2710 }
2711 
2712 /*
2713  * Feature: Framework
2714  * Function: Test anomalous branch.
2715  * SubFunction: NA
2716  * FunctionPoints: NA
2717  * EnvConditions: NA
2718  * CaseDescription: Test capture session focus point with anomalous branch.
2719  */
2720 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_050, TestSize.Level0)
2721 {
2722     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2723     ASSERT_NE(camSession, nullptr);
2724 
2725     Point focusPoint = camSession->GetFocusPoint();
2726     EXPECT_EQ(focusPoint.x, 0);
2727     EXPECT_EQ(focusPoint.y, 0);
2728 
2729     float focalLength = camSession->GetFocalLength();
2730     EXPECT_EQ(focalLength, 0);
2731 
2732     int32_t focalLengthGet = camSession->GetFocalLength(focalLength);
2733     EXPECT_EQ(focalLengthGet, 7400103);
2734 
2735     int32_t focusPointGet = camSession->GetFocusPoint(focusPoint);
2736     EXPECT_EQ(focusPointGet, 7400103);
2737 
2738     int32_t setFocusPoint = camSession->SetFocusPoint(focusPoint);
2739     EXPECT_EQ(setFocusPoint, 7400103);
2740 
2741     int32_t intResult = camSession->BeginConfig();
2742     EXPECT_EQ(intResult, 0);
2743 
2744     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2745     intResult = camSession->AddInput(input);
2746     EXPECT_EQ(intResult, 0);
2747 
2748     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2749     ASSERT_NE(previewOutput, nullptr);
2750 
2751     intResult = camSession->AddOutput(previewOutput);
2752     EXPECT_EQ(intResult, 0);
2753 
2754     intResult = camSession->CommitConfig();
2755     EXPECT_EQ(intResult, 0);
2756 
2757     setFocusPoint = camSession->SetFocusPoint(focusPoint);
2758     EXPECT_EQ(setFocusPoint, 0);
2759 
2760     camSession->LockForControl();
2761 
2762     Point point = {0, 0};
2763     setFocusPoint = camSession->SetFocusPoint(point);
2764     EXPECT_EQ(setFocusPoint, 0);
2765 
2766     point.x = CameraErrorCode::SESSION_NOT_CONFIG;
2767     setFocusPoint = camSession->SetFocusPoint(point);
2768     EXPECT_EQ(setFocusPoint, 0);
2769 
2770     focusPointGet = camSession->GetFocusPoint(focusPoint);
2771     EXPECT_EQ(focusPointGet, 0);
2772 
2773     focalLengthGet = camSession->GetFocalLength(focalLength);
2774     EXPECT_EQ(focalLengthGet, 0);
2775 
2776     ReleaseInput();
2777 
2778     focusPoint = camSession->GetFocusPoint();
2779     EXPECT_EQ(focusPoint.x, 0);
2780     EXPECT_EQ(focusPoint.y, 0);
2781 
2782     focusPointGet = camSession->GetFocusPoint(focusPoint);
2783     EXPECT_EQ(focusPointGet, 0);
2784 
2785     focalLength = camSession->GetFocalLength();
2786     EXPECT_EQ(focalLength, 0);
2787 
2788     focalLengthGet = camSession->GetFocalLength(focalLength);
2789     EXPECT_EQ(focalLengthGet, 0);
2790 }
2791 
2792 /*
2793  * Feature: Framework
2794  * Function: Test anomalous branch.
2795  * SubFunction: NA
2796  * FunctionPoints: NA
2797  * EnvConditions: NA
2798  * CaseDescription: Test capture session flash mode with anomalous branch.
2799  */
2800 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_051, TestSize.Level0)
2801 {
2802     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2803     ASSERT_NE(camSession, nullptr);
2804 
2805     bool hasFlash = camSession->HasFlash();
2806     EXPECT_EQ(hasFlash, false);
2807 
2808     int32_t isFlash = camSession->HasFlash(hasFlash);
2809     EXPECT_EQ(isFlash, 7400103);
2810 
2811     FlashMode flashMode = camSession->GetFlashMode();
2812     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
2813 
2814     int32_t flashModeGet = camSession->GetFlashMode(flashMode);
2815     EXPECT_EQ(flashModeGet, 7400103);
2816 
2817     int32_t setFlashMode = camSession->SetFlashMode(flashMode);
2818     EXPECT_EQ(setFlashMode, 7400103);
2819 
2820     bool isFlashModeSupported = camSession->IsFlashModeSupported(flashMode);
2821     EXPECT_EQ(isFlashModeSupported, false);
2822 
2823     bool isSupported = true;
2824 
2825     int32_t flashModeSupported = camSession->IsFlashModeSupported(flashMode, isSupported);
2826     EXPECT_EQ(setFlashMode, 7400103);
2827 
2828     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
2829     EXPECT_EQ(getSupportedFlashModes.empty(), true);
2830 
2831     int32_t getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
2832     EXPECT_EQ(getSupportedFlashMode, 7400103);
2833 
2834     int32_t intResult = camSession->BeginConfig();
2835     EXPECT_EQ(intResult, 0);
2836 
2837     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2838     ASSERT_NE(input, nullptr);
2839 
2840     intResult = camSession->AddInput(input);
2841     EXPECT_EQ(intResult, 0);
2842 
2843     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2844     ASSERT_NE(previewOutput, nullptr);
2845 
2846     intResult = camSession->AddOutput(previewOutput);
2847     EXPECT_EQ(intResult, 0);
2848 
2849     intResult = camSession->CommitConfig();
2850     EXPECT_EQ(intResult, 0);
2851 
2852     isFlash = camSession->HasFlash(hasFlash);
2853     EXPECT_EQ(isFlash, 0);
2854 
2855     setFlashMode = camSession->SetFlashMode(flashMode);
2856     EXPECT_EQ(setFlashMode, 0);
2857 
2858     flashModeGet = camSession->GetFlashMode(flashMode);
2859     EXPECT_EQ(flashModeGet, 0);
2860 
2861     flashModeSupported = camSession->IsFlashModeSupported(flashMode, isSupported);
2862     EXPECT_EQ(setFlashMode, 0);
2863 
2864     getSupportedFlashModes = camSession->GetSupportedFlashModes();
2865     EXPECT_EQ(getSupportedFlashModes.empty(), false);
2866 
2867     getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
2868     EXPECT_EQ(getSupportedFlashMode, 0);
2869 
2870     camSession->LockForControl();
2871     setFlashMode = camSession->SetFlashMode(flashMode);
2872     EXPECT_EQ(setFlashMode, 0);
2873 }
2874 
2875 /*
2876  * Feature: Framework
2877  * Function: Test anomalous branch.
2878  * SubFunction: NA
2879  * FunctionPoints: NA
2880  * EnvConditions: NA
2881  * CaseDescription: Test flash mode with release input.
2882  */
2883 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_052, TestSize.Level0)
2884 {
2885     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2886     ASSERT_NE(camSession, nullptr);
2887 
2888     int32_t intResult = camSession->BeginConfig();
2889     EXPECT_EQ(intResult, 0);
2890 
2891     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2892     ASSERT_NE(input, nullptr);
2893 
2894     intResult = camSession->AddInput(input);
2895     EXPECT_EQ(intResult, 0);
2896 
2897     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2898     ASSERT_NE(previewOutput, nullptr);
2899 
2900     intResult = camSession->AddOutput(previewOutput);
2901     EXPECT_EQ(intResult, 0);
2902 
2903     intResult = camSession->CommitConfig();
2904     EXPECT_EQ(intResult, 0);
2905 
2906     ReleaseInput();
2907 
2908     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
2909     EXPECT_EQ(getSupportedFlashModes.empty(), true);
2910 
2911     int32_t getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
2912     EXPECT_EQ(getSupportedFlashMode, 0);
2913 
2914     FlashMode flashMode = camSession->GetFlashMode();
2915     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
2916 
2917     int32_t flashModeGet = camSession->GetFlashMode(flashMode);
2918     EXPECT_EQ(flashModeGet, 0);
2919 }
2920 
2921 /*
2922  * Feature: Framework
2923  * Function: Test anomalous branch.
2924  * SubFunction: NA
2925  * FunctionPoints: NA
2926  * EnvConditions: NA
2927  * CaseDescription: Test capture session zoom ratio with anomalous branch.
2928  */
2929 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_053, TestSize.Level0)
2930 {
2931     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
2932     ASSERT_NE(camSession, nullptr);
2933 
2934     float zoomRatio = camSession->GetZoomRatio();
2935     EXPECT_EQ(zoomRatio, 0);
2936 
2937     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
2938     EXPECT_EQ(zoomRatioRange.empty(), true);
2939 
2940     int32_t zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
2941     EXPECT_EQ(zoomRatioRangeGet, 7400103);
2942 
2943     int32_t zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
2944     EXPECT_EQ(zoomRatioGet, 7400103);
2945 
2946     int32_t setZoomRatio = camSession->SetZoomRatio(zoomRatio);
2947     EXPECT_EQ(setZoomRatio, 7400103);
2948 
2949     int32_t intResult = camSession->BeginConfig();
2950     EXPECT_EQ(intResult, 0);
2951 
2952     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
2953     ASSERT_NE(input, nullptr);
2954 
2955     intResult = camSession->AddInput(input);
2956     EXPECT_EQ(intResult, 0);
2957 
2958     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2959     ASSERT_NE(previewOutput, nullptr);
2960 
2961     intResult = camSession->AddOutput(previewOutput);
2962     EXPECT_EQ(intResult, 0);
2963 
2964     intResult = camSession->CommitConfig();
2965     EXPECT_EQ(intResult, 0);
2966 
2967     zoomRatioRange = camSession->GetZoomRatioRange();
2968     EXPECT_EQ(zoomRatioRange.empty(), false);
2969 
2970     zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
2971     EXPECT_EQ(zoomRatioRangeGet, 0);
2972 
2973     zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
2974     EXPECT_EQ(zoomRatioGet, 0);
2975 
2976     setZoomRatio = camSession->SetZoomRatio(zoomRatio);
2977     EXPECT_EQ(setZoomRatio, 0);
2978 
2979     ReleaseInput();
2980 
2981     zoomRatioRange = camSession->GetZoomRatioRange();
2982     EXPECT_EQ(zoomRatioRange.empty(), true);
2983 
2984     zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
2985     EXPECT_EQ(zoomRatioRangeGet, 0);
2986 
2987     zoomRatio = camSession->GetZoomRatio();
2988     EXPECT_EQ(zoomRatio, 0);
2989 
2990     zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
2991     EXPECT_EQ(zoomRatioGet, 0);
2992 
2993     camSession->LockForControl();
2994 
2995     setZoomRatio = camSession->SetZoomRatio(zoomRatio);
2996     EXPECT_EQ(setZoomRatio, 0);
2997 }
2998 
2999 /*
3000  * Feature: Framework
3001  * Function: Test anomalous branch.
3002  * SubFunction: NA
3003  * FunctionPoints: NA
3004  * EnvConditions: NA
3005  * CaseDescription: Test capture session with set metadata Object type anomalous branch.
3006  */
3007 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_054, TestSize.Level0)
3008 {
3009     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3010     ASSERT_NE(camSession, nullptr);
3011 
3012     std::set<camera_face_detect_mode_t> metadataObjectTypes;
3013     camSession->SetCaptureMetadataObjectTypes(metadataObjectTypes);
3014 }
3015 
3016 /*
3017  * Feature: Framework
3018  * Function: Test anomalous branch.
3019  * SubFunction: NA
3020  * FunctionPoints: NA
3021  * EnvConditions: NA
3022  * CaseDescription: Test metadataOutput with anomalous branch.
3023  */
3024 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_055, TestSize.Level0)
3025 {
3026     int32_t intResult = session_->BeginConfig();
3027     EXPECT_EQ(intResult, 0);
3028 
3029     intResult = session_->AddInput(input_);
3030     EXPECT_EQ(intResult, 0);
3031 
3032     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3033     ASSERT_NE(previewOutput, nullptr);
3034 
3035     intResult = session_->AddOutput(previewOutput);
3036     EXPECT_EQ(intResult, 0);
3037 
3038     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
3039     ASSERT_NE(metadatOutput, nullptr);
3040 
3041     intResult = session_->AddOutput(metadatOutput);
3042     EXPECT_EQ(intResult, 0);
3043 
3044     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput> &)metadatOutput;
3045 
3046     sptr<MetadataObjectListener> metaObjListener = new(std::nothrow) MetadataObjectListener(metaOutput);
3047     ASSERT_NE(metaObjListener, nullptr);
3048 
3049     metaObjListener->OnBufferAvailable();
3050 
3051     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
3052     EXPECT_EQ(metadataObjectTypes.empty(), true);
3053 
3054     metaOutput->SetCapturingMetadataObjectTypes(metadataObjectTypes);
3055     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::FACE});
3056 
3057     metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
3058 
3059     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
3060     metaOutput->SetCallback(metadataObjectCallback);
3061     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
3062     metaOutput->SetCallback(metadataStateCallback);
3063 
3064     int32_t startResult = metaOutput->Start();
3065     EXPECT_EQ(startResult, 7400103);
3066 
3067     int32_t stopResult = metaOutput->Stop();
3068     EXPECT_EQ(stopResult, 7400201);
3069 
3070     intResult = session_->CommitConfig();
3071     EXPECT_EQ(intResult, 0);
3072 
3073     intResult = session_->Start();
3074     EXPECT_EQ(intResult, 0);
3075 
3076     sleep(WAIT_TIME_AFTER_START);
3077 
3078     intResult = metaOutput->Start();
3079     EXPECT_EQ(intResult, 0);
3080 
3081     metaObjListener->OnBufferAvailable();
3082 
3083     sleep(WAIT_TIME_AFTER_START);
3084 
3085     intResult = metaOutput->Stop();
3086     EXPECT_EQ(intResult, 0);
3087 
3088     intResult = metaOutput->Release();
3089     EXPECT_EQ(intResult, 0);
3090 }
3091 
3092 /*
3093  * Feature: Framework
3094  * Function: Test anomalous branch
3095  * SubFunction: NA
3096  * FunctionPoints: NA
3097  * EnvConditions: NA
3098  * CaseDescription: test capture session callback error with anomalous branch
3099  */
3100 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_056, TestSize.Level0)
3101 {
3102     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3103     ASSERT_NE(camSession, nullptr);
3104 
3105     sptr<CaptureSessionCallback> capSessionCallback = new(std::nothrow) CaptureSessionCallback();
3106     int32_t onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
3107     EXPECT_EQ(onError, 0);
3108 
3109     capSessionCallback = new(std::nothrow) CaptureSessionCallback(camSession);
3110     onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
3111     EXPECT_EQ(onError, 0);
3112 
3113     std::shared_ptr<SessionCallback> callback = nullptr;
3114     camSession->SetCallback(callback);
3115 
3116     callback = std::make_shared<AppSessionCallback>();
3117     camSession->SetCallback(callback);
3118     capSessionCallback = new(std::nothrow) CaptureSessionCallback(camSession);
3119     onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
3120     EXPECT_EQ(onError, 0);
3121 }
3122 
3123 /*
3124  * Feature: Framework
3125  * Function: Test anomalous branch
3126  * SubFunction: NA
3127  * FunctionPoints: NA
3128  * EnvConditions: NA
3129  * CaseDescription: test remove input with anomalous branch
3130  */
3131 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_057, TestSize.Level0)
3132 {
3133     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3134     ASSERT_NE(camSession, nullptr);
3135 
3136     sptr<CaptureInput> input = nullptr;
3137     int32_t intResult = camSession->RemoveInput(input);
3138     EXPECT_EQ(intResult, 7400102);
3139 
3140     intResult = camSession->BeginConfig();
3141     EXPECT_EQ(intResult, 0);
3142 
3143     input = (sptr<CaptureInput> &)input_;
3144     ASSERT_NE(input, nullptr);
3145 
3146     intResult = camSession->RemoveInput(input);
3147     EXPECT_EQ(intResult, 7400201);
3148 
3149     intResult = camSession->AddInput(input);
3150     EXPECT_EQ(intResult, 0);
3151 
3152     intResult = camSession->RemoveInput(input);
3153     EXPECT_EQ(intResult, 0);
3154 }
3155 
3156 /*
3157  * Feature: Framework
3158  * Function: Test anomalous branch
3159  * SubFunction: NA
3160  * FunctionPoints: NA
3161  * EnvConditions: NA
3162  * CaseDescription: test remove output with anomalous branch
3163  */
3164 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_058, TestSize.Level0)
3165 {
3166     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3167     ASSERT_NE(camSession, nullptr);
3168 
3169     sptr<CaptureOutput> output = nullptr;
3170     int32_t intResult = camSession->RemoveOutput(output);
3171     EXPECT_EQ(intResult, 7400102);
3172 
3173     intResult = camSession->BeginConfig();
3174     EXPECT_EQ(intResult, 0);
3175 
3176     output = CreatePreviewOutput();
3177     ASSERT_NE(output, nullptr);
3178 
3179     intResult = camSession->RemoveOutput(output);
3180     EXPECT_EQ(intResult, 7400201);
3181 }
3182 
3183 /*
3184  * Feature: Framework
3185  * Function: Test anomalous branch
3186  * SubFunction: NA
3187  * FunctionPoints: NA
3188  * EnvConditions: NA
3189  * CaseDescription: test stop/release session and preview with anomalous branch
3190  */
3191 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_059, TestSize.Level0)
3192 {
3193     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3194     ASSERT_NE(camSession, nullptr);
3195     delete camSession;
3196 
3197     int32_t intResult = camSession->Stop();
3198     EXPECT_EQ(intResult, 7400201);
3199 
3200     intResult = camSession->Release();
3201     EXPECT_EQ(intResult, 7400201);
3202 }
3203 
3204 /*
3205  * Feature: Framework
3206  * Function: Test anomalous branch.
3207  * SubFunction: NA
3208  * FunctionPoints: NA
3209  * EnvConditions: NA
3210  * CaseDescription: Test metadataOutput with anomalous branch.
3211  */
3212 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_060, TestSize.Level0)
3213 {
3214     int32_t intResult = session_->BeginConfig();
3215     EXPECT_EQ(intResult, 0);
3216 
3217     intResult = session_->AddInput(input_);
3218     EXPECT_EQ(intResult, 0);
3219 
3220     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3221     ASSERT_NE(previewOutput, nullptr);
3222 
3223     intResult = session_->AddOutput(previewOutput);
3224     EXPECT_EQ(intResult, 0);
3225 
3226     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
3227     ASSERT_NE(metadatOutput, nullptr);
3228 
3229     intResult = session_->AddOutput(metadatOutput);
3230     EXPECT_EQ(intResult, 0);
3231 
3232     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput> &)metadatOutput;
3233 
3234     sptr<MetadataObjectListener> metaObjListener = new(std::nothrow) MetadataObjectListener(metaOutput);
3235     ASSERT_NE(metaObjListener, nullptr);
3236 
3237     metaObjListener->OnBufferAvailable();
3238 
3239     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::FACE});
3240 
3241     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
3242 
3243     sptr<CaptureOutput> metadatOutput_2 = manager_->CreateMetadataOutput();
3244     ASSERT_NE(metadatOutput_2, nullptr);
3245 
3246     intResult = metaOutput->Release();
3247     EXPECT_EQ(intResult, 0);
3248 
3249     sptr<MetadataOutput> metaOutput_2 = (sptr<MetadataOutput> &)metadatOutput_2;
3250 
3251     delete metaOutput_2;
3252 
3253     metadataObjectTypes = metaOutput_2->GetSupportedMetadataObjectTypes();
3254     EXPECT_EQ(metadataObjectTypes.empty(), true);
3255 
3256     intResult = metaOutput->Stop();
3257     EXPECT_EQ(intResult, 7400201);
3258 
3259     intResult = metaOutput->Release();
3260     EXPECT_EQ(intResult, 7400201);
3261 
3262     metaObjListener->OnBufferAvailable();
3263 
3264     sptr<MetadataOutput> metaOutput_3 = nullptr;
3265 
3266     sptr<MetadataObjectListener> metaObjListener_2 = new(std::nothrow) MetadataObjectListener(metaOutput_3);
3267     ASSERT_NE(metaObjListener_2, nullptr);
3268 
3269     metaObjListener_2->OnBufferAvailable();
3270 }
3271 
3272 /*
3273  * Feature: Framework
3274  * Function: Test anomalous branch.
3275  * SubFunction: NA
3276  * FunctionPoints: NA
3277  * EnvConditions: NA
3278  * CaseDescription: Test photoOutput with anomalous branch.
3279  */
3280 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_061, TestSize.Level0)
3281 {
3282     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
3283     PhotoCaptureSetting::QualityLevel quality = photoSetting->GetQuality();
3284     EXPECT_EQ(quality, PhotoCaptureSetting::QualityLevel::QUALITY_LEVEL_MEDIUM);
3285 
3286     photoSetting->SetQuality(PhotoCaptureSetting::QualityLevel::QUALITY_LEVEL_HIGH);
3287     photoSetting->SetQuality(quality);
3288 
3289     PhotoCaptureSetting::RotationConfig rotation = photoSetting->GetRotation();
3290     EXPECT_EQ(rotation, PhotoCaptureSetting::RotationConfig::Rotation_0);
3291 
3292     photoSetting->SetRotation(rotation);
3293 
3294     std::unique_ptr<Location> location = std::make_unique<Location>();
3295     location->latitude = 12.972442;
3296     location->longitude = 77.580643;
3297 
3298     photoSetting->SetGpsLocation(location->latitude, location->longitude);
3299 
3300     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3301     ASSERT_NE(camSession, nullptr);
3302 
3303     int32_t intResult = camSession->BeginConfig();
3304     EXPECT_EQ(intResult, 0);
3305 
3306     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3307     ASSERT_NE(input, nullptr);
3308 
3309     intResult = camSession->AddInput(input);
3310     EXPECT_EQ(intResult, 0);
3311 
3312     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3313     ASSERT_NE(previewOutput, nullptr);
3314 
3315     intResult = camSession->AddOutput(previewOutput);
3316     EXPECT_EQ(intResult, 0);
3317 
3318     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
3319     ASSERT_NE(photoOutput, nullptr);
3320 
3321     intResult = camSession->AddOutput(photoOutput);
3322     EXPECT_EQ(intResult, 0);
3323 
3324     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput> &)photoOutput;
3325 
3326     intResult = photoOutput_1->Capture(photoSetting);
3327     EXPECT_EQ(intResult, 7400104);
3328 
3329     intResult = camSession->CommitConfig();
3330     EXPECT_EQ(intResult, 0);
3331 
3332     bool isMirrorSupported = photoOutput_1->IsMirrorSupported();
3333     EXPECT_EQ(isMirrorSupported, true);
3334 
3335     int32_t capture = photoOutput_1->Capture();
3336     EXPECT_EQ(capture, 0);
3337 
3338     int32_t cancelCapture = photoOutput_1->CancelCapture();
3339     EXPECT_EQ(cancelCapture, 0);
3340 
3341     intResult = photoOutput_1->Release();
3342     EXPECT_EQ(intResult, 0);
3343 
3344     intResult = photoOutput_1->Release();
3345     EXPECT_EQ(intResult, 7400201);
3346 
3347     delete photoOutput_1;
3348 
3349     cancelCapture = photoOutput_1->CancelCapture();
3350     EXPECT_EQ(cancelCapture, 7400104);
3351 
3352     isMirrorSupported = photoOutput_1->IsMirrorSupported();
3353     EXPECT_EQ(isMirrorSupported, false);
3354 }
3355 
3356 /*
3357  * Feature: Framework
3358  * Function: Test anomalous branch.
3359  * SubFunction: NA
3360  * FunctionPoints: NA
3361  * EnvConditions: NA
3362  * CaseDescription: Test captureCallback with anomalous branch.
3363  */
3364 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_062, TestSize.Level0)
3365 {
3366     std::shared_ptr<HStreamCaptureCallbackImpl> captureCallback = std::make_shared<HStreamCaptureCallbackImpl>();
3367 
3368     int32_t captureId = 2001;
3369     int32_t intResult = captureCallback->OnCaptureStarted(captureId);
3370     EXPECT_EQ(intResult, 0);
3371 
3372     int32_t frameCount = 0;
3373     intResult = captureCallback->OnCaptureEnded(captureId, frameCount);
3374     EXPECT_EQ(intResult, 0);
3375 
3376     int32_t errorCode = 0;
3377     intResult = captureCallback->OnCaptureError(captureId, errorCode);
3378     EXPECT_EQ(intResult, 0);
3379 
3380     uint64_t timestamp = 10;
3381     intResult = captureCallback->OnFrameShutter(captureId, timestamp);
3382     EXPECT_EQ(intResult, 0);
3383 
3384     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3385     ASSERT_NE(camSession, nullptr);
3386 
3387     intResult = camSession->BeginConfig();
3388     EXPECT_EQ(intResult, 0);
3389 
3390     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3391     ASSERT_NE(input, nullptr);
3392 
3393     intResult = camSession->AddInput(input);
3394     EXPECT_EQ(intResult, 0);
3395 
3396     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3397     ASSERT_NE(previewOutput, nullptr);
3398 
3399     intResult = camSession->AddOutput(previewOutput);
3400     EXPECT_EQ(intResult, 0);
3401 
3402     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
3403     ASSERT_NE(photoOutput, nullptr);
3404 
3405     intResult = camSession->AddOutput(photoOutput);
3406     EXPECT_EQ(intResult, 0);
3407 
3408     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput> &)photoOutput;
3409 
3410     intResult = camSession->CommitConfig();
3411     EXPECT_EQ(intResult, 0);
3412 
3413     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
3414     photoOutput_1->SetCallback(callback);
3415 
3416     sptr<HStreamCaptureCallbackImpl> captureCallback_2 = new(std::nothrow) HStreamCaptureCallbackImpl(photoOutput_1);
3417 
3418     intResult = captureCallback_2->OnCaptureEnded(captureId, frameCount);
3419     EXPECT_EQ(intResult, 0);
3420 
3421     intResult = captureCallback_2->OnCaptureError(captureId, errorCode);
3422     EXPECT_EQ(intResult, 0);
3423 
3424     intResult = captureCallback_2->OnFrameShutter(captureId, timestamp);
3425     EXPECT_EQ(intResult, 0);
3426 }
3427 
3428 /*
3429  * Feature: Framework
3430  * Function: Test anomalous branch
3431  * SubFunction: NA
3432  * FunctionPoints: NA
3433  * EnvConditions: NA
3434  * CaseDescription: test preview output repeat callback with anomalous branch
3435  */
3436 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_063, TestSize.Level0)
3437 {
3438     std::shared_ptr<PreviewOutputCallbackImpl> repeatCallback = std::make_shared<PreviewOutputCallbackImpl>();
3439 
3440     int32_t intResult = repeatCallback->OnFrameStarted();
3441     EXPECT_EQ(intResult, 0);
3442 
3443     int32_t frameCount = 0;
3444     intResult = repeatCallback->OnFrameEnded(frameCount);
3445     EXPECT_EQ(intResult, 0);
3446 
3447     int32_t errorCode = 0;
3448     intResult = repeatCallback->OnFrameError(errorCode);
3449     EXPECT_EQ(intResult, 0);
3450 
3451     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3452     ASSERT_NE(camSession, nullptr);
3453 
3454     intResult = camSession->BeginConfig();
3455     EXPECT_EQ(intResult, 0);
3456 
3457     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3458     ASSERT_NE(input, nullptr);
3459 
3460     intResult = camSession->AddInput(input);
3461     EXPECT_EQ(intResult, 0);
3462 
3463     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3464     ASSERT_NE(previewOutput, nullptr);
3465 
3466     intResult = camSession->AddOutput(previewOutput);
3467     EXPECT_EQ(intResult, 0);
3468 
3469     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput> &)previewOutput;
3470 
3471     intResult = camSession->CommitConfig();
3472     EXPECT_EQ(intResult, 0);
3473 
3474     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
3475     previewOutput_1->SetCallback(callback);
3476 
3477     sptr<PreviewOutputCallbackImpl> repeatCallback_2 = new(std::nothrow) PreviewOutputCallbackImpl(previewOutput_1);
3478 
3479     intResult = repeatCallback_2->OnFrameError(errorCode);
3480     EXPECT_EQ(intResult, 0);
3481 }
3482 
3483 /*
3484  * Feature: Framework
3485  * Function: Test anomalous branch
3486  * SubFunction: NA
3487  * FunctionPoints: NA
3488  * EnvConditions: NA
3489  * CaseDescription: test preview output with anomalous branch
3490  */
3491 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_064, TestSize.Level0)
3492 {
3493     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3494     ASSERT_NE(camSession, nullptr);
3495 
3496     int32_t intResult = camSession->BeginConfig();
3497     EXPECT_EQ(intResult, 0);
3498 
3499     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3500     ASSERT_NE(input, nullptr);
3501 
3502     intResult = camSession->AddInput(input);
3503     EXPECT_EQ(intResult, 0);
3504 
3505     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3506     ASSERT_NE(previewOutput, nullptr);
3507 
3508     intResult = camSession->AddOutput(previewOutput);
3509     EXPECT_EQ(intResult, 0);
3510 
3511     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput> &)previewOutput;
3512 
3513     intResult = camSession->CommitConfig();
3514     EXPECT_EQ(intResult, 0);
3515 
3516     sptr<Surface> surface = nullptr;
3517 
3518     previewOutput_1->AddDeferredSurface(surface);
3519 
3520     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
3521     sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
3522     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(previewProducer);
3523 
3524     previewOutput_1->AddDeferredSurface(pSurface);
3525 
3526     intResult = previewOutput_1->CaptureOutput::Release();
3527     EXPECT_EQ(intResult, 0);
3528 
3529     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
3530     previewOutput_1->SetCallback(callback);
3531 
3532     intResult = previewOutput_1->Stop();
3533     EXPECT_EQ(intResult, 7400201);
3534 
3535     intResult = previewOutput_1->Release();
3536     EXPECT_EQ(intResult, 7400201);
3537 
3538     previewOutput_1->AddDeferredSurface(pSurface);
3539 }
3540 
3541 /*
3542  * Feature: Framework
3543  * Function: Test anomalous branch
3544  * SubFunction: NA
3545  * FunctionPoints: NA
3546  * EnvConditions: NA
3547  * CaseDescription: test video output with anomalous branch
3548  */
3549 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_065, TestSize.Level0)
3550 {
3551     int32_t intResult = session_->BeginConfig();
3552     EXPECT_EQ(intResult, 0);
3553 
3554     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3555     ASSERT_NE(input, nullptr);
3556 
3557     intResult = session_->AddInput(input);
3558     EXPECT_EQ(intResult, 0);
3559 
3560     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3561     ASSERT_NE(previewOutput, nullptr);
3562 
3563     intResult = session_->AddOutput(previewOutput);
3564     EXPECT_EQ(intResult, 0);
3565 
3566     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
3567     ASSERT_NE(videoOutput, nullptr);
3568 
3569     intResult = session_->AddOutput(videoOutput);
3570     EXPECT_EQ(intResult, 0);
3571 
3572     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput> &)videoOutput;
3573 
3574     std::shared_ptr<AppVideoCallback> callback = std::make_shared<AppVideoCallback>();
3575 
3576     intResult = videoOutput_1->Start();
3577     EXPECT_EQ(intResult, 7400103);
3578 
3579     intResult = session_->CommitConfig();
3580     EXPECT_EQ(intResult, 0);
3581 
3582     intResult = session_->Start();
3583     EXPECT_EQ(intResult, 0);
3584 
3585     sleep(WAIT_TIME_AFTER_START);
3586 
3587     sleep(WAIT_TIME_AFTER_START);
3588 
3589     intResult = videoOutput_1->Start();
3590     EXPECT_EQ(intResult, 0);
3591 
3592     sleep(WAIT_TIME_AFTER_START);
3593 
3594     intResult = videoOutput_1->Pause();
3595     EXPECT_EQ(intResult, 0);
3596 
3597     sleep(WAIT_TIME_AFTER_START);
3598 
3599     intResult = videoOutput_1->Resume();
3600     EXPECT_EQ(intResult, 0);
3601 
3602     intResult = videoOutput_1->Stop();
3603     EXPECT_EQ(intResult, 0);
3604 
3605     intResult = videoOutput_1->CaptureOutput::Release();
3606     EXPECT_EQ(intResult, 0);
3607 
3608     videoOutput_1->SetCallback(callback);
3609 
3610     intResult = videoOutput_1->Pause();
3611     EXPECT_EQ(intResult, 7400201);
3612 
3613     intResult = videoOutput_1->Resume();
3614     EXPECT_EQ(intResult, 7400201);
3615 
3616     intResult = videoOutput_1->Stop();
3617     EXPECT_EQ(intResult, 7400201);
3618 
3619     intResult = videoOutput_1->Release();
3620     EXPECT_EQ(intResult, 7400201);
3621 }
3622 
3623 /*
3624  * Feature: Framework
3625  * Function: Test anomalous branch
3626  * SubFunction: NA
3627  * FunctionPoints: NA
3628  * EnvConditions: NA
3629  * CaseDescription: test video output repeat callback with anomalous branch
3630  */
3631 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_066, TestSize.Level0)
3632 {
3633     std::shared_ptr<VideoOutputCallbackImpl> repeatCallback = std::make_shared<VideoOutputCallbackImpl>();
3634 
3635     int32_t intResult = repeatCallback->OnFrameStarted();
3636     EXPECT_EQ(intResult, 0);
3637 
3638     int32_t frameCount = 0;
3639     intResult = repeatCallback->OnFrameEnded(frameCount);
3640     EXPECT_EQ(intResult, 0);
3641 
3642     int32_t errorCode = 0;
3643     intResult = repeatCallback->OnFrameError(errorCode);
3644     EXPECT_EQ(intResult, 0);
3645 
3646     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
3647     ASSERT_NE(camSession, nullptr);
3648 
3649     intResult = camSession->BeginConfig();
3650     EXPECT_EQ(intResult, 0);
3651 
3652     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
3653     ASSERT_NE(input, nullptr);
3654 
3655     intResult = camSession->AddInput(input);
3656     EXPECT_EQ(intResult, 0);
3657 
3658     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3659     ASSERT_NE(previewOutput, nullptr);
3660 
3661     intResult = camSession->AddOutput(previewOutput);
3662     EXPECT_EQ(intResult, 0);
3663 
3664     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
3665     ASSERT_NE(videoOutput, nullptr);
3666 
3667     intResult = camSession->AddOutput(videoOutput);
3668     EXPECT_EQ(intResult, 0);
3669 
3670     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput> &)videoOutput;
3671 
3672     intResult = camSession->CommitConfig();
3673     EXPECT_EQ(intResult, 0);
3674 
3675     std::shared_ptr<AppVideoCallback> callback = std::make_shared<AppVideoCallback>();
3676     videoOutput_1->SetCallback(callback);
3677 
3678     sptr<VideoOutputCallbackImpl> repeatCallback_2 = new(std::nothrow) VideoOutputCallbackImpl(videoOutput_1);
3679 
3680     intResult = repeatCallback->OnFrameStarted();
3681     EXPECT_EQ(intResult, 0);
3682 
3683     intResult = repeatCallback->OnFrameEnded(frameCount);
3684     EXPECT_EQ(intResult, 0);
3685 
3686     intResult = repeatCallback_2->OnFrameError(errorCode);
3687     EXPECT_EQ(intResult, 0);
3688 }
3689 
3690 /*
3691  * Feature: Framework
3692  * Function: Test anomalous branch
3693  * SubFunction: NA
3694  * FunctionPoints: NA
3695  * EnvConditions: NA
3696  * CaseDescription: test HCameraDeviceProxy_cpp with anomalous branch
3697  */
3698 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_067, TestSize.Level0)
3699 {
3700     sptr<CameraInput> input_1 = (sptr<CameraInput> &)input_;
3701     sptr<ICameraDeviceService> deviceObj = input_1->GetCameraDevice();
3702     ASSERT_NE(deviceObj, nullptr);
3703 
3704     sptr<ICameraDeviceServiceCallback> callback = nullptr;
3705     int32_t intResult = deviceObj->SetCallback(callback);
3706     EXPECT_EQ(intResult, 200);
3707 
3708     std::shared_ptr<Camera::CameraMetadata> settings = nullptr;
3709     intResult = deviceObj->UpdateSetting(settings);
3710     EXPECT_EQ(intResult, 200);
3711 
3712     std::vector<int32_t> results = {};
3713     intResult = deviceObj->GetEnabledResults(results);
3714     EXPECT_EQ(intResult, 0);
3715 
3716     intResult = deviceObj->EnableResult(results);
3717     EXPECT_EQ(intResult, 2);
3718 
3719     intResult = deviceObj->DisableResult(results);
3720     EXPECT_EQ(intResult, 2);
3721 }
3722 
3723 /*
3724  * Feature: Framework
3725  * Function: Test anomalous branch
3726  * SubFunction: NA
3727  * FunctionPoints: NA
3728  * EnvConditions: NA
3729  * CaseDescription: test HCameraServiceProxy_cpp with anomalous branch
3730  */
3731 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_068, TestSize.Level0)
3732 {
3733     sptr<IRemoteObject> object = nullptr;
3734     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3735     ASSERT_NE(samgr, nullptr);
3736 
3737     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
3738     sptr<ICameraService> serviceProxy = iface_cast<ICameraService>(object);
3739     ASSERT_NE(serviceProxy, nullptr);
3740 
3741     sptr<ICameraServiceCallback> callback = nullptr;
3742     int32_t intResult = serviceProxy->SetCallback(callback);
3743     EXPECT_EQ(intResult, 200);
3744 
3745     sptr<ICameraMuteServiceCallback> callback_2 = nullptr;
3746     intResult = serviceProxy->SetMuteCallback(callback_2);
3747     EXPECT_EQ(intResult, 200);
3748 
3749     int32_t format = 0;
3750     int32_t width = 0;
3751     int32_t height = 0;
3752     sptr<IStreamCapture> output = nullptr;
3753     sptr<IBufferProducer> Producer = nullptr;
3754     intResult = serviceProxy->CreatePhotoOutput(Producer, format, width, height, output);
3755     EXPECT_EQ(intResult, 200);
3756 
3757     sptr<IStreamRepeat> output_2 = nullptr;
3758     intResult = serviceProxy->CreatePreviewOutput(Producer, format, width, height, output_2);
3759     EXPECT_EQ(intResult, 200);
3760 
3761     intResult = serviceProxy->CreateDeferredPreviewOutput(format, width, height, output_2);
3762     EXPECT_EQ(intResult, 200);
3763 
3764     sptr<IStreamMetadata> output_3 = nullptr;
3765     intResult = serviceProxy->CreateMetadataOutput(Producer, format, output_3);
3766     EXPECT_EQ(intResult, 200);
3767 
3768     intResult = serviceProxy->CreateVideoOutput(Producer, format, width, height, output_2);
3769     EXPECT_EQ(intResult, 200);
3770 }
3771 
3772 /*
3773  * Feature: Framework
3774  * Function: Test anomalous branch
3775  * SubFunction: NA
3776  * FunctionPoints: NA
3777  * EnvConditions: NA
3778  * CaseDescription: test HCameraServiceProxy_cpp with anomalous branch
3779  */
3780 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_069, TestSize.Level0)
3781 {
3782     int32_t format = 0;
3783     int32_t width = 0;
3784     int32_t height = 0;
3785     std::string cameraId = "";
3786     std::vector<std::string> cameraIds = {};
3787     std::vector<std::shared_ptr<Camera::CameraMetadata>> cameraAbilityList = {};
3788 
3789     sptr<IConsumerSurface> Surface = IConsumerSurface::Create();
3790     sptr<IBufferProducer> Producer = Surface->GetProducer();
3791 
3792     sptr<IRemoteObject> object = nullptr;
3793     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3794     ASSERT_NE(samgr, nullptr);
3795 
3796     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
3797     sptr<ICameraService> serviceProxy = iface_cast<ICameraService>(object);
3798     ASSERT_NE(serviceProxy, nullptr);
3799 
3800     sptr<ICameraServiceCallback> callback = new(std::nothrow) CameraStatusServiceCallback(manager_);
3801     int32_t intResult = serviceProxy->SetCallback(callback);
3802     EXPECT_EQ(intResult, -1);
3803 
3804     sptr<ICameraMuteServiceCallback> callback_2 = new(std::nothrow) CameraMuteServiceCallback(manager_);
3805     serviceProxy->SetMuteCallback(callback_2);
3806     EXPECT_EQ(intResult, -1);
3807 
3808     intResult = serviceProxy->GetCameras(cameraIds, cameraAbilityList);
3809     EXPECT_EQ(intResult, -1);
3810 
3811     sptr<ICaptureSession> session = nullptr;
3812     intResult = serviceProxy->CreateCaptureSession(session);
3813     EXPECT_EQ(intResult, -1);
3814 
3815     sptr<IStreamCapture> output = nullptr;
3816     intResult = serviceProxy->CreatePhotoOutput(Producer, format, width, height, output);
3817     EXPECT_EQ(intResult, -1);
3818 
3819     width = PREVIEW_DEFAULT_WIDTH;
3820     height = PREVIEW_DEFAULT_HEIGHT;
3821     sptr<IStreamRepeat> output_2 = nullptr;
3822     intResult = serviceProxy->CreatePreviewOutput(Producer, format, width, height, output_2);
3823     EXPECT_EQ(intResult, -1);
3824 
3825     intResult = serviceProxy->CreateDeferredPreviewOutput(format, width, height, output_2);
3826     EXPECT_EQ(intResult, -1);
3827 
3828     sptr<IStreamMetadata> output_3 = nullptr;
3829     intResult = serviceProxy->CreateMetadataOutput(Producer, format, output_3);
3830     EXPECT_EQ(intResult, -1);
3831 
3832     intResult = serviceProxy->CreateVideoOutput(Producer, format, width, height, output_2);
3833     EXPECT_EQ(intResult, -1);
3834 
3835     intResult = serviceProxy->SetListenerObject(object);
3836     EXPECT_EQ(intResult, 200);
3837 
3838     bool muteMode = true;
3839     intResult = serviceProxy->IsCameraMuted(muteMode);
3840     EXPECT_EQ(intResult, -1);
3841 }
3842 
3843 /*
3844  * Feature: Framework
3845  * Function: Test anomalous branch
3846  * SubFunction: NA
3847  * FunctionPoints: NA
3848  * EnvConditions: NA
3849  * CaseDescription: test HCameraDeviceProxy_cpp with anomalous branch
3850  */
3851 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_070, TestSize.Level0)
3852 {
3853     sptr<IRemoteObject> object = nullptr;
3854     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3855     ASSERT_NE(samgr, nullptr);
3856 
3857     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
3858 
3859     sptr<ICameraDeviceService> deviceObj = iface_cast<ICameraDeviceService>(object);
3860     ASSERT_NE(deviceObj, nullptr);
3861 
3862     int32_t intResult = deviceObj->Open();
3863     EXPECT_EQ(intResult, -1);
3864 
3865     intResult = deviceObj->Close();
3866     EXPECT_EQ(intResult, -1);
3867 
3868     intResult = deviceObj->Release();
3869     EXPECT_EQ(intResult, -1);
3870 
3871     sptr<CameraInput> input = (sptr<CameraInput> &)input_;
3872     sptr<ICameraDeviceServiceCallback> callback = new(std::nothrow) CameraDeviceServiceCallback(input);
3873     ASSERT_NE(callback, nullptr);
3874 
3875     intResult = deviceObj->SetCallback(callback);
3876     EXPECT_EQ(intResult, -1);
3877 
3878     std::shared_ptr<Camera::CameraMetadata> settings = cameras_[0]->GetMetadata();
3879     ASSERT_NE(settings, nullptr);
3880 
3881     intResult = deviceObj->UpdateSetting(settings);
3882     EXPECT_EQ(intResult, -1);
3883 
3884     std::vector<int32_t> results = {};
3885     intResult = deviceObj->GetEnabledResults(results);
3886     EXPECT_EQ(intResult, 200);
3887 }
3888 
3889 /*
3890  * Feature: Framework
3891  * Function: Test anomalous branch
3892  * SubFunction: NA
3893  * FunctionPoints: NA
3894  * EnvConditions: NA
3895  * CaseDescription: test HCaptureSessionProxy_cpp with anomalous branch
3896  */
3897 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_071, TestSize.Level0)
3898 {
3899     sptr<IRemoteObject> object = nullptr;
3900     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3901     ASSERT_NE(samgr, nullptr);
3902 
3903     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
3904 
3905     sptr<ICaptureSession> captureSession = iface_cast<ICaptureSession>(object);
3906     ASSERT_NE(captureSession, nullptr);
3907 
3908     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3909     ASSERT_NE(previewOutput, nullptr);
3910 
3911     sptr<IStreamCommon> stream = nullptr;
3912 
3913     int32_t intResult = captureSession->AddOutput(previewOutput->GetStreamType(), stream);
3914     EXPECT_EQ(intResult, 200);
3915 
3916     sptr<ICameraDeviceService> cameraDevice = nullptr;
3917     intResult = captureSession->RemoveInput(cameraDevice);
3918     EXPECT_EQ(intResult, 200);
3919 
3920     intResult = captureSession->RemoveOutput(previewOutput->GetStreamType(), stream);
3921     EXPECT_EQ(intResult, 200);
3922 
3923     sptr<ICaptureSessionCallback> callback = nullptr;
3924     EXPECT_EQ(intResult, 200);
3925 }
3926 
3927 /*
3928  * Feature: Framework
3929  * Function: Test anomalous branch
3930  * SubFunction: NA
3931  * FunctionPoints: NA
3932  * EnvConditions: NA
3933  * CaseDescription: test HCaptureSessionProxy_cpp with anomalous branch
3934  */
3935 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_072, TestSize.Level0)
3936 {
3937     sptr<IRemoteObject> object = nullptr;
3938     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3939     ASSERT_NE(samgr, nullptr);
3940 
3941     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
3942 
3943     sptr<ICaptureSession> captureSession = iface_cast<ICaptureSession>(object);
3944     ASSERT_NE(captureSession, nullptr);
3945 
3946     int32_t intResult = captureSession->BeginConfig();
3947     EXPECT_EQ(intResult, -1);
3948 
3949     sptr<CameraInput> input_1 = (sptr<CameraInput> &)input_;
3950     sptr<ICameraDeviceService> deviceObj = input_1->GetCameraDevice();
3951     ASSERT_NE(deviceObj, nullptr);
3952 
3953     intResult = captureSession->AddInput(deviceObj);
3954     EXPECT_EQ(intResult, -1);
3955 
3956     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
3957     ASSERT_NE(previewOutput, nullptr);
3958 
3959     intResult = captureSession->AddOutput(previewOutput->GetStreamType(), previewOutput->GetStream());
3960     EXPECT_EQ(intResult, -1);
3961 
3962     intResult = captureSession->Start();
3963     EXPECT_EQ(intResult, -1);
3964 
3965     pid_t pid = 0;
3966     intResult = captureSession->Release(pid);
3967     EXPECT_EQ(intResult, -1);
3968 
3969     sptr<ICaptureSessionCallback> callback = new(std::nothrow) CaptureSessionCallback(session_);
3970     ASSERT_NE(callback, nullptr);
3971 
3972     intResult = captureSession->SetCallback(callback);
3973     EXPECT_EQ(intResult, -1);
3974 
3975     CaptureSessionState currentState = CaptureSessionState::SESSION_CONFIG_INPROGRESS;
3976     intResult = captureSession->GetSessionState(currentState);
3977     EXPECT_EQ(intResult, -1);
3978 }
3979 
3980 /*
3981  * Feature: Framework
3982  * Function: Test anomalous branch
3983  * SubFunction: NA
3984  * FunctionPoints: NA
3985  * EnvConditions: NA
3986  * CaseDescription: test HStreamCaptureProxy_cpp with anomalous branch
3987  */
3988 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_073, TestSize.Level0)
3989 {
3990     sptr<IRemoteObject> object = nullptr;
3991     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
3992     ASSERT_NE(samgr, nullptr);
3993 
3994     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
3995 
3996     sptr<IStreamCapture> capture = iface_cast<IStreamCapture>(object);
3997     ASSERT_NE(capture, nullptr);
3998 
3999     sptr<IStreamCaptureCallback> callback = nullptr;
4000     int32_t intResult = capture->SetCallback(callback);
4001     EXPECT_EQ(intResult, 200);
4002 
4003     bool isEnabled = false;
4004     sptr<OHOS::IBufferProducer> producer = nullptr;
4005     intResult = capture->SetThumbnail(isEnabled, producer);
4006     EXPECT_EQ(intResult, 200);
4007 
4008     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
4009     producer = previewSurface->GetProducer();
4010 
4011     intResult = capture->SetThumbnail(isEnabled, producer);
4012     EXPECT_EQ(intResult, -1);
4013 
4014     std::shared_ptr<Camera::CameraMetadata> captureSettings = nullptr;
4015     intResult = capture->Capture(captureSettings);
4016     EXPECT_EQ(intResult, 200);
4017 }
4018 
4019 /*
4020  * Feature: Framework
4021  * Function: Test anomalous branch
4022  * SubFunction: NA
4023  * FunctionPoints: NA
4024  * EnvConditions: NA
4025  * CaseDescription: test HStreamCaptureProxy_cpp with anomalous branch
4026  */
4027 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_074, TestSize.Level0)
4028 {
4029     sptr<IRemoteObject> object = nullptr;
4030     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
4031     ASSERT_NE(samgr, nullptr);
4032 
4033     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
4034 
4035     sptr<IStreamCapture> capture = iface_cast<IStreamCapture>(object);
4036     ASSERT_NE(capture, nullptr);
4037 
4038     std::shared_ptr<Camera::CameraMetadata> captureSettings = cameras_[0]->GetMetadata();
4039     int32_t intResult = capture->Capture(captureSettings);
4040     EXPECT_EQ(intResult, -1);
4041 
4042     intResult = capture->CancelCapture();
4043     EXPECT_EQ(intResult, -1);
4044 
4045     intResult = capture->Release();
4046     EXPECT_EQ(intResult, -1);
4047 
4048     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
4049     ASSERT_NE(photoOutput, nullptr);
4050 
4051     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput> &)photoOutput;
4052     sptr<IStreamCaptureCallback> callback = new(std::nothrow) HStreamCaptureCallbackImpl(photoOutput_1);
4053     ASSERT_NE(callback, nullptr);
4054 
4055     intResult = capture->SetCallback(callback);
4056     EXPECT_EQ(intResult, -1);
4057 }
4058 
4059 /*
4060  * Feature: Framework
4061  * Function: Test anomalous branch
4062  * SubFunction: NA
4063  * FunctionPoints: NA
4064  * EnvConditions: NA
4065  * CaseDescription: test HStreamMetadataProxy_cpp with anomalous branch
4066  */
4067 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_075, TestSize.Level0)
4068 {
4069     sptr<IRemoteObject> object = nullptr;
4070     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
4071     ASSERT_NE(samgr, nullptr);
4072 
4073     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
4074 
4075     sptr<IStreamMetadata> metadata = iface_cast<IStreamMetadata>(object);
4076     ASSERT_NE(metadata, nullptr);
4077 
4078     int32_t intResult = metadata->Start();
4079     EXPECT_EQ(intResult, -1);
4080 
4081     intResult = metadata->Release();
4082     EXPECT_EQ(intResult, -1);
4083 }
4084 
4085 /*
4086  * Feature: Framework
4087  * Function: Test anomalous branch
4088  * SubFunction: NA
4089  * FunctionPoints: NA
4090  * EnvConditions: NA
4091  * CaseDescription: test HStreamRepeatProxy_cpp with anomalous branch
4092  */
4093 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_076, TestSize.Level0)
4094 {
4095     sptr<IRemoteObject> object = nullptr;
4096     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
4097     ASSERT_NE(samgr, nullptr);
4098 
4099     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
4100 
4101     sptr<IStreamRepeat> repeat = iface_cast<IStreamRepeat>(object);
4102     ASSERT_NE(repeat, nullptr);
4103 
4104     sptr<IStreamRepeatCallback> callback = nullptr;
4105     int32_t intResult = repeat->SetCallback(callback);
4106     EXPECT_EQ(intResult, 200);
4107 
4108     sptr<OHOS::IBufferProducer> producer = nullptr;
4109     intResult = repeat->AddDeferredSurface(producer);
4110     EXPECT_EQ(intResult, 200);
4111 
4112     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
4113 
4114     repeat = iface_cast<IStreamRepeat>(object);
4115     ASSERT_NE(repeat, nullptr);
4116 
4117     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4118     ASSERT_NE(previewOutput, nullptr);
4119 
4120     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput> &)previewOutput;
4121     callback = new(std::nothrow) PreviewOutputCallbackImpl(previewOutput_1);
4122     ASSERT_NE(callback, nullptr);
4123 
4124     intResult = repeat->SetCallback(callback);
4125     EXPECT_EQ(intResult, -1);
4126 
4127     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
4128     producer = previewSurface->GetProducer();
4129 
4130     intResult = repeat->AddDeferredSurface(producer);
4131     EXPECT_EQ(intResult, -1);
4132 }
4133 
4134 /*
4135  * Feature: Framework
4136  * Function: Test anomalous branch
4137  * SubFunction: NA
4138  * FunctionPoints: NA
4139  * EnvConditions: NA
4140  * CaseDescription: test set the Thumbnail with anomalous branch
4141  */
4142 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_077, TestSize.Level0)
4143 {
4144     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4145     ASSERT_NE(camSession, nullptr);
4146 
4147     int32_t intResult = camSession->BeginConfig();
4148     EXPECT_EQ(intResult, 0);
4149 
4150     sptr<CaptureInput> input = (sptr<CaptureInput> &)input_;
4151     ASSERT_NE(input, nullptr);
4152 
4153     intResult = camSession->AddInput(input);
4154     EXPECT_EQ(intResult, 0);
4155 
4156     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4157     ASSERT_NE(previewOutput, nullptr);
4158 
4159     intResult = camSession->AddOutput(previewOutput);
4160     EXPECT_EQ(intResult, 0);
4161 
4162     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
4163     ASSERT_NE(photoOutput, nullptr);
4164 
4165     intResult = camSession->AddOutput(photoOutput);
4166     EXPECT_EQ(intResult, 0);
4167 
4168     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput> &)photoOutput;
4169 
4170     intResult = camSession->CommitConfig();
4171     EXPECT_EQ(intResult, 0);
4172 
4173     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
4174     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
4175     sptr<IBufferConsumerListener> listener_1 = (sptr<IBufferConsumerListener> &)listener;
4176 
4177     photoOutput_1->SetThumbnailListener(listener_1);
4178 
4179     intResult = photoOutput_1->IsQuickThumbnailSupported();
4180     EXPECT_EQ(intResult, -1);
4181 
4182     bool isEnabled = false;
4183     intResult = photoOutput_1->SetThumbnail(isEnabled);
4184     EXPECT_EQ(intResult, 0);
4185 
4186     photoOutput_1->SetThumbnailListener(listener_1);
4187 
4188     intResult = photoOutput_1->Release();
4189     EXPECT_EQ(intResult, 0);
4190 
4191     photoOutput_1->~PhotoOutput();
4192 
4193     intResult = photoOutput_1->IsQuickThumbnailSupported();
4194     EXPECT_EQ(intResult, 7400104);
4195 
4196     intResult = photoOutput_1->SetThumbnail(isEnabled);
4197     EXPECT_EQ(intResult, 7400104);
4198 }
4199 
4200 /*
4201  * Feature: Framework
4202  * Function: Test anomalous branch
4203  * SubFunction: NA
4204  * FunctionPoints: NA
4205  * EnvConditions: NA
4206  * CaseDescription: test submit device control setting with anomalous branch
4207  */
4208 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_079, TestSize.Level0)
4209 {
4210     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4211     ASSERT_NE(camSession, nullptr);
4212     delete camSession;
4213 
4214     int32_t intResult = camSession->UnlockForControl();
4215     EXPECT_EQ(intResult, 7400201);
4216 }
4217 
4218 /*
4219  * Feature: Framework
4220  * Function: Test anomalous branch
4221  * SubFunction: NA
4222  * FunctionPoints: NA
4223  * EnvConditions: NA
4224  * CaseDescription: test MuteCamera with anomalous branch
4225  */
4226 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_080, TestSize.Level0)
4227 {
4228     bool cameraMuted = manager_->IsCameraMuted();
4229     EXPECT_EQ(cameraMuted, false);
4230 
4231     bool cameraMuteSupported = manager_->IsCameraMuteSupported();
4232     EXPECT_EQ(cameraMuteSupported, false);
4233 
4234     manager_->MuteCamera(cameraMuted);
4235 
4236     sptr<CameraMuteServiceCallback> muteService = new(std::nothrow) CameraMuteServiceCallback();
4237     ASSERT_NE(muteService, nullptr);
4238 
4239     int32_t muteCameraState = muteService->OnCameraMute(cameraMuted);
4240     EXPECT_EQ(muteCameraState, 0);
4241 
4242     muteService = new(std::nothrow) CameraMuteServiceCallback(manager_);
4243     ASSERT_NE(muteService, nullptr);
4244 
4245     muteCameraState = muteService->OnCameraMute(cameraMuted);
4246     EXPECT_EQ(muteCameraState, 0);
4247 
4248     std::shared_ptr<CameraMuteListener> listener = nullptr;
4249     manager_->RegisterCameraMuteListener(listener);
4250 }
4251 
4252 /*
4253  * Feature: Framework
4254  * Function: Test anomalous branch
4255  * SubFunction: NA
4256  * FunctionPoints: NA
4257  * EnvConditions: NA
4258  * CaseDescription: test service callback with anomalous branch
4259  */
4260 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_081, TestSize.Level0)
4261 {
4262     std::string cameraIdtest = "";
4263     FlashStatus status = FLASH_STATUS_OFF;
4264 
4265     sptr<CameraStatusServiceCallback> camServiceCallback = new(std::nothrow) CameraStatusServiceCallback();
4266     int32_t cameraStatusChanged = camServiceCallback->OnFlashlightStatusChanged(cameraIdtest, status);
4267     EXPECT_EQ(cameraStatusChanged, 0);
4268 
4269     sptr<CameraDeviceServiceCallback> camDeviceSvcCallback = new(std::nothrow) CameraDeviceServiceCallback();
4270     int32_t onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
4271     EXPECT_EQ(onError, 0);
4272 
4273     std::shared_ptr<OHOS::Camera::CameraMetadata> result = nullptr;
4274     int32_t onResult = camDeviceSvcCallback->OnResult(0, result);
4275     EXPECT_EQ(onResult, 0);
4276 
4277     sptr<CameraInput> input = (sptr<CameraInput> &)input_;
4278     sptr<ICameraDeviceService> deviceObj = input->GetCameraDevice();
4279     ASSERT_NE(deviceObj, nullptr);
4280 
4281     sptr<CameraDevice> camdeviceObj = nullptr;
4282     sptr<CameraInput> camInput_1 = new(std::nothrow) CameraInput(deviceObj, camdeviceObj);
4283     ASSERT_NE(camInput_1, nullptr);
4284 
4285     camDeviceSvcCallback = new(std::nothrow) CameraDeviceServiceCallback(camInput_1);
4286     onResult = camDeviceSvcCallback->OnResult(0, result);
4287     EXPECT_EQ(onResult, 0);
4288 
4289     sptr<CameraInput> camInput_2 = new(std::nothrow) CameraInput(deviceObj, cameras_[0]);
4290     camDeviceSvcCallback = new(std::nothrow) CameraDeviceServiceCallback(camInput_2);
4291     onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
4292     EXPECT_EQ(onError, 0);
4293 
4294     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
4295     camInput_2->SetErrorCallback(callback);
4296 
4297     camDeviceSvcCallback = new(std::nothrow) CameraDeviceServiceCallback(camInput_2);
4298     onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
4299     EXPECT_EQ(onError, 0);
4300 
4301     callback = nullptr;
4302     camInput_2->SetErrorCallback(callback);
4303     camInput_2->SetResultCallback(callback);
4304 }
4305 
4306 /*
4307  * Feature: Framework
4308  * Function: Test anomalous branch
4309  * SubFunction: NA
4310  * FunctionPoints: NA
4311  * EnvConditions: NA
4312  * CaseDescription: test create camera input instance with provided camera position and type anomalous branch
4313  */
4314 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_082, TestSize.Level0)
4315 {
4316     CameraPosition cameraPosition = cameras_[0]->GetPosition();
4317     CameraType cameraType = cameras_[0]->GetCameraType();
4318     sptr<CaptureInput> camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
4319     EXPECT_EQ(camInputtest, nullptr);
4320 
4321     cameraType = CAMERA_TYPE_UNSUPPORTED;
4322     cameraPosition = CAMERA_POSITION_UNSPECIFIED;
4323     camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
4324     EXPECT_EQ(camInputtest, nullptr);
4325 
4326     cameraType = CAMERA_TYPE_UNSUPPORTED;
4327     cameraPosition = cameras_[0]->GetPosition();
4328     camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
4329     EXPECT_EQ(camInputtest, nullptr);
4330 }
4331 
4332 /*
4333  * Feature: Framework
4334  * Function: Test anomalous branch
4335  * SubFunction: NA
4336  * FunctionPoints: NA
4337  * EnvConditions: NA
4338  * CaseDescription: test the supported exposure compensation range and Zoom Ratio range with anomalous branch
4339  */
4340 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_083, TestSize.Level0)
4341 {
4342     std::string cameraId = "";
4343     dmDeviceInfo deviceInfo = {};
4344     sptr<CameraDevice> camdeviceObj = new(std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
4345     ASSERT_NE(camdeviceObj, nullptr);
4346 
4347     std::vector<float> zoomRatioRange = camdeviceObj->GetZoomRatioRange();
4348     EXPECT_EQ(zoomRatioRange.empty(), true);
4349 
4350     std::vector<float> exposureBiasRange = camdeviceObj->GetExposureBiasRange();
4351     EXPECT_EQ(exposureBiasRange.empty(), true);
4352 }
4353 
4354 /*
4355  * Feature: Framework
4356  * Function: Test anomalous branch
4357  * SubFunction: NA
4358  * FunctionPoints: NA
4359  * EnvConditions: NA
4360  * CaseDescription: test session with anomalous branch
4361  */
4362 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_084, TestSize.Level0)
4363 {
4364     sptr<ICameraDeviceService> deviceObj = nullptr;
4365     sptr<CaptureInput> camInput = new(std::nothrow) CameraInput(deviceObj, cameras_[0]);
4366     ASSERT_NE(camInput, nullptr);
4367 
4368     int32_t intResult = session_->BeginConfig();
4369     EXPECT_EQ(intResult, 0);
4370 
4371     intResult = session_->BeginConfig();
4372     EXPECT_EQ(intResult, 7400105);
4373 
4374     intResult = session_->AddInput(camInput);
4375     EXPECT_EQ(intResult, 7400201);
4376 
4377     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4378     ASSERT_NE(camSession, nullptr);
4379     delete camSession;
4380 
4381     intResult = camSession->BeginConfig();
4382     EXPECT_EQ(intResult, 7400201);
4383 }
4384 
4385 /*
4386  * Feature: Framework
4387  * Function: Test anomalous branch
4388  * SubFunction: NA
4389  * FunctionPoints: NA
4390  * EnvConditions: NA
4391  * CaseDescription: test create preview output with anomalous branch
4392  */
4393 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_085, TestSize.Level0)
4394 {
4395     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
4396     sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
4397     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(previewProducer);
4398 
4399     sptr<Surface> pSurface_1 = nullptr;
4400 
4401     sptr<CaptureOutput> previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface_1);
4402     EXPECT_EQ(previewOutput, nullptr);
4403 
4404     sptr<CaptureOutput> previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
4405     ASSERT_NE(previewOutput_1, nullptr);
4406 
4407     // height is zero
4408     CameraFormat previewFormat = previewProfiles[0].GetCameraFormat();
4409     Size previewSize;
4410     previewSize.width = previewProfiles[0].GetSize().width;
4411     previewSize.height = 0;
4412     previewProfiles[0] = Profile(previewFormat, previewSize);
4413 
4414     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
4415     EXPECT_EQ(previewOutput, nullptr);
4416 
4417     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
4418     EXPECT_EQ(previewOutput_1, nullptr);
4419 
4420     sptr<CaptureOutput> previewOutput_2 = manager_->CreatePreviewOutput(previewProducer, previewFormat);
4421     EXPECT_EQ(previewOutput_2, nullptr);
4422 
4423     sptr<CaptureOutput> previewOutput_3 = nullptr;
4424     previewOutput_3 = manager_->CreateCustomPreviewOutput(pSurface, previewSize.width, previewSize.height);
4425     EXPECT_EQ(previewOutput_3, nullptr);
4426 
4427     // width is zero
4428     previewSize.width = 0;
4429     previewSize.height = PREVIEW_DEFAULT_HEIGHT;
4430     previewProfiles[0] = Profile(previewFormat, previewSize);
4431 
4432     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
4433     EXPECT_EQ(previewOutput, nullptr);
4434 
4435     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
4436     EXPECT_EQ(previewOutput_1, nullptr);
4437 
4438     // format is CAMERA_FORMAT_INVALID
4439     previewFormat = CAMERA_FORMAT_INVALID;
4440     previewSize.width = PREVIEW_DEFAULT_WIDTH;
4441     previewProfiles[0] = Profile(previewFormat, previewSize);
4442 
4443     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
4444     EXPECT_EQ(previewOutput, nullptr);
4445 
4446     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
4447     EXPECT_EQ(previewOutput_1, nullptr);
4448 }
4449 
4450 /*
4451  * Feature: Framework
4452  * Function: Test anomalous branch
4453  * SubFunction: NA
4454  * FunctionPoints: NA
4455  * EnvConditions: NA
4456  * CaseDescription: test create photo output with anomalous branch
4457  */
4458 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_086, TestSize.Level0)
4459 {
4460     sptr<IConsumerSurface> photosurface = IConsumerSurface::Create();
4461     sptr<IBufferProducer> surfaceProducer_1 = photosurface->GetProducer();
4462 
4463     sptr<IBufferProducer> surfaceProducer_2 = nullptr;
4464 
4465     sptr<CaptureOutput> photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_2);
4466     EXPECT_EQ(photoOutput, nullptr);
4467 
4468     // height is zero
4469     CameraFormat photoFormat = photoProfiles[0].GetCameraFormat();
4470     Size photoSize;
4471     photoSize.width = photoProfiles[0].GetSize().width;
4472     photoSize.height = 0;
4473     photoProfiles[0] = Profile(photoFormat, photoSize);
4474 
4475     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
4476     EXPECT_EQ(photoOutput, nullptr);
4477 
4478     // width is zero
4479     photoSize.width = 0;
4480     photoSize.height = PHOTO_DEFAULT_HEIGHT;
4481     photoProfiles[0] = Profile(photoFormat, photoSize);
4482 
4483     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
4484     EXPECT_EQ(photoOutput, nullptr);
4485 
4486     // format is CAMERA_FORMAT_INVALID
4487     photoFormat = CAMERA_FORMAT_INVALID;
4488     photoSize.width = PHOTO_DEFAULT_WIDTH;
4489     photoProfiles[0] = Profile(photoFormat, photoSize);
4490 
4491     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
4492     EXPECT_EQ(photoOutput, nullptr);
4493 }
4494 
4495 /*
4496  * Feature: Framework
4497  * Function: Test anomalous branch
4498  * SubFunction: NA
4499  * FunctionPoints: NA
4500  * EnvConditions: NA
4501  * CaseDescription: test create video output with anomalous branch
4502  */
4503 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_087, TestSize.Level0)
4504 {
4505     sptr<IConsumerSurface> videoSurface = IConsumerSurface::Create();
4506     sptr<IBufferProducer> videoProducer = videoSurface->GetProducer();
4507     sptr<Surface> pSurface_1 = Surface::CreateSurfaceAsProducer(videoProducer);
4508 
4509     sptr<Surface> pSurface_2 = nullptr;
4510 
4511     sptr<CaptureOutput> videoOutput = manager_->CreateVideoOutput(videoProfiles[0], pSurface_2);
4512     EXPECT_EQ(videoOutput, nullptr);
4513 
4514     sptr<CaptureOutput> videoOutput_1 = manager_->CreateVideoOutput(pSurface_2);
4515     EXPECT_EQ(videoOutput_1, nullptr);
4516 
4517     // height is zero
4518     std::vector<int32_t> framerates;
4519     CameraFormat videoFormat = videoProfiles[0].GetCameraFormat();
4520     Size videoSize;
4521     videoSize.width = videoProfiles[0].GetSize().width;
4522     videoSize.height = 0;
4523     VideoProfile videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
4524 
4525     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
4526     EXPECT_EQ(videoOutput, nullptr);
4527 
4528     // width is zero
4529     videoSize.width = 0;
4530     videoSize.height = VIDEO_DEFAULT_HEIGHT;
4531     videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
4532 
4533     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
4534     EXPECT_EQ(videoOutput, nullptr);
4535 
4536     // format is CAMERA_FORMAT_INVALID
4537     videoFormat = CAMERA_FORMAT_INVALID;
4538     videoSize.width = VIDEO_DEFAULT_WIDTH;
4539     videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
4540 
4541     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
4542     EXPECT_EQ(videoOutput, nullptr);
4543 }
4544 
4545 /*
4546  * Feature: Framework
4547  * Function: Test anomalous branch
4548  * SubFunction: NA
4549  * FunctionPoints: NA
4550  * EnvConditions: NA
4551  * CaseDescription: Test camera settings with anomalous branch
4552  */
4553 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_088, TestSize.Level0)
4554 {
4555     sptr<ICameraDeviceService> deviceObj_1 = nullptr;
4556     sptr<CameraInput> camInput_1 =  new(std::nothrow) CameraInput(deviceObj_1, cameras_[0]);
4557     ASSERT_NE(camInput_1, nullptr);
4558 
4559     sptr<CameraInput> input = (sptr<CameraInput> &)input_;
4560     sptr<ICameraDeviceService> deviceObj_2 = input->GetCameraDevice();
4561     ASSERT_NE(deviceObj_2, nullptr);
4562 
4563     sptr<CameraDevice> camdeviceObj = nullptr;
4564     sptr<CameraInput> camInput_2 = new(std::nothrow) CameraInput(deviceObj_2, camdeviceObj);
4565     ASSERT_NE(camInput_2, nullptr);
4566 
4567     int32_t intResult = camInput_1->Open();
4568     EXPECT_EQ(intResult, 7400201);
4569 
4570     std::string cameraId = camInput_1->GetCameraId();
4571 
4572     std::string getCameraSettings_1 = camInput_1->GetCameraSettings();
4573     intResult = camInput_1->SetCameraSettings(getCameraSettings_1);
4574     EXPECT_EQ(intResult, 0);
4575 
4576     std::string getCameraSettings_2 = "";
4577 
4578     intResult = camInput_2->SetCameraSettings(getCameraSettings_2);
4579     EXPECT_EQ(intResult, 2);
4580 
4581     sptr<CameraInput> camInput_3 = (sptr<CameraInput> &)input_;
4582     getCameraSettings_2 = camInput_3->GetCameraSettings();
4583     intResult = camInput_3->SetCameraSettings(getCameraSettings_2);
4584     EXPECT_EQ(intResult, 0);
4585 
4586     intResult = camInput_2->Release();
4587     EXPECT_EQ(intResult, 0);
4588 }
4589 
4590 /*
4591  * Feature: Framework
4592  * Function: Test anomalous branch
4593  * SubFunction: NA
4594  * FunctionPoints: NA
4595  * EnvConditions: NA
4596  * CaseDescription: test submit device control setting with anomalous branch
4597  */
4598 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_089, TestSize.Level0)
4599 {
4600     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4601     ASSERT_NE(camSession, nullptr);
4602 
4603     int32_t intResult = camSession->BeginConfig();
4604     EXPECT_EQ(intResult, 0);
4605 
4606     intResult = camSession->AddInput(input_);
4607     EXPECT_EQ(intResult, 0);
4608 
4609     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4610     ASSERT_NE(previewOutput, nullptr);
4611 
4612     intResult = camSession->AddOutput(previewOutput);
4613     EXPECT_EQ(intResult, 0);
4614 
4615     intResult = camSession->CommitConfig();
4616     EXPECT_EQ(intResult, 0);
4617 
4618     camSession->LockForControl();
4619 
4620     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
4621     if (!zoomRatioRange.empty()) {
4622         camSession->SetZoomRatio(zoomRatioRange[0]);
4623     }
4624 
4625     sptr<CameraInput> camInput = (sptr<CameraInput> &)input_;
4626     camInput->Close();
4627 
4628     intResult = camSession->UnlockForControl();
4629     EXPECT_EQ(intResult, 0);
4630 
4631     camSession->LockForControl();
4632 
4633     intResult = camSession->UnlockForControl();
4634     EXPECT_EQ(intResult, 0);
4635 }
4636 
4637 /*
4638  * Feature: Framework
4639  * Function: Test anomalous branch
4640  * SubFunction: NA
4641  * FunctionPoints: NA
4642  * EnvConditions: NA
4643  * CaseDescription: Test abnormal branches with empty inputDevice_
4644  */
4645 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_090, TestSize.Level0)
4646 {
4647     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4648     ASSERT_NE(camSession, nullptr);
4649 
4650     int32_t intResult = camSession->BeginConfig();
4651     EXPECT_EQ(intResult, 0);
4652 
4653     intResult = camSession->AddInput(input_);
4654     EXPECT_EQ(intResult, 0);
4655 
4656     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4657     ASSERT_NE(previewOutput, nullptr);
4658 
4659     intResult = camSession->AddOutput(previewOutput);
4660     EXPECT_EQ(intResult, 0);
4661 
4662     intResult = camSession->CommitConfig();
4663     EXPECT_EQ(intResult, 0);
4664 
4665     camSession->inputDevice_ = nullptr;
4666     VideoStabilizationMode mode = MIDDLE;
4667 
4668     intResult = camSession->GetActiveVideoStabilizationMode(mode);
4669     EXPECT_EQ(intResult, 0);
4670 
4671     std::vector<VideoStabilizationMode> videoStabilizationMode = camSession->GetSupportedStabilizationMode();
4672     EXPECT_EQ(videoStabilizationMode.empty(), true);
4673 
4674     intResult = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
4675     EXPECT_EQ(intResult, 0);
4676 
4677     std::vector<ExposureMode> getSupportedExpModes = camSession->GetSupportedExposureModes();
4678     EXPECT_EQ(getSupportedExpModes.empty(), true);
4679 
4680     intResult = camSession->GetSupportedExposureModes(getSupportedExpModes);
4681     EXPECT_EQ(intResult, 0);
4682 
4683     ExposureMode exposureMode = camSession->GetExposureMode();
4684     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
4685 
4686     intResult = camSession->GetExposureMode(exposureMode);
4687     EXPECT_EQ(intResult, 0);
4688 
4689     Point exposurePointGet = camSession->GetMeteringPoint();
4690     EXPECT_EQ(exposurePointGet.x, 0);
4691     EXPECT_EQ(exposurePointGet.y, 0);
4692 
4693     intResult = camSession->GetMeteringPoint(exposurePointGet);
4694     EXPECT_EQ(intResult, 0);
4695 
4696     std::vector<float> getExposureBiasRange = camSession->GetExposureBiasRange();
4697     EXPECT_EQ(getExposureBiasRange.empty(), true);
4698 
4699     intResult = camSession->GetExposureBiasRange(getExposureBiasRange);
4700     EXPECT_EQ(intResult, 0);
4701 
4702     float exposureValue = camSession->GetExposureValue();
4703     EXPECT_EQ(exposureValue, 0);
4704 
4705     intResult = camSession->GetExposureValue(exposureValue);
4706     EXPECT_EQ(intResult, 0);
4707 
4708     camSession->LockForControl();
4709 
4710     intResult = camSession->SetExposureBias(exposureValue);
4711     EXPECT_EQ(intResult, 7400102);
4712 
4713     std::vector<FocusMode> getSupportedFocusModes = camSession->GetSupportedFocusModes();
4714     EXPECT_EQ(getSupportedFocusModes.empty(), true);
4715 
4716     intResult = camSession->GetSupportedFocusModes(getSupportedFocusModes);
4717     EXPECT_EQ(intResult, 0);
4718 }
4719 
4720 /*
4721  * Feature: Framework
4722  * Function: Test anomalous branch
4723  * SubFunction: NA
4724  * FunctionPoints: NA
4725  * EnvConditions: NA
4726  * CaseDescription: Test abnormal branches with empty inputDevice_
4727  */
4728 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_091, TestSize.Level0)
4729 {
4730     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4731     ASSERT_NE(camSession, nullptr);
4732 
4733     int32_t intResult = camSession->BeginConfig();
4734     EXPECT_EQ(intResult, 0);
4735 
4736     intResult = camSession->AddInput(input_);
4737     EXPECT_EQ(intResult, 0);
4738 
4739     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4740     ASSERT_NE(previewOutput, nullptr);
4741 
4742     intResult = camSession->AddOutput(previewOutput);
4743     EXPECT_EQ(intResult, 0);
4744 
4745     intResult = camSession->CommitConfig();
4746     EXPECT_EQ(intResult, 0);
4747 
4748     camSession->inputDevice_ = nullptr;
4749 
4750     FocusMode focusMode = camSession->GetFocusMode();
4751     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
4752 
4753     intResult = camSession->GetFocusMode(focusMode);
4754     EXPECT_EQ(intResult, 0);
4755 
4756     Point focusPoint = camSession->GetFocusPoint();
4757     EXPECT_EQ(focusPoint.x, 0);
4758     EXPECT_EQ(focusPoint.y, 0);
4759 
4760     intResult = camSession->GetFocusPoint(focusPoint);
4761     EXPECT_EQ(intResult, 0);
4762 
4763     float focalLength = camSession->GetFocalLength();
4764     EXPECT_EQ(focalLength, 0);
4765 
4766     intResult = camSession->GetFocalLength(focalLength);
4767     EXPECT_EQ(intResult, 0);
4768 
4769     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
4770     EXPECT_EQ(getSupportedFlashModes.empty(), true);
4771 
4772     intResult = camSession->GetSupportedFlashModes(getSupportedFlashModes);
4773     EXPECT_EQ(intResult, 0);
4774 
4775     FlashMode flashMode = camSession->GetFlashMode();
4776     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
4777 
4778     intResult = camSession->GetFlashMode(flashMode);
4779     EXPECT_EQ(intResult, 0);
4780 
4781     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
4782     EXPECT_EQ(zoomRatioRange.empty(), true);
4783 
4784     intResult = camSession->GetZoomRatioRange(zoomRatioRange);
4785     EXPECT_EQ(intResult, 0);
4786 
4787     float zoomRatio = camSession->GetZoomRatio();
4788     EXPECT_EQ(zoomRatio, 0);
4789 
4790     intResult = camSession->GetZoomRatio(zoomRatio);
4791     EXPECT_EQ(intResult, 0);
4792 
4793     camSession->LockForControl();
4794 
4795     intResult = camSession->SetZoomRatio(zoomRatio);
4796     EXPECT_EQ(intResult, 0);
4797 
4798     intResult = camSession->SetMeteringPoint(focusPoint);
4799     EXPECT_EQ(intResult, 0);
4800 }
4801 
4802 /*
4803  * Feature: Framework
4804  * Function: Test anomalous branch
4805  * SubFunction: NA
4806  * FunctionPoints: NA
4807  * EnvConditions: NA
4808  * CaseDescription: test submit device control setting with anomalous branch
4809  */
4810 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_092, TestSize.Level0)
4811 {
4812     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4813     ASSERT_NE(camSession, nullptr);
4814 
4815     int32_t intResult = camSession->BeginConfig();
4816     EXPECT_EQ(intResult, 0);
4817 
4818     intResult = camSession->AddInput(input_);
4819     EXPECT_EQ(intResult, 0);
4820 
4821     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4822     ASSERT_NE(previewOutput, nullptr);
4823 
4824     intResult = camSession->AddOutput(previewOutput);
4825     EXPECT_EQ(intResult, 0);
4826 
4827     intResult = camSession->CommitConfig();
4828     EXPECT_EQ(intResult, 0);
4829 
4830     camSession->LockForControl();
4831 
4832     std::vector<float> exposureBiasRange = camSession->GetExposureBiasRange();
4833     if (!exposureBiasRange.empty()) {
4834         camSession->SetExposureBias(exposureBiasRange[0]);
4835     }
4836 
4837     camSession->inputDevice_ = nullptr;
4838 
4839     intResult = camSession->UnlockForControl();
4840     EXPECT_EQ(intResult, 0);
4841 }
4842 
4843 /*
4844  * Feature: Framework
4845  * Function: Test anomalous branch
4846  * SubFunction: NA
4847  * FunctionPoints: NA
4848  * EnvConditions: NA
4849  * CaseDescription: test serviceProxy_ null with anomalous branch
4850  */
4851 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_093, TestSize.Level0)
4852 {
4853     sptr<Surface> pSurface = nullptr;
4854     sptr<IBufferProducer> surfaceProducer = nullptr;
4855 
4856     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
4857     ASSERT_NE(camManagerObj, nullptr);
4858 
4859     delete camManagerObj;
4860 
4861     std::vector<sptr<CameraDevice>> camdeviceObj_1 = camManagerObj->GetSupportedCameras();
4862     ASSERT_TRUE(camdeviceObj_1.size() == 0);
4863 
4864     sptr<CaptureSession> captureSession = camManagerObj->CreateCaptureSession();
4865     EXPECT_EQ(captureSession, nullptr);
4866 
4867     sptr<CaptureOutput> metadataOutput = camManagerObj->CreateMetadataOutput();
4868     EXPECT_EQ(metadataOutput, nullptr);
4869 
4870     sptr<CaptureOutput> previewOutput = camManagerObj->CreatePreviewOutput(previewProfiles[0], pSurface);
4871     EXPECT_EQ(previewOutput, nullptr);
4872 
4873     previewOutput = camManagerObj->CreateDeferredPreviewOutput(previewProfiles[0]);
4874     EXPECT_EQ(previewOutput, nullptr);
4875 
4876     sptr<CaptureOutput> photoOutput = camManagerObj->CreatePhotoOutput(photoProfiles[0], surfaceProducer);
4877     EXPECT_EQ(photoOutput, nullptr);
4878 
4879     sptr<CaptureOutput> videoOutput = camManagerObj->CreateVideoOutput(videoProfiles[0], pSurface);
4880     EXPECT_EQ(videoOutput, nullptr);
4881 }
4882 
4883 /*
4884  * Feature: Framework
4885  * Function: Test anomalous branch
4886  * SubFunction: NA
4887  * FunctionPoints: NA
4888  * EnvConditions: NA
4889  * CaseDescription: test serviceProxy_ null with muteCamera anomalous branch
4890  */
4891 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_094, TestSize.Level0)
4892 {
4893     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
4894     ASSERT_NE(camManagerObj, nullptr);
4895 
4896     delete camManagerObj;
4897 
4898     bool cameraMuted = camManagerObj->IsCameraMuted();
4899     EXPECT_EQ(cameraMuted, false);
4900 
4901     bool cameraMuteSupported = camManagerObj->IsCameraMuteSupported();
4902     EXPECT_EQ(cameraMuteSupported, false);
4903 
4904     camManagerObj->MuteCamera(cameraMuted);
4905 }
4906 
4907 /*
4908  * Feature: Framework
4909  * Function: Test anomalous branch
4910  * SubFunction: NA
4911  * FunctionPoints: NA
4912  * EnvConditions: NA
4913  * CaseDescription: test create camera input and construct device object with anomalous branch
4914  */
4915 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_095, TestSize.Level0)
4916 {
4917     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
4918     ASSERT_NE(camManagerObj, nullptr);
4919 
4920     delete camManagerObj;
4921 
4922     std::string cameraId = "";
4923     dmDeviceInfo deviceInfo = {};
4924     sptr<CameraDevice> camdeviceObj_1 = new(std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
4925     ASSERT_NE(camdeviceObj_1, nullptr);
4926 
4927     cameraId = cameras_[0]->GetID();
4928     sptr<CameraDevice> camdeviceObj_2  = new(std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
4929     ASSERT_NE(camdeviceObj_2, nullptr);
4930 
4931     sptr<CameraDevice> camdeviceObj_3 = nullptr;
4932     sptr<CaptureInput> camInput = camManagerObj->CreateCameraInput(camdeviceObj_3);
4933     EXPECT_EQ(camInput, nullptr);
4934 
4935     camInput = camManagerObj->CreateCameraInput(camdeviceObj_1);
4936     EXPECT_EQ(camInput, nullptr);
4937 
4938     sptr<CameraInfo> camera = nullptr;
4939     camInput = camManagerObj->CreateCameraInput(camera);
4940     EXPECT_EQ(camInput, nullptr);
4941 
4942     CameraPosition cameraPosition = cameras_[0]->GetPosition();
4943     CameraType cameraType = cameras_[0]->GetCameraType();
4944     camInput = camManagerObj->CreateCameraInput(cameraPosition, cameraType);
4945     EXPECT_EQ(camInput, nullptr);
4946 
4947     sptr<ICameraDeviceService> deviceObj_1 = nullptr;
4948     sptr<CameraInput> input_1 =  new(std::nothrow) CameraInput(deviceObj_1, cameras_[0]);
4949     ASSERT_NE(input_1, nullptr);
4950 
4951     sptr<CameraInput> input_2 = (sptr<CameraInput> &)input_;
4952     sptr<ICameraDeviceService> deviceObj_2 = input_2->GetCameraDevice();
4953     ASSERT_NE(deviceObj_2, nullptr);
4954 
4955     input_2 = new(std::nothrow) CameraInput(deviceObj_2, camdeviceObj_3);
4956     ASSERT_NE(input_2, nullptr);
4957 
4958     input_2 = new(std::nothrow) CameraInput(deviceObj_1, cameras_[0]);
4959     ASSERT_NE(input_2, nullptr);
4960 }
4961 } // CameraStandard
4962 } // OHOS
4963