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 
18 #include <algorithm>
19 #include <cinttypes>
20 #include <memory>
21 #include <vector>
22 #include <thread>
23 #include <cstdint>
24 
25 #include "accesstoken_kit.h"
26 #include "aperture_video_session.h"
27 #include "camera_error_code.h"
28 #include "camera_log.h"
29 #include "camera_output_capability.h"
30 #include "camera_util.h"
31 #include "capture_scene_const.h"
32 #include "capture_session.h"
33 #include "gtest/gtest.h"
34 #include "hap_token_info.h"
35 #include "hcamera_device.h"
36 #include "hcamera_device_callback_proxy.h"
37 #include "hcamera_device_proxy.h"
38 #include "hcamera_service.h"
39 #include "hcamera_service_stub.h"
40 #include "session/light_painting_session.h"
41 #include "session/time_lapse_photo_session.h"
42 #include "session/slow_motion_session.h"
43 #include "input/camera_input.h"
44 #include "input/camera_manager.h"
45 #include "ipc_skeleton.h"
46 #include "iservice_registry.h"
47 #include "nativetoken_kit.h"
48 #include "night_session.h"
49 #include "parameter.h"
50 #include "photo_output.h"
51 #include "quick_shot_photo_session.h"
52 #include "scan_session.h"
53 #include "session/panorama_session.h"
54 #include "session/photo_session.h"
55 #include "session/profession_session.h"
56 #include "session/photo_session.h"
57 #include "session/video_session.h"
58 #include "session/portrait_session.h"
59 #include "session/secure_camera_session.h"
60 #include "surface.h"
61 #include "system_ability_definition.h"
62 #include "test_common.h"
63 #include "token_setproc.h"
64 #include "video_session.h"
65 
66 using namespace testing::ext;
67 using namespace OHOS::HDI::Camera::V1_0;
68 
69 namespace OHOS {
70 namespace CameraStandard {
71 namespace {
72 enum class CAM_PHOTO_EVENTS {
73     CAM_PHOTO_CAPTURE_START = 0,
74     CAM_PHOTO_CAPTURE_END,
75     CAM_PHOTO_CAPTURE_ERR,
76     CAM_PHOTO_FRAME_SHUTTER,
77     CAM_PHOTO_MAX_EVENT,
78     CAM_PHOTO_FRAME_SHUTTER_END,
79     CAM_PHOTO_CAPTURE_READY,
80     CAM_PHOTO_ESTIMATED_CAPTURE_DURATION
81 };
82 
83 enum class CAM_PREVIEW_EVENTS {
84     CAM_PREVIEW_FRAME_START = 0,
85     CAM_PREVIEW_FRAME_END,
86     CAM_PREVIEW_FRAME_ERR,
87     CAM_PREVIEW_SKETCH_STATUS_CHANGED,
88     CAM_PREVIEW_MAX_EVENT
89 };
90 
91 enum class CAM_VIDEO_EVENTS {
92     CAM_VIDEO_FRAME_START = 0,
93     CAM_VIDEO_FRAME_END,
94     CAM_VIDEO_FRAME_ERR,
95     CAM_VIDEO_MAX_EVENT
96 };
97 
98 enum class CAM_MACRO_DETECT_EVENTS {
99     CAM_MACRO_EVENT_IDLE = 0,
100     CAM_MACRO_EVENT_ACTIVE,
101     CAM_MACRO_EVENT_MAX_EVENT
102 };
103 
104 enum class CAM_MOON_CAPTURE_BOOST_EVENTS {
105     CAM_MOON_CAPTURE_BOOST_EVENT_IDLE = 0,
106     CAM_MOON_CAPTURE_BOOST_EVENT_ACTIVE,
107     CAM_MOON_CAPTURE_BOOST_EVENT_MAX_EVENT
108 };
109 
110 const int32_t WAIT_TIME_AFTER_CAPTURE = 1;
111 const int32_t WAIT_TIME_AFTER_DEFERRED_CAPTURE = 2;
112 const int32_t WAIT_TIME_AFTER_RECORDING = 3;
113 const int32_t WAIT_TIME_AFTER_START = 2;
114 const int32_t WAIT_TIME_BEFORE_STOP = 1;
115 const int32_t WAIT_TIME_AFTER_CLOSE = 1;
116 const int32_t WAIT_TIME_CALLBACK = 1;
117 const int32_t CAMERA_NUMBER = 2;
118 const int32_t MIN_FRAME_RATE = 15;
119 const int32_t MAX_FRAME_RATE = 30;
120 const int32_t SKETCH_PREVIEW_MIN_HEIGHT = 720;
121 const int32_t SKETCH_PREVIEW_MAX_WIDTH = 3000;
122 const int32_t SKETCH_DEFAULT_WIDTH = 640;
123 const int32_t SKETCH_DEFAULT_HEIGHT = 480;
124 const int32_t PRVIEW_WIDTH_176 = 176;
125 const int32_t PRVIEW_HEIGHT_144 = 144;
126 const int32_t PRVIEW_WIDTH_640 = 640;
127 const int32_t PRVIEW_WIDTH_4096 = 4096;
128 const int32_t PRVIEW_HEIGHT_3072 = 3072;
129 const int32_t PRVIEW_WIDTH_4160 = 4160;
130 const int32_t PRVIEW_HEIGHT_3120 = 3120;
131 const int32_t PRVIEW_WIDTH_8192 = 8192;
132 const int32_t PRVIEW_HEIGHT_6144 = 6144;
133 
134 bool g_camInputOnError = false;
135 bool g_sessionclosed = false;
136 bool g_brightnessStatusChanged = false;
137 bool g_slowMotionStatusChanged = false;
138 std::shared_ptr<OHOS::Camera::CameraMetadata> g_metaResult = nullptr;
139 int32_t g_videoFd = -1;
140 int32_t g_previewFd = -1;
141 int32_t g_sketchFd = -1;
142 std::bitset<static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_MAX_EVENT)> g_photoEvents;
143 std::bitset<static_cast<unsigned int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_MAX_EVENT)> g_previewEvents;
144 std::bitset<static_cast<unsigned int>(CAM_VIDEO_EVENTS::CAM_VIDEO_MAX_EVENT)> g_videoEvents;
145 std::bitset<static_cast<unsigned int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_MAX_EVENT)> g_macroEvents;
146 std::bitset<static_cast<unsigned int>(CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_MAX_EVENT)>
147     g_moonCaptureBoostEvents;
148 std::list<int32_t> g_sketchStatus;
149 std::unordered_map<std::string, int> g_camStatusMap;
150 std::unordered_map<std::string, bool> g_camFlashMap;
151 TorchStatusInfo g_torchInfo;
152 
153 class AppCallback : public CameraManagerCallback,
154                     public TorchListener,
155                     public ErrorCallback,
156                     public PhotoStateCallback,
157                     public PreviewStateCallback,
158                     public ResultCallback,
159                     public SlowMotionStateCallback,
160                     public MacroStatusCallback,
161                     public FeatureDetectionStatusCallback,
162                     public FoldListener,
163                     public BrightnessStatusCallback {
164 public:
OnCameraStatusChanged(const CameraStatusInfo & cameraDeviceInfo) const165     void OnCameraStatusChanged(const CameraStatusInfo& cameraDeviceInfo) const override
166     {
167         const std::string cameraID = cameraDeviceInfo.cameraDevice->GetID();
168         const CameraStatus cameraStatus = cameraDeviceInfo.cameraStatus;
169         EXPECT_TRUE(true)<<"OnCameraStatusChanged:CameraId="<<cameraID<<",CameraStatus="<<cameraDeviceInfo.cameraStatus
170             <<",bundleName="<<cameraDeviceInfo.bundleName<<endl;
171         switch (cameraStatus) {
172             case CAMERA_STATUS_UNAVAILABLE: {
173                 MEDIA_DEBUG_LOG(
174                     "AppCallback::OnCameraStatusChanged %{public}s: CAMERA_STATUS_UNAVAILABLE", cameraID.c_str());
175                 g_camStatusMap[cameraID] = CAMERA_STATUS_UNAVAILABLE;
176                 break;
177             }
178             case CAMERA_STATUS_AVAILABLE: {
179                 MEDIA_DEBUG_LOG(
180                     "AppCallback::OnCameraStatusChanged %{public}s: CAMERA_STATUS_AVAILABLE", cameraID.c_str());
181                 g_camStatusMap[cameraID] = CAMERA_STATUS_AVAILABLE;
182                 break;
183             }
184             default: {
185                 MEDIA_DEBUG_LOG("AppCallback::OnCameraStatusChanged %{public}s: unknown", cameraID.c_str());
186                 EXPECT_TRUE(false);
187             }
188         }
189         return;
190     }
191 
OnFlashlightStatusChanged(const std::string & cameraID,const FlashStatus flashStatus) const192     void OnFlashlightStatusChanged(const std::string& cameraID, const FlashStatus flashStatus) const override
193     {
194         switch (flashStatus) {
195             case FLASH_STATUS_OFF: {
196                 MEDIA_DEBUG_LOG(
197                     "AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_OFF", cameraID.c_str());
198                 g_camFlashMap[cameraID] = false;
199                 break;
200             }
201             case FLASH_STATUS_ON: {
202                 MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_ON", cameraID.c_str());
203                 g_camFlashMap[cameraID] = true;
204                 break;
205             }
206             case FLASH_STATUS_UNAVAILABLE: {
207                 MEDIA_DEBUG_LOG(
208                     "AppCallback::OnFlashlightStatusChanged %{public}s: FLASH_STATUS_UNAVAILABLE", cameraID.c_str());
209                 g_camFlashMap.erase(cameraID);
210                 break;
211             }
212             default: {
213                 MEDIA_DEBUG_LOG("AppCallback::OnFlashlightStatusChanged %{public}s: unknown", cameraID.c_str());
214                 EXPECT_TRUE(false);
215             }
216         }
217         return;
218     }
219 
OnTorchStatusChange(const TorchStatusInfo & torchStatusInfo) const220     void OnTorchStatusChange(const TorchStatusInfo &torchStatusInfo) const override
221     {
222         MEDIA_DEBUG_LOG("TorchListener::OnTorchStatusChange called %{public}d %{public}d %{public}f",
223             torchStatusInfo.isTorchAvailable, torchStatusInfo.isTorchActive, torchStatusInfo.torchLevel);
224         g_torchInfo = torchStatusInfo;
225         return;
226     }
227 
OnError(const int32_t errorType,const int32_t errorMsg) const228     void OnError(const int32_t errorType, const int32_t errorMsg) const override
229     {
230         MEDIA_DEBUG_LOG("AppCallback::OnError errorType: %{public}d, errorMsg: %{public}d", errorType, errorMsg);
231         g_camInputOnError = true;
232         if (errorType == CAMERA_DEVICE_PREEMPTED) {
233             g_sessionclosed = true;
234         }
235         return;
236     }
237 
OnResult(const uint64_t timestamp,const std::shared_ptr<OHOS::Camera::CameraMetadata> & result) const238     void OnResult(const uint64_t timestamp, const std::shared_ptr<OHOS::Camera::CameraMetadata>& result) const override
239     {
240         MEDIA_INFO_LOG("CameraDeviceServiceCallback::OnResult() is called!");
241 
242         if (result != nullptr) {
243             g_metaResult = result;
244             common_metadata_header_t* data = result->get();
245             std::vector<int32_t> fpsRange;
246             camera_metadata_item_t entry;
247             int ret = OHOS::Camera::FindCameraMetadataItem(data, OHOS_ABILITY_FPS_RANGES, &entry);
248             MEDIA_INFO_LOG("CameraDeviceServiceCallback::FindCameraMetadataItem() %{public}d", ret);
249             if (ret != 0) {
250                 MEDIA_INFO_LOG("demo test: get OHOS_ABILITY_FPS_RANGES error");
251             }
252             uint32_t count = entry.count;
253             MEDIA_INFO_LOG("demo test: fpsRange count  %{public}d", count);
254             for (uint32_t i = 0; i < count; i++) {
255                 fpsRange.push_back(*(entry.data.i32 + i));
256             }
257             for (auto it = fpsRange.begin(); it != fpsRange.end(); it++) {
258                 MEDIA_INFO_LOG("demo test: fpsRange %{public}d ", *it);
259             }
260         }
261     }
262 
OnCaptureStarted(const int32_t captureId) const263     void OnCaptureStarted(const int32_t captureId) const override
264     {
265         MEDIA_DEBUG_LOG("AppCallback::OnCaptureStarted captureId: %{public}d", captureId);
266         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] = 1;
267         return;
268     }
269 
OnCaptureStarted(const int32_t captureId,uint32_t exposureTime) const270     void OnCaptureStarted(const int32_t captureId, uint32_t exposureTime) const override
271     {
272         MEDIA_DEBUG_LOG("AppCallback::OnCaptureStarted captureId: %{public}d", captureId);
273         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] = 1;
274         return;
275     }
276 
OnCaptureEnded(const int32_t captureId,const int32_t frameCount) const277     void OnCaptureEnded(const int32_t captureId, const int32_t frameCount) const override
278     {
279         MEDIA_DEBUG_LOG("AppCallback::OnCaptureEnded captureId: %{public}d, frameCount: %{public}d",
280                         captureId, frameCount);
281         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_END)] = 1;
282         return;
283     }
284 
OnFrameShutter(const int32_t captureId,const uint64_t timestamp) const285     void OnFrameShutter(const int32_t captureId, const uint64_t timestamp) const override
286     {
287         MEDIA_DEBUG_LOG(
288             "AppCallback::OnFrameShutter captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
289         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_FRAME_SHUTTER)] = 1;
290         return;
291     }
292 
OnFrameShutterEnd(const int32_t captureId,const uint64_t timestamp) const293     void OnFrameShutterEnd(const int32_t captureId, const uint64_t timestamp) const override
294     {
295         MEDIA_DEBUG_LOG(
296             "AppCallback::OnFrameShutterEnd captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
297         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_FRAME_SHUTTER_END)] = 1;
298         return;
299     }
300 
OnCaptureReady(const int32_t captureId,const uint64_t timestamp) const301     void OnCaptureReady(const int32_t captureId, const uint64_t timestamp) const override
302     {
303         MEDIA_DEBUG_LOG(
304             "AppCallback::OnCaptureReady captureId: %{public}d, timestamp: %{public}" PRIu64, captureId, timestamp);
305         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_READY)] = 1;
306         return;
307     }
308 
OnEstimatedCaptureDuration(const int32_t duration) const309     void OnEstimatedCaptureDuration(const int32_t duration) const override
310     {
311         MEDIA_DEBUG_LOG("AppCallback::OnEstimatedCaptureDuration duration: %{public}d", duration);
312         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_ESTIMATED_CAPTURE_DURATION)] = 1;
313         return;
314     }
315 
OnCaptureError(const int32_t captureId,const int32_t errorCode) const316     void OnCaptureError(const int32_t captureId, const int32_t errorCode) const override
317     {
318         MEDIA_DEBUG_LOG(
319             "AppCallback::OnCaptureError captureId: %{public}d, errorCode: %{public}d", captureId, errorCode);
320         g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_ERR)] = 1;
321         return;
322     }
323 
OnFrameStarted() const324     void OnFrameStarted() const override
325     {
326         MEDIA_DEBUG_LOG("AppCallback::OnFrameStarted");
327         g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_START)] = 1;
328         return;
329     }
OnFrameEnded(const int32_t frameCount) const330     void OnFrameEnded(const int32_t frameCount) const override
331     {
332         MEDIA_DEBUG_LOG("AppCallback::OnFrameEnded frameCount: %{public}d", frameCount);
333         g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_END)] = 1;
334         return;
335     }
OnError(const int32_t errorCode) const336     void OnError(const int32_t errorCode) const override
337     {
338         MEDIA_DEBUG_LOG("AppCallback::OnError errorCode: %{public}d", errorCode);
339         g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_ERR)] = 1;
340         return;
341     }
OnSketchStatusDataChanged(const SketchStatusData & statusData) const342     void OnSketchStatusDataChanged(const SketchStatusData& statusData) const override
343     {
344         MEDIA_DEBUG_LOG("AppCallback::OnSketchStatusDataChanged");
345         g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)] = 1;
346         g_sketchStatus.push_back(static_cast<int32_t>(statusData.status));
347         return;
348     }
OnMacroStatusChanged(MacroStatus status)349     void OnMacroStatusChanged(MacroStatus status) override
350     {
351         MEDIA_DEBUG_LOG("AppCallback::OnMacroStatusChanged");
352         if (status == MacroStatus::IDLE) {
353             g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_IDLE)] = 1;
354             g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_ACTIVE)] = 0;
355         } else if (status == MacroStatus::ACTIVE) {
356             g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_ACTIVE)] = 1;
357             g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_IDLE)] = 0;
358         }
359         return;
360     }
361 
OnFeatureDetectionStatusChanged(SceneFeature feature,FeatureDetectionStatus status)362     void OnFeatureDetectionStatusChanged(SceneFeature feature, FeatureDetectionStatus status) override
363     {
364         MEDIA_DEBUG_LOG("AppCallback::OnFeatureDetectionStatusChanged");
365         if (feature == SceneFeature::FEATURE_MOON_CAPTURE_BOOST) {
366             if (status == FeatureDetectionStatus::IDLE) {
367                 g_moonCaptureBoostEvents[static_cast<int>(
368                     CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_IDLE)] = 1;
369                 g_moonCaptureBoostEvents[static_cast<int>(
370                     CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_ACTIVE)] = 0;
371             } else if (status == FeatureDetectionStatus::ACTIVE) {
372                 g_moonCaptureBoostEvents[static_cast<int>(
373                     CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_ACTIVE)] = 1;
374                 g_moonCaptureBoostEvents[static_cast<int>(
375                     CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_IDLE)] = 0;
376             }
377         }
378     }
379 
IsFeatureSubscribed(SceneFeature feature)380     bool IsFeatureSubscribed(SceneFeature feature) override
381     {
382         return true;
383     }
384 
OnBrightnessStatusChanged(bool state)385     void OnBrightnessStatusChanged(bool state) override
386     {
387         MEDIA_DEBUG_LOG("AppCallback::OnBrightnessStatusChanged");
388         g_brightnessStatusChanged = true;
389     }
390 
OnSlowMotionState(const SlowMotionState state)391     void OnSlowMotionState(const SlowMotionState state) override
392     {
393         MEDIA_DEBUG_LOG("AppCallback::OnSlowMotionState");
394         g_slowMotionStatusChanged = true;
395     }
OnFoldStatusChanged(const FoldStatusInfo & foldStatusInfo) const396     void OnFoldStatusChanged(const FoldStatusInfo &foldStatusInfo) const override
397     {
398         MEDIA_DEBUG_LOG("AppCallback::OnFoldStatusChanged");
399         return;
400     }
401 };
402 
403 class AppVideoCallback : public VideoStateCallback {
OnFrameStarted() const404     void OnFrameStarted() const override
405     {
406         MEDIA_DEBUG_LOG("AppVideoCallback::OnFrameStarted");
407         g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_START)] = 1;
408         return;
409     }
OnFrameEnded(const int32_t frameCount) const410     void OnFrameEnded(const int32_t frameCount) const override
411     {
412         MEDIA_DEBUG_LOG("AppVideoCallback::OnFrameEnded frameCount: %{public}d", frameCount);
413         g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_END)] = 1;
414         return;
415     }
OnError(const int32_t errorCode) const416     void OnError(const int32_t errorCode) const override
417     {
418         MEDIA_DEBUG_LOG("AppVideoCallback::OnError errorCode: %{public}d", errorCode);
419         g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_ERR)] = 1;
420         return;
421     }
OnDeferredVideoEnhancementInfo(const CaptureEndedInfoExt info) const422     void OnDeferredVideoEnhancementInfo(const CaptureEndedInfoExt info) const override
423     {
424         MEDIA_DEBUG_LOG("AppVideoCallback::OnDeferredVideoEnhancementInfo");
425         return;
426     }
427 };
428 
429 class AppMetadataCallback : public MetadataObjectCallback, public MetadataStateCallback {
430 public:
OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const431     void OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const
432     {
433         MEDIA_DEBUG_LOG("AppMetadataCallback::OnMetadataObjectsAvailable received");
434     }
OnError(int32_t errorCode) const435     void OnError(int32_t errorCode) const
436     {
437         MEDIA_DEBUG_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
438     }
439 };
440 
441 class AppSessionCallback : public SessionCallback {
442 public:
OnError(int32_t errorCode)443     void OnError(int32_t errorCode)
444     {
445         MEDIA_DEBUG_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
446         return;
447     }
448 };
449 } // namespace
450 
CreatePhotoOutput(int32_t width,int32_t height)451 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput(int32_t width, int32_t height)
452 {
453     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
454     CameraFormat photoFormat = photoFormat_;
455     Size photoSize;
456     photoSize.width = width;
457     photoSize.height = height;
458     Profile photoProfile = Profile(photoFormat, photoSize);
459     sptr<CaptureOutput> photoOutput = nullptr;
460     sptr<IBufferProducer> surfaceProducer = surface->GetProducer();
461     manager_->CreatePhotoOutput(surfaceProducer);
462     photoOutput = manager_->CreatePhotoOutput(photoProfile, surfaceProducer);
463     return photoOutput;
464 }
465 
CreatePhotoOutput()466 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput()
467 {
468     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(photoWidth_, photoHeight_);
469     return photoOutput;
470 }
471 
CreatePreviewOutput(int32_t width,int32_t height)472 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput(int32_t width, int32_t height)
473 {
474     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
475     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
476     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
477     Size previewSize;
478     previewSize.width = previewProfiles[0].GetSize().width;
479     previewSize.height = previewProfiles[0].GetSize().height;
480     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewProfiles[0].GetCameraFormat()));
481     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
482 
483     sptr<IBufferProducer> bp = previewSurface->GetProducer();
484     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(bp);
485 
486     sptr<CaptureOutput> previewOutput = nullptr;
487     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
488     return previewOutput;
489 }
490 
GetSketchPreviewProfile()491 std::shared_ptr<Profile> CameraFrameworkModuleTest::GetSketchPreviewProfile()
492 {
493     std::shared_ptr<Profile> returnProfile;
494     Size size720P { 1280, 720 };
495     Size size1080P { 1920, 1080 };
496     for (const auto& profile : previewProfiles) {
497         if (profile.format_ != CAMERA_FORMAT_YUV_420_SP) {
498             continue;
499         }
500         if (profile.size_.width == size720P.width && profile.size_.height == size720P.height) {
501             returnProfile = std::make_shared<Profile>(profile);
502             return returnProfile;
503         }
504         if (profile.size_.width == size1080P.width && profile.size_.height == size1080P.height) {
505             returnProfile = std::make_shared<Profile>(profile);
506             return returnProfile;
507         }
508         if (profile.size_.height < SKETCH_PREVIEW_MIN_HEIGHT || profile.size_.width > SKETCH_PREVIEW_MAX_WIDTH) {
509             continue;
510         }
511         if (returnProfile == nullptr) {
512             returnProfile = std::make_shared<Profile>(profile);
513             continue;
514         }
515         if (profile.size_.width > returnProfile->size_.width) {
516             returnProfile = std::make_shared<Profile>(profile);
517         }
518     }
519     return returnProfile;
520 }
521 
CreatePreviewOutput(Profile & profile)522 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput(Profile& profile)
523 {
524     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
525     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
526     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
527     Size previewSize = profile.GetSize();
528     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(profile.GetCameraFormat()));
529     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
530 
531     sptr<IBufferProducer> bp = previewSurface->GetProducer();
532     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(bp);
533 
534     sptr<CaptureOutput> previewOutput = nullptr;
535     previewOutput = manager_->CreatePreviewOutput(profile, pSurface);
536     return previewOutput;
537 }
538 
CreateSketchSurface(CameraFormat cameraFormat)539 sptr<Surface> CameraFrameworkModuleTest::CreateSketchSurface(CameraFormat cameraFormat)
540 {
541     sptr<IConsumerSurface> sketchSurface = IConsumerSurface::Create();
542     sptr<SurfaceListener> listener = new SurfaceListener("Sketch", SurfaceType::SKETCH, g_sketchFd, sketchSurface);
543     sketchSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
544     sketchSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(cameraFormat));
545     sketchSurface->SetDefaultWidthAndHeight(SKETCH_DEFAULT_WIDTH, SKETCH_DEFAULT_HEIGHT);
546     sptr<IBufferProducer> bp = sketchSurface->GetProducer();
547     return Surface::CreateSurfaceAsProducer(bp);
548 }
549 
CreatePreviewOutput()550 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput()
551 {
552     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(previewWidth_, previewHeight_);
553     return previewOutput;
554 }
555 
CreateVideoOutput(int32_t width,int32_t height)556 sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput(int32_t width, int32_t height)
557 {
558     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
559     sptr<SurfaceListener> videoSurfaceListener =
560         new (std::nothrow) SurfaceListener("Video", SurfaceType::VIDEO, g_videoFd, surface);
561     if (videoSurfaceListener == nullptr) {
562         MEDIA_ERR_LOG("Failed to create new SurfaceListener");
563         return nullptr;
564     }
565     surface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)videoSurfaceListener);
566     sptr<IBufferProducer> videoProducer = surface->GetProducer();
567     sptr<Surface> videoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
568     VideoProfile videoProfile = videoProfiles[0];
569     sptr<CaptureOutput> videoOutput = nullptr;
570     videoOutput = manager_->CreateVideoOutput(videoProfile, videoSurface);
571     return videoOutput;
572 }
573 
CreateVideoOutput(VideoProfile & videoProfile)574 sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput(VideoProfile& videoProfile)
575 {
576     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
577     sptr<SurfaceListener> videoSurfaceListener =
578         new (std::nothrow) SurfaceListener("Video", SurfaceType::VIDEO, g_videoFd, surface);
579     if (videoSurfaceListener == nullptr) {
580         MEDIA_ERR_LOG("Failed to create new SurfaceListener");
581         return nullptr;
582     }
583     surface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)videoSurfaceListener);
584     sptr<IBufferProducer> videoProducer = surface->GetProducer();
585     sptr<Surface> videoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
586     sptr<CaptureOutput> videoOutput = nullptr;
587     videoOutput = manager_->CreateVideoOutput(videoProfile, videoSurface);
588     return videoOutput;
589 }
590 
CreateVideoOutput()591 sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput()
592 {
593     sptr<CaptureOutput> videoOutput = CreateVideoOutput(videoWidth_, videoHeight_);
594     return videoOutput;
595 }
596 
CreatePhotoOutput(Profile profile)597 sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput(Profile profile)
598 {
599     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
600     Size photoSize;
601     photoSize.width = profile.GetSize().width;
602     photoSize.height = profile.GetSize().height;
603     sptr<CaptureOutput> photoOutput = nullptr;
604     sptr<IBufferProducer> surfaceProducer = surface->GetProducer();
605     photoOutput = manager_->CreatePhotoOutput(profile, surfaceProducer);
606     return photoOutput;
607 }
608 
ConfigScanSession(sptr<CaptureOutput> & previewOutput_1,sptr<CaptureOutput> & previewOutput_2)609 void CameraFrameworkModuleTest::ConfigScanSession(sptr<CaptureOutput> &previewOutput_1,
610                                                   sptr<CaptureOutput> &previewOutput_2)
611 {
612     scanSession_ = manager_ -> CreateCaptureSession(SceneMode::SCAN);
613     ASSERT_NE(scanSession_, nullptr);
614 
615     int32_t intResult = scanSession_->BeginConfig();
616     EXPECT_EQ(intResult, 0);
617 
618     intResult = scanSession_->AddInput(input_);
619     EXPECT_EQ(intResult, 0);
620 
621     previewOutput_1 = CreatePreviewOutput();
622     ASSERT_NE(previewOutput_1, nullptr);
623 
624     intResult = scanSession_->AddOutput(previewOutput_1);
625     EXPECT_EQ(intResult, 0);
626 
627     previewOutput_2 = CreatePreviewOutput();
628     ASSERT_NE(previewOutput_2, nullptr);
629 
630     intResult = scanSession_->AddOutput(previewOutput_2);
631     EXPECT_EQ(intResult, 0);
632 
633     intResult = scanSession_->CommitConfig();
634     EXPECT_EQ(intResult, 0);
635 }
636 
ConfigHighResSession(sptr<CaptureOutput> & previewOutput,sptr<CaptureOutput> & photoOutput)637 void CameraFrameworkModuleTest::ConfigHighResSession(sptr<CaptureOutput> &previewOutput,
638                                                      sptr<CaptureOutput> &photoOutput)
639 {
640     if (session_) {
641         MEDIA_INFO_LOG("old session exist, need release");
642         session_->Release();
643         input_->Close();
644     }
645 
646     cameras_ = manager_->GetSupportedCameras();
647     ASSERT_TRUE(cameras_.size() != 0);
648 
649     std::cout<<std::endl;
650 
651     sptr<CameraDevice> device;
652     for (auto deviceEach : cameras_) {
653         if (deviceEach->GetPosition() == 1 && deviceEach->GetCameraType() == CameraType::CAMERA_TYPE_WIDE_ANGLE) {
654             device = deviceEach;
655             break;
656         }
657     }
658     sptr<CaptureInput> input = manager_->CreateCameraInput(device);
659     ASSERT_NE(input, nullptr);
660 
661     int32_t intResult = input->Open();
662     EXPECT_EQ(intResult, 0);
663 
664     highResSession_ = manager_ -> CreateCaptureSession(SceneMode::HIGH_RES_PHOTO);
665     ASSERT_NE(highResSession_, nullptr);
666 
667     intResult = highResSession_->BeginConfig();
668     EXPECT_EQ(intResult, 0);
669 
670     intResult = highResSession_->AddInput(input);
671     EXPECT_EQ(intResult, 0);
672 
673     sptr<CameraOutputCapability> capability =
674         manager_->GetSupportedOutputCapability(device, SceneMode::HIGH_RES_PHOTO);
675 
676     CreateHighResPhotoOutput(previewOutput, photoOutput,
677                              capability->previewProfiles_[0], capability->photoProfiles_[0]);
678     ASSERT_NE(previewOutput, nullptr);
679     ASSERT_NE(photoOutput, nullptr);
680 
681     intResult = highResSession_->AddOutput(previewOutput);
682     EXPECT_EQ(intResult, 0);
683 
684     intResult = highResSession_->AddOutput(photoOutput);
685     EXPECT_EQ(intResult, 0);
686 
687     intResult = highResSession_->CommitConfig();
688     EXPECT_EQ(intResult, 0);
689 
690     std::vector<float> zoomRatioRange = highResSession_->GetZoomRatioRange();
691     ASSERT_NE(zoomRatioRange.size(), 0);
692 }
693 
ConfigSlowMotionSession(sptr<CaptureOutput> & previewOutput_frame,sptr<CaptureOutput> & videoOutput_frame)694 void CameraFrameworkModuleTest::ConfigSlowMotionSession(sptr<CaptureOutput> &previewOutput_frame,
695                                                    sptr<CaptureOutput> &videoOutput_frame)
696 {
697     if (session_) {
698         MEDIA_INFO_LOG("old session exist, need release");
699         session_->Release();
700     }
701     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::SLOW_MOTION);
702     slowMotionSession_ = static_cast<SlowMotionSession*>(captureSession.GetRefPtr());
703     slowMotionSession_->SetCallback(std::make_shared<AppCallback>());
704     ASSERT_NE(slowMotionSession_, nullptr);
705 
706     int32_t intResult = slowMotionSession_->BeginConfig();
707     EXPECT_EQ(intResult, 0);
708 
709     intResult = slowMotionSession_->AddInput(input_);
710     EXPECT_EQ(intResult, 0);
711 
712     Profile previewProfile = previewProfiles[0];
713     const int32_t sizeOfWidth = 1920;
714     const int32_t sizeOfHeight = 1080;
715     for (auto item : previewProfiles) {
716         if (item.GetSize().width == sizeOfWidth && item.GetSize().height == sizeOfHeight) {
717             previewProfile = item;
718             break;
719         }
720     }
721     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
722     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
723     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
724     Size previewSize;
725     previewSize.width = previewProfile.GetSize().width;
726     previewSize.height = previewProfile.GetSize().height;
727     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewProfile.GetCameraFormat()));
728     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
729     sptr<IBufferProducer> bp = previewSurface->GetProducer();
730     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(bp);
731     sptr<CaptureOutput> previewOutput = nullptr;
732     previewOutput_frame = manager_->CreatePreviewOutput(previewProfile, pSurface);
733     ASSERT_NE(previewOutput_frame, nullptr);
734 
735     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
736     sptr<SurfaceListener> videoSurfaceListener =
737         new (std::nothrow) SurfaceListener("Video", SurfaceType::VIDEO, g_videoFd, surface);
738     ASSERT_NE(videoSurfaceListener, nullptr);
739     surface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)videoSurfaceListener);
740 
741     sptr<IBufferProducer> videoProducer = surface->GetProducer();
742     sptr<Surface> videoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
743     std::vector<int32_t> fps = {120, 120};
744     Size size = {.width = 1920, .height = 1080};
745     VideoProfile videoProfile = VideoProfile(CameraFormat::CAMERA_FORMAT_YUV_420_SP, size, fps);
746     videoOutput_frame = manager_->CreateVideoOutput(videoProfile, videoSurface);
747     ASSERT_NE(videoOutput_frame, nullptr);
748 }
749 
CreateHighResPhotoOutput(sptr<CaptureOutput> & previewOutput,sptr<CaptureOutput> & photoOutput,Profile previewProfile,Profile photoProfile)750 void CameraFrameworkModuleTest::CreateHighResPhotoOutput(sptr<CaptureOutput> &previewOutput,
751                                                          sptr<CaptureOutput> &photoOutput,
752                                                          Profile previewProfile,
753                                                          Profile photoProfile)
754 {
755     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
756     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
757     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
758     Size previewSize;
759     previewSize.width = previewProfile.GetSize().width;
760     previewSize.height = previewProfile.GetSize().height;
761     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewProfile.GetCameraFormat()));
762     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
763 
764     sptr<IBufferProducer> bp = previewSurface->GetProducer();
765     sptr<Surface> consumerInPreview = Surface::CreateSurfaceAsProducer(bp);
766     previewOutput = manager_->CreatePreviewOutput(previewProfile, consumerInPreview);
767 
768     sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create();
769     Size photoSize;
770     photoSize.width = photoProfile.GetSize().width;
771     photoSize.height = photoProfile.GetSize().height;
772     sptr<IBufferProducer> surfaceProducerOfPhoto = photoSurface->GetProducer();
773     photoOutput = manager_->CreatePhotoOutput(photoProfile, surfaceProducerOfPhoto);
774 }
775 
ConfigVideoSession(sptr<CaptureOutput> & previewOutput_frame,sptr<CaptureOutput> & videoOutput_frame)776 void CameraFrameworkModuleTest::ConfigVideoSession(sptr<CaptureOutput> &previewOutput_frame,
777                                                    sptr<CaptureOutput> &videoOutput_frame)
778 {
779     if (session_) {
780         MEDIA_INFO_LOG("old session exist, need release");
781         session_->Release();
782     }
783     videoSession_ = manager_ -> CreateCaptureSession(SceneMode::VIDEO);
784     ASSERT_NE(videoSession_, nullptr);
785 
786     int32_t intResult = videoSession_->BeginConfig();
787     EXPECT_EQ(intResult, 0);
788 
789     intResult = videoSession_->AddInput(input_);
790     EXPECT_EQ(intResult, 0);
791 
792     Profile previewProfile = previewProfiles[0];
793     const int32_t sizeOfWidth = 1920;
794     const int32_t sizeOfHeight = 1080;
795     for (auto item : previewProfiles) {
796         if (item.GetSize().width == sizeOfWidth && item.GetSize().height == sizeOfHeight) {
797             previewProfile = item;
798             break;
799         }
800     }
801     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
802     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
803     previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)listener);
804     Size previewSize;
805     previewSize.width = previewProfile.GetSize().width;
806     previewSize.height = previewProfile.GetSize().height;
807     previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewProfile.GetCameraFormat()));
808     previewSurface->SetDefaultWidthAndHeight(previewSize.width, previewSize.height);
809     sptr<IBufferProducer> bp = previewSurface->GetProducer();
810     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(bp);
811     sptr<CaptureOutput> previewOutput = nullptr;
812     previewOutput_frame = manager_->CreatePreviewOutput(previewProfile, pSurface);
813     ASSERT_NE(previewOutput_frame, nullptr);
814 
815     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
816     sptr<SurfaceListener> videoSurfaceListener =
817         new (std::nothrow) SurfaceListener("Video", SurfaceType::VIDEO, g_videoFd, surface);
818     surface->RegisterConsumerListener((sptr<IBufferConsumerListener>&)videoSurfaceListener);
819     ASSERT_NE(videoSurfaceListener, nullptr);
820 
821     sptr<IBufferProducer> videoProducer = surface->GetProducer();
822     sptr<Surface> videoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
823     VideoProfile videoProfile = videoProfiles[0];
824     for (auto item : videoProfiles) {
825         if (item.GetSize().width == sizeOfWidth && item.GetSize().height == sizeOfHeight) {
826             videoProfile = item;
827             break;
828         }
829     }
830     videoOutput_frame = manager_->CreateVideoOutput(videoProfile, videoSurface);
831     ASSERT_NE(videoOutput_frame, nullptr);
832 }
833 
GetSupportedOutputCapability()834 void CameraFrameworkModuleTest::GetSupportedOutputCapability()
835 {
836     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
837     std::vector<sptr<CameraDevice>> cameraObjList = camManagerObj->GetSupportedCameras();
838     ASSERT_GE(cameraObjList.size(), CAMERA_NUMBER);
839     sptr<CameraOutputCapability> outputcapability = camManagerObj->GetSupportedOutputCapability(cameraObjList[1]);
840     previewProfiles = outputcapability->GetPreviewProfiles();
841     ASSERT_TRUE(!previewProfiles.empty());
842 
843     photoProfiles = outputcapability->GetPhotoProfiles();
844     ASSERT_TRUE(!photoProfiles.empty());
845 
846     videoProfiles = outputcapability->GetVideoProfiles();
847     ASSERT_TRUE(!videoProfiles.empty());
848     return;
849 }
850 
SelectProfileByRatioAndFormat(sptr<CameraOutputCapability> & modeAbility,float ratio,CameraFormat format)851 Profile CameraFrameworkModuleTest::SelectProfileByRatioAndFormat(sptr<CameraOutputCapability>& modeAbility,
852                                                                  float ratio, CameraFormat format)
853 {
854     uint32_t width;
855     uint32_t height;
856     float profileRatio;
857     Profile profile;
858     std::vector<Profile> profiles;
859 
860     if (format == photoFormat_) {
861         profiles = modeAbility->GetPhotoProfiles();
862     } else if (format == previewFormat_) {
863         profiles = modeAbility->GetPreviewProfiles();
864     }
865 
866     for (int i = 0; i < profiles.size(); ++i) {
867         width = profiles[i].GetSize().width;
868         height = profiles[i].GetSize().height;
869         profileRatio = float(width) / float(height);
870 
871         if (profileRatio == ratio) {
872             profile = profiles[i];
873             break;
874         }
875     }
876     MEDIA_ERR_LOG("SelectProfileByRatioAndFormat format:%{public}d width:%{public}d height:%{public}d",
877         profile.format_, profile.size_.width, profile.size_.height);
878     return profile;
879 }
880 
ReleaseInput()881 void CameraFrameworkModuleTest::ReleaseInput()
882 {
883     if (input_) {
884         sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
885         camInput->Close();
886         input_->Release();
887     }
888     return;
889 }
890 
SetCameraParameters(sptr<CaptureSession> & session,bool video)891 void CameraFrameworkModuleTest::SetCameraParameters(sptr<CaptureSession>& session, bool video)
892 {
893     session->LockForControl();
894 
895     std::vector<float> zoomRatioRange = session->GetZoomRatioRange();
896     if (!zoomRatioRange.empty()) {
897         session->SetZoomRatio(zoomRatioRange[0]);
898     }
899 
900     // GetExposureBiasRange
901     std::vector<float> exposureBiasRange = session->GetExposureBiasRange();
902     if (!exposureBiasRange.empty()) {
903         session->SetExposureBias(exposureBiasRange[0]);
904     }
905 
906     // Get/Set Exposurepoint
907     Point exposurePoint = { 1, 2 };
908     session->SetMeteringPoint(exposurePoint);
909 
910     // GetFocalLength
911     float focalLength = session->GetFocalLength();
912     EXPECT_NE(focalLength, 0);
913 
914     // Get/Set focuspoint
915     Point focusPoint = { 1, 2 };
916     session->SetFocusPoint(focusPoint);
917 
918     FlashMode flash = FLASH_MODE_OPEN;
919     if (video) {
920         flash = FLASH_MODE_ALWAYS_OPEN;
921     }
922     session->SetFlashMode(flash);
923 
924     FocusMode focus = FOCUS_MODE_AUTO;
925     session->SetFocusMode(focus);
926 
927     ExposureMode exposure = EXPOSURE_MODE_AUTO;
928     session->SetExposureMode(exposure);
929 
930     session->UnlockForControl();
931 
932     Point exposurePointGet = session->GetMeteringPoint();
933     EXPECT_EQ(exposurePointGet.x, exposurePoint.x > 1 ? 1 : exposurePoint.x);
934     EXPECT_EQ(exposurePointGet.y, exposurePoint.y > 1 ? 1 : exposurePoint.y);
935 
936     Point focusPointGet = session->GetFocusPoint();
937     EXPECT_EQ(focusPointGet.x, focusPoint.x > 1 ? 1 : focusPoint.x);
938     EXPECT_EQ(focusPointGet.y, focusPoint.y > 1 ? 1 : focusPoint.y);
939 
940     // exposureBiasRange
941     if (!exposureBiasRange.empty()) {
942         EXPECT_EQ(session->GetExposureValue(), exposureBiasRange[0]);
943     }
944 
945     EXPECT_EQ(session->GetFlashMode(), flash);
946     EXPECT_EQ(session->GetFocusMode(), focus);
947     EXPECT_EQ(session->GetExposureMode(), exposure);
948 }
949 
TestCallbacksSession(sptr<CaptureOutput> photoOutput,sptr<CaptureOutput> videoOutput)950 void CameraFrameworkModuleTest::TestCallbacksSession(sptr<CaptureOutput> photoOutput, sptr<CaptureOutput> videoOutput)
951 {
952     int32_t intResult;
953 
954     if (videoOutput != nullptr) {
955         intResult = session_->Start();
956         EXPECT_EQ(intResult, 0);
957 
958         intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
959         EXPECT_EQ(intResult, 0);
960         sleep(WAIT_TIME_AFTER_START);
961     }
962 
963     if (photoOutput != nullptr) {
964         intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
965         EXPECT_EQ(intResult, 0);
966     }
967 
968     if (videoOutput != nullptr) {
969         intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
970         EXPECT_EQ(intResult, 0);
971     }
972 
973     sleep(WAIT_TIME_BEFORE_STOP);
974     session_->Stop();
975 }
976 
TestCallbacks(sptr<CameraDevice> & cameraInfo,bool video)977 void CameraFrameworkModuleTest::TestCallbacks(sptr<CameraDevice>& cameraInfo, bool video)
978 {
979     int32_t intResult = session_->BeginConfig();
980     EXPECT_EQ(intResult, 0);
981 
982     // Register error callback
983     RegisterErrorCallback();
984 
985     intResult = session_->AddInput(input_);
986     EXPECT_EQ(intResult, 0);
987 
988     sptr<CaptureOutput> photoOutput = nullptr;
989     sptr<CaptureOutput> videoOutput = nullptr;
990     if (!video) {
991         photoOutput = CreatePhotoOutput();
992         ASSERT_NE(photoOutput, nullptr);
993 
994         // Register photo callback
995         ((sptr<PhotoOutput>&)photoOutput)->SetCallback(std::make_shared<AppCallback>());
996         intResult = session_->AddOutput(photoOutput);
997     } else {
998         videoOutput = CreateVideoOutput();
999         ASSERT_NE(videoOutput, nullptr);
1000 
1001         // Register video callback
1002         ((sptr<VideoOutput>&)videoOutput)->SetCallback(std::make_shared<AppVideoCallback>());
1003         intResult = session_->AddOutput(videoOutput);
1004     }
1005 
1006     EXPECT_EQ(intResult, 0);
1007 
1008     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1009     ASSERT_NE(previewOutput, nullptr);
1010 
1011     // Register preview callback
1012     ((sptr<PreviewOutput>&)previewOutput)->SetCallback(std::make_shared<AppCallback>());
1013     intResult = session_->AddOutput(previewOutput);
1014     EXPECT_EQ(intResult, 0);
1015 
1016     intResult = session_->CommitConfig();
1017     EXPECT_EQ(intResult, 0);
1018 
1019     SetCameraParameters(session_, video);
1020 
1021     /* In case of wagner device, once commit config is done with flash on
1022     it is not giving the flash status callback, removing it */
1023     EXPECT_TRUE(g_photoEvents.none());
1024     EXPECT_TRUE(g_previewEvents.none());
1025     EXPECT_TRUE(g_videoEvents.none());
1026 
1027     TestCallbacksSession(photoOutput, videoOutput);
1028 
1029     if (photoOutput != nullptr) {
1030         if (IsSupportNow()) {
1031             EXPECT_TRUE(g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] == 1);
1032         } else {
1033             EXPECT_TRUE(g_photoEvents[static_cast<int>(CAM_PHOTO_EVENTS::CAM_PHOTO_CAPTURE_START)] == 0);
1034         }
1035         ((sptr<PhotoOutput>&)photoOutput)->Release();
1036     }
1037 
1038     if (videoOutput != nullptr) {
1039         EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_FRAME_START)], 1);
1040 
1041         TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1042 
1043         EXPECT_EQ(g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_START)], 1);
1044         EXPECT_EQ(g_videoEvents[static_cast<int>(CAM_VIDEO_EVENTS::CAM_VIDEO_FRAME_END)], 1);
1045 
1046         ((sptr<VideoOutput>&)videoOutput)->Release();
1047     }
1048 
1049     ((sptr<PreviewOutput>&)previewOutput)->Release();
1050 }
1051 
RegisterErrorCallback()1052 void CameraFrameworkModuleTest::RegisterErrorCallback()
1053 {
1054     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
1055     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
1056     camInput->SetErrorCallback(callback);
1057 
1058     EXPECT_EQ(g_camInputOnError, false);
1059 }
1060 
IsSupportNow()1061 bool CameraFrameworkModuleTest::IsSupportNow()
1062 {
1063     const char* deviveTypeString = GetDeviceType();
1064     std::string deviveType = std::string(deviveTypeString);
1065     if (deviveType.compare("default") == 0 ||
1066         (cameras_[0] != nullptr && cameras_[0]->GetConnectionType() == CAMERA_CONNECTION_USB_PLUGIN)) {
1067         return false;
1068     }
1069     return true;
1070 }
1071 
IsSupportMode(SceneMode mode)1072 bool CameraFrameworkModuleTest::IsSupportMode(SceneMode mode)
1073 {
1074     std::vector<SceneMode> modes = manager_->GetSupportedModes(cameras_[0]);
1075     if (modes.size() == 0) {
1076         MEDIA_ERR_LOG("IsSupportMode: modes.size is null");
1077         return false;
1078     }
1079     bool supportMode = false;
1080     for (auto &it : modes) {
1081         if (it == mode) {
1082             supportMode = true;
1083             break;
1084         }
1085     }
1086     return supportMode;
1087 }
1088 
SetUpTestCase(void)1089 void CameraFrameworkModuleTest::SetUpTestCase(void)
1090 {
1091     MEDIA_ERR_LOG("SetUpTestCase of camera test case!");
1092     // set native token
1093     SetNativeToken();
1094     // set hap token please use SetHapToken();
1095 }
1096 
TearDownTestCase(void)1097 void CameraFrameworkModuleTest::TearDownTestCase(void)
1098 {
1099     MEDIA_ERR_LOG("TearDownTestCase of camera test case!");
1100 }
1101 
SetUpInit()1102 void CameraFrameworkModuleTest::SetUpInit()
1103 {
1104     MEDIA_ERR_LOG("SetUpInit of camera test case!");
1105     g_photoEvents.reset();
1106     g_previewEvents.reset();
1107     g_videoEvents.reset();
1108     g_moonCaptureBoostEvents.reset();
1109     g_macroEvents.reset();
1110     g_camStatusMap.clear();
1111     g_camFlashMap.clear();
1112     g_sketchStatus.clear();
1113     g_camInputOnError = false;
1114     g_videoFd = -1;
1115     g_previewFd = -1;
1116     previewFormat_ = CAMERA_FORMAT_YUV_420_SP;
1117     videoFormat_ = CAMERA_FORMAT_YUV_420_SP;
1118     photoFormat_ = CAMERA_FORMAT_JPEG;
1119     previewWidth_ = PREVIEW_DEFAULT_WIDTH;
1120     previewHeight_ = PREVIEW_DEFAULT_HEIGHT;
1121     photoWidth_ = PHOTO_DEFAULT_WIDTH;
1122     photoHeight_ = PHOTO_DEFAULT_HEIGHT;
1123     videoWidth_ = VIDEO_DEFAULT_WIDTH;
1124     videoHeight_ = VIDEO_DEFAULT_HEIGHT;
1125 }
1126 
SetUp()1127 void CameraFrameworkModuleTest::SetUp()
1128 {
1129     MEDIA_ERR_LOG("SetUp testName:%{public}s",
1130         ::testing::UnitTest::GetInstance()->current_test_info()->name());
1131     SetUpInit();
1132     // set hap token please use SetHapToken();
1133     manager_ = CameraManager::GetInstance();
1134     ASSERT_NE(manager_, nullptr);
1135     manager_->SetCallback(std::make_shared<AppCallback>());
1136 
1137     cameras_ = manager_->GetSupportedCameras();
1138     ASSERT_TRUE(cameras_.size() != 0);
1139 
1140     input_ = manager_->CreateCameraInput(cameras_[0]);
1141     ASSERT_NE(input_, nullptr);
1142 
1143     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
1144     std::vector<sptr<CameraDevice>> cameraObjList = camManagerObj->GetSupportedCameras();
1145     sptr<CameraOutputCapability> outputcapability = camManagerObj->GetSupportedOutputCapability(cameraObjList[0]);
1146 
1147     ProcessPreviewProfiles(outputcapability);
1148     ASSERT_TRUE(!previewFormats_.empty());
1149     ASSERT_TRUE(!previewSizes_.empty());
1150     if (std::find(previewFormats_.begin(), previewFormats_.end(), CAMERA_FORMAT_YUV_420_SP) != previewFormats_.end()) {
1151         previewFormat_ = CAMERA_FORMAT_YUV_420_SP;
1152     } else {
1153         previewFormat_ = previewFormats_[0];
1154     }
1155     photoProfiles = outputcapability->GetPhotoProfiles();
1156 
1157     for (auto i : photoProfiles) {
1158         photoFormats_.push_back(i.GetCameraFormat());
1159         photoSizes_.push_back(i.GetSize());
1160     }
1161     ASSERT_TRUE(!photoFormats_.empty());
1162     ASSERT_TRUE(!photoSizes_.empty());
1163     photoFormat_ = photoFormats_[0];
1164     videoProfiles = outputcapability->GetVideoProfiles();
1165 
1166     for (auto i : videoProfiles) {
1167         videoFormats_.push_back(i.GetCameraFormat());
1168         videoSizes_.push_back(i.GetSize());
1169         videoFrameRates_ = i.GetFrameRates();
1170     }
1171     ASSERT_TRUE(!videoFormats_.empty());
1172     ASSERT_TRUE(!videoSizes_.empty());
1173     ASSERT_TRUE(!videoFrameRates_.empty());
1174     if (std::find(videoFormats_.begin(), videoFormats_.end(), CAMERA_FORMAT_YUV_420_SP) != videoFormats_.end()) {
1175         videoFormat_ = CAMERA_FORMAT_YUV_420_SP;
1176     } else {
1177         videoFormat_ = videoFormats_[0];
1178     }
1179     ProcessSize();
1180 }
1181 
TearDown()1182 void CameraFrameworkModuleTest::TearDown()
1183 {
1184     MEDIA_ERR_LOG("TearDown start testName:%{public}s",
1185         ::testing::UnitTest::GetInstance()->current_test_info()->name());
1186     if (input_) {
1187         sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
1188         camInput->Close();
1189         input_->Release();
1190         input_ = nullptr;
1191     }
1192     if (session_) {
1193         MEDIA_ERR_LOG("TearDown session_ release");
1194         session_->Release();
1195         session_ = nullptr;
1196     }
1197     if (scanSession_) {
1198         MEDIA_ERR_LOG("TearDown scanSession_ release");
1199         scanSession_->Release();
1200         scanSession_ = nullptr;
1201     }
1202     if (videoSession_) {
1203         MEDIA_ERR_LOG("TearDown videoSession_ release");
1204         videoSession_->Release();
1205         videoSession_ = nullptr;
1206     }
1207     MEDIA_ERR_LOG("TearDown end testName:%{public}s",
1208         ::testing::UnitTest::GetInstance()->current_test_info()->name());
1209 }
1210 
SetNativeToken()1211 void CameraFrameworkModuleTest::SetNativeToken()
1212 {
1213     uint64_t tokenId;
1214     const char* perms[2];
1215     perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC";
1216     perms[1] = "ohos.permission.CAMERA";
1217     NativeTokenInfoParams infoInstance = {
1218         .dcapsNum = 0,
1219         .permsNum = 2,
1220         .aclsNum = 0,
1221         .dcaps = NULL,
1222         .perms = perms,
1223         .acls = NULL,
1224         .processName = "native_camera_tdd",
1225         .aplStr = "system_basic",
1226     };
1227     tokenId = GetAccessTokenId(&infoInstance);
1228     SetSelfTokenID(tokenId);
1229     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
1230 }
1231 
SetHapToken()1232 void CameraFrameworkModuleTest::SetHapToken()
1233 {
1234     static Security::AccessToken::PermissionStateFull cameraPermission = {
1235         .permissionName = "ohos.permission.CAMERA",
1236         .isGeneral = true,
1237         .resDeviceID = {"local"},
1238         .grantStatus = {Security::AccessToken::PermissionState::PERMISSION_GRANTED},
1239         .grantFlags = {1}
1240     };
1241 
1242     static Security::AccessToken::PermissionStateFull distributePermission = {
1243         .permissionName = "ohos.permission.DISTRIBUTED_DATASYNC",
1244         .isGeneral = true,
1245         .resDeviceID = {"local"},
1246         .grantStatus = {Security::AccessToken::PermissionState::PERMISSION_GRANTED},
1247         .grantFlags = {1}
1248     };
1249 
1250     static Security::AccessToken::HapPolicyParams cameraFwkMstPolicy = {
1251         .apl = Security::AccessToken::APL_SYSTEM_BASIC,
1252         .domain = "test.domain",
1253         // 权限定义,为空即可
1254         .permList = {},
1255         // 要授予的权限
1256         .permStateList = { cameraPermission, distributePermission },
1257     };
1258 
1259     // 模拟应用的参数
1260     Security::AccessToken::HapInfoParams hapInfo = {
1261     .userID = 0,
1262     .bundleName = "com.ohos.cameraFwk.Mst",
1263     .instIndex = 0,
1264     .appIDDesc = "com.ohos.cameraFwk.Mst",
1265     .apiVersion = 0,
1266     .isSystemApp = true
1267 };
1268     Security::AccessToken::AccessTokenIDEx tokenIdEx = {0};
1269     // 获取模拟hap的tokenID
1270     tokenIdEx = Security::AccessToken::AccessTokenKit::AllocHapToken(hapInfo, cameraFwkMstPolicy);
1271     // 将模拟的应用tokenID设置给本测试进程
1272     SetSelfTokenID(tokenIdEx.tokenIDEx);
1273 }
1274 
ProcessPreviewProfiles(sptr<CameraOutputCapability> & outputcapability)1275 void CameraFrameworkModuleTest::ProcessPreviewProfiles(sptr<CameraOutputCapability>& outputcapability)
1276 {
1277     previewProfiles.clear();
1278     std::vector<Profile> tempPreviewProfiles = outputcapability->GetPreviewProfiles();
1279     for (const auto& profile : tempPreviewProfiles) {
1280         if ((profile.size_.width == PRVIEW_WIDTH_176 && profile.size_.height == PRVIEW_HEIGHT_144) ||
1281             (profile.size_.width == PRVIEW_WIDTH_640 && profile.size_.height == PRVIEW_WIDTH_640) ||
1282             (profile.size_.width == PRVIEW_WIDTH_4096 && profile.size_.height == PRVIEW_HEIGHT_3072) ||
1283             (profile.size_.width == PRVIEW_WIDTH_4160 && profile.size_.height == PRVIEW_HEIGHT_3120) ||
1284             (profile.size_.width == PRVIEW_WIDTH_8192 && profile.size_.height == PRVIEW_HEIGHT_6144)) {
1285             MEDIA_DEBUG_LOG("SetUp skip previewProfile width:%{public}d height:%{public}d",
1286                 profile.size_.width, profile.size_.height);
1287             continue;
1288         }
1289         previewProfiles.push_back(profile);
1290     }
1291 
1292     for (auto i : previewProfiles) {
1293         MEDIA_DEBUG_LOG("SetUp previewProfiles width:%{public}d height:%{public}d", i.size_.width, i.size_.height);
1294         previewFormats_.push_back(i.GetCameraFormat());
1295         previewSizes_.push_back(i.GetSize());
1296     }
1297 }
1298 
ProcessSize()1299 void CameraFrameworkModuleTest::ProcessSize()
1300 {
1301     Size size = previewSizes_.back();
1302     previewWidth_ = size.width;
1303     previewHeight_ = size.height;
1304     size = photoSizes_.back();
1305     photoWidth_ = size.width;
1306     photoHeight_ = size.height;
1307     size = videoSizes_.back();
1308     videoWidth_ = size.width;
1309     videoHeight_ = size.height;
1310 
1311     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
1312     camInput->Open();
1313     session_ = manager_->CreateCaptureSession();
1314     ASSERT_NE(session_, nullptr);
1315 }
1316 
ProcessPortraitSession(sptr<PortraitSession> & portraitSession,sptr<CaptureOutput> & previewOutput)1317 void CameraFrameworkModuleTest::ProcessPortraitSession(sptr<PortraitSession>& portraitSession,
1318     sptr<CaptureOutput>& previewOutput)
1319 {
1320     int32_t intResult = portraitSession->AddOutput(previewOutput);
1321     EXPECT_EQ(intResult, 0);
1322 
1323     intResult = portraitSession->CommitConfig();
1324     EXPECT_EQ(intResult, 0);
1325 
1326     portraitSession->LockForControl();
1327 
1328     std::vector<PortraitEffect> effects = portraitSession->GetSupportedPortraitEffects();
1329     if (!effects.empty()) {
1330         portraitSession->SetPortraitEffect(effects[0]);
1331     }
1332 
1333     portraitSession->UnlockForControl();
1334 
1335     if (!effects.empty()) {
1336         EXPECT_EQ(portraitSession->GetPortraitEffect(), effects[0]);
1337     }
1338 }
1339 
1340 /*
1341  * Feature: Framework
1342  * Function: Test Result Callback
1343  * SubFunction: NA
1344  * FunctionPoints: NA
1345  * EnvConditions: NA
1346  * CaseDescription: Test Result Callback
1347  */
1348 
1349 HWTEST_F(CameraFrameworkModuleTest, Camera_ResultCallback_moduletest, TestSize.Level0)
1350 {
1351     int32_t intResult = session_->BeginConfig();
1352     EXPECT_EQ(intResult, 0);
1353 
1354     intResult = session_->AddInput(input_);
1355     EXPECT_EQ(intResult, 0);
1356 
1357     // Register error callback
1358     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
1359     std::shared_ptr<ResultCallback> resultCallback = callback;
1360     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
1361     camInput->SetResultCallback(resultCallback);
1362     EXPECT_EQ(g_camInputOnError, false);
1363 
1364     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1365     ASSERT_NE(previewOutput, nullptr);
1366 
1367     intResult = session_->AddOutput(previewOutput);
1368     EXPECT_EQ(intResult, 0);
1369 
1370     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1371     ASSERT_NE(videoOutput, nullptr);
1372 
1373     intResult = session_->AddOutput(videoOutput);
1374     EXPECT_EQ(intResult, 0);
1375 
1376     intResult = session_->CommitConfig();
1377     EXPECT_EQ(intResult, 0);
1378 
1379     sleep(WAIT_TIME_AFTER_START);
1380     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
1381     EXPECT_EQ(intResult, 0);
1382 
1383     sleep(WAIT_TIME_AFTER_START);
1384 
1385     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
1386     EXPECT_EQ(intResult, 0);
1387 
1388     sleep(WAIT_TIME_AFTER_START);
1389     EXPECT_NE(g_metaResult, nullptr);
1390 
1391     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
1392     EXPECT_EQ(intResult, 0);
1393 
1394     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1395 
1396     sleep(WAIT_TIME_BEFORE_STOP);
1397     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1398     session_->Stop();
1399 }
1400 
1401 /*
1402  * Feature: Framework
1403  * Function: Test get distributed camera hostname
1404  * SubFunction: NA
1405  * FunctionPoints: NA
1406  * EnvConditions: NA
1407  * CaseDescription: Test get distributed camera hostname
1408  */
1409 HWTEST_F(CameraFrameworkModuleTest, Camera_fwInfoManager_moduletest_001, TestSize.Level0)
1410 {
1411     std::string hostName;
1412     for (size_t i = 0; i < cameras_.size(); i++) {
1413         hostName = cameras_[i]->GetHostName();
1414         std::string cameraId = cameras_[i]->GetID();
1415         std::string networkId = cameras_[i]->GetNetWorkId();
1416         if (networkId != "") {
1417             ASSERT_NE(hostName, "");
1418         } else {
1419             ASSERT_EQ(hostName, "");
1420         }
1421     }
1422 }
1423 /*
1424  * Feature: Framework
1425  * Function: Test get DeviceType
1426  * SubFunction: NA
1427  * FunctionPoints: NA
1428  * EnvConditions: NA
1429  * CaseDescription: Test get DeviceType
1430  */
1431 HWTEST_F(CameraFrameworkModuleTest, Camera_fwInfoManager_moduletest_002, TestSize.Level0)
1432 {
1433     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
__anon0f1f2f4b0202() 1434     auto judgeDeviceType = [&cameras]() -> bool {
1435         bool isOk = false;
1436         for (size_t i = 0; i < cameras.size(); i++) {
1437             uint16_t deviceType = cameras[i]->GetDeviceType();
1438             switch (deviceType) {
1439                 case HostDeviceType::UNKNOWN:
1440                 case HostDeviceType::PHONE:
1441                 case HostDeviceType::TABLET:
1442                     isOk = true;
1443                     break;
1444                 default:
1445                     isOk = false;
1446                     break;
1447             }
1448             if (isOk == false) {
1449                 break;
1450             }
1451         }
1452         return isOk;
1453     };
1454     ASSERT_NE(judgeDeviceType(), false);
1455 }
1456 
1457 /*
1458  * Feature: Framework
1459  * Function: Test Capture
1460  * SubFunction: NA
1461  * FunctionPoints: NA
1462  * EnvConditions: NA
1463  * CaseDescription: Test Capture
1464  */
1465 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_001, TestSize.Level0)
1466 {
1467     int32_t intResult = session_->BeginConfig();
1468     EXPECT_EQ(intResult, 0);
1469 
1470     intResult = session_->AddInput(input_);
1471     EXPECT_EQ(intResult, 0);
1472 
1473     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1474     ASSERT_NE(photoOutput, nullptr);
1475 
1476     intResult = session_->AddOutput(photoOutput);
1477     EXPECT_EQ(intResult, 0);
1478 
1479     intResult = session_->CommitConfig();
1480     EXPECT_EQ(intResult, 0);
1481 
1482     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
1483     EXPECT_EQ(intResult, 0);
1484     sleep(WAIT_TIME_AFTER_CAPTURE);
1485 
1486     ((sptr<PhotoOutput>&)photoOutput)->Release();
1487 }
1488 /*
1489  * Feature: Framework
1490  * Function: Test Capture + Preview
1491  * SubFunction: NA
1492  * FunctionPoints: NA
1493  * EnvConditions: NA
1494  * CaseDescription: Test Capture + Preview
1495  */
1496 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_002, TestSize.Level0)
1497 {
1498     int32_t intResult = session_->BeginConfig();
1499     EXPECT_EQ(intResult, 0);
1500 
1501     intResult = session_->AddInput(input_);
1502     EXPECT_EQ(intResult, 0);
1503 
1504     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1505     ASSERT_NE(photoOutput, nullptr);
1506 
1507     intResult = session_->AddOutput(photoOutput);
1508     EXPECT_EQ(intResult, 0);
1509 
1510     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1511     ASSERT_NE(previewOutput, nullptr);
1512 
1513     intResult = session_->AddOutput(previewOutput);
1514     EXPECT_EQ(intResult, 0);
1515 
1516     intResult = session_->CommitConfig();
1517     EXPECT_EQ(intResult, 0);
1518 
1519     sleep(WAIT_TIME_AFTER_START);
1520     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
1521     EXPECT_EQ(intResult, 0);
1522 
1523     sleep(WAIT_TIME_AFTER_START);
1524     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
1525     EXPECT_EQ(intResult, 0);
1526     sleep(WAIT_TIME_AFTER_CAPTURE);
1527 
1528     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1529     session_->Stop();
1530 }
1531 
1532 /*
1533  * Feature: Framework
1534  * Function: Test Preview + Video
1535  * SubFunction: NA
1536  * FunctionPoints: NA
1537  * EnvConditions: NA
1538  * CaseDescription: Test Preview + Video
1539  */
1540 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_003, TestSize.Level0)
1541 {
1542     int32_t intResult = session_->BeginConfig();
1543     EXPECT_EQ(intResult, 0);
1544 
1545     intResult = session_->AddInput(input_);
1546     EXPECT_EQ(intResult, 0);
1547 
1548     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1549     ASSERT_NE(previewOutput, nullptr);
1550 
1551     intResult = session_->AddOutput(previewOutput);
1552     EXPECT_EQ(intResult, 0);
1553 
1554     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1555     ASSERT_NE(videoOutput, nullptr);
1556 
1557     intResult = session_->AddOutput(videoOutput);
1558     EXPECT_EQ(intResult, 0);
1559 
1560     intResult = session_->CommitConfig();
1561     EXPECT_EQ(intResult, 0);
1562 
1563     sleep(WAIT_TIME_AFTER_START);
1564     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
1565     EXPECT_EQ(intResult, 0);
1566 
1567     sleep(WAIT_TIME_AFTER_START);
1568 
1569     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
1570     EXPECT_EQ(intResult, 0);
1571 
1572     sleep(WAIT_TIME_AFTER_START);
1573 
1574     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
1575     EXPECT_EQ(intResult, 0);
1576 
1577     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
1578 
1579     sleep(WAIT_TIME_BEFORE_STOP);
1580     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1581     session_->Stop();
1582 }
1583 
1584 /*
1585  * Feature: Framework
1586  * Function: Test camera status, flash, camera input, photo output and preview output callbacks
1587  * SubFunction: NA
1588  * FunctionPoints: NA
1589  * EnvConditions: NA
1590  * CaseDescription: Test callbacks
1591  */
1592 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_004, TestSize.Level0)
1593 {
1594     TestCallbacks(cameras_[0], false);
1595 }
1596 
1597 /*
1598  * Feature: Framework
1599  * Function: Test camera status, flash, camera input, preview output and video output callbacks
1600  * SubFunction: NA
1601  * FunctionPoints: NA
1602  * EnvConditions: NA
1603  * CaseDescription: Test callbacks
1604  */
1605 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_005, TestSize.Level0)
1606 {
1607     TestCallbacks(cameras_[0], true);
1608 }
1609 
1610 /*
1611  * Feature: Framework
1612  * Function: Test Preview
1613  * SubFunction: NA
1614  * FunctionPoints: NA
1615  * EnvConditions: NA
1616  * CaseDescription: Test Preview
1617  */
1618 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_006, TestSize.Level0)
1619 {
1620     int32_t intResult = session_->BeginConfig();
1621     EXPECT_EQ(intResult, 0);
1622 
1623     intResult = session_->AddInput(input_);
1624     EXPECT_EQ(intResult, 0);
1625 
1626     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1627     ASSERT_NE(previewOutput, nullptr);
1628 
1629     intResult = session_->AddOutput(previewOutput);
1630     EXPECT_EQ(intResult, 0);
1631 
1632     intResult = session_->CommitConfig();
1633     EXPECT_EQ(intResult, 0);
1634 
1635     sleep(WAIT_TIME_AFTER_START);
1636     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
1637     EXPECT_EQ(intResult, 0);
1638 
1639     sleep(WAIT_TIME_AFTER_START);
1640 
1641     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1642     session_->Stop();
1643 }
1644 
1645 /*
1646  * Feature: Framework
1647  * Function: Test Video
1648  * SubFunction: NA
1649  * FunctionPoints: NA
1650  * EnvConditions: NA
1651  * CaseDescription: Test Video
1652  */
1653 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_007, TestSize.Level0)
1654 {
1655     int32_t intResult = session_->BeginConfig();
1656     EXPECT_EQ(intResult, 0);
1657 
1658     intResult = session_->AddInput(input_);
1659     EXPECT_EQ(intResult, 0);
1660 
1661     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1662     ASSERT_NE(previewOutput, nullptr);
1663 
1664     intResult = session_->AddOutput(previewOutput);
1665     EXPECT_EQ(intResult, 0);
1666 
1667     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
1668     ASSERT_NE(videoOutput, nullptr);
1669 
1670     intResult = session_->AddOutput(videoOutput);
1671     EXPECT_EQ(intResult, 0);
1672 
1673     intResult = session_->CommitConfig();
1674     EXPECT_EQ(intResult, 0);
1675     // Video mode without preview is not supported
1676 }
1677 
1678 /*
1679  * Feature: Framework
1680  * Function: Test Custom Preview with invalid resolutions
1681  * SubFunction: NA
1682  * FunctionPoints: NA
1683  * EnvConditions: NA
1684  * CaseDescription: Test Custom Preview with invalid resolution(0 * 0)
1685  */
1686 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_011, TestSize.Level0)
1687 {
1688     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1689     ASSERT_NE(previewOutput, nullptr);
1690 }
1691 
1692 /*
1693  * Feature: Framework
1694  * Function: Test capture session with commit config multiple times
1695  * SubFunction: NA
1696  * FunctionPoints: NA
1697  * EnvConditions: NA
1698  * CaseDescription: Test capture session with commit config multiple times
1699  */
1700 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_017, TestSize.Level0)
1701 {
1702     int32_t intResult = session_->BeginConfig();
1703     EXPECT_EQ(intResult, 0);
1704 
1705     intResult = session_->AddInput(input_);
1706     EXPECT_EQ(intResult, 0);
1707 
1708     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1709     ASSERT_NE(previewOutput, nullptr);
1710 
1711     intResult = session_->AddOutput(previewOutput);
1712     EXPECT_EQ(intResult, 0);
1713 
1714     intResult = session_->CommitConfig();
1715     EXPECT_EQ(intResult, 0);
1716 
1717     sleep(WAIT_TIME_AFTER_START);
1718 
1719     intResult = session_->CommitConfig();
1720     EXPECT_NE(intResult, 0);
1721 }
1722 
1723 /*
1724  * Feature: Framework
1725  * Function: Test capture session add input with invalid value
1726  * SubFunction: NA
1727  * FunctionPoints: NA
1728  * EnvConditions: NA
1729  * CaseDescription: Test capture session add input with invalid value
1730  */
1731 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_018, TestSize.Level0)
1732 {
1733     int32_t intResult = session_->BeginConfig();
1734     EXPECT_EQ(intResult, 0);
1735 
1736     sptr<CaptureInput> input1 = nullptr;
1737     intResult = session_->AddInput(input1);
1738     EXPECT_NE(intResult, 0);
1739 
1740     session_->Stop();
1741 }
1742 
1743 /*
1744  * Feature: Framework
1745  * Function: Test capture session add output with invalid value
1746  * SubFunction: NA
1747  * FunctionPoints: NA
1748  * EnvConditions: NA
1749  * CaseDescription: Test capture session add output with invalid value
1750  */
1751 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_019, TestSize.Level0)
1752 {
1753     int32_t intResult = session_->BeginConfig();
1754     EXPECT_EQ(intResult, 0);
1755 
1756     sptr<CaptureOutput> previewOutput = nullptr;
1757     intResult = session_->AddOutput(previewOutput);
1758     EXPECT_NE(intResult, 0);
1759 
1760     session_->Stop();
1761 }
1762 
1763 /*
1764  * Feature: Framework
1765  * Function: Test capture session commit config without adding input
1766  * SubFunction: NA
1767  * FunctionPoints: NA
1768  * EnvConditions: NA
1769  * CaseDescription: Test capture session commit config without adding input
1770  */
1771 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_020, TestSize.Level0)
1772 {
1773     int32_t intResult = session_->BeginConfig();
1774     EXPECT_EQ(intResult, 0);
1775 
1776     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1777     ASSERT_NE(previewOutput, nullptr);
1778 
1779     intResult = session_->AddOutput(previewOutput);
1780     EXPECT_EQ(intResult, 7400201);
1781 
1782     intResult = session_->CommitConfig();
1783     EXPECT_NE(intResult, 0);
1784 
1785     session_->Stop();
1786 }
1787 
1788 /*
1789  * Feature: Framework
1790  * Function: Test capture session commit config without adding output
1791  * SubFunction: NA
1792  * FunctionPoints: NA
1793  * EnvConditions: NA
1794  * CaseDescription: Test capture session commit config without adding output
1795  */
1796 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_021, TestSize.Level0)
1797 {
1798     int32_t intResult = session_->BeginConfig();
1799     EXPECT_EQ(intResult, 0);
1800 
1801     intResult = session_->AddInput(input_);
1802     EXPECT_EQ(intResult, 0);
1803 
1804     intResult = session_->CommitConfig();
1805     EXPECT_NE(intResult, 0);
1806 
1807     session_->Stop();
1808 }
1809 
1810 /*
1811  * Feature: Framework
1812  * Function: Test capture session start and stop without adding preview output
1813  * SubFunction: NA
1814  * FunctionPoints: NA
1815  * EnvConditions: NA
1816  * CaseDescription: Test capture session start and stop without adding preview output
1817  */
1818 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_022, TestSize.Level0)
1819 {
1820     int32_t intResult = session_->BeginConfig();
1821     EXPECT_EQ(intResult, 0);
1822 
1823     intResult = session_->AddInput(input_);
1824     EXPECT_EQ(intResult, 0);
1825 
1826     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1827     ASSERT_NE(photoOutput, nullptr);
1828 
1829     intResult = session_->AddOutput(photoOutput);
1830     EXPECT_EQ(intResult, 0);
1831 
1832     intResult = session_->CommitConfig();
1833     EXPECT_EQ(intResult, 0);
1834 
1835     intResult = session_->Start();
1836     EXPECT_EQ(intResult, 0);
1837 
1838     intResult = session_->Stop();
1839     EXPECT_EQ(intResult, 0);
1840 }
1841 
1842 /*
1843  * Feature: Framework
1844  * Function: Test capture session without begin config
1845  * SubFunction: NA
1846  * FunctionPoints: NA
1847  * EnvConditions: NA
1848  * CaseDescription: Test capture session without begin config
1849  */
1850 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_023, TestSize.Level0)
1851 {
1852     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
1853     ASSERT_NE(photoOutput, nullptr);
1854 
1855     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1856     ASSERT_NE(previewOutput, nullptr);
1857 
1858     int32_t intResult = session_->AddInput(input_);
1859     EXPECT_NE(intResult, 0);
1860 
1861     intResult = session_->AddOutput(photoOutput);
1862     EXPECT_NE(intResult, 0);
1863 
1864     intResult = session_->AddOutput(previewOutput);
1865     EXPECT_NE(intResult, 0);
1866 
1867     intResult = session_->CommitConfig();
1868     EXPECT_NE(intResult, 0);
1869 
1870     intResult = session_->Start();
1871     EXPECT_NE(intResult, 0);
1872 
1873     sleep(WAIT_TIME_AFTER_START);
1874     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
1875     EXPECT_NE(intResult, 0);
1876 
1877     sleep(WAIT_TIME_AFTER_START);
1878     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
1879     EXPECT_NE(intResult, 0);
1880     sleep(WAIT_TIME_AFTER_CAPTURE);
1881 
1882     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1883     session_->Stop();
1884 }
1885 
1886 /*
1887  * Feature: Framework
1888  * Function: Test capture session with multiple photo outputs
1889  * SubFunction: NA
1890  * FunctionPoints: NA
1891  * EnvConditions: NA
1892  * CaseDescription: Test capture session with multiple photo outputs
1893  */
1894 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_024, TestSize.Level0)
1895 {
1896     if (!IsSupportNow()) {
1897         return;
1898     }
1899     int32_t intResult = session_->BeginConfig();
1900     EXPECT_EQ(intResult, 0);
1901 
1902     intResult = session_->AddInput(input_);
1903     EXPECT_EQ(intResult, 0);
1904 
1905     sptr<CaptureOutput> photoOutput1 = CreatePhotoOutput();
1906     ASSERT_NE(photoOutput1, nullptr);
1907 
1908     intResult = session_->AddOutput(photoOutput1);
1909     EXPECT_EQ(intResult, 0);
1910 
1911     sptr<CaptureOutput> photoOutput2 = CreatePhotoOutput();
1912     ASSERT_NE(photoOutput2, nullptr);
1913 
1914     intResult = session_->AddOutput(photoOutput2);
1915     EXPECT_EQ(intResult, 0);
1916 
1917     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
1918     ASSERT_NE(previewOutput, nullptr);
1919 
1920     intResult = session_->AddOutput(previewOutput);
1921     EXPECT_EQ(intResult, 0);
1922 
1923     intResult = session_->CommitConfig();
1924     EXPECT_EQ(intResult, 0);
1925 
1926     intResult = session_->Start();
1927     EXPECT_EQ(intResult, 0);
1928 
1929     sleep(WAIT_TIME_AFTER_START);
1930     intResult = ((sptr<PhotoOutput>&)photoOutput1)->Capture();
1931     EXPECT_EQ(intResult, 0);
1932     sleep(WAIT_TIME_AFTER_CAPTURE);
1933 
1934     intResult = ((sptr<PhotoOutput>&)photoOutput2)->Capture();
1935     EXPECT_EQ(intResult, 0);
1936     sleep(WAIT_TIME_AFTER_CAPTURE);
1937 
1938     ((sptr<PreviewOutput>&)previewOutput)->Stop();
1939     session_->Stop();
1940 
1941     ((sptr<PhotoOutput>&)photoOutput1)->Release();
1942     ((sptr<PhotoOutput>&)photoOutput2)->Release();
1943 }
1944 
1945 /*
1946  * Feature: Framework
1947  * Function: Test capture session with multiple preview outputs
1948  * SubFunction: NA
1949  * FunctionPoints: NA
1950  * EnvConditions: NA
1951  * CaseDescription: Test capture session with multiple preview ouputs
1952  */
1953 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_025, TestSize.Level0)
1954 {
1955     int32_t intResult = session_->BeginConfig();
1956     EXPECT_EQ(intResult, 0);
1957 
1958     intResult = session_->AddInput(input_);
1959     EXPECT_EQ(intResult, 0);
1960 
1961     sptr<CaptureOutput> previewOutput1 = CreatePreviewOutput();
1962     ASSERT_NE(previewOutput1, nullptr);
1963 
1964     intResult = session_->AddOutput(previewOutput1);
1965     EXPECT_EQ(intResult, 0);
1966 
1967     sptr<CaptureOutput> previewOutput2 = CreatePreviewOutput();
1968     ASSERT_NE(previewOutput2, nullptr);
1969 
1970     intResult = session_->AddOutput(previewOutput2);
1971     EXPECT_EQ(intResult, 0);
1972 
1973     intResult = session_->CommitConfig();
1974     EXPECT_EQ(intResult, 0);
1975 
1976     sleep(WAIT_TIME_AFTER_START);
1977     intResult = ((sptr<PreviewOutput>&)previewOutput1)->Start();
1978     EXPECT_EQ(intResult, 0);
1979 
1980     sleep(WAIT_TIME_AFTER_START);
1981     intResult = ((sptr<PreviewOutput>&)previewOutput2)->Start();
1982     EXPECT_EQ(intResult, 0);
1983 
1984     sleep(WAIT_TIME_AFTER_START);
1985 
1986     ((sptr<PreviewOutput>&)previewOutput1)->Release();
1987     ((sptr<PreviewOutput>&)previewOutput2)->Release();
1988 }
1989 
1990 /*
1991  * Feature: Framework
1992  * Function: Test capture session with multiple video outputs
1993  * SubFunction: NA
1994  * FunctionPoints: NA
1995  * EnvConditions: NA
1996  * CaseDescription: Test capture session with multiple video ouputs
1997  */
1998 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_026, TestSize.Level0)
1999 {
2000     if (!IsSupportNow()) {
2001         return;
2002     }
2003     int32_t intResult = session_->BeginConfig();
2004     EXPECT_EQ(intResult, 0);
2005 
2006     intResult = session_->AddInput(input_);
2007     EXPECT_EQ(intResult, 0);
2008 
2009     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2010     ASSERT_NE(previewOutput, nullptr);
2011 
2012     intResult = session_->AddOutput(previewOutput);
2013     EXPECT_EQ(intResult, 0);
2014 
2015     sptr<CaptureOutput> videoOutput1 = CreateVideoOutput();
2016     ASSERT_NE(videoOutput1, nullptr);
2017 
2018     intResult = session_->AddOutput(videoOutput1);
2019     EXPECT_EQ(intResult, 0);
2020 
2021     sptr<CaptureOutput> videoOutput2 = CreateVideoOutput();
2022     ASSERT_NE(videoOutput2, nullptr);
2023 
2024     intResult = session_->AddOutput(videoOutput2);
2025     EXPECT_EQ(intResult, 0);
2026 
2027     intResult = session_->CommitConfig();
2028     EXPECT_EQ(intResult, 0);
2029 
2030     intResult = session_->Start();
2031     EXPECT_EQ(intResult, 0);
2032     sleep(WAIT_TIME_AFTER_START);
2033     intResult = ((sptr<VideoOutput>&)videoOutput1)->Start();
2034     EXPECT_EQ(intResult, 0);
2035 
2036     intResult = ((sptr<VideoOutput>&)videoOutput2)->Start();
2037     EXPECT_EQ(intResult, 0);
2038 
2039     sleep(WAIT_TIME_AFTER_START);
2040 
2041     intResult = ((sptr<VideoOutput>&)videoOutput1)->Stop();
2042     EXPECT_EQ(intResult, 0);
2043 
2044     intResult = ((sptr<VideoOutput>&)videoOutput2)->Stop();
2045     EXPECT_EQ(intResult, 0);
2046 
2047     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2048 
2049     ((sptr<PreviewOutput>&)previewOutput)->Stop();
2050     session_->Stop();
2051 
2052     ((sptr<VideoOutput>&)videoOutput1)->Release();
2053     ((sptr<VideoOutput>&)videoOutput2)->Release();
2054 }
2055 
2056 /*
2057  * Feature: Framework
2058  * Function: Test capture session start and stop preview multiple times
2059  * SubFunction: NA
2060  * FunctionPoints: NA
2061  * EnvConditions: NA
2062  * CaseDescription: Test capture session start and stop preview multiple times
2063  */
2064 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_027, TestSize.Level0)
2065 {
2066     int32_t intResult = session_->BeginConfig();
2067     EXPECT_EQ(intResult, 0);
2068 
2069     intResult = session_->AddInput(input_);
2070     EXPECT_EQ(intResult, 0);
2071 
2072     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2073     ASSERT_NE(previewOutput, nullptr);
2074 
2075     intResult = session_->AddOutput(previewOutput);
2076     EXPECT_EQ(intResult, 0);
2077 
2078     intResult = session_->CommitConfig();
2079     EXPECT_EQ(intResult, 0);
2080 
2081     sleep(WAIT_TIME_AFTER_START);
2082     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
2083     EXPECT_EQ(intResult, 0);
2084 
2085     sleep(WAIT_TIME_AFTER_START);
2086 
2087     ((sptr<PreviewOutput>&)previewOutput)->Stop();
2088 
2089     sleep(WAIT_TIME_AFTER_START);
2090 
2091     sleep(WAIT_TIME_AFTER_START);
2092     intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
2093     EXPECT_EQ(intResult, 0);
2094 
2095     sleep(WAIT_TIME_AFTER_START);
2096 
2097     ((sptr<PreviewOutput>&)previewOutput)->Stop();
2098 }
2099 
2100 /*
2101  * Feature: Framework
2102  * Function: Test capture session start and stop video multiple times
2103  * SubFunction: NA
2104  * FunctionPoints: NA
2105  * EnvConditions: NA
2106  * CaseDescription: Test capture session start and stop video multiple times
2107  */
2108 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_028, TestSize.Level0)
2109 {
2110     int32_t intResult = session_->BeginConfig();
2111     EXPECT_EQ(intResult, 0);
2112 
2113     intResult = session_->AddInput(input_);
2114     EXPECT_EQ(intResult, 0);
2115 
2116     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2117     ASSERT_NE(previewOutput, nullptr);
2118 
2119     intResult = session_->AddOutput(previewOutput);
2120     EXPECT_EQ(intResult, 0);
2121 
2122     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2123     ASSERT_NE(videoOutput, nullptr);
2124 
2125     intResult = session_->AddOutput(videoOutput);
2126     EXPECT_EQ(intResult, 0);
2127 
2128     intResult = session_->CommitConfig();
2129     EXPECT_EQ(intResult, 0);
2130 
2131     intResult = session_->Start();
2132     EXPECT_EQ(intResult, 0);
2133 
2134     sleep(WAIT_TIME_AFTER_START);
2135 
2136     sleep(WAIT_TIME_AFTER_START);
2137 
2138     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2139     EXPECT_EQ(intResult, 0);
2140 
2141     sleep(WAIT_TIME_AFTER_START);
2142 
2143     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2144     EXPECT_EQ(intResult, 0);
2145 
2146     sleep(WAIT_TIME_AFTER_START);
2147 
2148     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2149     EXPECT_EQ(intResult, 0);
2150 
2151     sleep(WAIT_TIME_AFTER_START);
2152 
2153     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2154     EXPECT_EQ(intResult, 0);
2155 
2156     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2157 
2158     sleep(WAIT_TIME_BEFORE_STOP);
2159 
2160     ((sptr<PreviewOutput>&)previewOutput)->Stop();
2161     session_->Stop();
2162 }
2163 
2164 /*
2165  * Feature: Framework
2166  * Function: Test remove video output and commit when preview + video outputs were committed
2167  * SubFunction: NA
2168  * FunctionPoints: NA
2169  * EnvConditions: NA
2170  * CaseDescription: Test remove video output and commit when preview + video outputs were committed
2171  */
2172 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_029, TestSize.Level0)
2173 {
2174     if (!IsSupportNow()) {
2175         return;
2176     }
2177     int32_t intResult = session_->BeginConfig();
2178     EXPECT_EQ(intResult, 0);
2179 
2180     intResult = session_->AddInput(input_);
2181     EXPECT_EQ(intResult, 0);
2182 
2183     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2184     ASSERT_NE(previewOutput, nullptr);
2185 
2186     intResult = session_->AddOutput(previewOutput);
2187     EXPECT_EQ(intResult, 0);
2188 
2189     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2190     ASSERT_NE(videoOutput, nullptr);
2191 
2192     intResult = session_->AddOutput(videoOutput);
2193     EXPECT_EQ(intResult, 0);
2194 
2195     intResult = session_->CommitConfig();
2196     EXPECT_EQ(intResult, 0);
2197 
2198     intResult = session_->BeginConfig();
2199     EXPECT_EQ(intResult, 0);
2200 
2201     intResult = session_->RemoveOutput(videoOutput);
2202     EXPECT_EQ(intResult, 0);
2203 
2204     intResult = session_->CommitConfig();
2205     EXPECT_EQ(intResult, 0);
2206 
2207     intResult = session_->Start();
2208     EXPECT_EQ(intResult, 0);
2209 
2210     sleep(WAIT_TIME_AFTER_START);
2211     session_->Stop();
2212 }
2213 
2214 /*
2215  * Feature: Framework
2216  * Function: Test remove video output, add photo output and commit when preview + video outputs were committed
2217  * SubFunction: NA
2218  * FunctionPoints: NA
2219  * EnvConditions: NA
2220  * CaseDescription: Test remove video output, add photo output and commit when preview + video outputs were committed
2221  */
2222 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_030, TestSize.Level0)
2223 {
2224     int32_t intResult = session_->BeginConfig();
2225     EXPECT_EQ(intResult, 0);
2226 
2227     intResult = session_->AddInput(input_);
2228     EXPECT_EQ(intResult, 0);
2229 
2230     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2231     ASSERT_NE(previewOutput, nullptr);
2232 
2233     intResult = session_->AddOutput(previewOutput);
2234     EXPECT_EQ(intResult, 0);
2235 
2236     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2237     ASSERT_NE(videoOutput, nullptr);
2238 
2239     intResult = session_->AddOutput(videoOutput);
2240     EXPECT_EQ(intResult, 0);
2241 
2242     intResult = session_->CommitConfig();
2243     EXPECT_EQ(intResult, 0);
2244 
2245     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2246     ASSERT_NE(photoOutput, nullptr);
2247 
2248     intResult = session_->BeginConfig();
2249     EXPECT_EQ(intResult, 0);
2250 
2251     intResult = session_->RemoveOutput(videoOutput);
2252     EXPECT_EQ(intResult, 0);
2253 
2254     intResult = session_->AddOutput(photoOutput);
2255     EXPECT_EQ(intResult, 0);
2256 
2257     intResult = session_->CommitConfig();
2258     EXPECT_EQ(intResult, 0);
2259 
2260     intResult = session_->Start();
2261     EXPECT_EQ(intResult, 0);
2262 
2263     sleep(WAIT_TIME_AFTER_START);
2264     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
2265     EXPECT_EQ(intResult, 0);
2266     sleep(WAIT_TIME_AFTER_CAPTURE);
2267 
2268     session_->Stop();
2269 }
2270 
2271 /*
2272  * Feature: Framework
2273  * Function: Test remove photo output and commit when preview + photo outputs were committed
2274  * SubFunction: NA
2275  * FunctionPoints: NA
2276  * EnvConditions: NA
2277  * CaseDescription: Test remove photo output and commit when preview + photo outputs were committed
2278  */
2279 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_031, TestSize.Level0)
2280 {
2281     if (!IsSupportNow()) {
2282         return;
2283     }
2284     int32_t intResult = session_->BeginConfig();
2285     EXPECT_EQ(intResult, 0);
2286 
2287     intResult = session_->AddInput(input_);
2288     EXPECT_EQ(intResult, 0);
2289 
2290     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2291     ASSERT_NE(previewOutput, nullptr);
2292 
2293     intResult = session_->AddOutput(previewOutput);
2294     EXPECT_EQ(intResult, 0);
2295 
2296     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2297     ASSERT_NE(photoOutput, nullptr);
2298 
2299     intResult = session_->AddOutput(photoOutput);
2300     EXPECT_EQ(intResult, 0);
2301 
2302     intResult = session_->CommitConfig();
2303     EXPECT_EQ(intResult, 0);
2304 
2305     intResult = session_->BeginConfig();
2306     EXPECT_EQ(intResult, 0);
2307 
2308     intResult = session_->RemoveOutput(photoOutput);
2309     EXPECT_EQ(intResult, 0);
2310 
2311     intResult = session_->CommitConfig();
2312     EXPECT_EQ(intResult, 0);
2313 
2314     intResult = session_->Start();
2315     EXPECT_EQ(intResult, 0);
2316 
2317     sleep(WAIT_TIME_AFTER_START);
2318 
2319     session_->Stop();
2320 }
2321 
2322 /*
2323  * Feature: Framework
2324  * Function: Test remove photo output, add video output and commit when preview + photo outputs were committed
2325  * SubFunction: NA
2326  * FunctionPoints: NA
2327  * EnvConditions: NA
2328  * CaseDescription: Test remove photo output, add video output and commit when preview + photo outputs were committed
2329  */
2330 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_032, TestSize.Level0)
2331 {
2332     int32_t intResult = session_->BeginConfig();
2333     EXPECT_EQ(intResult, 0);
2334 
2335     intResult = session_->AddInput(input_);
2336     EXPECT_EQ(intResult, 0);
2337 
2338     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2339     ASSERT_NE(previewOutput, nullptr);
2340 
2341     intResult = session_->AddOutput(previewOutput);
2342     EXPECT_EQ(intResult, 0);
2343 
2344     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2345     ASSERT_NE(photoOutput, nullptr);
2346 
2347     intResult = session_->AddOutput(photoOutput);
2348     EXPECT_EQ(intResult, 0);
2349 
2350     intResult = session_->CommitConfig();
2351     EXPECT_EQ(intResult, 0);
2352 
2353     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2354     ASSERT_NE(videoOutput, nullptr);
2355 
2356     intResult = session_->BeginConfig();
2357     EXPECT_EQ(intResult, 0);
2358 
2359     intResult = session_->RemoveOutput(photoOutput);
2360     EXPECT_EQ(intResult, 0);
2361 
2362     intResult = session_->AddOutput(videoOutput);
2363     EXPECT_EQ(intResult, 0);
2364 
2365     intResult = session_->CommitConfig();
2366     EXPECT_EQ(intResult, 0);
2367 
2368     intResult = session_->Start();
2369     EXPECT_EQ(intResult, 0);
2370 
2371     sleep(WAIT_TIME_AFTER_START);
2372 
2373     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2374     EXPECT_EQ(intResult, 0);
2375 
2376     sleep(WAIT_TIME_AFTER_START);
2377 
2378     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2379     EXPECT_EQ(intResult, 0);
2380 
2381     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2382 
2383     sleep(WAIT_TIME_BEFORE_STOP);
2384 
2385     session_->Stop();
2386 }
2387 
2388 /*
2389  * Feature: Framework
2390  * Function: Test capture session remove output with null
2391  * SubFunction: NA
2392  * FunctionPoints: NA
2393  * EnvConditions: NA
2394  * CaseDescription: Test capture session remove output with null
2395  */
2396 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_033, TestSize.Level0)
2397 {
2398     int32_t intResult = session_->BeginConfig();
2399     EXPECT_EQ(intResult, 0);
2400 
2401     sptr<CaptureOutput> output = nullptr;
2402     intResult = session_->RemoveOutput(output);
2403     EXPECT_NE(intResult, 0);
2404 }
2405 
2406 /*
2407  * Feature: Framework
2408  * Function: Test capture session remove input with null
2409  * SubFunction: NA
2410  * FunctionPoints: NA
2411  * EnvConditions: NA
2412  * CaseDescription: Test capture session remove input with null
2413  */
2414 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_034, TestSize.Level0)
2415 {
2416     int32_t intResult = session_->BeginConfig();
2417     EXPECT_EQ(intResult, 0);
2418 
2419     sptr<CaptureInput> input = nullptr;
2420     intResult = session_->RemoveInput(input);
2421     EXPECT_NE(intResult, 0);
2422 }
2423 
2424 /*
2425  * Feature: Framework
2426  * Function: Test Capture with location setting [lat:1 ,long:1 ,alt:1]
2427  * SubFunction: NA
2428  * FunctionPoints: NA
2429  * EnvConditions: NA
2430  * CaseDescription: Test Capture with location setting
2431  */
2432 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_035, TestSize.Level0)
2433 {
2434     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2435     std::shared_ptr<Location> location = std::make_shared<Location>();
2436     location->latitude = 1;
2437     location->longitude = 1;
2438     location->altitude = 1;
2439 
2440     photoSetting->SetLocation(location);
2441     photoSetting->SetLocation(location);
2442 
2443     int32_t intResult = session_->BeginConfig();
2444     EXPECT_EQ(intResult, 0);
2445 
2446     intResult = session_->AddInput(input_);
2447     EXPECT_EQ(intResult, 0);
2448 
2449     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2450     ASSERT_NE(photoOutput, nullptr);
2451 
2452     intResult = session_->AddOutput(photoOutput);
2453     EXPECT_EQ(intResult, 0);
2454 
2455     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2456     ASSERT_NE(previewOutput, nullptr);
2457 
2458     intResult = session_->AddOutput(previewOutput);
2459     EXPECT_EQ(intResult, 0);
2460 
2461     intResult = session_->CommitConfig();
2462     EXPECT_EQ(intResult, 0);
2463 
2464     intResult = session_->Start();
2465     EXPECT_EQ(intResult, 0);
2466 
2467     sleep(WAIT_TIME_AFTER_START);
2468     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
2469     EXPECT_EQ(intResult, 0);
2470     sleep(WAIT_TIME_AFTER_CAPTURE);
2471 
2472     session_->Stop();
2473 }
2474 
2475 /*
2476  * Feature: Framework
2477  * Function: Test Capture with location setting [lat:0.0 ,long:0.0 ,alt:0.0]
2478  * SubFunction: NA
2479  * FunctionPoints: NA
2480  * EnvConditions: NA
2481  * CaseDescription: Test Capture with location setting
2482  */
2483 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_036, TestSize.Level0)
2484 {
2485     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2486     std::shared_ptr<Location> location = std::make_shared<Location>();
2487     location->latitude = 0.0;
2488     location->longitude = 0.0;
2489     location->altitude = 0.0;
2490 
2491     photoSetting->SetLocation(location);
2492 
2493     int32_t intResult = session_->BeginConfig();
2494     EXPECT_EQ(intResult, 0);
2495 
2496     intResult = session_->AddInput(input_);
2497     EXPECT_EQ(intResult, 0);
2498 
2499     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2500     ASSERT_NE(photoOutput, nullptr);
2501 
2502     intResult = session_->AddOutput(photoOutput);
2503     EXPECT_EQ(intResult, 0);
2504 
2505     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2506     ASSERT_NE(previewOutput, nullptr);
2507 
2508     intResult = session_->AddOutput(previewOutput);
2509     EXPECT_EQ(intResult, 0);
2510 
2511     intResult = session_->CommitConfig();
2512     EXPECT_EQ(intResult, 0);
2513 
2514     intResult = session_->Start();
2515     EXPECT_EQ(intResult, 0);
2516 
2517     sleep(WAIT_TIME_AFTER_START);
2518     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
2519     EXPECT_EQ(intResult, 0);
2520     sleep(WAIT_TIME_AFTER_CAPTURE);
2521 
2522     session_->Stop();
2523 }
2524 
2525 /*
2526  * Feature: Framework
2527  * Function: Test Capture with location setting [lat:-1 ,long:-1 ,alt:-1]
2528  * SubFunction: NA
2529  * FunctionPoints: NA
2530  * EnvConditions: NA
2531  * CaseDescription: Test Capture with location setting
2532  */
2533 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_037, TestSize.Level0)
2534 {
2535     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2536     std::shared_ptr<Location> location = std::make_shared<Location>();
2537     location->latitude = -1;
2538     location->longitude = -1;
2539     location->altitude = -1;
2540 
2541     photoSetting->SetLocation(location);
2542 
2543     int32_t intResult = session_->BeginConfig();
2544     EXPECT_EQ(intResult, 0);
2545 
2546     intResult = session_->AddInput(input_);
2547     EXPECT_EQ(intResult, 0);
2548 
2549     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2550     ASSERT_NE(photoOutput, nullptr);
2551 
2552     intResult = session_->AddOutput(photoOutput);
2553     EXPECT_EQ(intResult, 0);
2554 
2555     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2556     ASSERT_NE(previewOutput, nullptr);
2557 
2558     intResult = session_->AddOutput(previewOutput);
2559     EXPECT_EQ(intResult, 0);
2560 
2561     intResult = session_->CommitConfig();
2562     EXPECT_EQ(intResult, 0);
2563 
2564     intResult = session_->Start();
2565     EXPECT_EQ(intResult, 0);
2566 
2567     sleep(WAIT_TIME_AFTER_START);
2568     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
2569     EXPECT_EQ(intResult, 0);
2570     sleep(WAIT_TIME_AFTER_CAPTURE);
2571 
2572     session_->Stop();
2573 }
2574 
2575 /*
2576  * Feature: Framework
2577  * Function: Test snapshot
2578  * SubFunction: NA
2579  * FunctionPoints: NA
2580  * EnvConditions: NA
2581  * CaseDescription: Test snapshot
2582  */
2583 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_038, TestSize.Level0)
2584 {
2585     int32_t intResult = session_->BeginConfig();
2586     EXPECT_EQ(intResult, 0);
2587 
2588     intResult = session_->AddInput(input_);
2589     EXPECT_EQ(intResult, 0);
2590 
2591     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2592     ASSERT_NE(photoOutput, nullptr);
2593 
2594     intResult = session_->AddOutput(photoOutput);
2595     EXPECT_EQ(intResult, 0);
2596 
2597     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2598     ASSERT_NE(previewOutput, nullptr);
2599 
2600     intResult = session_->AddOutput(previewOutput);
2601     EXPECT_EQ(intResult, 0);
2602 
2603     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2604     ASSERT_NE(videoOutput, nullptr);
2605 
2606     intResult = session_->AddOutput(videoOutput);
2607     EXPECT_EQ(intResult, 0);
2608 
2609     intResult = session_->CommitConfig();
2610     EXPECT_EQ(intResult, 0);
2611 
2612     intResult = session_->Start();
2613     EXPECT_EQ(intResult, 0);
2614 
2615     sleep(WAIT_TIME_AFTER_START);
2616 
2617     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2618     EXPECT_EQ(intResult, 0);
2619 
2620     sleep(WAIT_TIME_AFTER_START);
2621     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
2622     EXPECT_EQ(intResult, 0);
2623     sleep(WAIT_TIME_AFTER_CAPTURE);
2624 
2625     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2626     EXPECT_EQ(intResult, 0);
2627 
2628     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2629 
2630     sleep(WAIT_TIME_BEFORE_STOP);
2631 
2632     session_->Stop();
2633 }
2634 
2635 /*
2636  * Feature: Framework
2637  * Function: Test snapshot with location setting
2638  * SubFunction: NA
2639  * FunctionPoints: NA
2640  * EnvConditions: NA
2641  * CaseDescription: Test snapshot with location setting
2642  */
2643 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_039, TestSize.Level0)
2644 {
2645     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2646     std::shared_ptr<Location> location = std::make_shared<Location>();
2647     location->latitude = 12.972442;
2648     location->longitude = 77.580643;
2649     location->altitude = 0;
2650 
2651     int32_t intResult = session_->BeginConfig();
2652     EXPECT_EQ(intResult, 0);
2653 
2654     intResult = session_->AddInput(input_);
2655     EXPECT_EQ(intResult, 0);
2656 
2657     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
2658     ASSERT_NE(photoOutput, nullptr);
2659 
2660     intResult = session_->AddOutput(photoOutput);
2661     EXPECT_EQ(intResult, 0);
2662 
2663     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2664     ASSERT_NE(previewOutput, nullptr);
2665 
2666     intResult = session_->AddOutput(previewOutput);
2667     EXPECT_EQ(intResult, 0);
2668 
2669     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2670     ASSERT_NE(videoOutput, nullptr);
2671 
2672     intResult = session_->AddOutput(videoOutput);
2673     EXPECT_EQ(intResult, 0);
2674 
2675     intResult = session_->CommitConfig();
2676     EXPECT_EQ(intResult, 0);
2677 
2678     intResult = session_->Start();
2679     EXPECT_EQ(intResult, 0);
2680 
2681     sleep(WAIT_TIME_AFTER_START);
2682 
2683     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2684     EXPECT_EQ(intResult, 0);
2685 
2686     sleep(WAIT_TIME_AFTER_START);
2687     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
2688     EXPECT_EQ(intResult, 0);
2689     sleep(WAIT_TIME_AFTER_CAPTURE);
2690 
2691     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2692     EXPECT_EQ(intResult, 0);
2693 
2694     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2695 
2696     sleep(WAIT_TIME_BEFORE_STOP);
2697 
2698     session_->Stop();
2699 }
2700 
2701 /*
2702  * Feature: Framework
2703  * Function: Test snapshot with mirror setting
2704  * SubFunction: NA
2705  * FunctionPoints: NA
2706  * EnvConditions: NA
2707  * CaseDescription: Test snapshot with mirror setting
2708  */
2709 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_040, TestSize.Level0)
2710 {
2711     ReleaseInput();
2712     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
2713     photoSetting->SetMirror(true);
2714     photoSetting->SetMirror(true);
2715 
2716     int32_t intResult = session_->BeginConfig();
2717     EXPECT_EQ(intResult, 0);
2718 
2719     if (cameras_.size() < 2) {
2720         return;
2721     }
2722 
2723     sptr<CaptureInput> input = manager_->CreateCameraInput(cameras_[1]);
2724     ASSERT_NE(input, nullptr);
2725 
2726     sptr<CameraInput> camInput = (sptr<CameraInput>&)input;
2727     camInput->Open();
2728 
2729     intResult = session_->AddInput(input);
2730     EXPECT_EQ(intResult, 0);
2731 
2732     GetSupportedOutputCapability();
2733 
2734     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(photoProfiles[0]);
2735     ASSERT_NE(photoOutput, nullptr);
2736 
2737     intResult = session_->AddOutput(photoOutput);
2738     EXPECT_EQ(intResult, 0);
2739 
2740     if (!(((sptr<PhotoOutput>&)photoOutput)->IsMirrorSupported())) {
2741         return;
2742     }
2743 
2744     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2745     ASSERT_NE(previewOutput, nullptr);
2746 
2747     intResult = session_->AddOutput(previewOutput);
2748     EXPECT_EQ(intResult, 0);
2749 
2750     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
2751     ASSERT_NE(videoOutput, nullptr);
2752 
2753     intResult = session_->AddOutput(videoOutput);
2754     EXPECT_EQ(intResult, 0);
2755 
2756     intResult = session_->CommitConfig();
2757     EXPECT_EQ(intResult, 0);
2758 
2759     intResult = session_->Start();
2760     EXPECT_EQ(intResult, 0);
2761 
2762     sleep(WAIT_TIME_AFTER_START);
2763 
2764     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
2765     EXPECT_EQ(intResult, 0);
2766 
2767     sleep(WAIT_TIME_AFTER_START);
2768     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
2769     EXPECT_EQ(intResult, 0);
2770     sleep(WAIT_TIME_AFTER_CAPTURE);
2771 
2772     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
2773     EXPECT_EQ(intResult, 0);
2774 
2775     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
2776 
2777     sleep(WAIT_TIME_BEFORE_STOP);
2778 
2779     session_->Stop();
2780 }
2781 
2782 /*
2783  * Feature: Framework
2784  * Function: Test capture session with color effect
2785  * SubFunction: NA
2786  * FunctionPoints: NA
2787  * EnvConditions: NA
2788  * CaseDescription: Test capture session with color effect
2789  */
2790 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_042, TestSize.Level0)
2791 {
2792     int32_t intResult = session_->BeginConfig();
2793     EXPECT_EQ(intResult, 0);
2794 
2795     intResult = session_->AddInput(input_);
2796     EXPECT_EQ(intResult, 0);
2797 
2798     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2799     ASSERT_NE(previewOutput, nullptr);
2800 
2801     intResult = session_->AddOutput(previewOutput);
2802     EXPECT_EQ(intResult, 0);
2803 
2804     intResult = session_->CommitConfig();
2805     EXPECT_EQ(intResult, 0);
2806 
2807     std::vector<ColorEffect> colorEffects = session_->GetSupportedColorEffects();
2808     if (colorEffects.empty()) {
2809         return;
2810     }
2811     ASSERT_EQ(colorEffects.empty(), false);
2812 
2813     ColorEffect colorEffect = colorEffects.back();
2814     session_->LockForControl();
2815     session_->SetColorEffect(colorEffect);
2816     session_->UnlockForControl();
2817     EXPECT_EQ(session_->GetColorEffect(), colorEffect);
2818 
2819     intResult = session_->Start();
2820     EXPECT_EQ(intResult, 0);
2821 
2822     sleep(WAIT_TIME_AFTER_START);
2823 
2824     sleep(WAIT_TIME_BEFORE_STOP);
2825     session_->Stop();
2826 }
2827 
2828 /*
2829  * Feature: Framework
2830  * Function: Test Preview + Metadata
2831  * SubFunction: NA
2832  * FunctionPoints: NA
2833  * EnvConditions: NA
2834  * CaseDescription: Test Preview + Metadata
2835  * @tc.require: SR000GVK5P SR000GVO5O
2836  */
2837 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_043, TestSize.Level0)
2838 {
2839     int32_t intResult = session_->BeginConfig();
2840     EXPECT_EQ(intResult, 0);
2841 
2842     intResult = session_->AddInput(input_);
2843     EXPECT_EQ(intResult, 0);
2844 
2845     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
2846     ASSERT_NE(previewOutput, nullptr);
2847 
2848     intResult = session_->AddOutput(previewOutput);
2849     EXPECT_EQ(intResult, 0);
2850 
2851     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
2852     ASSERT_NE(metadatOutput, nullptr);
2853 
2854     intResult = session_->AddOutput(metadatOutput);
2855     EXPECT_EQ(intResult, 0);
2856 
2857     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
2858     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
2859     if (metadataObjectTypes.size() == 0) {
2860         return;
2861     }
2862 
2863     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
2864 
2865     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
2866     metaOutput->SetCallback(metadataObjectCallback);
2867     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
2868     metaOutput->SetCallback(metadataStateCallback);
2869 
2870     intResult = session_->CommitConfig();
2871     EXPECT_EQ(intResult, 0);
2872 
2873     intResult = session_->Start();
2874     EXPECT_EQ(intResult, 0);
2875 
2876     sleep(WAIT_TIME_AFTER_START);
2877 
2878     session_->Stop();
2879     metaOutput->Release();
2880 }
2881 
2882 /* Feature: Framework
2883  * Function: Test preview/capture with portrait session's portraitEffect
2884  * SubFunction: NA
2885  * FunctionPoints: NA
2886  * EnvConditions: NA
2887  * CaseDescription: Test preview/capture with portrait session's portraitEffect
2888  */
2889 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_045, TestSize.Level0)
2890 {
2891     SceneMode portraitMode = SceneMode::PORTRAIT;
2892     if (!IsSupportMode(portraitMode)) {
2893         return;
2894     }
2895     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
2896     ASSERT_NE(cameraManagerObj, nullptr);
2897 
2898     std::vector<SceneMode> modes = cameraManagerObj->GetSupportedModes(cameras_[0]);
2899     ASSERT_TRUE(modes.size() != 0);
2900 
2901 
2902     sptr<CameraOutputCapability> modeAbility =
2903         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], portraitMode);
2904     ASSERT_NE(modeAbility, nullptr);
2905 
2906     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(portraitMode);
2907 
2908     ASSERT_NE(captureSession, nullptr);
2909     sptr<PortraitSession> portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
2910     ASSERT_NE(portraitSession, nullptr);
2911 
2912     int32_t intResult = portraitSession->BeginConfig();
2913     EXPECT_EQ(intResult, 0);
2914 
2915     intResult = portraitSession->AddInput(input_);
2916     EXPECT_EQ(intResult, 0);
2917 
2918     float ratioWidth = 16;
2919     float ratioHeight = 9;
2920     float ratio = ratioWidth / ratioHeight;
2921     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
2922     ASSERT_NE(profile.format_, -1);
2923 
2924     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
2925     ASSERT_NE(photoOutput, nullptr);
2926 
2927     intResult = portraitSession->AddOutput(photoOutput);
2928     EXPECT_EQ(intResult, 0);
2929 
2930     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
2931     ASSERT_NE(profile.format_, -1);
2932 
2933     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
2934     ASSERT_NE(previewOutput, nullptr);
2935 
2936     ProcessPortraitSession(portraitSession, previewOutput);
2937 
2938     intResult = portraitSession->Start();
2939     EXPECT_EQ(intResult, 0);
2940     sleep(WAIT_TIME_AFTER_START);
2941 
2942     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
2943     EXPECT_EQ(intResult, 0);
2944     sleep(WAIT_TIME_AFTER_CAPTURE);
2945 
2946     portraitSession->Stop();
2947 }
2948 
2949 /* Feature: Framework
2950  * Function: Test preview/capture with portrait session's filter
2951  * SubFunction: NA
2952  * FunctionPoints: NA
2953  * EnvConditions: NA
2954  * CaseDescription: Test preview/capture with portrait session's filter
2955  */
2956 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_046, TestSize.Level0)
2957 {
2958     SceneMode portraitMode = SceneMode::PORTRAIT;
2959     if (!IsSupportMode(portraitMode)) {
2960         return;
2961     }
2962     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
2963     ASSERT_NE(cameraManagerObj, nullptr);
2964 
2965     std::vector<SceneMode> modes = cameraManagerObj->GetSupportedModes(cameras_[0]);
2966     ASSERT_TRUE(modes.size() != 0);
2967 
2968     sptr<CameraOutputCapability> modeAbility =
2969         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], portraitMode);
2970     ASSERT_NE(modeAbility, nullptr);
2971 
2972     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(portraitMode);
2973 
2974     ASSERT_NE(captureSession, nullptr);
2975     sptr<PortraitSession> portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
2976     ASSERT_NE(portraitSession, nullptr);
2977 
2978     int32_t intResult = portraitSession->BeginConfig();
2979     EXPECT_EQ(intResult, 0);
2980 
2981     intResult = portraitSession->AddInput(input_);
2982     EXPECT_EQ(intResult, 0);
2983 
2984     float ratioWidth = 4;
2985     float ratioHeight = 3;
2986     float ratio = ratioWidth / ratioHeight;
2987     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
2988     ASSERT_NE(profile.format_, -1);
2989 
2990     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
2991     ASSERT_NE(photoOutput, nullptr);
2992 
2993     intResult = portraitSession->AddOutput(photoOutput);
2994     EXPECT_EQ(intResult, 0);
2995 
2996     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
2997     ASSERT_NE(profile.format_, -1);
2998 
2999     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
3000     ASSERT_NE(previewOutput, nullptr);
3001 
3002     intResult = portraitSession->AddOutput(previewOutput);
3003     EXPECT_EQ(intResult, 0);
3004 
3005     intResult = portraitSession->CommitConfig();
3006     EXPECT_EQ(intResult, 0);
3007 
3008     portraitSession->LockForControl();
3009 
3010     std::vector<FilterType> filterLists = portraitSession->GetSupportedFilters();
3011     if (!filterLists.empty()) {
3012         portraitSession->SetFilter(filterLists[0]);
3013     }
3014 
3015     portraitSession->UnlockForControl();
3016 
3017     if (!filterLists.empty()) {
3018         EXPECT_EQ(portraitSession->GetFilter(), filterLists[0]);
3019     }
3020 
3021     intResult = portraitSession->Start();
3022     EXPECT_EQ(intResult, 0);
3023     sleep(WAIT_TIME_AFTER_START);
3024 
3025     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
3026     EXPECT_EQ(intResult, 0);
3027     sleep(WAIT_TIME_AFTER_CAPTURE);
3028 
3029     portraitSession->Stop();
3030 }
3031 
3032 /* Feature: Framework
3033  * Function: Test preview/capture with portrait session's beauty
3034  * SubFunction: NA
3035  * FunctionPoints: NA
3036  * EnvConditions: NA
3037  * CaseDescription: Test preview/capture with portrait session's beauty
3038  */
3039 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_047, TestSize.Level0)
3040 {
3041     SceneMode portraitMode = SceneMode::PORTRAIT;
3042     if (!IsSupportMode(portraitMode)) {
3043         return;
3044     }
3045     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3046     ASSERT_NE(cameraManagerObj, nullptr);
3047 
3048     std::vector<SceneMode> modes = cameraManagerObj->GetSupportedModes(cameras_[1]);
3049     ASSERT_TRUE(modes.size() != 0);
3050 
3051     sptr<CameraOutputCapability> modeAbility =
3052         cameraManagerObj->GetSupportedOutputCapability(cameras_[1], portraitMode);
3053     ASSERT_NE(modeAbility, nullptr);
3054 
3055     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(portraitMode);
3056     ASSERT_NE(captureSession, nullptr);
3057     sptr<PortraitSession> portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
3058     ASSERT_NE(portraitSession, nullptr);
3059 
3060     EXPECT_EQ(portraitSession->BeginConfig(), 0);
3061 
3062     if (input_) {
3063         input_->Close();
3064         input_->Release();
3065     }
3066     input_ = cameraManagerObj->CreateCameraInput(cameras_[1]);
3067     int32_t intResult = input_->Open();
3068     EXPECT_EQ(intResult, 0);
3069     EXPECT_EQ(portraitSession->AddInput(input_), 0);
3070 
3071     float ratioWidth = 16;
3072     float ratioHeight = 9;
3073     float ratio = ratioWidth / ratioHeight;
3074     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
3075     ASSERT_NE(profile.format_, -1);
3076 
3077     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
3078     ASSERT_NE(photoOutput, nullptr);
3079 
3080     EXPECT_EQ(portraitSession->AddOutput(photoOutput), 0);
3081 
3082     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
3083     ASSERT_NE(profile.format_, -1);
3084 
3085     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
3086     ASSERT_NE(previewOutput, nullptr);
3087 
3088     EXPECT_EQ(portraitSession->AddOutput(previewOutput), 0);
3089 
3090     EXPECT_EQ(portraitSession->CommitConfig(), 0);
3091 
3092     portraitSession->LockForControl();
3093 
3094     std::vector<BeautyType> beautyLists = portraitSession->GetSupportedBeautyTypes();
3095     EXPECT_GE(beautyLists.size(), 3);
3096 
3097     std::vector<int32_t> rangeLists = {};
3098     if (beautyLists.size() >= 3) {
3099         rangeLists = portraitSession->GetSupportedBeautyRange(beautyLists[0]);
3100     }
3101 
3102     if (beautyLists.size() >= 3) {
3103         portraitSession->SetBeauty(beautyLists[0], rangeLists[0]);
3104     }
3105 
3106     portraitSession->UnlockForControl();
3107 
3108     if (beautyLists.size() >= 3) {
3109         EXPECT_EQ(portraitSession->GetBeauty(beautyLists[0]), rangeLists[0]);
3110     }
3111 
3112     EXPECT_EQ(portraitSession->Start(), 0);
3113     sleep(WAIT_TIME_AFTER_START);
3114 
3115     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
3116     EXPECT_EQ(intResult, 0);
3117     sleep(WAIT_TIME_AFTER_CAPTURE);
3118 
3119     portraitSession->Stop();
3120 }
3121 
3122 /* Feature: Framework
3123  * Function: Test preview/capture with portrait session
3124  * SubFunction: NA
3125  * FunctionPoints: NA
3126  * EnvConditions: NA
3127  * CaseDescription: Test preview/capture with portrait session
3128  */
3129 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_048, TestSize.Level0)
3130 {
3131     SceneMode portraitMode = SceneMode::PORTRAIT;
3132     if (!IsSupportMode(portraitMode)) {
3133         return;
3134     }
3135     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3136     ASSERT_NE(cameraManagerObj, nullptr);
3137 
3138     std::vector<SceneMode> modes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3139     ASSERT_TRUE(modes.size() != 0);
3140 
3141     sptr<CameraOutputCapability> modeAbility =
3142         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], portraitMode);
3143     ASSERT_NE(modeAbility, nullptr);
3144 
3145     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(portraitMode);
3146     ASSERT_NE(captureSession, nullptr);
3147     sptr<PortraitSession> portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
3148     ASSERT_NE(portraitSession, nullptr);
3149 
3150     int32_t intResult = portraitSession->BeginConfig();
3151     EXPECT_EQ(intResult, 0);
3152 
3153     intResult = portraitSession->AddInput(input_);
3154     EXPECT_EQ(intResult, 0);
3155 
3156     float ratioWidth = 4;
3157     float ratioHeight = 3;
3158     float ratio = ratioWidth / ratioHeight;
3159     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
3160     ASSERT_NE(profile.format_, -1);
3161 
3162     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
3163     ASSERT_NE(photoOutput, nullptr);
3164 
3165     intResult = portraitSession->AddOutput(photoOutput);
3166     EXPECT_EQ(intResult, 0);
3167 
3168     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
3169     ASSERT_NE(profile.format_, -1);
3170 
3171     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
3172     ASSERT_NE(previewOutput, nullptr);
3173 
3174     intResult = portraitSession->AddOutput(previewOutput);
3175     EXPECT_EQ(intResult, 0);
3176 
3177     intResult = portraitSession->CommitConfig();
3178     EXPECT_EQ(intResult, 0);
3179 
3180     intResult = portraitSession->Start();
3181     EXPECT_EQ(intResult, 0);
3182     sleep(WAIT_TIME_AFTER_START);
3183 
3184     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
3185     EXPECT_EQ(intResult, 0);
3186     sleep(WAIT_TIME_AFTER_CAPTURE);
3187 
3188     portraitSession->Stop();
3189 }
3190 
3191 /* Feature: Framework
3192  * Function: Test preview/video with profession session
3193  * SubFunction: NA
3194  * FunctionPoints: NA
3195  * EnvConditions: NA
3196  * CaseDescription: Test preview/video with profession session
3197  */
3198 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_071, TestSize.Level0)
3199 {
3200     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3201     if (!IsSupportMode(sceneMode)) {
3202         return;
3203     }
3204     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3205     ASSERT_NE(cameraManagerObj, nullptr);
3206 
3207     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3208     ASSERT_TRUE(sceneModes.size() != 0);
3209 
3210     sptr<CameraOutputCapability> modeAbility =
3211         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3212     ASSERT_NE(modeAbility, nullptr);
3213 
3214     SelectProfiles wanted;
3215     wanted.preview.size_ = {640, 480};
3216     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3217     wanted.photo.size_ = {640, 480};
3218     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
3219     wanted.video.size_ = {640, 480};
3220     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3221     wanted.video.framerates_ = {30, 30};
3222 
3223     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3224     ASSERT_NE(captureSession, nullptr);
3225     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3226     ASSERT_NE(session, nullptr);
3227 
3228     int32_t intResult = session->BeginConfig();
3229     EXPECT_EQ(intResult, 0);
3230 
3231     intResult = session->AddInput(input_);
3232     EXPECT_EQ(intResult, 0);
3233 
3234     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
3235     ASSERT_NE(previewOutput, nullptr);
3236 
3237     intResult = session->AddOutput(previewOutput);
3238     EXPECT_EQ(intResult, 0);
3239 
3240     sptr<CaptureOutput> videoOutput = CreateVideoOutput(wanted.video);
3241     ASSERT_NE(videoOutput, nullptr);
3242 
3243     intResult = session->AddOutput(videoOutput);
3244     EXPECT_EQ(intResult, 0);
3245 
3246 
3247     intResult = session->CommitConfig();
3248     EXPECT_EQ(intResult, 0);
3249 
3250     intResult = session->Start();
3251     EXPECT_EQ(intResult, 0);
3252     sleep(WAIT_TIME_AFTER_START);
3253 
3254     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3255     EXPECT_EQ(intResult, 0);
3256     sleep(WAIT_TIME_AFTER_RECORDING);
3257     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3258     session->Stop();
3259 }
3260 
3261 /* Feature: Framework
3262  * Function: Test profession session metering mode
3263  * SubFunction: NA
3264  * FunctionPoints: NA
3265  * EnvConditions: NA
3266  * CaseDescription: Test profession session metering mode
3267  */
3268 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_072, TestSize.Level0)
3269 {
3270     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3271     if (!IsSupportMode(sceneMode)) {
3272         return;
3273     }
3274     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3275     ASSERT_NE(cameraManagerObj, nullptr);
3276 
3277     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3278     ASSERT_TRUE(sceneModes.size() != 0);
3279 
3280     sptr<CameraOutputCapability> modeAbility =
3281         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3282     ASSERT_NE(modeAbility, nullptr);
3283 
3284     SelectProfiles wanted;
3285     wanted.preview.size_ = {640, 480};
3286     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3287     wanted.photo.size_ = {640, 480};
3288     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
3289     wanted.video.size_ = {640, 480};
3290     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3291     wanted.video.framerates_ = {30, 30};
3292 
3293     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3294     ASSERT_NE(captureSession, nullptr);
3295     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3296     ASSERT_NE(session, nullptr);
3297 
3298     int32_t intResult = session->BeginConfig();
3299     EXPECT_EQ(intResult, 0);
3300 
3301     intResult = session->AddInput(input_);
3302     EXPECT_EQ(intResult, 0);
3303 
3304     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
3305     ASSERT_NE(previewOutput, nullptr);
3306 
3307     intResult = session->AddOutput(previewOutput);
3308     EXPECT_EQ(intResult, 0);
3309 
3310     sptr<CaptureOutput> videoOutput = CreateVideoOutput(wanted.video);
3311     ASSERT_NE(videoOutput, nullptr);
3312 
3313     intResult = session->AddOutput(videoOutput);
3314     EXPECT_EQ(intResult, 0);
3315 
3316     intResult = session->CommitConfig();
3317     EXPECT_EQ(intResult, 0);
3318 
3319     MeteringMode meteringMode = METERING_MODE_CENTER_WEIGHTED;
3320     bool isSupported;
3321     intResult = session->IsMeteringModeSupported(meteringMode, isSupported);
3322     EXPECT_EQ(intResult, 0);
3323     EXPECT_EQ(isSupported, true);
3324 
3325     std::vector<MeteringMode> modes = {};
3326     intResult = session->GetSupportedMeteringModes(modes);
3327     EXPECT_EQ(intResult, 0);
3328     EXPECT_NE(modes.size(), 0);
3329 
3330     session->LockForControl();
3331     intResult = session->SetMeteringMode(modes[0]);
3332     session->UnlockForControl();
3333     EXPECT_EQ(intResult, 0);
3334     intResult = session->GetMeteringMode(meteringMode);
3335     EXPECT_EQ(intResult, 0);
3336 
3337     EXPECT_EQ(meteringMode, modes[0]);
3338     intResult = session->Start();
3339     EXPECT_EQ(intResult, 0);
3340     sleep(WAIT_TIME_AFTER_START);
3341 
3342     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3343     EXPECT_EQ(intResult, 0);
3344     sleep(WAIT_TIME_AFTER_RECORDING);
3345     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3346     session->Stop();
3347 }
3348 
3349 /* Feature: Framework
3350  * Function: Test profession session focus Assist flash mode
3351  * SubFunction: NA
3352  * FunctionPoints: NA
3353  * EnvConditions: NA
3354  * CaseDescription: Test profession session focus Assist flash mode
3355  */
3356 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_073, TestSize.Level0)
3357 {
3358     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3359     if (!IsSupportMode(sceneMode)) {
3360         return;
3361     }
3362     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3363     ASSERT_NE(cameraManagerObj, nullptr);
3364 
3365     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3366     ASSERT_TRUE(sceneModes.size() != 0);
3367 
3368     sptr<CameraOutputCapability> modeAbility =
3369         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3370     ASSERT_NE(modeAbility, nullptr);
3371 
3372     SelectProfiles wanted;
3373     wanted.preview.size_ = {640, 480};
3374     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3375     wanted.photo.size_ = {640, 480};
3376     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
3377     wanted.video.size_ = {640, 480};
3378     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3379     wanted.video.framerates_ = {30, 30};
3380 
3381     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3382     ASSERT_NE(captureSession, nullptr);
3383     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3384     ASSERT_NE(session, nullptr);
3385 
3386     int32_t intResult = session->BeginConfig();
3387     EXPECT_EQ(intResult, 0);
3388 
3389     intResult = session->AddInput(input_);
3390     EXPECT_EQ(intResult, 0);
3391 
3392     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
3393     ASSERT_NE(previewOutput, nullptr);
3394 
3395     intResult = session->AddOutput(previewOutput);
3396     EXPECT_EQ(intResult, 0);
3397 
3398     sptr<CaptureOutput> videoOutput = CreateVideoOutput(wanted.video);
3399     ASSERT_NE(videoOutput, nullptr);
3400 
3401     intResult = session->AddOutput(videoOutput);
3402     EXPECT_EQ(intResult, 0);
3403 
3404     intResult = session->CommitConfig();
3405     EXPECT_EQ(intResult, 0);
3406 
3407     FocusAssistFlashMode mode = FocusAssistFlashMode::FOCUS_ASSIST_FLASH_MODE_DEFAULT;
3408     bool isSupported;
3409     intResult = session->IsFocusAssistFlashModeSupported(mode, isSupported);
3410     EXPECT_EQ(intResult, 0);
3411     EXPECT_EQ(isSupported, true);
3412 
3413     std::vector<FocusAssistFlashMode> modes = {};
3414     intResult = session->GetSupportedFocusAssistFlashModes(modes);
3415     EXPECT_EQ(intResult, 0);
3416     EXPECT_NE(modes.size(), 0);
3417 
3418     session->LockForControl();
3419     intResult = session->SetFocusAssistFlashMode(modes[0]);
3420     session->UnlockForControl();
3421     EXPECT_EQ(intResult, 0);
3422     intResult = session->GetFocusAssistFlashMode(mode);
3423     EXPECT_EQ(intResult, 0);
3424 
3425     EXPECT_EQ(mode, modes[0]);
3426     intResult = session->Start();
3427     EXPECT_EQ(intResult, 0);
3428     sleep(WAIT_TIME_AFTER_START);
3429 
3430     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3431     EXPECT_EQ(intResult, 0);
3432     sleep(WAIT_TIME_AFTER_RECORDING);
3433     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3434     session->Stop();
3435 }
3436 
3437 /* Feature: Framework
3438  * Function: Test profession session exposure hint mode
3439  * SubFunction: NA
3440  * FunctionPoints: NA
3441  * EnvConditions: NA
3442  * CaseDescription: Test profession session exposure hint mode
3443  */
3444 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_074, TestSize.Level0)
3445 {
3446     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3447     if (!IsSupportMode(sceneMode)) {
3448         return;
3449     }
3450     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3451     ASSERT_NE(cameraManagerObj, nullptr);
3452 
3453     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3454     ASSERT_TRUE(sceneModes.size() != 0);
3455 
3456     sptr<CameraOutputCapability> modeAbility =
3457         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3458     ASSERT_NE(modeAbility, nullptr);
3459 
3460     SelectProfiles wanted;
3461     wanted.preview.size_ = {640, 480};
3462     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3463     wanted.photo.size_ = {640, 480};
3464     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
3465     wanted.video.size_ = {640, 480};
3466     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3467     wanted.video.framerates_ = {30, 30};
3468 
3469     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3470     ASSERT_NE(captureSession, nullptr);
3471     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3472     ASSERT_NE(session, nullptr);
3473 
3474     int32_t intResult = session->BeginConfig();
3475     EXPECT_EQ(intResult, 0);
3476 
3477     intResult = session->AddInput(input_);
3478     EXPECT_EQ(intResult, 0);
3479 
3480     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
3481     ASSERT_NE(previewOutput, nullptr);
3482 
3483     intResult = session->AddOutput(previewOutput);
3484     EXPECT_EQ(intResult, 0);
3485 
3486     sptr<CaptureOutput> videoOutput = CreateVideoOutput(wanted.video);
3487     ASSERT_NE(videoOutput, nullptr);
3488 
3489     intResult = session->AddOutput(videoOutput);
3490     EXPECT_EQ(intResult, 0);
3491 
3492 
3493     intResult = session->CommitConfig();
3494     EXPECT_EQ(intResult, 0);
3495     std::vector<ExposureHintMode> modes = {};
3496     intResult = session->GetSupportedExposureHintModes(modes);
3497     EXPECT_EQ(intResult, 0);
3498     EXPECT_NE(modes.size(), 0);
3499 
3500     session->LockForControl();
3501     intResult = session->SetExposureHintMode(modes[0]);
3502     EXPECT_EQ(intResult, 0);
3503     session->UnlockForControl();
3504 
3505     ExposureHintMode mode;
3506     intResult = session->GetExposureHintMode(mode);
3507     EXPECT_EQ(intResult, 0);
3508 
3509     EXPECT_EQ(mode, modes[0]);
3510     intResult = session->Start();
3511     EXPECT_EQ(intResult, 0);
3512     sleep(WAIT_TIME_AFTER_START);
3513 
3514     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3515     EXPECT_EQ(intResult, 0);
3516     sleep(WAIT_TIME_AFTER_RECORDING);
3517     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3518     session->Stop();
3519 }
3520 /*
3521 * Feature: Framework
3522 * Function: Test manual_iso_props && auto_awb_props && manual_awb_props
3523 * SubFunction: NA
3524 * FunctionPoints: NA
3525 * EnvConditions: NA
3526 * CaseDescription: test manual_iso_props && auto_awb_props && manual_awb_props
3527 */
3528 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_075, TestSize.Level0)
3529 {
3530     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3531     if (!IsSupportMode(sceneMode)) {
3532         return;
3533     }
3534     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
3535     ASSERT_NE(modeManagerObj, nullptr);
3536 
3537     std::vector<SceneMode> sceneModes = modeManagerObj->GetSupportedModes(cameras_[0]);
3538     ASSERT_TRUE(sceneModes.size() != 0);
3539 
3540     sptr<CameraOutputCapability> modeAbility =
3541         modeManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3542     ASSERT_NE(modeAbility, nullptr);
3543 
3544     SelectProfiles wanted;
3545     wanted.preview.size_ = {640, 480};
3546     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3547     wanted.photo.size_ = {640, 480};
3548     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
3549     wanted.video.size_ = {640, 480};
3550     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3551     wanted.video.framerates_ = {30, 30};
3552 
3553     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(sceneMode);
3554     ASSERT_NE(captureSession, nullptr);
3555 
3556     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3557     ASSERT_NE(session, nullptr);
3558 
3559     int32_t intResult = session->BeginConfig();
3560     EXPECT_EQ(intResult, 0);
3561 
3562     intResult = session->AddInput(input_);
3563     EXPECT_EQ(intResult, 0);
3564 
3565     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
3566     ASSERT_NE(previewOutput, nullptr);
3567 
3568     intResult = session->AddOutput(previewOutput);
3569     EXPECT_EQ(intResult, 0);
3570 
3571     sptr<CaptureOutput> videoOutput = CreateVideoOutput(wanted.video);
3572     ASSERT_NE(videoOutput, nullptr);
3573 
3574     intResult = session->AddOutput(videoOutput);
3575     EXPECT_EQ(intResult, 0);
3576 
3577     intResult = session->CommitConfig();
3578     EXPECT_EQ(intResult, 0);
3579 
3580     bool isSupported = session->IsManualIsoSupported();
3581     if (isSupported) {
3582         std::vector<int32_t> isoRange;
3583         session->GetIsoRange(isoRange);
3584         ASSERT_EQ(isoRange.empty(), false);
3585         session->LockForControl();
3586         intResult = session->SetISO(isoRange[1]+1);
3587         EXPECT_NE(intResult, 0);
3588         session->UnlockForControl();
3589 
3590         session->LockForControl();
3591         intResult = session->SetISO(isoRange[1]);
3592         EXPECT_EQ(intResult, 0);
3593         session->UnlockForControl();
3594 
3595         int32_t iso;
3596         session->GetISO(iso);
3597         EXPECT_EQ(isoRange[1], iso);
3598     }
3599 
3600     std::vector<WhiteBalanceMode> supportedWhiteBalanceModes;
3601     session->GetSupportedWhiteBalanceModes(supportedWhiteBalanceModes);
3602     if (!supportedWhiteBalanceModes.empty()) {
3603         session->IsWhiteBalanceModeSupported(supportedWhiteBalanceModes[0], isSupported);
3604         ASSERT_EQ(isSupported, true);
3605         session->LockForControl();
3606         intResult = session->SetWhiteBalanceMode(supportedWhiteBalanceModes[0]);
3607         ASSERT_EQ(isSupported, 0);
3608         session->UnlockForControl();
3609         WhiteBalanceMode currentMode;
3610         session->GetWhiteBalanceMode(currentMode);
3611         ASSERT_EQ(currentMode, supportedWhiteBalanceModes[0]);
3612     }
3613 
3614     session->IsManualWhiteBalanceSupported(isSupported);
3615     std::vector<int32_t> whiteBalanceRange;
3616     if (isSupported) {
3617         session->GetManualWhiteBalanceRange(whiteBalanceRange);
3618         ASSERT_EQ(whiteBalanceRange.size() == 2, true);
3619 
3620         session->LockForControl();
3621         intResult = session->SetManualWhiteBalance(whiteBalanceRange[0] - 1);
3622         session->UnlockForControl();
3623 
3624         int32_t wbValue;
3625         session->GetManualWhiteBalance(wbValue);
3626         ASSERT_EQ(wbValue, whiteBalanceRange[0]);
3627     } else {
3628         session->GetManualWhiteBalanceRange(whiteBalanceRange);
3629         ASSERT_EQ(whiteBalanceRange.size() < 2, true);
3630     }
3631 }
3632 
3633 /* Feature: Framework
3634  * Function: Test profession session focus mode
3635  * SubFunction: NA
3636  * FunctionPoints: NA
3637  * EnvConditions: NA
3638  * CaseDescription: Test profession session focus mode
3639  */
3640 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_076, TestSize.Level0)
3641 {
3642     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3643     if (!IsSupportMode(sceneMode)) {
3644         return;
3645     }
3646     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3647     ASSERT_NE(cameraManagerObj, nullptr);
3648 
3649     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3650     ASSERT_TRUE(sceneModes.size() != 0);
3651 
3652     sptr<CameraOutputCapability> modeAbility =
3653         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3654     ASSERT_NE(modeAbility, nullptr);
3655 
3656     SelectProfiles profiles;
3657     profiles.preview.size_ = {640, 480};
3658     profiles.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3659     profiles.photo.size_ = {640, 480};
3660     profiles.photo.format_ = CAMERA_FORMAT_JPEG;
3661     profiles.video.size_ = {640, 480};
3662     profiles.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3663     profiles.video.framerates_ = {30, 30};
3664 
3665     ASSERT_NE(profiles.preview.format_, CAMERA_FORMAT_INVALID);
3666     ASSERT_NE(profiles.photo.format_, CAMERA_FORMAT_INVALID);
3667     ASSERT_NE(profiles.video.format_, CAMERA_FORMAT_INVALID);
3668 
3669     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3670     ASSERT_NE(captureSession, nullptr);
3671     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3672     ASSERT_NE(session, nullptr);
3673 
3674     int32_t intResult = session->BeginConfig();
3675     EXPECT_EQ(intResult, 0);
3676 
3677     intResult = session->AddInput(input_);
3678     EXPECT_EQ(intResult, 0);
3679 
3680     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profiles.preview);
3681     ASSERT_NE(previewOutput, nullptr);
3682 
3683     intResult = session->AddOutput(previewOutput);
3684     EXPECT_EQ(intResult, 0);
3685 
3686     sptr<CaptureOutput> videoOutput = CreateVideoOutput(profiles.video);
3687     ASSERT_NE(videoOutput, nullptr);
3688 
3689     intResult = session->AddOutput(videoOutput);
3690     EXPECT_EQ(intResult, 0);
3691 
3692     intResult = session->CommitConfig();
3693     EXPECT_EQ(intResult, 0);
3694 
3695     FocusMode focusMode = FocusMode::FOCUS_MODE_MANUAL;
3696     bool isSupported;
3697     intResult = session->IsFocusModeSupported(focusMode, isSupported);
3698     EXPECT_EQ(intResult, 0);
3699     EXPECT_EQ(isSupported, true);
3700 
3701     std::vector<FocusMode> modes = {};
3702     intResult = session->GetSupportedFocusModes(modes);
3703     EXPECT_EQ(intResult, 0);
3704     EXPECT_NE(modes.size(), 0);
3705 
3706     session->LockForControl();
3707     intResult = session->SetFocusMode(modes[0]);
3708     session->UnlockForControl();
3709     EXPECT_EQ(intResult, 0);
3710     intResult = session->GetFocusMode(focusMode);
3711     EXPECT_EQ(intResult, 0);
3712 
3713     EXPECT_EQ(focusMode, modes[0]);
3714     intResult = session->Start();
3715     EXPECT_EQ(intResult, 0);
3716     sleep(WAIT_TIME_AFTER_START);
3717 
3718     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3719     EXPECT_EQ(intResult, 0);
3720     sleep(WAIT_TIME_AFTER_RECORDING);
3721     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3722     session->Stop();
3723 }
3724 
3725 /* Feature: Framework
3726  * Function: Test profession session FlashMode
3727  * SubFunction: NA
3728  * FunctionPoints: NA
3729  * EnvConditions: NA
3730  * CaseDescription: Test profession session FlashMode
3731  */
3732 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_077, TestSize.Level0)
3733 {
3734     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3735     if (!IsSupportMode(sceneMode)) {
3736         return;
3737     }
3738     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3739     ASSERT_NE(cameraManagerObj, nullptr);
3740 
3741     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3742     ASSERT_TRUE(sceneModes.size() != 0);
3743 
3744     sptr<CameraOutputCapability> modeAbility =
3745         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3746     ASSERT_NE(modeAbility, nullptr);
3747 
3748     SelectProfiles profiles;
3749     profiles.preview.size_ = {640, 480};
3750     profiles.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3751     profiles.photo.size_ = {640, 480};
3752     profiles.photo.format_ = CAMERA_FORMAT_JPEG;
3753     profiles.video.size_ = {640, 480};
3754     profiles.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3755     profiles.video.framerates_ = {30, 30};
3756 
3757     ASSERT_NE(profiles.preview.format_, CAMERA_FORMAT_INVALID);
3758     ASSERT_NE(profiles.photo.format_, CAMERA_FORMAT_INVALID);
3759     ASSERT_NE(profiles.video.format_, CAMERA_FORMAT_INVALID);
3760 
3761     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3762     ASSERT_NE(captureSession, nullptr);
3763     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3764     ASSERT_NE(session, nullptr);
3765 
3766     int32_t intResult = session->BeginConfig();
3767     EXPECT_EQ(intResult, 0);
3768 
3769     intResult = session->AddInput(input_);
3770     EXPECT_EQ(intResult, 0);
3771 
3772     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profiles.preview);
3773     ASSERT_NE(previewOutput, nullptr);
3774 
3775     intResult = session->AddOutput(previewOutput);
3776     EXPECT_EQ(intResult, 0);
3777 
3778     sptr<CaptureOutput> videoOutput = CreateVideoOutput(profiles.video);
3779     ASSERT_NE(videoOutput, nullptr);
3780 
3781     intResult = session->AddOutput(videoOutput);
3782     EXPECT_EQ(intResult, 0);
3783 
3784     intResult = session->CommitConfig();
3785     EXPECT_EQ(intResult, 0);
3786 
3787     bool isSupported = false;
3788     intResult = session->HasFlash(isSupported);
3789     EXPECT_EQ(isSupported, true);
3790 
3791     std::vector<FlashMode> modes = {};
3792     intResult = session->GetSupportedFlashModes(modes);
3793     EXPECT_EQ(intResult, 0);
3794     EXPECT_NE(modes.size(), 0);
3795 
3796     intResult = session->IsFlashModeSupported(modes[0], isSupported);
3797     EXPECT_EQ(intResult, 0);
3798     EXPECT_EQ(isSupported, true);
3799 
3800     session->LockForControl();
3801     intResult = session->SetFlashMode(modes[0]);
3802     EXPECT_EQ(intResult, 0);
3803     session->UnlockForControl();
3804 
3805     FlashMode mode;
3806     intResult = session->GetFlashMode(mode);
3807     EXPECT_EQ(intResult, 0);
3808     EXPECT_EQ(mode, modes[0]);
3809 }
3810 
3811 /* Feature: Framework
3812  * Function: Test profession session ColorEffect
3813  * SubFunction: NA
3814  * FunctionPoints: NA
3815  * EnvConditions: NA
3816  * CaseDescription: Test profession session ColorEffect
3817  */
3818 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_profession_078, TestSize.Level0)
3819 {
3820     SceneMode sceneMode = SceneMode::PROFESSIONAL_VIDEO;
3821     if (!IsSupportMode(sceneMode)) {
3822         return;
3823     }
3824     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
3825     ASSERT_NE(cameraManagerObj, nullptr);
3826 
3827     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
3828     ASSERT_TRUE(sceneModes.size() != 0);
3829 
3830     sptr<CameraOutputCapability> modeAbility =
3831         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
3832     ASSERT_NE(modeAbility, nullptr);
3833 
3834     SelectProfiles profiles;
3835     profiles.preview.size_ = {640, 480};
3836     profiles.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
3837     profiles.photo.size_ = {640, 480};
3838     profiles.photo.format_ = CAMERA_FORMAT_JPEG;
3839     profiles.video.size_ = {640, 480};
3840     profiles.video.format_ = CAMERA_FORMAT_YUV_420_SP;
3841     profiles.video.framerates_ = {30, 30};
3842 
3843     ASSERT_NE(profiles.preview.format_, CAMERA_FORMAT_INVALID);
3844     ASSERT_NE(profiles.photo.format_, CAMERA_FORMAT_INVALID);
3845     ASSERT_NE(profiles.video.format_, CAMERA_FORMAT_INVALID);
3846 
3847     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
3848     ASSERT_NE(captureSession, nullptr);
3849     sptr<ProfessionSession> session = static_cast<ProfessionSession*>(captureSession.GetRefPtr());
3850     ASSERT_NE(session, nullptr);
3851 
3852     int32_t intResult = session->BeginConfig();
3853     EXPECT_EQ(intResult, 0);
3854 
3855     intResult = session->AddInput(input_);
3856     EXPECT_EQ(intResult, 0);
3857 
3858     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profiles.preview);
3859     ASSERT_NE(previewOutput, nullptr);
3860 
3861     intResult = session->AddOutput(previewOutput);
3862     EXPECT_EQ(intResult, 0);
3863 
3864     sptr<CaptureOutput> videoOutput = CreateVideoOutput(profiles.video);
3865     ASSERT_NE(videoOutput, nullptr);
3866 
3867     intResult = session->AddOutput(videoOutput);
3868     EXPECT_EQ(intResult, 0);
3869 
3870 
3871     intResult = session->CommitConfig();
3872     EXPECT_EQ(intResult, 0);
3873     std::vector<ColorEffect> colorEffects = {};
3874     intResult = session->GetSupportedColorEffects(colorEffects);
3875     EXPECT_EQ(intResult, 0);
3876     EXPECT_NE(colorEffects.size(), 0);
3877 
3878     session->LockForControl();
3879     intResult = session->SetColorEffect(colorEffects[0]);
3880     EXPECT_EQ(intResult, 0);
3881     session->UnlockForControl();
3882 
3883     ColorEffect colorEffect;
3884     intResult = session->GetColorEffect(colorEffect);
3885     EXPECT_EQ(intResult, 0);
3886 
3887     EXPECT_EQ(colorEffect, colorEffects[0]);
3888     intResult = session->Start();
3889     EXPECT_EQ(intResult, 0);
3890     sleep(WAIT_TIME_AFTER_START);
3891 
3892     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
3893     EXPECT_EQ(intResult, 0);
3894     sleep(WAIT_TIME_AFTER_RECORDING);
3895     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
3896     session->Stop();
3897 }
3898 
3899 /*
3900  * Feature: Framework
3901  * Function: Test Scan Session add output
3902  * SubFunction: NA
3903  * FunctionPoints: NA
3904  * EnvConditions: NA
3905  * CaseDescription: Test scan session with two preview outputs
3906  */
3907 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_049, TestSize.Level0)
3908 {
3909     if (!IsSupportNow())
3910     {
3911         return;
3912     }
3913     MEDIA_INFO_LOG("teset049 begin");
3914     sptr<CaptureOutput> previewOutput_1;
3915     sptr<CaptureOutput> previewOutput_2;
3916     ConfigScanSession(previewOutput_1, previewOutput_2);
3917 
3918     int32_t intResult = scanSession_->Start();
3919     EXPECT_EQ(intResult, 0);
3920 
3921     sleep(WAIT_TIME_AFTER_START);
3922 
3923     intResult = scanSession_->Stop();
3924     EXPECT_EQ(intResult, 0);
3925 
3926     ((sptr<PreviewOutput> &) previewOutput_1)->Release();
3927     ((sptr<PreviewOutput> &) previewOutput_2)->Release();
3928     MEDIA_INFO_LOG("teset049 end");
3929 }
3930 
3931 /*
3932  * Feature: Framework
3933  * Function: Test Scan Session add output
3934  * SubFunction: NA
3935  * FunctionPoints: NA
3936  * EnvConditions: NA
3937  * CaseDescription: Test scan session with Capture and video output
3938  */
3939 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_050, TestSize.Level0)
3940 {
3941     if (!IsSupportNow())
3942     {
3943         return;
3944     }
3945     MEDIA_INFO_LOG("teset050 begin");
3946     scanSession_ = manager_ -> CreateCaptureSession(SceneMode::SCAN);
3947     ASSERT_NE(scanSession_, nullptr);
3948 
3949     int32_t intResult = scanSession_->BeginConfig();
3950     EXPECT_EQ(intResult, 0);
3951 
3952     intResult = scanSession_->AddInput(input_);
3953     EXPECT_EQ(intResult, 0);
3954 
3955     sptr<CaptureOutput> phtotOutput = CreatePhotoOutput();
3956     ASSERT_NE(phtotOutput, nullptr);
3957 
3958     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
3959     ASSERT_NE(phtotOutput, nullptr);
3960 
3961     intResult = scanSession_->AddOutput(videoOutput);
3962     EXPECT_NE(intResult, 0);
3963 
3964     intResult = scanSession_->AddOutput(phtotOutput);
3965     EXPECT_NE(intResult, 0);
3966 
3967     intResult = scanSession_->CommitConfig();
3968     EXPECT_NE(intResult, 0);
3969 
3970     ((sptr<PhotoOutput> &) phtotOutput)->Release();
3971     ((sptr<VideoOutput> &) videoOutput)->Release();
3972     MEDIA_INFO_LOG("teset050 end");
3973 }
3974 
3975 /*
3976  * Feature: Framework
3977  * Function: Test Scan Session outputcapability and supported mode
3978  * SubFunction: NA
3979  * FunctionPoints: NA
3980  * EnvConditions: NA
3981  * CaseDescription: Test scan session print outputcapability and supported mode
3982  */
3983 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_051, TestSize.Level0)
3984 {
3985     MEDIA_INFO_LOG("teset051 start");
3986     if (!IsSupportNow()) {
3987         return;
3988     }
3989     sptr<CameraDevice> scanModeDevice = cameras_[0];
3990     vector<SceneMode> modeVec = manager_ -> GetSupportedModes(scanModeDevice);
3991     EXPECT_TRUE(find(modeVec.begin(), modeVec.end(), SceneMode::SCAN) != modeVec.end());
3992 
3993     for (auto iter : modeVec) {
3994         MEDIA_INFO_LOG("get supportedMode : %{public}d", iter);
3995     }
3996 
3997     sptr<CameraOutputCapability> scanCapability =
3998         manager_ -> GetSupportedOutputCapability(scanModeDevice, SceneMode::SCAN);
3999     EXPECT_EQ(scanCapability -> GetPhotoProfiles().size(), 0);
4000     EXPECT_NE(scanCapability -> GetPreviewProfiles().size(), 0);
4001     EXPECT_EQ(scanCapability -> GetVideoProfiles().size(), 0);
4002 
4003     MEDIA_INFO_LOG("photoProfile/previewProfile/videoProfiles size : %{public}zu, %{public}zu, %{public}zu",
4004                     scanCapability -> GetPhotoProfiles().size(),
4005                     scanCapability -> GetPreviewProfiles().size(),
4006                     scanCapability -> GetVideoProfiles().size());
4007     MEDIA_INFO_LOG("teset051 end");
4008 }
4009 
4010 /*
4011  * Feature: Framework
4012  * Function: Test scan session set Focus mode
4013  * SubFunction: NA
4014  * FunctionPoints: NA
4015  * EnvConditions: NA
4016  * CaseDescription: Test scan session set Focus mode
4017  */
4018 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_052, TestSize.Level0)
4019 {
4020     if (!IsSupportNow()) {
4021         return;
4022     }
4023     sptr<CaptureOutput> previewOutput_1;
4024     sptr<CaptureOutput> previewOutput_2;
4025     ConfigScanSession(previewOutput_1, previewOutput_2);
4026 
4027     scanSession_->LockForControl();
4028     int32_t setFocusMode = scanSession_->SetFocusMode(FOCUS_MODE_AUTO);
4029     EXPECT_EQ(setFocusMode, 0);
4030     scanSession_->UnlockForControl();
4031 
4032     FocusMode focusMode = scanSession_->GetFocusMode();
4033     EXPECT_NE(focusMode, FOCUS_MODE_MANUAL);
4034     EXPECT_NE(focusMode, FOCUS_MODE_CONTINUOUS_AUTO);
4035     EXPECT_EQ(focusMode, FOCUS_MODE_AUTO);
4036     EXPECT_NE(focusMode, FOCUS_MODE_LOCKED);
4037 
4038     int32_t getFoucusMode = scanSession_->GetFocusMode(focusMode);
4039     EXPECT_EQ(getFoucusMode, 0);
4040     EXPECT_EQ(focusMode, FOCUS_MODE_AUTO);
4041 
4042     bool isSupported = scanSession_->IsFocusModeSupported(focusMode);
4043     EXPECT_EQ(isSupported, true);
4044 
4045     int32_t isFocusSupported = scanSession_->IsFocusModeSupported(focusMode, isSupported);
4046     EXPECT_EQ(isFocusSupported, 0);
4047     EXPECT_EQ(isSupported, true);
4048 
4049     std::vector<FocusMode> supportedFocusModes = scanSession_->GetSupportedFocusModes();
4050     EXPECT_EQ(supportedFocusModes.empty(), false);
4051 
4052     int32_t getSupportedFocusModes = scanSession_->GetSupportedFocusModes(supportedFocusModes);
4053     EXPECT_EQ(supportedFocusModes.empty(), false);
4054     EXPECT_EQ(getSupportedFocusModes, 0);
4055 
4056     ((sptr<PreviewOutput> &) previewOutput_1)->Release();
4057     ((sptr<PreviewOutput> &) previewOutput_2)->Release();
4058 }
4059 
4060 /*
4061  * Feature: Framework
4062  * Function: Test scan session set Focus Point
4063  * SubFunction: NA
4064  * FunctionPoints: NA
4065  * EnvConditions: NA
4066  * CaseDescription: Test scan session set Focus Point
4067  */
4068 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_053, TestSize.Level0)
4069 {
4070     if (!IsSupportNow()) {
4071         return;
4072     }
4073     sptr<CaptureOutput> previewOutput_1;
4074     sptr<CaptureOutput> previewOutput_2;
4075     ConfigScanSession(previewOutput_1, previewOutput_2);
4076 
4077     Point point = { 1, 1 };
4078     scanSession_->LockForControl();
4079     int32_t setFocusMode = scanSession_->SetFocusPoint(point);
4080     EXPECT_EQ(setFocusMode, 0);
4081     scanSession_->UnlockForControl();
4082 
4083     Point focusPointGet = scanSession_->GetFocusPoint();
4084     EXPECT_EQ(focusPointGet.x, 1);
4085     EXPECT_EQ(focusPointGet.y, 1);
4086 
4087     float focalLength;
4088     int32_t focalLengthGet = scanSession_->GetFocalLength(focalLength);
4089     EXPECT_EQ(focalLengthGet, 0);
4090 
4091     ((sptr<PreviewOutput> &) previewOutput_1)->Release();
4092     ((sptr<PreviewOutput> &) previewOutput_2)->Release();
4093 }
4094 
4095 /*
4096  * Feature: Framework
4097  * Function: Test scan session set Focus Point
4098  * SubFunction: NA
4099  * FunctionPoints: NA
4100  * EnvConditions: NA
4101  * CaseDescription: Test scan session set Zoom Ratio
4102  */
4103 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_054, TestSize.Level0)
4104 {
4105     if (!IsSupportNow()) {
4106         return;
4107     }
4108     sptr<CaptureOutput> previewOutput_1;
4109     sptr<CaptureOutput> previewOutput_2;
4110     ConfigScanSession(previewOutput_1, previewOutput_2);
4111 
4112     scanSession_->LockForControl();
4113     int32_t zoomRatioSet = scanSession_->SetZoomRatio(100);
4114     EXPECT_EQ(zoomRatioSet, 0);
4115     scanSession_->UnlockForControl();
4116 
4117     std::vector<float> zoomRatioRange = scanSession_->GetZoomRatioRange();
4118     EXPECT_EQ(zoomRatioRange.empty(), false);
4119 
4120     int32_t zoomRatioRangeGet = scanSession_->GetZoomRatioRange(zoomRatioRange);
4121     EXPECT_EQ(zoomRatioRange.empty(), false);
4122     EXPECT_EQ(zoomRatioRangeGet, 0);
4123 
4124     float zoomRatio = scanSession_->GetZoomRatio();
4125     int32_t zoomRatioGet = scanSession_->GetZoomRatio(zoomRatio);
4126     EXPECT_EQ(zoomRatioGet, 0);
4127 
4128     ((sptr<PreviewOutput> &) previewOutput_1)->Release();
4129     ((sptr<PreviewOutput> &) previewOutput_2)->Release();
4130 }
4131 
4132 /*
4133  * Feature: Framework
4134  * Function: Test scan session report brightness status
4135  * SubFunction: NA
4136  * FunctionPoints: NA
4137  * EnvConditions: NA
4138  * CaseDescription: Test scan session report brightness status
4139  */
4140 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_scan_055, TestSize.Level0)
4141 {
4142     if (!IsSupportNow()) {
4143         return;
4144     }
4145     sptr<CaptureOutput> previewOutput_1;
4146     sptr<CaptureOutput> previewOutput_2;
4147     ConfigScanSession(previewOutput_1, previewOutput_2);
4148 
4149     auto scanSession = static_cast<ScanSession*>(scanSession_.GetRefPtr());
4150     bool isSupported = scanSession->IsBrightnessStatusSupported();
4151     EXPECT_EQ(isSupported, true);
4152 
4153     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
4154     scanSession->RegisterBrightnessStatusCallback(callback);
4155 
4156     int32_t intResult = scanSession->Start();
4157     EXPECT_EQ(intResult, 0);
4158 
4159     sleep(WAIT_TIME_AFTER_START);
4160 
4161     EXPECT_EQ(g_brightnessStatusChanged, true);
4162 
4163     scanSession->UnRegisterBrightnessStatusCallback();
4164     intResult = scanSession->Stop();
4165     EXPECT_EQ(intResult, 0);
4166 
4167     ((sptr<PreviewOutput> &) previewOutput_1)->Release();
4168     ((sptr<PreviewOutput> &) previewOutput_2)->Release();
4169 }
4170 
4171 /*
4172  * Feature: Framework
4173  * Function: Test photo ability function.
4174  * SubFunction: NA
4175  * FunctionPoints: NA
4176  * EnvConditions: NA
4177  * CaseDescription: Test photo ability function.
4178  */
4179 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_ability001, TestSize.Level0)
4180 {
4181     SceneMode photoMode = SceneMode::CAPTURE;
4182     if (!IsSupportMode(photoMode)) {
4183         return;
4184     }
4185     sptr<CameraManager> cameraMgr = CameraManager::GetInstance();
4186     ASSERT_NE(cameraMgr, nullptr);
4187 
4188     sptr<CameraOutputCapability> capability = cameraMgr->GetSupportedOutputCapability(cameras_[0], photoMode);
4189     ASSERT_NE(capability, nullptr);
4190 
4191     sptr<CaptureSession> captureSession = cameraMgr->CreateCaptureSession(photoMode);
4192     ASSERT_NE(captureSession, nullptr);
4193 
4194     sptr<PhotoSession> photoSession = static_cast<PhotoSession *>(captureSession.GetRefPtr());
4195     ASSERT_NE(photoSession, nullptr);
4196 
4197     std::vector<sptr<CameraOutputCapability>> cocList = photoSession->GetCameraOutputCapabilities(cameras_[0]);
4198     ASSERT_TRUE(cocList.size() != 0);
4199     auto previewProfiles = cocList[0]->GetPreviewProfiles();
4200     auto photoProfiles = cocList[0]->GetPhotoProfiles();
4201     auto videoProfiles = cocList[0]->GetVideoProfiles();
4202 
4203     int32_t intResult = photoSession->BeginConfig();
4204     EXPECT_EQ(intResult, 0);
4205 
4206     intResult = photoSession->AddInput(input_);
4207     EXPECT_EQ(intResult, 0);
4208 
4209     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
4210     ASSERT_NE(photoOutput, nullptr);
4211     intResult = photoSession->AddOutput(photoOutput);
4212     EXPECT_EQ(intResult, 0);
4213 
4214     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4215     ASSERT_NE(previewOutput, nullptr);
4216     intResult = photoSession->AddOutput(previewOutput);
4217     EXPECT_EQ(intResult, 0);
4218 
4219     intResult = photoSession->CommitConfig();
4220     EXPECT_EQ(intResult, 0);
4221 
4222     auto photoFunctionsList = photoSession->GetSessionFunctions(previewProfiles, photoProfiles, videoProfiles, true);
4223     ASSERT_TRUE(photoFunctionsList.size() != 0);
4224     auto photoFunctions = photoFunctionsList[0];
4225     photoFunctions->HasFlash();
4226     photoFunctions->GetSupportedFocusModes();
4227     photoFunctions->GetSupportedBeautyTypes();
4228     photoFunctions->GetSupportedBeautyRange(BeautyType::AUTO_TYPE);
4229     photoFunctions->GetSupportedColorEffects();
4230     photoFunctions->GetSupportedColorSpaces();
4231     photoFunctions->IsFocusModeSupported(FocusMode::FOCUS_MODE_MANUAL);
4232     std::vector<sptr<CameraAbility>> photoConflictFunctionsList = photoSession->GetSessionConflictFunctions();
4233 
4234     std::vector<float> zoomRatioRange = photoSession->GetZoomRatioRange();
4235     ASSERT_NE(zoomRatioRange.size(), 0);
4236 
4237     photoSession->LockForControl();
4238     photoSession->EnableMacro(true);
4239     photoSession->UnlockForControl();
4240 
4241     zoomRatioRange = photoSession->GetZoomRatioRange();
4242     ASSERT_NE(zoomRatioRange.size(), 0);
4243 
4244     photoSession->LockForControl();
4245     photoSession->EnableMacro(false);
4246     photoSession->UnlockForControl();
4247 
4248     photoSession->IsMacroSupported();
4249 
4250     photoSession->LockForControl();
4251     photoSession->SetZoomRatio(zoomRatioRange[1]);
4252     photoSession->UnlockForControl();
4253 
4254     photoSession->IsMacroSupported();
4255 }
4256 
4257 /*
4258  * Feature: Framework
4259  * Function: Test portrait photo ability function.
4260  * SubFunction: NA
4261  * FunctionPoints: NA
4262  * EnvConditions: NA
4263  * CaseDescription: Test portrait photo ability function.
4264  */
4265 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_ability002, TestSize.Level0)
4266 {
4267     SceneMode portraitMode = SceneMode::PORTRAIT;
4268     if (!IsSupportMode(portraitMode)) {
4269         return;
4270     }
4271 
4272     sptr<CameraManager> cameraMgr = CameraManager::GetInstance();
4273     ASSERT_NE(cameraMgr, nullptr);
4274 
4275     sptr<CameraOutputCapability> capability = cameraMgr->GetSupportedOutputCapability(cameras_[0], portraitMode);
4276     ASSERT_NE(capability, nullptr);
4277 
4278     sptr<CaptureSession> captureSession = cameraMgr->CreateCaptureSession(portraitMode);
4279     ASSERT_NE(captureSession, nullptr);
4280 
4281     sptr<PortraitSession> portraitSession = static_cast<PortraitSession *>(captureSession.GetRefPtr());
4282     ASSERT_NE(portraitSession, nullptr);
4283 
4284     std::vector<sptr<CameraOutputCapability>> cocList = portraitSession->GetCameraOutputCapabilities(cameras_[0]);
4285     ASSERT_TRUE(cocList.size() != 0);
4286     auto previewProfiles = cocList[0]->GetPreviewProfiles();
4287     auto photoProfiles = cocList[0]->GetPhotoProfiles();
4288     auto videoProfiles = cocList[0]->GetVideoProfiles();
4289 
4290     int32_t intResult = portraitSession->BeginConfig();
4291     EXPECT_EQ(intResult, 0);
4292 
4293     intResult = portraitSession->AddInput(input_);
4294     EXPECT_EQ(intResult, 0);
4295 
4296     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
4297     ASSERT_NE(photoOutput, nullptr);
4298     intResult = portraitSession->AddOutput(photoOutput);
4299     EXPECT_EQ(intResult, 0);
4300 
4301     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4302     ASSERT_NE(previewOutput, nullptr);
4303     intResult = portraitSession->AddOutput(previewOutput);
4304     EXPECT_EQ(intResult, 0);
4305 
4306     intResult = portraitSession->CommitConfig();
4307     EXPECT_EQ(intResult, 0);
4308 
4309     auto portraitFunctionsList = portraitSession->GetSessionFunctions(previewProfiles, photoProfiles, videoProfiles, true);
4310     ASSERT_TRUE(portraitFunctionsList.size() != 0);
4311     auto portraitFunctions = portraitFunctionsList[0];
4312     portraitFunctions->GetSupportedPortraitEffects();
4313     portraitFunctions->GetSupportedVirtualApertures();
4314     portraitFunctions->GetSupportedPhysicalApertures();
4315     std::vector<sptr<CameraAbility>> portraitConflictFunctionsList = portraitSession->GetSessionConflictFunctions();
4316 }
4317 
4318 /*
4319  * Feature: Framework
4320  * Function: Test video ability function.
4321  * SubFunction: NA
4322  * FunctionPoints: NA
4323  * EnvConditions: NA
4324  * CaseDescription: Test video ability function.
4325  */
4326 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_ability003, TestSize.Level0)
4327 {
4328     SceneMode videoMode = SceneMode::VIDEO;
4329     if (!IsSupportMode(videoMode)) {
4330         return;
4331     }
4332     sptr<CameraManager> cameraMgr = CameraManager::GetInstance();
4333     ASSERT_NE(cameraMgr, nullptr);
4334 
4335     sptr<CameraOutputCapability> capability = cameraMgr->GetSupportedOutputCapability(cameras_[0], videoMode);
4336     ASSERT_NE(capability, nullptr);
4337 
4338     sptr<CaptureSession> captureSession = cameraMgr->CreateCaptureSession(videoMode);
4339     ASSERT_NE(captureSession, nullptr);
4340 
4341     sptr<VideoSession> videoSession = static_cast<VideoSession *>(captureSession.GetRefPtr());
4342     ASSERT_NE(videoSession, nullptr);
4343 
4344     std::vector<sptr<CameraOutputCapability>> cocList = videoSession->GetCameraOutputCapabilities(cameras_[0]);
4345     ASSERT_TRUE(cocList.size() != 0);
4346     auto previewProfiles = cocList[0]->GetPreviewProfiles();
4347     auto photoProfiles = cocList[0]->GetPhotoProfiles();
4348     auto videoProfiles = cocList[0]->GetVideoProfiles();
4349 
4350     int32_t intResult = videoSession->BeginConfig();
4351     EXPECT_EQ(intResult, 0);
4352 
4353     intResult = videoSession->AddInput(input_);
4354     EXPECT_EQ(intResult, 0);
4355 
4356     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
4357     ASSERT_NE(photoOutput, nullptr);
4358     intResult = videoSession->AddOutput(photoOutput);
4359     EXPECT_EQ(intResult, 0);
4360 
4361     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4362     ASSERT_NE(previewOutput, nullptr);
4363     intResult = videoSession->AddOutput(previewOutput);
4364     EXPECT_EQ(intResult, 0);
4365 
4366     intResult = videoSession->CommitConfig();
4367     EXPECT_EQ(intResult, 0);
4368 
4369     auto videoFunctionsList = videoSession->GetSessionFunctions(previewProfiles, photoProfiles, videoProfiles, true);
4370     ASSERT_TRUE(videoFunctionsList.size() != 0);
4371     auto videoFunctions = videoFunctionsList[0];
4372     videoFunctions->GetSupportedStabilizationMode();
4373     videoFunctions->IsVideoStabilizationModeSupported(VideoStabilizationMode::HIGH);
4374     std::vector<sptr<CameraAbility>> videoConflictFunctionsList = videoSession->GetSessionConflictFunctions();
4375 }
4376 
4377 /*
4378  * Feature: Framework
4379  * Function: Test anomalous branch.
4380  * SubFunction: NA
4381  * FunctionPoints: NA
4382  * EnvConditions: NA
4383  * CaseDescription: Test capture session video stabilization mode with anomalous branch.
4384  */
4385 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_001, TestSize.Level0)
4386 {
4387     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4388     ASSERT_NE(camSession, nullptr);
4389 
4390     VideoStabilizationMode stabilizationMode = camSession->GetActiveVideoStabilizationMode();
4391     EXPECT_EQ(stabilizationMode, OFF);
4392 
4393     int32_t actVideoStaMode = camSession->SetVideoStabilizationMode(stabilizationMode);
4394     EXPECT_EQ(actVideoStaMode, 7400103);
4395 
4396     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
4397     EXPECT_EQ(actVideoStaMode, 7400103);
4398 
4399     bool isSupported = true;
4400 
4401     int32_t videoStaModeSupported = camSession->IsVideoStabilizationModeSupported(stabilizationMode, isSupported);
4402     EXPECT_EQ(videoStaModeSupported, 7400103);
4403 
4404     std::vector<VideoStabilizationMode> videoStabilizationMode = camSession->GetSupportedStabilizationMode();
4405     EXPECT_EQ(videoStabilizationMode.empty(), true);
4406 
4407     int32_t supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
4408     EXPECT_EQ(supportedVideoStaMode, 7400103);
4409 
4410     int32_t intResult = camSession->BeginConfig();
4411     EXPECT_EQ(intResult, 0);
4412 
4413     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4414     ASSERT_NE(input, nullptr);
4415 
4416     intResult = camSession->AddInput(input);
4417     EXPECT_EQ(intResult, 0);
4418 
4419     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4420     ASSERT_NE(previewOutput, nullptr);
4421 
4422     intResult = camSession->AddOutput(previewOutput);
4423     EXPECT_EQ(intResult, 0);
4424 
4425     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
4426     ASSERT_NE(videoOutput, nullptr);
4427 
4428     intResult = camSession->AddOutput(videoOutput);
4429     EXPECT_EQ(intResult, 0);
4430 
4431     intResult = camSession->CommitConfig();
4432     EXPECT_EQ(intResult, 0);
4433 
4434     videoStaModeSupported = camSession->IsVideoStabilizationModeSupported(stabilizationMode, isSupported);
4435     EXPECT_EQ(videoStaModeSupported, 0);
4436 
4437     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
4438     EXPECT_EQ(actVideoStaMode, 0);
4439 
4440     supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
4441     EXPECT_EQ(supportedVideoStaMode, 0);
4442 
4443     ReleaseInput();
4444 
4445     stabilizationMode = camSession->GetActiveVideoStabilizationMode();
4446     EXPECT_EQ(stabilizationMode, OFF);
4447 
4448     actVideoStaMode = camSession->GetActiveVideoStabilizationMode(stabilizationMode);
4449     EXPECT_EQ(actVideoStaMode, 0);
4450 
4451     videoStabilizationMode = camSession->GetSupportedStabilizationMode();
4452     EXPECT_EQ(videoStabilizationMode.empty(), true);
4453 
4454     supportedVideoStaMode = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
4455     EXPECT_EQ(supportedVideoStaMode, 0);
4456 }
4457 
4458 /*
4459  * Feature: Framework
4460  * Function: Test anomalous branch.
4461  * SubFunction: NA
4462  * FunctionPoints: NA
4463  * EnvConditions: NA
4464  * CaseDescription: Test capture session exposure mode with anomalous branch.
4465  */
4466 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_002, TestSize.Level0)
4467 {
4468     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4469     ASSERT_NE(camSession, nullptr);
4470 
4471     ExposureMode exposureMode = camSession->GetExposureMode();
4472     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
4473 
4474     int32_t getExposureMode = camSession->GetExposureMode(exposureMode);
4475     EXPECT_EQ(getExposureMode, 7400103);
4476 
4477     int32_t setExposureMode = camSession->SetExposureMode(exposureMode);
4478     EXPECT_EQ(setExposureMode, 7400103);
4479 
4480     bool isExposureModeSupported = camSession->IsExposureModeSupported(exposureMode);
4481     EXPECT_EQ(isExposureModeSupported, false);
4482 
4483     bool isSupported = true;
4484 
4485     int32_t exposureModeSupported = camSession->IsExposureModeSupported(exposureMode, isSupported);
4486     EXPECT_EQ(exposureModeSupported, 7400103);
4487 
4488     std::vector<ExposureMode> getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
4489     EXPECT_EQ(getSupportedExpModes_1.empty(), true);
4490 
4491     int32_t getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
4492     EXPECT_EQ(getSupportedExpModes_2, 7400103);
4493 
4494     int32_t intResult = camSession->BeginConfig();
4495     EXPECT_EQ(intResult, 0);
4496 
4497     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4498     ASSERT_NE(input, nullptr);
4499 
4500     intResult = camSession->AddInput(input);
4501     EXPECT_EQ(intResult, 0);
4502 
4503     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4504     ASSERT_NE(previewOutput, nullptr);
4505 
4506     intResult = camSession->AddOutput(previewOutput);
4507     EXPECT_EQ(intResult, 0);
4508 
4509     intResult = camSession->CommitConfig();
4510     EXPECT_EQ(intResult, 0);
4511 
4512     setExposureMode = camSession->SetExposureMode(exposureMode);
4513     EXPECT_EQ(setExposureMode, 0);
4514 
4515     getExposureMode = camSession->GetExposureMode(exposureMode);
4516     EXPECT_EQ(getExposureMode, 0);
4517 
4518     exposureModeSupported = camSession->IsExposureModeSupported(exposureMode, isSupported);
4519     EXPECT_EQ(exposureModeSupported, 0);
4520 
4521     getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
4522     EXPECT_EQ(getSupportedExpModes_1.empty(), false);
4523 
4524     getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
4525     EXPECT_EQ(getSupportedExpModes_2, 0);
4526 
4527     ReleaseInput();
4528 
4529     getSupportedExpModes_1 = camSession->GetSupportedExposureModes();
4530     EXPECT_EQ(getSupportedExpModes_1.empty(), true);
4531 
4532     getSupportedExpModes_2 = camSession->GetSupportedExposureModes(getSupportedExpModes_1);
4533     EXPECT_EQ(getSupportedExpModes_2, 0);
4534 
4535     exposureMode = camSession->GetExposureMode();
4536     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
4537 
4538     getExposureMode = camSession->GetExposureMode(exposureMode);
4539     EXPECT_EQ(getExposureMode, 0);
4540 }
4541 
4542 /*
4543  * Feature: Framework
4544  * Function: Test anomalous branch.
4545  * SubFunction: NA
4546  * FunctionPoints: NA
4547  * EnvConditions: NA
4548  * CaseDescription: Test capture session metering point with anomalous branch.
4549  */
4550 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_003, TestSize.Level0)
4551 {
4552     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4553     ASSERT_NE(camSession, nullptr);
4554 
4555     Point exposurePointGet = camSession->GetMeteringPoint();
4556     EXPECT_EQ(exposurePointGet.x, 0);
4557     EXPECT_EQ(exposurePointGet.y, 0);
4558 
4559     int32_t setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
4560     EXPECT_EQ(setMeteringPoint, 7400103);
4561 
4562     int32_t getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
4563     EXPECT_EQ(getMeteringPoint, 7400103);
4564 
4565     int32_t intResult = camSession->BeginConfig();
4566     EXPECT_EQ(intResult, 0);
4567 
4568     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4569     ASSERT_NE(input, nullptr);
4570 
4571     intResult = camSession->AddInput(input);
4572     EXPECT_EQ(intResult, 0);
4573 
4574     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4575     ASSERT_NE(previewOutput, nullptr);
4576 
4577     intResult = camSession->AddOutput(previewOutput);
4578     EXPECT_EQ(intResult, 0);
4579 
4580     intResult = camSession->CommitConfig();
4581     EXPECT_EQ(intResult, 0);
4582 
4583     setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
4584     EXPECT_EQ(setMeteringPoint, 0);
4585 
4586     getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
4587     EXPECT_EQ(getMeteringPoint, 0);
4588 
4589     ReleaseInput();
4590 
4591     exposurePointGet = camSession->GetMeteringPoint();
4592     EXPECT_EQ(exposurePointGet.x, 0);
4593     EXPECT_EQ(exposurePointGet.y, 0);
4594 
4595     getMeteringPoint = camSession->GetMeteringPoint(exposurePointGet);
4596     EXPECT_EQ(getMeteringPoint, 0);
4597 
4598     camSession->LockForControl();
4599 
4600     setMeteringPoint = camSession->SetMeteringPoint(exposurePointGet);
4601     EXPECT_EQ(setMeteringPoint, 0);
4602 }
4603 
4604 /*
4605  * Feature: Framework
4606  * Function: Test anomalous branch.
4607  * SubFunction: NA
4608  * FunctionPoints: NA
4609  * EnvConditions: NA
4610  * CaseDescription: Test capture session exposure value and range with anomalous branch.
4611  */
4612 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_004, TestSize.Level0)
4613 {
4614     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4615     ASSERT_NE(camSession, nullptr);
4616 
4617     std::shared_ptr<OHOS::Camera::CameraMetadata> metadata = cameras_[0]->GetMetadata();
4618     ASSERT_NE(metadata, nullptr);
4619 
4620     camSession->ProcessAutoExposureUpdates(metadata);
4621 
4622     float exposureValue = camSession->GetExposureValue();
4623     EXPECT_EQ(exposureValue, 0);
4624 
4625     int32_t exposureValueGet = camSession->GetExposureValue(exposureValue);
4626     EXPECT_EQ(exposureValueGet, 7400103);
4627 
4628     int32_t setExposureBias = camSession->SetExposureBias(exposureValue);
4629     EXPECT_EQ(setExposureBias, 7400103);
4630 
4631     std::vector<float> getExposureBiasRange = camSession->GetExposureBiasRange();
4632     EXPECT_EQ(getExposureBiasRange.empty(), true);
4633 
4634     int32_t exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
4635     EXPECT_EQ(exposureBiasRangeGet, 7400103);
4636 
4637     int32_t intResult = camSession->BeginConfig();
4638     EXPECT_EQ(intResult, 0);
4639 
4640     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4641     ASSERT_NE(input, nullptr);
4642 
4643     intResult = camSession->AddInput(input);
4644     EXPECT_EQ(intResult, 0);
4645 
4646     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4647     ASSERT_NE(previewOutput, nullptr);
4648 
4649     intResult = camSession->AddOutput(previewOutput);
4650     EXPECT_EQ(intResult, 0);
4651 
4652     intResult = camSession->CommitConfig();
4653     EXPECT_EQ(intResult, 0);
4654 
4655     setExposureBias = camSession->SetExposureBias(exposureValue);
4656     EXPECT_EQ(setExposureBias, 0);
4657 
4658     exposureValueGet = camSession->GetExposureValue(exposureValue);
4659     EXPECT_EQ(exposureValueGet, 0);
4660 
4661     exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
4662     EXPECT_EQ(exposureBiasRangeGet, 0);
4663 
4664     ReleaseInput();
4665 
4666     getExposureBiasRange = camSession->GetExposureBiasRange();
4667     EXPECT_EQ(getExposureBiasRange.empty(), true);
4668 
4669     exposureBiasRangeGet = camSession->GetExposureBiasRange(getExposureBiasRange);
4670     EXPECT_EQ(exposureBiasRangeGet, 0);
4671 
4672     exposureValue = camSession->GetExposureValue();
4673     EXPECT_EQ(exposureValue, 0);
4674 
4675     exposureValueGet = camSession->GetExposureValue(exposureValue);
4676     EXPECT_EQ(exposureValueGet, 0);
4677 
4678     camSession->LockForControl();
4679 
4680     setExposureBias = camSession->SetExposureBias(exposureValue);
4681     EXPECT_EQ(setExposureBias, 7400102);
4682 }
4683 
4684 /*
4685  * Feature: Framework
4686  * Function: Test anomalous branch.
4687  * SubFunction: NA
4688  * FunctionPoints: NA
4689  * EnvConditions: NA
4690  * CaseDescription: Test capture session focus mode with anomalous branch.
4691  */
4692 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_005, TestSize.Level0)
4693 {
4694     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4695     ASSERT_NE(camSession, nullptr);
4696 
4697     FocusMode focusMode = camSession->GetFocusMode();
4698     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
4699 
4700     int32_t getFocusMode = camSession->GetFocusMode(focusMode);
4701     EXPECT_EQ(getFocusMode, 7400103);
4702 
4703     int32_t setFocusMode = camSession->SetFocusMode(focusMode);
4704     EXPECT_EQ(setFocusMode, 7400103);
4705 
4706     bool isFocusModeSupported = camSession->IsFocusModeSupported(focusMode);
4707     EXPECT_EQ(isFocusModeSupported, false);
4708 
4709     bool isSupported = true;
4710 
4711     int32_t focusModeSupported = camSession->IsFocusModeSupported(focusMode, isSupported);
4712     EXPECT_EQ(focusModeSupported, 7400103);
4713 
4714     std::vector<FocusMode> getSupportedFocusModes = camSession->GetSupportedFocusModes();
4715     EXPECT_EQ(getSupportedFocusModes.empty(), true);
4716 
4717     int32_t supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
4718     EXPECT_EQ(supportedFocusModesGet, 7400103);
4719 
4720     int32_t intResult = camSession->BeginConfig();
4721     EXPECT_EQ(intResult, 0);
4722 
4723     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4724     ASSERT_NE(input, nullptr);
4725 
4726     intResult = camSession->AddInput(input);
4727     EXPECT_EQ(intResult, 0);
4728 
4729     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4730     ASSERT_NE(previewOutput, nullptr);
4731 
4732     intResult = camSession->AddOutput(previewOutput);
4733     EXPECT_EQ(intResult, 0);
4734 
4735     intResult = camSession->CommitConfig();
4736     EXPECT_EQ(intResult, 0);
4737 
4738     setFocusMode = camSession->SetFocusMode(focusMode);
4739     EXPECT_EQ(setFocusMode, 0);
4740 
4741     getFocusMode = camSession->GetFocusMode(focusMode);
4742     EXPECT_EQ(getFocusMode, 0);
4743 
4744     focusModeSupported = camSession->IsFocusModeSupported(focusMode, isSupported);
4745     EXPECT_EQ(focusModeSupported, 0);
4746 
4747     getSupportedFocusModes = camSession->GetSupportedFocusModes();
4748     EXPECT_EQ(getSupportedFocusModes.empty(), false);
4749 
4750     supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
4751     EXPECT_EQ(supportedFocusModesGet, 0);
4752 
4753     ReleaseInput();
4754 
4755     getSupportedFocusModes = camSession->GetSupportedFocusModes();
4756     EXPECT_EQ(getSupportedFocusModes.empty(), true);
4757 
4758     supportedFocusModesGet = camSession->GetSupportedFocusModes(getSupportedFocusModes);
4759     EXPECT_EQ(supportedFocusModesGet, 0);
4760 
4761     focusMode = camSession->GetFocusMode();
4762     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
4763 
4764     getFocusMode = camSession->GetFocusMode(focusMode);
4765     EXPECT_EQ(getFocusMode, 0);
4766 }
4767 
4768 /*
4769  * Feature: Framework
4770  * Function: Test anomalous branch.
4771  * SubFunction: NA
4772  * FunctionPoints: NA
4773  * EnvConditions: NA
4774  * CaseDescription: Test capture session focus point with anomalous branch.
4775  */
4776 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_006, TestSize.Level0)
4777 {
4778     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4779     ASSERT_NE(camSession, nullptr);
4780 
4781     Point focusPoint = camSession->GetFocusPoint();
4782     EXPECT_EQ(focusPoint.x, 0);
4783     EXPECT_EQ(focusPoint.y, 0);
4784 
4785     float focalLength = camSession->GetFocalLength();
4786     EXPECT_EQ(focalLength, 0);
4787 
4788     int32_t focalLengthGet = camSession->GetFocalLength(focalLength);
4789     EXPECT_EQ(focalLengthGet, 7400103);
4790 
4791     int32_t focusPointGet = camSession->GetFocusPoint(focusPoint);
4792     EXPECT_EQ(focusPointGet, 7400103);
4793 
4794     int32_t setFocusPoint = camSession->SetFocusPoint(focusPoint);
4795     EXPECT_EQ(setFocusPoint, 7400103);
4796 
4797     int32_t intResult = camSession->BeginConfig();
4798     EXPECT_EQ(intResult, 0);
4799 
4800     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4801     intResult = camSession->AddInput(input);
4802     EXPECT_EQ(intResult, 0);
4803 
4804     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4805     ASSERT_NE(previewOutput, nullptr);
4806 
4807     intResult = camSession->AddOutput(previewOutput);
4808     EXPECT_EQ(intResult, 0);
4809 
4810     intResult = camSession->CommitConfig();
4811     EXPECT_EQ(intResult, 0);
4812 
4813     setFocusPoint = camSession->SetFocusPoint(focusPoint);
4814     EXPECT_EQ(setFocusPoint, 0);
4815 
4816     camSession->LockForControl();
4817 
4818     Point point = { 0, 0 };
4819     setFocusPoint = camSession->SetFocusPoint(point);
4820     EXPECT_EQ(setFocusPoint, 0);
4821 
4822     point.x = CameraErrorCode::SESSION_NOT_CONFIG;
4823     setFocusPoint = camSession->SetFocusPoint(point);
4824     EXPECT_EQ(setFocusPoint, 0);
4825 
4826     focusPointGet = camSession->GetFocusPoint(focusPoint);
4827     EXPECT_EQ(focusPointGet, 0);
4828 
4829     focalLengthGet = camSession->GetFocalLength(focalLength);
4830     EXPECT_EQ(focalLengthGet, 0);
4831 
4832     ReleaseInput();
4833 
4834     focusPoint = camSession->GetFocusPoint();
4835     EXPECT_EQ(focusPoint.x, 0);
4836     EXPECT_EQ(focusPoint.y, 0);
4837 
4838     focusPointGet = camSession->GetFocusPoint(focusPoint);
4839     EXPECT_EQ(focusPointGet, 0);
4840 
4841     focalLength = camSession->GetFocalLength();
4842     EXPECT_EQ(focalLength, 0);
4843 
4844     focalLengthGet = camSession->GetFocalLength(focalLength);
4845     EXPECT_EQ(focalLengthGet, 0);
4846 }
4847 
4848 /*
4849  * Feature: Framework
4850  * Function: Test anomalous branch.
4851  * SubFunction: NA
4852  * FunctionPoints: NA
4853  * EnvConditions: NA
4854  * CaseDescription: Test capture session flash mode with anomalous branch.
4855  */
4856 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_007, TestSize.Level0)
4857 {
4858     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4859     ASSERT_NE(camSession, nullptr);
4860 
4861     bool hasFlash = camSession->HasFlash();
4862     EXPECT_EQ(hasFlash, false);
4863 
4864     int32_t isFlash = camSession->HasFlash(hasFlash);
4865     EXPECT_EQ(isFlash, 7400103);
4866 
4867     FlashMode flashMode = camSession->GetFlashMode();
4868     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
4869 
4870     int32_t flashModeGet = camSession->GetFlashMode(flashMode);
4871     EXPECT_EQ(flashModeGet, 7400103);
4872 
4873     int32_t setFlashMode = camSession->SetFlashMode(flashMode);
4874     EXPECT_EQ(setFlashMode, 7400103);
4875 
4876     bool isFlashModeSupported = camSession->IsFlashModeSupported(flashMode);
4877     EXPECT_EQ(isFlashModeSupported, false);
4878 
4879     bool isSupported = true;
4880 
4881     int32_t flashModeSupported = camSession->IsFlashModeSupported(flashMode, isSupported);
4882     EXPECT_EQ(flashModeSupported, 7400103);
4883 
4884     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
4885     EXPECT_EQ(getSupportedFlashModes.empty(), true);
4886 
4887     int32_t getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
4888     EXPECT_EQ(getSupportedFlashMode, 7400103);
4889 
4890     int32_t intResult = camSession->BeginConfig();
4891     EXPECT_EQ(intResult, 0);
4892 
4893     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4894     ASSERT_NE(input, nullptr);
4895 
4896     intResult = camSession->AddInput(input);
4897     EXPECT_EQ(intResult, 0);
4898 
4899     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4900     ASSERT_NE(previewOutput, nullptr);
4901 
4902     intResult = camSession->AddOutput(previewOutput);
4903     EXPECT_EQ(intResult, 0);
4904 
4905     intResult = camSession->CommitConfig();
4906     EXPECT_EQ(intResult, 0);
4907 
4908     isFlash = camSession->HasFlash(hasFlash);
4909     EXPECT_EQ(isFlash, 0);
4910 
4911     setFlashMode = camSession->SetFlashMode(flashMode);
4912     EXPECT_EQ(setFlashMode, 0);
4913 
4914     flashModeGet = camSession->GetFlashMode(flashMode);
4915     EXPECT_EQ(flashModeGet, 0);
4916 
4917     flashModeSupported = camSession->IsFlashModeSupported(flashMode, isSupported);
4918     EXPECT_EQ(setFlashMode, 0);
4919 
4920     getSupportedFlashModes = camSession->GetSupportedFlashModes();
4921     EXPECT_EQ(getSupportedFlashModes.empty(), false);
4922 
4923     getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
4924     EXPECT_EQ(getSupportedFlashMode, 0);
4925 
4926     camSession->LockForControl();
4927     setFlashMode = camSession->SetFlashMode(flashMode);
4928     EXPECT_EQ(setFlashMode, 0);
4929 }
4930 
4931 /*
4932  * Feature: Framework
4933  * Function: Test anomalous branch.
4934  * SubFunction: NA
4935  * FunctionPoints: NA
4936  * EnvConditions: NA
4937  * CaseDescription: Test flash mode with release input.
4938  */
4939 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_008, TestSize.Level0)
4940 {
4941     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4942     ASSERT_NE(camSession, nullptr);
4943 
4944     int32_t intResult = camSession->BeginConfig();
4945     EXPECT_EQ(intResult, 0);
4946 
4947     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
4948     ASSERT_NE(input, nullptr);
4949 
4950     intResult = camSession->AddInput(input);
4951     EXPECT_EQ(intResult, 0);
4952 
4953     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
4954     ASSERT_NE(previewOutput, nullptr);
4955 
4956     intResult = camSession->AddOutput(previewOutput);
4957     EXPECT_EQ(intResult, 0);
4958 
4959     intResult = camSession->CommitConfig();
4960     EXPECT_EQ(intResult, 0);
4961 
4962     ReleaseInput();
4963 
4964     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
4965     EXPECT_EQ(getSupportedFlashModes.empty(), true);
4966 
4967     int32_t getSupportedFlashMode = camSession->GetSupportedFlashModes(getSupportedFlashModes);
4968     EXPECT_EQ(getSupportedFlashMode, 0);
4969 
4970     FlashMode flashMode = camSession->GetFlashMode();
4971     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
4972 
4973     int32_t flashModeGet = camSession->GetFlashMode(flashMode);
4974     EXPECT_EQ(flashModeGet, 0);
4975 }
4976 
4977 /*
4978  * Feature: Framework
4979  * Function: Test anomalous branch.
4980  * SubFunction: NA
4981  * FunctionPoints: NA
4982  * EnvConditions: NA
4983  * CaseDescription: Test capture session zoom ratio with anomalous branch.
4984  */
4985 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_009, TestSize.Level0)
4986 {
4987     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
4988     ASSERT_NE(camSession, nullptr);
4989 
4990     float zoomRatio = camSession->GetZoomRatio();
4991     EXPECT_EQ(zoomRatio, 0);
4992 
4993     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
4994     EXPECT_EQ(zoomRatioRange.empty(), true);
4995 
4996     int32_t zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
4997     EXPECT_EQ(zoomRatioRangeGet, 7400103);
4998 
4999     int32_t zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
5000     EXPECT_EQ(zoomRatioGet, 7400103);
5001 
5002     int32_t setZoomRatio = camSession->SetZoomRatio(zoomRatio);
5003     EXPECT_EQ(setZoomRatio, 7400103);
5004 
5005     int32_t intResult = camSession->BeginConfig();
5006     EXPECT_EQ(intResult, 0);
5007 
5008     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5009     ASSERT_NE(input, nullptr);
5010 
5011     intResult = camSession->AddInput(input);
5012     EXPECT_EQ(intResult, 0);
5013 
5014     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5015     ASSERT_NE(previewOutput, nullptr);
5016 
5017     intResult = camSession->AddOutput(previewOutput);
5018     EXPECT_EQ(intResult, 0);
5019 
5020     intResult = camSession->CommitConfig();
5021     EXPECT_EQ(intResult, 0);
5022 
5023     zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
5024     EXPECT_EQ(zoomRatioRangeGet, 0);
5025 
5026     zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
5027     EXPECT_EQ(zoomRatioGet, 0);
5028 
5029     setZoomRatio = camSession->SetZoomRatio(zoomRatio);
5030     EXPECT_EQ(setZoomRatio, 0);
5031 
5032     ReleaseInput();
5033 
5034     zoomRatioRange = camSession->GetZoomRatioRange();
5035     EXPECT_EQ(zoomRatioRange.empty(), true);
5036 
5037     zoomRatioRangeGet = camSession->GetZoomRatioRange(zoomRatioRange);
5038     EXPECT_EQ(zoomRatioRangeGet, 0);
5039 
5040     zoomRatio = camSession->GetZoomRatio();
5041     EXPECT_EQ(zoomRatio, 0);
5042 
5043     zoomRatioGet = camSession->GetZoomRatio(zoomRatio);
5044     EXPECT_EQ(zoomRatioGet, 0);
5045 
5046     camSession->LockForControl();
5047 
5048     setZoomRatio = camSession->SetZoomRatio(zoomRatio);
5049     EXPECT_EQ(setZoomRatio, 0);
5050 }
5051 
5052 /*
5053  * Feature: Framework
5054  * Function: Test anomalous branch.
5055  * SubFunction: NA
5056  * FunctionPoints: NA
5057  * EnvConditions: NA
5058  * CaseDescription: Test capture session with set metadata Object type anomalous branch.
5059  */
5060 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_010, TestSize.Level0)
5061 {
5062     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5063     ASSERT_NE(camSession, nullptr);
5064 
5065     std::set<camera_face_detect_mode_t> metadataObjectTypes;
5066     camSession->SetCaptureMetadataObjectTypes(metadataObjectTypes);
5067 }
5068 
5069 /*
5070  * Feature: Framework
5071  * Function: Test anomalous branch.
5072  * SubFunction: NA
5073  * FunctionPoints: NA
5074  * EnvConditions: NA
5075  * CaseDescription: Test metadataOutput with anomalous branch.
5076  */
5077 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_011, TestSize.Level0)
5078 {
5079     int32_t intResult = session_->BeginConfig();
5080     EXPECT_EQ(intResult, 0);
5081 
5082     intResult = session_->AddInput(input_);
5083     EXPECT_EQ(intResult, 0);
5084 
5085     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5086     ASSERT_NE(previewOutput, nullptr);
5087 
5088     intResult = session_->AddOutput(previewOutput);
5089     EXPECT_EQ(intResult, 0);
5090 
5091     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
5092     ASSERT_NE(metadatOutput, nullptr);
5093 
5094     intResult = session_->AddOutput(metadatOutput);
5095     EXPECT_EQ(intResult, 0);
5096 
5097     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
5098 
5099     sptr<MetadataObjectListener> metaObjListener = new (std::nothrow) MetadataObjectListener(metaOutput);
5100     ASSERT_NE(metaObjListener, nullptr);
5101 
5102     metaObjListener->OnBufferAvailable();
5103 
5104     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
5105 
5106     metaOutput->SetCapturingMetadataObjectTypes(metadataObjectTypes);
5107     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
5108 
5109     metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
5110 
5111     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
5112     metaOutput->SetCallback(metadataObjectCallback);
5113     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
5114     metaOutput->SetCallback(metadataStateCallback);
5115 
5116     intResult = session_->CommitConfig();
5117     EXPECT_EQ(intResult, 0);
5118 
5119     intResult = session_->Start();
5120     EXPECT_EQ(intResult, 0);
5121 
5122     sleep(WAIT_TIME_AFTER_START);
5123 
5124     intResult = metaOutput->Release();
5125     EXPECT_EQ(intResult, 0);
5126 }
5127 
5128 /*
5129  * Feature: Framework
5130  * Function: Test anomalous branch
5131  * SubFunction: NA
5132  * FunctionPoints: NA
5133  * EnvConditions: NA
5134  * CaseDescription: test capture session callback error with anomalous branch
5135  */
5136 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_012, TestSize.Level0)
5137 {
5138     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5139     ASSERT_NE(camSession, nullptr);
5140 
5141     sptr<CaptureSessionCallback> capSessionCallback = new (std::nothrow) CaptureSessionCallback();
5142     ASSERT_NE(capSessionCallback, nullptr);
5143     int32_t onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
5144     EXPECT_EQ(onError, 0);
5145 
5146     capSessionCallback = new (std::nothrow) CaptureSessionCallback(camSession);
5147     ASSERT_NE(capSessionCallback, nullptr);
5148     onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
5149     EXPECT_EQ(onError, 0);
5150 
5151     std::shared_ptr<SessionCallback> callback = nullptr;
5152     camSession->SetCallback(callback);
5153 
5154     callback = std::make_shared<AppSessionCallback>();
5155     camSession->SetCallback(callback);
5156     capSessionCallback = new (std::nothrow) CaptureSessionCallback(camSession);
5157     ASSERT_NE(capSessionCallback, nullptr);
5158     onError = capSessionCallback->OnError(CAMERA_DEVICE_PREEMPTED);
5159     EXPECT_EQ(onError, 0);
5160 }
5161 
5162 /*
5163  * Feature: Framework
5164  * Function: Test anomalous branch
5165  * SubFunction: NA
5166  * FunctionPoints: NA
5167  * EnvConditions: NA
5168  * CaseDescription: test remove input with anomalous branch
5169  */
5170 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_013, TestSize.Level0)
5171 {
5172     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5173     ASSERT_NE(camSession, nullptr);
5174 
5175     sptr<CaptureInput> input = nullptr;
5176     int32_t intResult = camSession->RemoveInput(input);
5177     EXPECT_EQ(intResult, 7400102);
5178 
5179     intResult = camSession->BeginConfig();
5180     EXPECT_EQ(intResult, 0);
5181 
5182     input = (sptr<CaptureInput>&)input_;
5183     ASSERT_NE(input, nullptr);
5184 
5185     intResult = camSession->RemoveInput(input);
5186     EXPECT_EQ(intResult, 7400201);
5187 
5188     intResult = camSession->AddInput(input);
5189     EXPECT_EQ(intResult, 0);
5190 
5191     intResult = camSession->RemoveInput(input);
5192     EXPECT_EQ(intResult, 0);
5193 }
5194 
5195 /*
5196  * Feature: Framework
5197  * Function: Test anomalous branch
5198  * SubFunction: NA
5199  * FunctionPoints: NA
5200  * EnvConditions: NA
5201  * CaseDescription: test remove output with anomalous branch
5202  */
5203 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_014, TestSize.Level0)
5204 {
5205     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5206     ASSERT_NE(camSession, nullptr);
5207 
5208     sptr<CaptureOutput> output = nullptr;
5209     int32_t intResult = camSession->RemoveOutput(output);
5210     EXPECT_EQ(intResult, 7400102);
5211 
5212     intResult = camSession->BeginConfig();
5213     EXPECT_EQ(intResult, 0);
5214 
5215     output = CreatePreviewOutput();
5216     ASSERT_NE(output, nullptr);
5217 
5218     intResult = camSession->RemoveOutput(output);
5219     EXPECT_EQ(intResult, 7400201);
5220 }
5221 
5222 /*
5223  * Feature: Framework
5224  * Function: Test anomalous branch
5225  * SubFunction: NA
5226  * FunctionPoints: NA
5227  * EnvConditions: NA
5228  * CaseDescription: test stop/release session and preview with anomalous branch
5229  */
5230 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_015, TestSize.Level0)
5231 {
5232     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5233     ASSERT_NE(camSession, nullptr);
5234     camSession->Release();
5235 
5236     int32_t intResult = camSession->Stop();
5237     EXPECT_EQ(intResult, 7400201);
5238 
5239     intResult = camSession->Release();
5240     EXPECT_EQ(intResult, 7400201);
5241 }
5242 
5243 /*
5244  * Feature: Framework
5245  * Function: Test anomalous branch.
5246  * SubFunction: NA
5247  * FunctionPoints: NA
5248  * EnvConditions: NA
5249  * CaseDescription: Test metadataOutput with anomalous branch.
5250  */
5251 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_016, TestSize.Level0)
5252 {
5253     int32_t intResult = session_->BeginConfig();
5254     EXPECT_EQ(intResult, 0);
5255 
5256     intResult = session_->AddInput(input_);
5257     EXPECT_EQ(intResult, 0);
5258 
5259     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5260     ASSERT_NE(previewOutput, nullptr);
5261 
5262     intResult = session_->AddOutput(previewOutput);
5263     EXPECT_EQ(intResult, 0);
5264 
5265     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
5266     ASSERT_NE(metadatOutput, nullptr);
5267 
5268     intResult = session_->AddOutput(metadatOutput);
5269     EXPECT_EQ(intResult, 0);
5270 
5271     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
5272 
5273     sptr<MetadataObjectListener> metaObjListener = new (std::nothrow) MetadataObjectListener(metaOutput);
5274     ASSERT_NE(metaObjListener, nullptr);
5275 
5276     metaObjListener->OnBufferAvailable();
5277 
5278     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
5279 
5280     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
5281 
5282     sptr<CaptureOutput> metadatOutput_2 = manager_->CreateMetadataOutput();
5283     ASSERT_NE(metadatOutput_2, nullptr);
5284 
5285     intResult = metaOutput->Release();
5286     EXPECT_EQ(intResult, 0);
5287 
5288     sptr<MetadataOutput> metaOutput_2 = (sptr<MetadataOutput>&)metadatOutput_2;
5289 
5290     metaOutput_2->Release();
5291 
5292     metadataObjectTypes = metaOutput_2->GetSupportedMetadataObjectTypes();
5293     EXPECT_EQ(metadataObjectTypes.empty(), true);
5294 
5295     metaObjListener->OnBufferAvailable();
5296 
5297     sptr<MetadataOutput> metaOutput_3 = nullptr;
5298 
5299     sptr<MetadataObjectListener> metaObjListener_2 = new (std::nothrow) MetadataObjectListener(metaOutput_3);
5300     ASSERT_NE(metaObjListener_2, nullptr);
5301 
5302     metaObjListener_2->OnBufferAvailable();
5303 }
5304 
5305 /*
5306  * Feature: Framework
5307  * Function: Test anomalous branch.
5308  * SubFunction: NA
5309  * FunctionPoints: NA
5310  * EnvConditions: NA
5311  * CaseDescription: Test photoOutput with anomalous branch.
5312  */
5313 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_017, TestSize.Level0)
5314 {
5315     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
5316     PhotoCaptureSetting::QualityLevel quality = photoSetting->GetQuality();
5317     EXPECT_EQ(quality, PhotoCaptureSetting::QualityLevel::QUALITY_LEVEL_MEDIUM);
5318 
5319     photoSetting->SetQuality(PhotoCaptureSetting::QualityLevel::QUALITY_LEVEL_HIGH);
5320     photoSetting->SetQuality(quality);
5321 
5322     PhotoCaptureSetting::RotationConfig rotation = photoSetting->GetRotation();
5323     EXPECT_EQ(rotation, PhotoCaptureSetting::RotationConfig::Rotation_0);
5324 
5325     photoSetting->SetRotation(rotation);
5326     photoSetting->SetRotation(rotation);
5327 
5328     std::shared_ptr<Location> location = std::make_shared<Location>();
5329     location->latitude = 12.972442;
5330     location->longitude = 77.580643;
5331 
5332     photoSetting->SetGpsLocation(location->latitude, location->longitude);
5333 
5334     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5335     ASSERT_NE(camSession, nullptr);
5336 
5337     int32_t intResult = camSession->BeginConfig();
5338     EXPECT_EQ(intResult, 0);
5339 
5340     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5341     ASSERT_NE(input, nullptr);
5342 
5343     intResult = camSession->AddInput(input);
5344     EXPECT_EQ(intResult, 0);
5345 
5346     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5347     ASSERT_NE(previewOutput, nullptr);
5348 
5349     intResult = camSession->AddOutput(previewOutput);
5350     EXPECT_EQ(intResult, 0);
5351 
5352     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
5353     ASSERT_NE(photoOutput, nullptr);
5354 
5355     intResult = camSession->AddOutput(photoOutput);
5356     EXPECT_EQ(intResult, 0);
5357 
5358     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
5359 
5360     intResult = photoOutput_1->Capture(photoSetting);
5361     EXPECT_EQ(intResult, 7400104);
5362 
5363     intResult = camSession->CommitConfig();
5364     EXPECT_EQ(intResult, 0);
5365 
5366     int32_t capture = photoOutput_1->Capture();
5367     EXPECT_EQ(capture, 0);
5368 
5369     int32_t cancelCapture = photoOutput_1->CancelCapture();
5370     EXPECT_EQ(cancelCapture, 0);
5371 
5372     intResult = photoOutput_1->Release();
5373     EXPECT_EQ(intResult, 0);
5374 
5375     intResult = photoOutput_1->Release();
5376     EXPECT_EQ(intResult, 7400201);
5377 
5378     cancelCapture = photoOutput_1->CancelCapture();
5379     EXPECT_EQ(cancelCapture, 7400104);
5380 
5381     bool isMirrorSupported = photoOutput_1->IsMirrorSupported();
5382     EXPECT_EQ(isMirrorSupported, false);
5383 }
5384 
5385 /*
5386  * Feature: Framework
5387  * Function: Test anomalous branch.
5388  * SubFunction: NA
5389  * FunctionPoints: NA
5390  * EnvConditions: NA
5391  * CaseDescription: Test captureCallback with anomalous branch.
5392  */
5393 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_018, TestSize.Level0)
5394 {
5395     std::shared_ptr<HStreamCaptureCallbackImpl> captureCallback = std::make_shared<HStreamCaptureCallbackImpl>(nullptr);
5396 
5397     int32_t captureId = 2001;
5398     int32_t intResult = captureCallback->OnCaptureStarted(captureId);
5399     EXPECT_EQ(intResult, 0);
5400 
5401     int32_t frameCount = 0;
5402     intResult = captureCallback->OnCaptureEnded(captureId, frameCount);
5403     EXPECT_EQ(intResult, 0);
5404 
5405     int32_t errorCode = 0;
5406     intResult = captureCallback->OnCaptureError(captureId, errorCode);
5407     EXPECT_EQ(intResult, 0);
5408 
5409     uint64_t timestamp = 10;
5410     intResult = captureCallback->OnFrameShutter(captureId, timestamp);
5411     EXPECT_EQ(intResult, 0);
5412 
5413     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5414     ASSERT_NE(camSession, nullptr);
5415 
5416     intResult = camSession->BeginConfig();
5417     EXPECT_EQ(intResult, 0);
5418 
5419     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5420     ASSERT_NE(input, nullptr);
5421 
5422     intResult = camSession->AddInput(input);
5423     EXPECT_EQ(intResult, 0);
5424 
5425     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5426     ASSERT_NE(previewOutput, nullptr);
5427 
5428     intResult = camSession->AddOutput(previewOutput);
5429     EXPECT_EQ(intResult, 0);
5430 
5431     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
5432     ASSERT_NE(photoOutput, nullptr);
5433 
5434     intResult = camSession->AddOutput(photoOutput);
5435     EXPECT_EQ(intResult, 0);
5436 
5437     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
5438 
5439     intResult = camSession->CommitConfig();
5440     EXPECT_EQ(intResult, 0);
5441 
5442     std::shared_ptr<AppCallback> callback = nullptr;
5443     photoOutput_1->SetCallback(callback);
5444 
5445     callback = std::make_shared<AppCallback>();
5446     photoOutput_1->SetCallback(callback);
5447     photoOutput_1->SetCallback(callback);
5448 
5449     sptr<HStreamCaptureCallbackImpl> captureCallback_2 = new (std::nothrow) HStreamCaptureCallbackImpl(photoOutput_1);
5450     ASSERT_NE(captureCallback_2, nullptr);
5451 
5452     intResult = captureCallback_2->OnCaptureEnded(captureId, frameCount);
5453     EXPECT_EQ(intResult, 0);
5454 
5455     intResult = captureCallback_2->OnCaptureError(captureId, errorCode);
5456     EXPECT_EQ(intResult, 0);
5457 
5458     intResult = captureCallback_2->OnFrameShutter(captureId, timestamp);
5459     EXPECT_EQ(intResult, 0);
5460 }
5461 
5462 /*
5463  * Feature: Framework
5464  * Function: Test anomalous branch
5465  * SubFunction: NA
5466  * FunctionPoints: NA
5467  * EnvConditions: NA
5468  * CaseDescription: test preview output repeat callback with anomalous branch
5469  */
5470 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_019, TestSize.Level0)
5471 {
5472     std::shared_ptr<PreviewOutputCallbackImpl> repeatCallback = std::make_shared<PreviewOutputCallbackImpl>();
5473 
5474     int32_t intResult = repeatCallback->OnFrameStarted();
5475     EXPECT_EQ(intResult, 0);
5476 
5477     int32_t frameCount = 0;
5478     intResult = repeatCallback->OnFrameEnded(frameCount);
5479     EXPECT_EQ(intResult, 0);
5480 
5481     int32_t errorCode = 0;
5482     intResult = repeatCallback->OnFrameError(errorCode);
5483     EXPECT_EQ(intResult, 0);
5484 
5485     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5486     ASSERT_NE(camSession, nullptr);
5487 
5488     intResult = camSession->BeginConfig();
5489     EXPECT_EQ(intResult, 0);
5490 
5491     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5492     ASSERT_NE(input, nullptr);
5493 
5494     intResult = camSession->AddInput(input);
5495     EXPECT_EQ(intResult, 0);
5496 
5497     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5498     ASSERT_NE(previewOutput, nullptr);
5499 
5500     intResult = camSession->AddOutput(previewOutput);
5501     EXPECT_EQ(intResult, 0);
5502 
5503     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
5504 
5505     intResult = camSession->CommitConfig();
5506     EXPECT_EQ(intResult, 0);
5507 
5508     std::shared_ptr<AppCallback> callback = nullptr;
5509     previewOutput_1->SetCallback(callback);
5510 
5511     callback = std::make_shared<AppCallback>();
5512     previewOutput_1->SetCallback(callback);
5513     previewOutput_1->SetCallback(callback);
5514 
5515     sptr<PreviewOutputCallbackImpl> repeatCallback_2 = new (std::nothrow) PreviewOutputCallbackImpl(previewOutput_1);
5516     ASSERT_NE(repeatCallback_2, nullptr);
5517 
5518     intResult = repeatCallback_2->OnFrameEnded(frameCount);
5519     EXPECT_EQ(intResult, 0);
5520 
5521     intResult = repeatCallback_2->OnFrameError(errorCode);
5522     EXPECT_EQ(intResult, 0);
5523 }
5524 
5525 /*
5526  * Feature: Framework
5527  * Function: Test anomalous branch
5528  * SubFunction: NA
5529  * FunctionPoints: NA
5530  * EnvConditions: NA
5531  * CaseDescription: test preview output with anomalous branch
5532  */
5533 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_020, TestSize.Level0)
5534 {
5535     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5536     ASSERT_NE(camSession, nullptr);
5537 
5538     int32_t intResult = camSession->BeginConfig();
5539     EXPECT_EQ(intResult, 0);
5540 
5541     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5542     ASSERT_NE(input, nullptr);
5543 
5544     intResult = camSession->AddInput(input);
5545     EXPECT_EQ(intResult, 0);
5546 
5547     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5548     ASSERT_NE(previewOutput, nullptr);
5549 
5550     intResult = camSession->AddOutput(previewOutput);
5551     EXPECT_EQ(intResult, 0);
5552 
5553     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
5554 
5555     EXPECT_EQ(previewOutput_1->Start(), 7400103);
5556 
5557     intResult = camSession->CommitConfig();
5558     EXPECT_EQ(intResult, 0);
5559 
5560     sptr<Surface> surface = nullptr;
5561 
5562     previewOutput_1->AddDeferredSurface(surface);
5563 
5564     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
5565     sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
5566     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(previewProducer);
5567 
5568     previewOutput_1->AddDeferredSurface(pSurface);
5569 
5570     intResult = previewOutput_1->CaptureOutput::Release();
5571     EXPECT_EQ(intResult, 0);
5572 
5573     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
5574     previewOutput_1->SetCallback(callback);
5575 
5576     intResult = previewOutput_1->Stop();
5577     EXPECT_EQ(intResult, 7400201);
5578 
5579     intResult = previewOutput_1->Release();
5580     EXPECT_EQ(intResult, 7400201);
5581 
5582     previewOutput_1->AddDeferredSurface(pSurface);
5583 }
5584 
5585 /*
5586  * Feature: Framework
5587  * Function: Test anomalous branch
5588  * SubFunction: NA
5589  * FunctionPoints: NA
5590  * EnvConditions: NA
5591  * CaseDescription: test video output with anomalous branch
5592  */
5593 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_021, TestSize.Level0)
5594 {
5595     int32_t intResult = session_->BeginConfig();
5596     EXPECT_EQ(intResult, 0);
5597 
5598     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5599     ASSERT_NE(input, nullptr);
5600 
5601     intResult = session_->AddInput(input);
5602     EXPECT_EQ(intResult, 0);
5603 
5604     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5605     ASSERT_NE(previewOutput, nullptr);
5606 
5607     intResult = session_->AddOutput(previewOutput);
5608     EXPECT_EQ(intResult, 0);
5609 
5610     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
5611     ASSERT_NE(videoOutput, nullptr);
5612 
5613     intResult = session_->AddOutput(videoOutput);
5614     EXPECT_EQ(intResult, 0);
5615 
5616     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput>&)videoOutput;
5617 
5618     std::shared_ptr<AppVideoCallback> callback = std::make_shared<AppVideoCallback>();
5619 
5620     intResult = videoOutput_1->Start();
5621     EXPECT_EQ(intResult, 7400103);
5622 
5623     intResult = session_->CommitConfig();
5624     EXPECT_EQ(intResult, 0);
5625 
5626     intResult = session_->Start();
5627     EXPECT_EQ(intResult, 0);
5628 
5629     sleep(WAIT_TIME_AFTER_START);
5630 
5631     sleep(WAIT_TIME_AFTER_START);
5632 
5633     intResult = videoOutput_1->Start();
5634     EXPECT_EQ(intResult, 0);
5635 
5636     sleep(WAIT_TIME_AFTER_START);
5637 
5638     intResult = videoOutput_1->Pause();
5639     EXPECT_EQ(intResult, 0);
5640 
5641     sleep(WAIT_TIME_AFTER_START);
5642 
5643     intResult = videoOutput_1->Resume();
5644     EXPECT_EQ(intResult, 0);
5645 
5646     intResult = videoOutput_1->Stop();
5647     EXPECT_EQ(intResult, 0);
5648 
5649     intResult = videoOutput_1->CaptureOutput::Release();
5650     EXPECT_EQ(intResult, 0);
5651 
5652     videoOutput_1->SetCallback(callback);
5653 
5654     intResult = videoOutput_1->Pause();
5655     EXPECT_EQ(intResult, 7400201);
5656 
5657     intResult = videoOutput_1->Resume();
5658     EXPECT_EQ(intResult, 7400201);
5659 
5660     intResult = videoOutput_1->Stop();
5661     EXPECT_EQ(intResult, 7400201);
5662 
5663     intResult = videoOutput_1->Release();
5664     EXPECT_EQ(intResult, 7400201);
5665 
5666     session_->Release();
5667     EXPECT_EQ(videoOutput_1->Start(), 7400103);
5668 }
5669 
5670 /*
5671  * Feature: Framework
5672  * Function: Test anomalous branch
5673  * SubFunction: NA
5674  * FunctionPoints: NA
5675  * EnvConditions: NA
5676  * CaseDescription: test video output repeat callback with anomalous branch
5677  */
5678 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_022, TestSize.Level0)
5679 {
5680     std::shared_ptr<VideoOutputCallbackImpl> repeatCallback = std::make_shared<VideoOutputCallbackImpl>();
5681 
5682     int32_t intResult = repeatCallback->OnFrameStarted();
5683     EXPECT_EQ(intResult, 0);
5684 
5685     int32_t frameCount = 0;
5686     intResult = repeatCallback->OnFrameEnded(frameCount);
5687     EXPECT_EQ(intResult, 0);
5688 
5689     int32_t errorCode = 0;
5690     intResult = repeatCallback->OnFrameError(errorCode);
5691     EXPECT_EQ(intResult, 0);
5692 
5693     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
5694     ASSERT_NE(camSession, nullptr);
5695 
5696     intResult = camSession->BeginConfig();
5697     EXPECT_EQ(intResult, 0);
5698 
5699     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
5700     ASSERT_NE(input, nullptr);
5701 
5702     intResult = camSession->AddInput(input);
5703     EXPECT_EQ(intResult, 0);
5704 
5705     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5706     ASSERT_NE(previewOutput, nullptr);
5707 
5708     intResult = camSession->AddOutput(previewOutput);
5709     EXPECT_EQ(intResult, 0);
5710 
5711     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
5712     ASSERT_NE(videoOutput, nullptr);
5713 
5714     intResult = camSession->AddOutput(videoOutput);
5715     EXPECT_EQ(intResult, 0);
5716 
5717     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput>&)videoOutput;
5718 
5719     intResult = camSession->CommitConfig();
5720     EXPECT_EQ(intResult, 0);
5721 
5722     std::shared_ptr<AppVideoCallback> callback = nullptr;
5723     videoOutput_1->SetCallback(callback);
5724 
5725     callback = std::make_shared<AppVideoCallback>();
5726     videoOutput_1->SetCallback(callback);
5727     videoOutput_1->SetCallback(callback);
5728 
5729     sptr<VideoOutputCallbackImpl> repeatCallback_2 = new (std::nothrow) VideoOutputCallbackImpl(videoOutput_1);
5730     ASSERT_NE(repeatCallback_2, nullptr);
5731 
5732     intResult = repeatCallback->OnFrameStarted();
5733     EXPECT_EQ(intResult, 0);
5734 
5735     intResult = repeatCallback->OnFrameEnded(frameCount);
5736     EXPECT_EQ(intResult, 0);
5737 
5738     intResult = repeatCallback_2->OnFrameError(errorCode);
5739     EXPECT_EQ(intResult, 0);
5740 }
5741 
5742 /*
5743  * Feature: Framework
5744  * Function: Test anomalous branch
5745  * SubFunction: NA
5746  * FunctionPoints: NA
5747  * EnvConditions: NA
5748  * CaseDescription: test HCameraDeviceProxy_cpp with anomalous branch
5749  */
5750 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_023, TestSize.Level0)
5751 {
5752     sptr<CameraInput> input_1 = (sptr<CameraInput>&)input_;
5753     sptr<ICameraDeviceService> deviceObj = input_1->GetCameraDevice();
5754     ASSERT_NE(deviceObj, nullptr);
5755 
5756     sptr<ICameraDeviceServiceCallback> callback = nullptr;
5757     int32_t intResult = deviceObj->SetCallback(callback);
5758     EXPECT_EQ(intResult, 200);
5759 
5760     std::shared_ptr<OHOS::Camera::CameraMetadata> settings = nullptr;
5761     intResult = deviceObj->UpdateSetting(settings);
5762     EXPECT_EQ(intResult, 200);
5763 
5764     std::vector<int32_t> results = {};
5765     intResult = deviceObj->GetEnabledResults(results);
5766     EXPECT_EQ(intResult, 0);
5767 
5768     deviceObj->EnableResult(results);
5769     deviceObj->DisableResult(results);
5770 }
5771 
5772 /*
5773  * Feature: Framework
5774  * Function: Test anomalous branch
5775  * SubFunction: NA
5776  * FunctionPoints: NA
5777  * EnvConditions: NA
5778  * CaseDescription: test HCameraServiceProxy_cpp with anomalous branch
5779  */
5780 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_024, TestSize.Level0)
5781 {
5782     sptr<IRemoteObject> object = nullptr;
5783     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
5784     ASSERT_NE(samgr, nullptr);
5785 
5786     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
5787     sptr<ICameraService> serviceProxy = iface_cast<ICameraService>(object);
5788     ASSERT_NE(serviceProxy, nullptr);
5789 
5790     sptr<ICameraServiceCallback> callback = nullptr;
5791     int32_t intResult = serviceProxy->SetCameraCallback(callback);
5792     EXPECT_EQ(intResult, 200);
5793 
5794     sptr<ICameraMuteServiceCallback> callback_2 = nullptr;
5795     intResult = serviceProxy->SetMuteCallback(callback_2);
5796     EXPECT_EQ(intResult, 200);
5797 
5798     int32_t format = 0;
5799     int32_t width = 0;
5800     int32_t height = 0;
5801     sptr<IStreamCapture> output = nullptr;
5802     sptr<IBufferProducer> Producer = nullptr;
5803     intResult = serviceProxy->CreatePhotoOutput(Producer, format, width, height, output);
5804     EXPECT_EQ(intResult, 200);
5805 
5806     sptr<IStreamRepeat> output_2 = nullptr;
5807     intResult = serviceProxy->CreatePreviewOutput(Producer, format, width, height, output_2);
5808     EXPECT_EQ(intResult, 200);
5809 
5810     intResult = serviceProxy->CreateDeferredPreviewOutput(format, width, height, output_2);
5811     EXPECT_EQ(intResult, 200);
5812 
5813     sptr<IStreamMetadata> output_3 = nullptr;
5814     intResult = serviceProxy->CreateMetadataOutput(Producer, format, {1}, output_3);
5815     EXPECT_EQ(intResult, 200);
5816 
5817     intResult = serviceProxy->CreateVideoOutput(Producer, format, width, height, output_2);
5818     EXPECT_EQ(intResult, 200);
5819 }
5820 
5821 /*
5822  * Feature: Framework
5823  * Function: Test anomalous branch
5824  * SubFunction: NA
5825  * FunctionPoints: NA
5826  * EnvConditions: NA
5827  * CaseDescription: test HCameraServiceProxy_cpp with anomalous branch
5828  */
5829 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_025, TestSize.Level0)
5830 {
5831     int32_t format = 0;
5832     int32_t width = 0;
5833     int32_t height = 0;
5834     std::string cameraId = "";
5835     std::vector<std::string> cameraIds = {};
5836     std::vector<std::shared_ptr<OHOS::Camera::CameraMetadata>> cameraAbilityList = {};
5837 
5838     sptr<IConsumerSurface> Surface = IConsumerSurface::Create();
5839     sptr<IBufferProducer> Producer = Surface->GetProducer();
5840 
5841     sptr<IRemoteObject> object = nullptr;
5842     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
5843     ASSERT_NE(samgr, nullptr);
5844 
5845     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
5846     sptr<ICameraService> serviceProxy = iface_cast<ICameraService>(object);
5847     ASSERT_NE(serviceProxy, nullptr);
5848 
5849     sptr<ICameraServiceCallback> callback = new (std::nothrow) CameraStatusServiceCallback(manager_);
5850     ASSERT_NE(callback, nullptr);
5851     int32_t intResult = serviceProxy->SetCameraCallback(callback);
5852     EXPECT_EQ(intResult, -1);
5853 
5854     sptr<ICameraMuteServiceCallback> callback_2 = new (std::nothrow) CameraMuteServiceCallback(manager_);
5855     ASSERT_NE(callback_2, nullptr);
5856     serviceProxy->SetMuteCallback(callback_2);
5857     EXPECT_EQ(intResult, -1);
5858 
5859     intResult = serviceProxy->GetCameras(cameraIds, cameraAbilityList);
5860     EXPECT_EQ(intResult, -1);
5861 
5862     sptr<ICaptureSession> session = nullptr;
5863     intResult = serviceProxy->CreateCaptureSession(session);
5864     EXPECT_EQ(intResult, -1);
5865 
5866     sptr<IStreamCapture> output = nullptr;
5867     intResult = serviceProxy->CreatePhotoOutput(Producer, format, width, height, output);
5868     EXPECT_EQ(intResult, -1);
5869 
5870     width = PREVIEW_DEFAULT_WIDTH;
5871     height = PREVIEW_DEFAULT_HEIGHT;
5872     sptr<IStreamRepeat> output_2 = nullptr;
5873     intResult = serviceProxy->CreatePreviewOutput(Producer, format, width, height, output_2);
5874     EXPECT_EQ(intResult, -1);
5875 
5876     intResult = serviceProxy->CreateDeferredPreviewOutput(format, width, height, output_2);
5877     EXPECT_EQ(intResult, -1);
5878 
5879     sptr<IStreamMetadata> output_3 = nullptr;
5880     intResult = serviceProxy->CreateMetadataOutput(Producer, format, {1}, output_3);
5881     EXPECT_EQ(intResult, -1);
5882 
5883     intResult = serviceProxy->CreateVideoOutput(Producer, format, width, height, output_2);
5884     EXPECT_EQ(intResult, -1);
5885 
5886     intResult = serviceProxy->SetListenerObject(object);
5887     EXPECT_EQ(intResult, 200);
5888 
5889     bool muteMode = true;
5890     intResult = serviceProxy->IsCameraMuted(muteMode);
5891     EXPECT_EQ(intResult, -1);
5892 }
5893 
5894 /*
5895  * Feature: Framework
5896  * Function: Test anomalous branch
5897  * SubFunction: NA
5898  * FunctionPoints: NA
5899  * EnvConditions: NA
5900  * CaseDescription: test HCameraDeviceProxy_cpp with anomalous branch
5901  */
5902 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_026, TestSize.Level0)
5903 {
5904     sptr<IRemoteObject> object = nullptr;
5905     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
5906     ASSERT_NE(samgr, nullptr);
5907 
5908     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
5909 
5910     sptr<ICameraDeviceService> deviceObj = iface_cast<ICameraDeviceService>(object);
5911     ASSERT_NE(deviceObj, nullptr);
5912 
5913     int32_t intResult = deviceObj->Open();
5914     EXPECT_EQ(intResult, -1);
5915 
5916     intResult = deviceObj->Close();
5917     EXPECT_EQ(intResult, -1);
5918 
5919     intResult = deviceObj->Release();
5920     EXPECT_EQ(intResult, -1);
5921 
5922     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
5923     sptr<ICameraDeviceServiceCallback> callback = new (std::nothrow) CameraDeviceServiceCallback(input);
5924     ASSERT_NE(callback, nullptr);
5925 
5926     intResult = deviceObj->SetCallback(callback);
5927     EXPECT_EQ(intResult, -1);
5928 
5929     std::shared_ptr<OHOS::Camera::CameraMetadata> settings = cameras_[0]->GetMetadata();
5930     ASSERT_NE(settings, nullptr);
5931 
5932     intResult = deviceObj->UpdateSetting(settings);
5933     EXPECT_EQ(intResult, -1);
5934 
5935     std::vector<int32_t> results = {};
5936     intResult = deviceObj->GetEnabledResults(results);
5937     EXPECT_EQ(intResult, 200);
5938 }
5939 
5940 /*
5941  * Feature: Framework
5942  * Function: Test anomalous branch
5943  * SubFunction: NA
5944  * FunctionPoints: NA
5945  * EnvConditions: NA
5946  * CaseDescription: test HCaptureSessionProxy_cpp with anomalous branch
5947  */
5948 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_027, TestSize.Level0)
5949 {
5950     sptr<IRemoteObject> object = nullptr;
5951     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
5952     ASSERT_NE(samgr, nullptr);
5953 
5954     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
5955 
5956     sptr<ICaptureSession> captureSession = iface_cast<ICaptureSession>(object);
5957     ASSERT_NE(captureSession, nullptr);
5958 
5959     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
5960     ASSERT_NE(previewOutput, nullptr);
5961 
5962     sptr<IStreamCommon> stream = nullptr;
5963 
5964     int32_t intResult = captureSession->AddOutput(previewOutput->GetStreamType(), stream);
5965     EXPECT_EQ(intResult, 200);
5966 
5967     sptr<ICameraDeviceService> cameraDevice = nullptr;
5968     intResult = captureSession->RemoveInput(cameraDevice);
5969     EXPECT_EQ(intResult, 200);
5970 
5971     intResult = captureSession->RemoveOutput(previewOutput->GetStreamType(), stream);
5972     EXPECT_EQ(intResult, 200);
5973 
5974     sptr<ICaptureSessionCallback> callback = nullptr;
5975     EXPECT_EQ(intResult, 200);
5976 }
5977 
5978 /*
5979  * Feature: Framework
5980  * Function: Test anomalous branch
5981  * SubFunction: NA
5982  * FunctionPoints: NA
5983  * EnvConditions: NA
5984  * CaseDescription: test HCaptureSessionProxy_cpp with anomalous branch
5985  */
5986 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_028, TestSize.Level0)
5987 {
5988     sptr<IRemoteObject> object = nullptr;
5989     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
5990     ASSERT_NE(samgr, nullptr);
5991 
5992     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
5993 
5994     sptr<ICaptureSession> captureSession = iface_cast<ICaptureSession>(object);
5995     ASSERT_NE(captureSession, nullptr);
5996 
5997     int32_t intResult = captureSession->BeginConfig();
5998     EXPECT_EQ(intResult, -1);
5999 
6000     sptr<CameraInput> input_1 = (sptr<CameraInput>&)input_;
6001     sptr<ICameraDeviceService> deviceObj = input_1->GetCameraDevice();
6002     ASSERT_NE(deviceObj, nullptr);
6003 
6004     intResult = captureSession->AddInput(deviceObj);
6005     EXPECT_EQ(intResult, -1);
6006 
6007     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6008     ASSERT_NE(previewOutput, nullptr);
6009 
6010     intResult = captureSession->AddOutput(previewOutput->GetStreamType(), previewOutput->GetStream());
6011     EXPECT_EQ(intResult, -1);
6012 
6013     intResult = captureSession->Start();
6014     EXPECT_EQ(intResult, -1);
6015 
6016     intResult = captureSession->Release();
6017     EXPECT_EQ(intResult, -1);
6018 
6019     sptr<ICaptureSessionCallback> callback = new (std::nothrow) CaptureSessionCallback(session_);
6020     ASSERT_NE(callback, nullptr);
6021 
6022     intResult = captureSession->SetCallback(callback);
6023     EXPECT_EQ(intResult, -1);
6024 
6025     CaptureSessionState currentState = CaptureSessionState::SESSION_CONFIG_INPROGRESS;
6026     intResult = captureSession->GetSessionState(currentState);
6027     EXPECT_EQ(intResult, -1);
6028 }
6029 
6030 /*
6031  * Feature: Framework
6032  * Function: Test anomalous branch
6033  * SubFunction: NA
6034  * FunctionPoints: NA
6035  * EnvConditions: NA
6036  * CaseDescription: test HStreamCaptureProxy_cpp with anomalous branch
6037  */
6038 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_029, TestSize.Level0)
6039 {
6040     sptr<IRemoteObject> object = nullptr;
6041     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
6042     ASSERT_NE(samgr, nullptr);
6043 
6044     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
6045 
6046     sptr<IStreamCapture> capture = iface_cast<IStreamCapture>(object);
6047     ASSERT_NE(capture, nullptr);
6048 
6049     sptr<IStreamCaptureCallback> callback = nullptr;
6050     int32_t intResult = capture->SetCallback(callback);
6051     EXPECT_EQ(intResult, 200);
6052 
6053     bool isEnabled = false;
6054     sptr<OHOS::IBufferProducer> producer = nullptr;
6055     intResult = capture->SetThumbnail(isEnabled, producer);
6056     EXPECT_EQ(intResult, 200);
6057 
6058     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
6059     producer = previewSurface->GetProducer();
6060 
6061     intResult = capture->SetThumbnail(isEnabled, producer);
6062     EXPECT_EQ(intResult, -1);
6063 
6064     std::shared_ptr<OHOS::Camera::CameraMetadata> captureSettings = nullptr;
6065     intResult = capture->Capture(captureSettings);
6066     EXPECT_EQ(intResult, 200);
6067 }
6068 
6069 /*
6070  * Feature: Framework
6071  * Function: Test anomalous branch
6072  * SubFunction: NA
6073  * FunctionPoints: NA
6074  * EnvConditions: NA
6075  * CaseDescription: test HStreamCaptureProxy_cpp with anomalous branch
6076  */
6077 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_030, TestSize.Level0)
6078 {
6079     sptr<IRemoteObject> object = nullptr;
6080     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
6081     ASSERT_NE(samgr, nullptr);
6082 
6083     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
6084 
6085     sptr<IStreamCapture> capture = iface_cast<IStreamCapture>(object);
6086     ASSERT_NE(capture, nullptr);
6087 
6088     std::shared_ptr<OHOS::Camera::CameraMetadata> captureSettings = cameras_[0]->GetMetadata();
6089     int32_t intResult = capture->Capture(captureSettings);
6090     EXPECT_EQ(intResult, -1);
6091 
6092     intResult = capture->CancelCapture();
6093     EXPECT_EQ(intResult, -1);
6094 
6095     intResult = capture->Release();
6096     EXPECT_EQ(intResult, -1);
6097 
6098     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
6099     ASSERT_NE(photoOutput, nullptr);
6100 
6101     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
6102     sptr<IStreamCaptureCallback> callback = new (std::nothrow) HStreamCaptureCallbackImpl(photoOutput_1);
6103     ASSERT_NE(callback, nullptr);
6104 
6105     intResult = capture->SetCallback(callback);
6106     EXPECT_EQ(intResult, -1);
6107 }
6108 
6109 /*
6110  * Feature: Framework
6111  * Function: Test anomalous branch
6112  * SubFunction: NA
6113  * FunctionPoints: NA
6114  * EnvConditions: NA
6115  * CaseDescription: test HStreamMetadataProxy_cpp with anomalous branch
6116  */
6117 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_031, TestSize.Level0)
6118 {
6119     sptr<IRemoteObject> object = nullptr;
6120     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
6121     ASSERT_NE(samgr, nullptr);
6122 
6123     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
6124 
6125     sptr<IStreamMetadata> metadata = iface_cast<IStreamMetadata>(object);
6126     ASSERT_NE(metadata, nullptr);
6127 
6128     int32_t intResult = metadata->Start();
6129     EXPECT_EQ(intResult, -1);
6130 
6131     intResult = metadata->Release();
6132     EXPECT_EQ(intResult, -1);
6133 }
6134 
6135 /*
6136  * Feature: Framework
6137  * Function: Test anomalous branch
6138  * SubFunction: NA
6139  * FunctionPoints: NA
6140  * EnvConditions: NA
6141  * CaseDescription: test HStreamRepeatProxy_cpp with anomalous branch
6142  */
6143 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_032, TestSize.Level0)
6144 {
6145     sptr<IRemoteObject> object = nullptr;
6146     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
6147     ASSERT_NE(samgr, nullptr);
6148 
6149     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
6150 
6151     sptr<IStreamRepeat> repeat = iface_cast<IStreamRepeat>(object);
6152     ASSERT_NE(repeat, nullptr);
6153 
6154     sptr<IStreamRepeatCallback> callback = nullptr;
6155     int32_t intResult = repeat->SetCallback(callback);
6156     EXPECT_EQ(intResult, 200);
6157 
6158     sptr<OHOS::IBufferProducer> producer = nullptr;
6159     intResult = repeat->AddDeferredSurface(producer);
6160     EXPECT_EQ(intResult, 200);
6161 
6162     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
6163 
6164     repeat = iface_cast<IStreamRepeat>(object);
6165     ASSERT_NE(repeat, nullptr);
6166 
6167     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6168     ASSERT_NE(previewOutput, nullptr);
6169 
6170     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
6171     callback = new (std::nothrow) PreviewOutputCallbackImpl(previewOutput_1);
6172     ASSERT_NE(callback, nullptr);
6173 
6174     intResult = repeat->SetCallback(callback);
6175     EXPECT_EQ(intResult, -1);
6176 
6177     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
6178     producer = previewSurface->GetProducer();
6179 
6180     intResult = repeat->AddDeferredSurface(producer);
6181     EXPECT_EQ(intResult, -1);
6182 }
6183 
6184 /*
6185  * Feature: Framework
6186  * Function: Test anomalous branch
6187  * SubFunction: NA
6188  * FunctionPoints: NA
6189  * EnvConditions: NA
6190  * CaseDescription: test set the Thumbnail with anomalous branch
6191  */
6192 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_033, TestSize.Level0)
6193 {
6194     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6195     ASSERT_NE(camSession, nullptr);
6196 
6197     int32_t intResult = camSession->BeginConfig();
6198     EXPECT_EQ(intResult, 0);
6199 
6200     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
6201     ASSERT_NE(input, nullptr);
6202 
6203     intResult = camSession->AddInput(input);
6204     EXPECT_EQ(intResult, 0);
6205 
6206     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6207     ASSERT_NE(previewOutput, nullptr);
6208 
6209     intResult = camSession->AddOutput(previewOutput);
6210     EXPECT_EQ(intResult, 0);
6211 
6212     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
6213     ASSERT_NE(photoOutput, nullptr);
6214 
6215     intResult = camSession->AddOutput(photoOutput);
6216     EXPECT_EQ(intResult, 0);
6217 
6218     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
6219 
6220     intResult = camSession->CommitConfig();
6221     EXPECT_EQ(intResult, 0);
6222 
6223     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
6224     sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, g_previewFd, previewSurface);
6225     sptr<IBufferConsumerListener> listener_1 = (sptr<IBufferConsumerListener>&)listener;
6226 
6227     photoOutput_1->SetThumbnailListener(listener_1);
6228 
6229     intResult = photoOutput_1->IsQuickThumbnailSupported();
6230 
6231     if (!IsSupportNow()) {
6232         EXPECT_EQ(intResult, -1);
6233     } else {
6234         EXPECT_EQ(intResult, 0);
6235     }
6236 
6237     bool isEnabled = false;
6238     intResult = photoOutput_1->SetThumbnail(isEnabled);
6239     EXPECT_EQ(intResult, 0);
6240 
6241     photoOutput_1->SetThumbnailListener(listener_1);
6242 
6243     intResult = photoOutput_1->Release();
6244     EXPECT_EQ(intResult, 0);
6245 
6246     intResult = photoOutput_1->IsQuickThumbnailSupported();
6247     EXPECT_EQ(intResult, 7400104);
6248 
6249     intResult = photoOutput_1->SetThumbnail(isEnabled);
6250     EXPECT_EQ(intResult, 7400104);
6251 }
6252 
6253 /*
6254  * Feature: Framework
6255  * Function: Test anomalous branch
6256  * SubFunction: NA
6257  * FunctionPoints: NA
6258  * EnvConditions: NA
6259  * CaseDescription: test submit device control setting with anomalous branch
6260  */
6261 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_034, TestSize.Level0)
6262 {
6263     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6264     ASSERT_NE(camSession, nullptr);
6265     camSession->Release();
6266 
6267     int32_t intResult = camSession->UnlockForControl();
6268     EXPECT_EQ(intResult, 7400201);
6269 }
6270 
6271 /*
6272  * Feature: Framework
6273  * Function: Test anomalous branch
6274  * SubFunction: NA
6275  * FunctionPoints: NA
6276  * EnvConditions: NA
6277  * CaseDescription: test MuteCamera with anomalous branch
6278  */
6279 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_035, TestSize.Level0)
6280 {
6281     bool cameraMuted = manager_->IsCameraMuted();
6282     EXPECT_EQ(cameraMuted, false);
6283 
6284     bool cameraMuteSupported = manager_->IsCameraMuteSupported();
6285     EXPECT_EQ(cameraMuteSupported, true);
6286 
6287     manager_->MuteCamera(cameraMuted);
6288 
6289     sptr<CameraMuteServiceCallback> muteService = new (std::nothrow) CameraMuteServiceCallback(nullptr);
6290     ASSERT_NE(muteService, nullptr);
6291 
6292     int32_t muteCameraState = muteService->OnCameraMute(cameraMuted);
6293     EXPECT_EQ(muteCameraState, 0);
6294 
6295     muteService = new (std::nothrow) CameraMuteServiceCallback(manager_);
6296     ASSERT_NE(muteService, nullptr);
6297 
6298     muteCameraState = muteService->OnCameraMute(cameraMuted);
6299     EXPECT_EQ(muteCameraState, 0);
6300 
6301     std::shared_ptr<CameraMuteListener> listener = nullptr;
6302     manager_->RegisterCameraMuteListener(listener);
6303 }
6304 
6305 /*
6306  * Feature: Framework
6307  * Function: Test anomalous branch
6308  * SubFunction: NA
6309  * FunctionPoints: NA
6310  * EnvConditions: NA
6311  * CaseDescription: test service callback with anomalous branch
6312  */
6313 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_036, TestSize.Level0)
6314 {
6315     std::string cameraIdtest = "";
6316     FlashStatus status = FLASH_STATUS_OFF;
6317 
6318     sptr<CameraStatusServiceCallback> camServiceCallback = new (std::nothrow) CameraStatusServiceCallback(nullptr);
6319     ASSERT_NE(camServiceCallback, nullptr);
6320     int32_t cameraStatusChanged = camServiceCallback->OnFlashlightStatusChanged(cameraIdtest, status);
6321     EXPECT_EQ(cameraStatusChanged, 0);
6322 
6323     sptr<CameraDeviceServiceCallback> camDeviceSvcCallback = new (std::nothrow) CameraDeviceServiceCallback();
6324     ASSERT_NE(camDeviceSvcCallback, nullptr);
6325     int32_t onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
6326     EXPECT_EQ(onError, 0);
6327 
6328     std::shared_ptr<OHOS::Camera::CameraMetadata> result = nullptr;
6329     int32_t onResult = camDeviceSvcCallback->OnResult(0, result);
6330     EXPECT_EQ(onResult, CAMERA_INVALID_ARG);
6331 
6332     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
6333     sptr<ICameraDeviceService> deviceObj = input->GetCameraDevice();
6334     ASSERT_NE(deviceObj, nullptr);
6335 
6336     sptr<CameraDevice> camdeviceObj = nullptr;
6337     sptr<CameraInput> camInput_1 = new (std::nothrow) CameraInput(deviceObj, camdeviceObj);
6338     ASSERT_NE(camInput_1, nullptr);
6339 
6340     camDeviceSvcCallback = new (std::nothrow) CameraDeviceServiceCallback(camInput_1);
6341     ASSERT_NE(camDeviceSvcCallback, nullptr);
6342     onResult = camDeviceSvcCallback->OnResult(0, result);
6343     EXPECT_EQ(onResult, CAMERA_INVALID_ARG);
6344 
6345     sptr<CameraInput> camInput_2 = new (std::nothrow) CameraInput(deviceObj, cameras_[0]);
6346     ASSERT_NE(camInput_2, nullptr);
6347     camDeviceSvcCallback = new (std::nothrow) CameraDeviceServiceCallback(camInput_2);
6348     ASSERT_NE(camDeviceSvcCallback, nullptr);
6349     onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
6350     EXPECT_EQ(onError, 0);
6351 
6352     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
6353     camInput_2->SetErrorCallback(callback);
6354 
6355     camDeviceSvcCallback = new (std::nothrow) CameraDeviceServiceCallback(camInput_2);
6356     ASSERT_NE(camDeviceSvcCallback, nullptr);
6357     onError = camDeviceSvcCallback->OnError(CAMERA_DEVICE_PREEMPTED, 0);
6358     EXPECT_EQ(onError, 0);
6359 
6360     callback = nullptr;
6361     camInput_2->SetErrorCallback(callback);
6362     camInput_2->SetResultCallback(callback);
6363 }
6364 
6365 /*
6366  * Feature: Framework
6367  * Function: Test anomalous branch
6368  * SubFunction: NA
6369  * FunctionPoints: NA
6370  * EnvConditions: NA
6371  * CaseDescription: test create camera input instance with provided camera position and type anomalous branch
6372  */
6373 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_037, TestSize.Level0)
6374 {
6375     CameraPosition cameraPosition = cameras_[0]->GetPosition();
6376     CameraType cameraType = cameras_[0]->GetCameraType();
6377     sptr<CaptureInput> camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
6378     ASSERT_NE(camInputtest, nullptr);
6379 
6380     cameraType = CAMERA_TYPE_UNSUPPORTED;
6381     cameraPosition = CAMERA_POSITION_UNSPECIFIED;
6382     camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
6383     EXPECT_EQ(camInputtest, nullptr);
6384 
6385     cameraType = CAMERA_TYPE_UNSUPPORTED;
6386     cameraPosition = cameras_[0]->GetPosition();
6387     camInputtest = manager_->CreateCameraInput(cameraPosition, cameraType);
6388     EXPECT_EQ(camInputtest, nullptr);
6389 }
6390 
6391 /*
6392  * Feature: Framework
6393  * Function: Test anomalous branch
6394  * SubFunction: NA
6395  * FunctionPoints: NA
6396  * EnvConditions: NA
6397  * CaseDescription: test the supported exposure compensation range and Zoom Ratio range with anomalous branch
6398  */
6399 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_038, TestSize.Level0)
6400 {
6401     std::string cameraId = "";
6402     dmDeviceInfo deviceInfo = {};
6403     sptr<CameraDevice> camdeviceObj = new (std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
6404     ASSERT_NE(camdeviceObj, nullptr);
6405 
6406     std::vector<float> zoomRatioRange = camdeviceObj->GetZoomRatioRange();
6407     EXPECT_EQ(zoomRatioRange.empty(), true);
6408 
6409     std::vector<float> exposureBiasRange = camdeviceObj->GetExposureBiasRange();
6410     EXPECT_EQ(exposureBiasRange.empty(), true);
6411 }
6412 
6413 /*
6414  * Feature: Framework
6415  * Function: Test anomalous branch
6416  * SubFunction: NA
6417  * FunctionPoints: NA
6418  * EnvConditions: NA
6419  * CaseDescription: test session with anomalous branch
6420  */
6421 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_039, TestSize.Level0)
6422 {
6423     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
6424     input->Close();
6425     input->SetMetadataResultProcessor(session_->GetMetadataResultProcessor());
6426 
6427     sptr<CaptureInput> input_2 = (sptr<CaptureInput>&)input;
6428 
6429     int32_t intResult = session_->BeginConfig();
6430     EXPECT_EQ(intResult, 0);
6431 
6432     intResult = session_->BeginConfig();
6433     EXPECT_EQ(intResult, 7400105);
6434 
6435     intResult = session_->AddInput(input_2);
6436     EXPECT_EQ(intResult, 7400201);
6437 
6438     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6439     ASSERT_NE(camSession, nullptr);
6440     camSession->Release();
6441 
6442     intResult = camSession->BeginConfig();
6443     EXPECT_EQ(intResult, 7400201);
6444 }
6445 
6446 /*
6447  * Feature: Framework
6448  * Function: Test anomalous branch
6449  * SubFunction: NA
6450  * FunctionPoints: NA
6451  * EnvConditions: NA
6452  * CaseDescription: test create preview output with anomalous branch
6453  */
6454 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_040, TestSize.Level0)
6455 {
6456     sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
6457     sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
6458     sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(previewProducer);
6459 
6460     sptr<Surface> pSurface_1 = nullptr;
6461 
6462     sptr<CaptureOutput> previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface_1);
6463     EXPECT_EQ(previewOutput, nullptr);
6464 
6465     sptr<CaptureOutput> previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
6466     ASSERT_NE(previewOutput_1, nullptr);
6467 
6468     // height is zero
6469     CameraFormat previewFormat = previewProfiles[0].GetCameraFormat();
6470     Size previewSize;
6471     previewSize.width = previewProfiles[0].GetSize().width;
6472     previewSize.height = 0;
6473     previewProfiles[0] = Profile(previewFormat, previewSize);
6474 
6475     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
6476     EXPECT_EQ(previewOutput, nullptr);
6477 
6478     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
6479     EXPECT_EQ(previewOutput_1, nullptr);
6480 
6481     sptr<CaptureOutput> previewOutput_2 = manager_->CreatePreviewOutput(previewProducer, previewFormat);
6482     EXPECT_EQ(previewOutput_2, nullptr);
6483 
6484     sptr<CaptureOutput> previewOutput_3 = nullptr;
6485     previewOutput_3 = manager_->CreateCustomPreviewOutput(pSurface, previewSize.width, previewSize.height);
6486     EXPECT_EQ(previewOutput_3, nullptr);
6487 
6488     // width is zero
6489     previewSize.width = 0;
6490     previewSize.height = PREVIEW_DEFAULT_HEIGHT;
6491     previewProfiles[0] = Profile(previewFormat, previewSize);
6492 
6493     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
6494     EXPECT_EQ(previewOutput, nullptr);
6495 
6496     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
6497     EXPECT_EQ(previewOutput_1, nullptr);
6498 
6499     // format is CAMERA_FORMAT_INVALID
6500     previewFormat = CAMERA_FORMAT_INVALID;
6501     previewSize.width = PREVIEW_DEFAULT_WIDTH;
6502     previewProfiles[0] = Profile(previewFormat, previewSize);
6503 
6504     previewOutput = manager_->CreatePreviewOutput(previewProfiles[0], pSurface);
6505     EXPECT_EQ(previewOutput, nullptr);
6506 
6507     previewOutput_1 = manager_->CreateDeferredPreviewOutput(previewProfiles[0]);
6508     EXPECT_EQ(previewOutput_1, nullptr);
6509 }
6510 
6511 /*
6512  * Feature: Framework
6513  * Function: Test anomalous branch
6514  * SubFunction: NA
6515  * FunctionPoints: NA
6516  * EnvConditions: NA
6517  * CaseDescription: test create photo output with anomalous branch
6518  */
6519 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_041, TestSize.Level0)
6520 {
6521     sptr<IConsumerSurface> photosurface = IConsumerSurface::Create();
6522     sptr<IBufferProducer> surfaceProducer_1 = photosurface->GetProducer();
6523 
6524     sptr<IBufferProducer> surfaceProducer_2 = nullptr;
6525 
6526     sptr<CaptureOutput> photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_2);
6527     EXPECT_EQ(photoOutput, nullptr);
6528 
6529     // height is zero
6530     CameraFormat photoFormat = photoProfiles[0].GetCameraFormat();
6531     Size photoSize;
6532     photoSize.width = photoProfiles[0].GetSize().width;
6533     photoSize.height = 0;
6534     photoProfiles[0] = Profile(photoFormat, photoSize);
6535 
6536     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
6537     EXPECT_EQ(photoOutput, nullptr);
6538 
6539     // width is zero
6540     photoSize.width = 0;
6541     photoSize.height = PHOTO_DEFAULT_HEIGHT;
6542     photoProfiles[0] = Profile(photoFormat, photoSize);
6543 
6544     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
6545     EXPECT_EQ(photoOutput, nullptr);
6546 
6547     // format is CAMERA_FORMAT_INVALID
6548     photoFormat = CAMERA_FORMAT_INVALID;
6549     photoSize.width = PHOTO_DEFAULT_WIDTH;
6550     photoProfiles[0] = Profile(photoFormat, photoSize);
6551 
6552     photoOutput = manager_->CreatePhotoOutput(photoProfiles[0], surfaceProducer_1);
6553     EXPECT_EQ(photoOutput, nullptr);
6554 }
6555 
6556 /*
6557  * Feature: Framework
6558  * Function: Test anomalous branch
6559  * SubFunction: NA
6560  * FunctionPoints: NA
6561  * EnvConditions: NA
6562  * CaseDescription: test create video output with anomalous branch
6563  */
6564 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_042, TestSize.Level0)
6565 {
6566     sptr<IConsumerSurface> videoSurface = IConsumerSurface::Create();
6567     sptr<IBufferProducer> videoProducer = videoSurface->GetProducer();
6568     sptr<Surface> pSurface_1 = Surface::CreateSurfaceAsProducer(videoProducer);
6569 
6570     sptr<Surface> pSurface_2 = nullptr;
6571 
6572     sptr<CaptureOutput> videoOutput = manager_->CreateVideoOutput(videoProfiles[0], pSurface_2);
6573     EXPECT_EQ(videoOutput, nullptr);
6574 
6575     sptr<CaptureOutput> videoOutput_1 = manager_->CreateVideoOutput(pSurface_2);
6576     EXPECT_EQ(videoOutput_1, nullptr);
6577 
6578     // height is zero
6579     std::vector<int32_t> framerates;
6580     CameraFormat videoFormat = videoProfiles[0].GetCameraFormat();
6581     Size videoSize;
6582     videoSize.width = videoProfiles[0].GetSize().width;
6583     videoSize.height = 0;
6584     VideoProfile videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
6585 
6586     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
6587     EXPECT_EQ(videoOutput, nullptr);
6588 
6589     // width is zero
6590     videoSize.width = 0;
6591     videoSize.height = VIDEO_DEFAULT_HEIGHT;
6592     videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
6593 
6594     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
6595     EXPECT_EQ(videoOutput, nullptr);
6596 
6597     // format is CAMERA_FORMAT_INVALID
6598     videoFormat = CAMERA_FORMAT_INVALID;
6599     videoSize.width = VIDEO_DEFAULT_WIDTH;
6600     videoProfile_1 = VideoProfile(videoFormat, videoSize, framerates);
6601 
6602     videoOutput = manager_->CreateVideoOutput(videoProfile_1, pSurface_1);
6603     EXPECT_EQ(videoOutput, nullptr);
6604 }
6605 
6606 /*
6607  * Feature: Framework
6608  * Function: Test anomalous branch
6609  * SubFunction: NA
6610  * FunctionPoints: NA
6611  * EnvConditions: NA
6612  * CaseDescription: Test camera settings with anomalous branch
6613  */
6614 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_043, TestSize.Level0)
6615 {
6616     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
6617     sptr<ICameraDeviceService> deviceObj_2 = input->GetCameraDevice();
6618     ASSERT_NE(deviceObj_2, nullptr);
6619 
6620     sptr<CameraDevice> camdeviceObj = nullptr;
6621     sptr<CameraInput> camInput_2 = new (std::nothrow) CameraInput(deviceObj_2, camdeviceObj);
6622     ASSERT_NE(camInput_2, nullptr);
6623 
6624     std::string cameraId = input->GetCameraId();
6625 
6626     std::string getCameraSettings_1 = input->GetCameraSettings();
6627     int32_t intResult = input->SetCameraSettings(getCameraSettings_1);
6628     EXPECT_EQ(intResult, 0);
6629 
6630     std::string getCameraSettings_2 = "";
6631 
6632     intResult = camInput_2->SetCameraSettings(getCameraSettings_2);
6633     EXPECT_EQ(intResult, 2);
6634 
6635     sptr<CameraInput> camInput_3 = (sptr<CameraInput>&)input_;
6636     getCameraSettings_2 = camInput_3->GetCameraSettings();
6637     intResult = camInput_3->SetCameraSettings(getCameraSettings_2);
6638     EXPECT_EQ(intResult, 0);
6639 
6640     sptr<CameraInput> input_1 = (sptr<CameraInput>&)input_;
6641     input_1->Close();
6642     input_1->SetMetadataResultProcessor(session_->GetMetadataResultProcessor());
6643 
6644     sptr<CaptureInput> input_2 = (sptr<CaptureInput>&)input_1;
6645 
6646     intResult = input_2->Open();
6647     EXPECT_EQ(intResult, 7400201);
6648 
6649     intResult = camInput_2->Release();
6650     EXPECT_EQ(intResult, 0);
6651 }
6652 
6653 /*
6654  * Feature: Framework
6655  * Function: Test anomalous branch
6656  * SubFunction: NA
6657  * FunctionPoints: NA
6658  * EnvConditions: NA
6659  * CaseDescription: test submit device control setting with anomalous branch
6660  */
6661 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_044, TestSize.Level0)
6662 {
6663     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6664     ASSERT_NE(camSession, nullptr);
6665 
6666     int32_t intResult = camSession->BeginConfig();
6667     EXPECT_EQ(intResult, 0);
6668 
6669     intResult = camSession->AddInput(input_);
6670     EXPECT_EQ(intResult, 0);
6671 
6672     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6673     ASSERT_NE(previewOutput, nullptr);
6674 
6675     intResult = camSession->AddOutput(previewOutput);
6676     EXPECT_EQ(intResult, 0);
6677 
6678     intResult = camSession->CommitConfig();
6679     EXPECT_EQ(intResult, 0);
6680 
6681     camSession->LockForControl();
6682 
6683     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
6684     if (!zoomRatioRange.empty()) {
6685         camSession->SetZoomRatio(zoomRatioRange[0]);
6686     }
6687 
6688     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
6689     camInput->Close();
6690 
6691     intResult = camSession->UnlockForControl();
6692     EXPECT_EQ(intResult, 0);
6693 
6694     camSession->LockForControl();
6695 
6696     intResult = camSession->UnlockForControl();
6697     EXPECT_EQ(intResult, 0);
6698 }
6699 
6700 /*
6701  * Feature: Framework
6702  * Function: Test anomalous branch
6703  * SubFunction: NA
6704  * FunctionPoints: NA
6705  * EnvConditions: NA
6706  * CaseDescription: Test abnormal branches with empty inputDevice
6707  */
6708 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_045, TestSize.Level0)
6709 {
6710     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6711     ASSERT_NE(camSession, nullptr);
6712 
6713     int32_t intResult = camSession->BeginConfig();
6714     EXPECT_EQ(intResult, 0);
6715 
6716     intResult = camSession->AddInput(input_);
6717     EXPECT_EQ(intResult, 0);
6718 
6719     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6720     ASSERT_NE(previewOutput, nullptr);
6721 
6722     intResult = camSession->AddOutput(previewOutput);
6723     EXPECT_EQ(intResult, 0);
6724 
6725     intResult = camSession->CommitConfig();
6726     EXPECT_EQ(intResult, 0);
6727 
6728     camSession->innerInputDevice_ = nullptr;
6729     VideoStabilizationMode mode = MIDDLE;
6730 
6731     intResult = camSession->GetActiveVideoStabilizationMode(mode);
6732     EXPECT_EQ(intResult, 0);
6733 
6734     std::vector<VideoStabilizationMode> videoStabilizationMode = camSession->GetSupportedStabilizationMode();
6735     EXPECT_EQ(videoStabilizationMode.empty(), true);
6736 
6737     intResult = camSession->GetSupportedStabilizationMode(videoStabilizationMode);
6738     EXPECT_EQ(intResult, 0);
6739 
6740     std::vector<ExposureMode> getSupportedExpModes = camSession->GetSupportedExposureModes();
6741     EXPECT_EQ(getSupportedExpModes.empty(), true);
6742 
6743     intResult = camSession->GetSupportedExposureModes(getSupportedExpModes);
6744     EXPECT_EQ(intResult, 0);
6745 
6746     ExposureMode exposureMode = camSession->GetExposureMode();
6747     EXPECT_EQ(exposureMode, EXPOSURE_MODE_UNSUPPORTED);
6748 
6749     intResult = camSession->GetExposureMode(exposureMode);
6750     EXPECT_EQ(intResult, 0);
6751 
6752     Point exposurePointGet = camSession->GetMeteringPoint();
6753     EXPECT_EQ(exposurePointGet.x, 0);
6754     EXPECT_EQ(exposurePointGet.y, 0);
6755 
6756     intResult = camSession->GetMeteringPoint(exposurePointGet);
6757     EXPECT_EQ(intResult, 0);
6758 
6759     std::vector<float> getExposureBiasRange = camSession->GetExposureBiasRange();
6760     EXPECT_EQ(getExposureBiasRange.empty(), true);
6761 
6762     intResult = camSession->GetExposureBiasRange(getExposureBiasRange);
6763     EXPECT_EQ(intResult, 0);
6764 
6765     float exposureValue = camSession->GetExposureValue();
6766     EXPECT_EQ(exposureValue, 0);
6767 
6768     intResult = camSession->GetExposureValue(exposureValue);
6769     EXPECT_EQ(intResult, 0);
6770 
6771     camSession->LockForControl();
6772 
6773     intResult = camSession->SetExposureBias(exposureValue);
6774     EXPECT_EQ(intResult, 7400102);
6775 
6776     std::vector<FocusMode> getSupportedFocusModes = camSession->GetSupportedFocusModes();
6777     EXPECT_EQ(getSupportedFocusModes.empty(), true);
6778 
6779     intResult = camSession->GetSupportedFocusModes(getSupportedFocusModes);
6780     EXPECT_EQ(intResult, 0);
6781 }
6782 
6783 /*
6784  * Feature: Framework
6785  * Function: Test anomalous branch
6786  * SubFunction: NA
6787  * FunctionPoints: NA
6788  * EnvConditions: NA
6789  * CaseDescription: Test abnormal branches with empty innerInputDevice_
6790  */
6791 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_046, TestSize.Level0)
6792 {
6793     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6794     ASSERT_NE(camSession, nullptr);
6795 
6796     int32_t intResult = camSession->BeginConfig();
6797     EXPECT_EQ(intResult, 0);
6798 
6799     intResult = camSession->AddInput(input_);
6800     EXPECT_EQ(intResult, 0);
6801 
6802     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6803     ASSERT_NE(previewOutput, nullptr);
6804 
6805     intResult = camSession->AddOutput(previewOutput);
6806     EXPECT_EQ(intResult, 0);
6807 
6808     intResult = camSession->CommitConfig();
6809     EXPECT_EQ(intResult, 0);
6810 
6811     camSession->innerInputDevice_ = nullptr;
6812 
6813     FocusMode focusMode = camSession->GetFocusMode();
6814     EXPECT_EQ(focusMode, FOCUS_MODE_MANUAL);
6815 
6816     intResult = camSession->GetFocusMode(focusMode);
6817     EXPECT_EQ(intResult, 0);
6818 
6819     Point focusPoint = camSession->GetFocusPoint();
6820     EXPECT_EQ(focusPoint.x, 0);
6821     EXPECT_EQ(focusPoint.y, 0);
6822 
6823     intResult = camSession->GetFocusPoint(focusPoint);
6824     EXPECT_EQ(intResult, 0);
6825 
6826     float focalLength = camSession->GetFocalLength();
6827     EXPECT_EQ(focalLength, 0);
6828 
6829     intResult = camSession->GetFocalLength(focalLength);
6830     EXPECT_EQ(intResult, 0);
6831 
6832     std::vector<FlashMode> getSupportedFlashModes = camSession->GetSupportedFlashModes();
6833     EXPECT_EQ(getSupportedFlashModes.empty(), true);
6834 
6835     intResult = camSession->GetSupportedFlashModes(getSupportedFlashModes);
6836     EXPECT_EQ(intResult, 0);
6837 
6838     FlashMode flashMode = camSession->GetFlashMode();
6839     EXPECT_EQ(flashMode, FLASH_MODE_CLOSE);
6840 
6841     intResult = camSession->GetFlashMode(flashMode);
6842     EXPECT_EQ(intResult, 0);
6843 
6844     std::vector<float> zoomRatioRange = camSession->GetZoomRatioRange();
6845     EXPECT_EQ(zoomRatioRange.empty(), true);
6846 
6847     intResult = camSession->GetZoomRatioRange(zoomRatioRange);
6848     EXPECT_EQ(intResult, 0);
6849 
6850     float zoomRatio = camSession->GetZoomRatio();
6851     EXPECT_EQ(zoomRatio, 0);
6852 
6853     intResult = camSession->GetZoomRatio(zoomRatio);
6854     EXPECT_EQ(intResult, 0);
6855 
6856     camSession->LockForControl();
6857 
6858     intResult = camSession->SetZoomRatio(zoomRatio);
6859     EXPECT_EQ(intResult, 0);
6860 
6861     intResult = camSession->SetMeteringPoint(focusPoint);
6862     EXPECT_EQ(intResult, 0);
6863 }
6864 
6865 /*
6866  * Feature: Framework
6867  * Function: Test anomalous branch
6868  * SubFunction: NA
6869  * FunctionPoints: NA
6870  * EnvConditions: NA
6871  * CaseDescription: test submit device control setting with anomalous branch
6872  */
6873 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_047, TestSize.Level0)
6874 {
6875     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6876     ASSERT_NE(camSession, nullptr);
6877 
6878     int32_t intResult = camSession->BeginConfig();
6879     EXPECT_EQ(intResult, 0);
6880 
6881     intResult = camSession->AddInput(input_);
6882     EXPECT_EQ(intResult, 0);
6883 
6884     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6885     ASSERT_NE(previewOutput, nullptr);
6886 
6887     intResult = camSession->AddOutput(previewOutput);
6888     EXPECT_EQ(intResult, 0);
6889 
6890     intResult = camSession->CommitConfig();
6891     EXPECT_EQ(intResult, 0);
6892 
6893     camSession->LockForControl();
6894 
6895     std::vector<float> exposureBiasRange = camSession->GetExposureBiasRange();
6896     if (!exposureBiasRange.empty()) {
6897         camSession->SetExposureBias(exposureBiasRange[0]);
6898     }
6899 
6900     camSession->innerInputDevice_ = nullptr;
6901 
6902     intResult = camSession->UnlockForControl();
6903     EXPECT_EQ(intResult, 0);
6904 }
6905 
6906 /*
6907  * Feature: Framework
6908  * Function: Test anomalous branch
6909  * SubFunction: NA
6910  * FunctionPoints: NA
6911  * EnvConditions: NA
6912  * CaseDescription: test stream_ null with anomalous branch
6913  */
6914 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_048, TestSize.Level0)
6915 {
6916     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
6917 
6918     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6919     ASSERT_NE(camSession, nullptr);
6920 
6921     int32_t intResult = camSession->BeginConfig();
6922     EXPECT_EQ(intResult, 0);
6923 
6924     intResult = camSession->AddInput(input_);
6925     EXPECT_EQ(intResult, 0);
6926 
6927     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
6928     ASSERT_NE(previewOutput, nullptr);
6929 
6930     intResult = camSession->AddOutput(previewOutput);
6931     EXPECT_EQ(intResult, 0);
6932 
6933     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
6934     ASSERT_NE(photoOutput, nullptr);
6935 
6936     intResult = camSession->AddOutput(photoOutput);
6937     EXPECT_EQ(intResult, 0);
6938 
6939     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
6940     ASSERT_NE(videoOutput, nullptr);
6941 
6942     intResult = camSession->AddOutput(videoOutput);
6943     EXPECT_EQ(intResult, 0);
6944 
6945     intResult = camSession->CommitConfig();
6946     EXPECT_EQ(intResult, 0);
6947 
6948     previewOutput->Release();
6949     previewOutput->SetSession(camSession);
6950 
6951     photoOutput->Release();
6952     photoOutput->SetSession(camSession);
6953 
6954     videoOutput->Release();
6955     videoOutput->SetSession(camSession);
6956 
6957     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
6958     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
6959     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput>&)videoOutput;
6960 
6961     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
6962     photoOutput_1->SetCallback(callback);
6963 
6964     intResult = previewOutput_1->Start();
6965     EXPECT_EQ(intResult, 7400201);
6966 
6967     intResult = photoOutput_1->Capture(photoSetting);
6968     EXPECT_EQ(intResult, 7400201);
6969 
6970     intResult = photoOutput_1->Capture();
6971     EXPECT_EQ(intResult, 7400201);
6972 
6973     intResult = photoOutput_1->CancelCapture();
6974     EXPECT_EQ(intResult, 7400201);
6975 
6976     intResult = videoOutput_1->Start();
6977     EXPECT_EQ(intResult, 7400201);
6978 }
6979 
6980 /*
6981  * Feature: Framework
6982  * Function: Test anomalous branch
6983  * SubFunction: NA
6984  * FunctionPoints: NA
6985  * EnvConditions: NA
6986  * CaseDescription: test stream_ null with anomalous branch
6987  */
6988 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_049, TestSize.Level0)
6989 {
6990     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
6991 
6992     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
6993     ASSERT_NE(camSession, nullptr);
6994 
6995     int32_t intResult = camSession->BeginConfig();
6996     EXPECT_EQ(intResult, 0);
6997 
6998     intResult = camSession->AddInput(input_);
6999     EXPECT_EQ(intResult, 0);
7000 
7001     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7002     ASSERT_NE(previewOutput, nullptr);
7003 
7004     intResult = camSession->AddOutput(previewOutput);
7005     EXPECT_EQ(intResult, 0);
7006 
7007     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
7008     ASSERT_NE(metadatOutput, nullptr);
7009 
7010     intResult = camSession->AddOutput(metadatOutput);
7011     EXPECT_EQ(intResult, 0);
7012 
7013     intResult = camSession->CommitConfig();
7014     EXPECT_EQ(intResult, 0);
7015 
7016     metadatOutput->Release();
7017     metadatOutput->SetSession(camSession);
7018 
7019     sptr<MetadataOutput> metadatOutput_1 = (sptr<MetadataOutput>&)metadatOutput;
7020 
7021     intResult = metadatOutput_1->Start();
7022     EXPECT_EQ(intResult, 0);
7023 }
7024 
7025 /*
7026  * Feature: Framework
7027  * Function: Test anomalous branch
7028  * SubFunction: NA
7029  * FunctionPoints: NA
7030  * EnvConditions: NA
7031  * CaseDescription: test cameraObj null with anomalous branch
7032  */
7033 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_050, TestSize.Level0)
7034 {
7035     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
7036 
7037     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
7038     ASSERT_NE(camSession, nullptr);
7039 
7040     int32_t intResult = camSession->BeginConfig();
7041     EXPECT_EQ(intResult, 0);
7042 
7043     intResult = camSession->AddInput(input_);
7044     EXPECT_EQ(intResult, 0);
7045 
7046     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7047     ASSERT_NE(previewOutput, nullptr);
7048 
7049     intResult = camSession->AddOutput(previewOutput);
7050     EXPECT_EQ(intResult, 0);
7051 
7052     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
7053     ASSERT_NE(photoOutput, nullptr);
7054 
7055     intResult = camSession->AddOutput(photoOutput);
7056     EXPECT_EQ(intResult, 0);
7057 
7058     intResult = camSession->CommitConfig();
7059     EXPECT_EQ(intResult, 0);
7060 
7061     ReleaseInput();
7062     photoOutput->SetSession(camSession);
7063 
7064     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
7065 
7066     bool isMirrorSupported = photoOutput_1->IsMirrorSupported();
7067     EXPECT_EQ(isMirrorSupported, false);
7068 
7069     intResult = photoOutput_1->IsQuickThumbnailSupported();
7070     EXPECT_EQ(intResult, 7400104);
7071 
7072     bool isEnabled = false;
7073     intResult = photoOutput_1->SetThumbnail(isEnabled);
7074     EXPECT_EQ(intResult, 7400104);
7075 }
7076 
7077 /*
7078  * Feature: Framework
7079  * Function: Test anomalous branch
7080  * SubFunction: NA
7081  * FunctionPoints: NA
7082  * EnvConditions: NA
7083  * CaseDescription: test CallbackProxy_cpp with anomalous branch
7084  */
7085 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_052, TestSize.Level0)
7086 {
7087     sptr<IRemoteObject> object = nullptr;
7088     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
7089     ASSERT_NE(samgr, nullptr);
7090 
7091     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
7092 
7093     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
7094     sptr<ICameraDeviceServiceCallback> callback = new (std::nothrow) CameraDeviceServiceCallback(input);
7095     ASSERT_NE(callback, nullptr);
7096 
7097     sptr<HCameraDeviceCallbackProxy> deviceCallback = (sptr<HCameraDeviceCallbackProxy>&)callback;
7098     deviceCallback = new (std::nothrow) HCameraDeviceCallbackProxy(object);
7099     ASSERT_NE(deviceCallback, nullptr);
7100 
7101     uint64_t timestamp = 10;
7102     std::shared_ptr<OHOS::Camera::CameraMetadata> result = nullptr;
7103     int32_t intResult = deviceCallback->OnResult(timestamp, result);
7104     EXPECT_EQ(intResult, 200);
7105 }
7106 
7107 /*
7108  * Feature: Framework
7109  * Function: Test anomalous branch
7110  * SubFunction: NA
7111  * FunctionPoints: NA
7112  * EnvConditions: NA
7113  * CaseDescription: test prelaunch the camera with serviceProxy_ null anomalous branch
7114  */
7115 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_058, TestSize.Level0)
7116 {
7117     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
7118     ASSERT_NE(camManagerObj, nullptr);
7119 
7120     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
7121     std::string cameraId = camInput->GetCameraId();
7122     int activeTime = 0;
7123     EffectParam effectParam = {0, 0, 0};
7124 
7125     int32_t intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::TRANSIENT_ACTIVE_PARAM_OHOS,
7126         activeTime, effectParam);
7127     if (!IsSupportNow()) {
7128         EXPECT_EQ(intResult, 7400201);
7129     } else {
7130         EXPECT_EQ(intResult, 0);
7131     }
7132 
7133     intResult = camManagerObj->PrelaunchCamera();
7134     EXPECT_EQ(intResult, 0);
7135     // CameraManager instance has been changed, need recover
7136     camManagerObj->SetServiceProxy(nullptr);
7137 
7138     intResult = camManagerObj->PrelaunchCamera();
7139     EXPECT_EQ(intResult, 7400201);
7140 
7141     bool isPreLaunchSupported = camManagerObj->IsPrelaunchSupported(cameras_[0]);
7142     if (!IsSupportNow()) {
7143         EXPECT_EQ(isPreLaunchSupported, false);
7144     } else {
7145         EXPECT_EQ(isPreLaunchSupported, true);
7146     }
7147 
7148     intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::TRANSIENT_ACTIVE_PARAM_OHOS,
7149         activeTime, effectParam);
7150     EXPECT_EQ(intResult, 7400201);
7151     // CameraManager recovered
7152     camManagerObj->InitCameraManager();
7153 }
7154 
7155 /*
7156  * Feature: Framework
7157  * Function: Test anomalous branch
7158  * SubFunction: NA
7159  * FunctionPoints: NA
7160  * EnvConditions: NA
7161  * CaseDescription: test serviceProxy_ null with anomalous branch
7162  */
7163 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_059, TestSize.Level0)
7164 {
7165     sptr<Surface> pSurface = nullptr;
7166     sptr<IBufferProducer> surfaceProducer = nullptr;
7167 
7168     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
7169     ASSERT_NE(camManagerObj, nullptr);
7170 
7171     // CameraManager instance has been changed, need recover
7172     camManagerObj->ClearCameraDeviceListCache();
7173 
7174     std::vector<sptr<CameraDevice>> camdeviceObj_1 = camManagerObj->GetSupportedCameras();
7175     ASSERT_TRUE(camdeviceObj_1.size() != 0);
7176 
7177     camManagerObj->SetServiceProxy(nullptr);
7178 
7179     sptr<CaptureSession> captureSession = camManagerObj->CreateCaptureSession();
7180     EXPECT_EQ(captureSession, nullptr);
7181 
7182     sptr<CaptureOutput> metadataOutput = camManagerObj->CreateMetadataOutput();
7183     EXPECT_EQ(metadataOutput, nullptr);
7184 
7185     sptr<CaptureOutput> previewOutput = camManagerObj->CreatePreviewOutput(previewProfiles[0], pSurface);
7186     EXPECT_EQ(previewOutput, nullptr);
7187 
7188     previewOutput = camManagerObj->CreateDeferredPreviewOutput(previewProfiles[0]);
7189     EXPECT_EQ(previewOutput, nullptr);
7190 
7191     sptr<CaptureOutput> photoOutput = camManagerObj->CreatePhotoOutput(photoProfiles[0], surfaceProducer);
7192     EXPECT_EQ(photoOutput, nullptr);
7193 
7194     sptr<CaptureOutput> videoOutput = camManagerObj->CreateVideoOutput(videoProfiles[0], pSurface);
7195     EXPECT_EQ(videoOutput, nullptr);
7196     // CameraManager recovered
7197     camManagerObj->InitCameraManager();
7198 }
7199 
7200 /*
7201  * Feature: Framework
7202  * Function: Test anomalous branch
7203  * SubFunction: NA
7204  * FunctionPoints: NA
7205  * EnvConditions: NA
7206  * CaseDescription: test serviceProxy_ null with muteCamera anomalous branch
7207  */
7208 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_060, TestSize.Level0)
7209 {
7210     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
7211     ASSERT_NE(camManagerObj, nullptr);
7212 
7213     // CameraManager instance has been changed, need recover
7214     camManagerObj->SetServiceProxy(nullptr);
7215 
7216     bool cameraMuted = camManagerObj->IsCameraMuted();
7217     EXPECT_EQ(cameraMuted, false);
7218 
7219     camManagerObj->ClearCameraDeviceListCache();
7220     bool cameraMuteSupported = camManagerObj->IsCameraMuteSupported();
7221     EXPECT_EQ(cameraMuteSupported, true);
7222 
7223     camManagerObj->MuteCamera(cameraMuted);
7224     // CameraManager recovered
7225     camManagerObj->InitCameraManager();
7226 }
7227 
7228 /*
7229  * Feature: Framework
7230  * Function: Test anomalous branch
7231  * SubFunction: NA
7232  * FunctionPoints: NA
7233  * EnvConditions: NA
7234  * CaseDescription: test create camera input and construct device object with anomalous branch
7235  */
7236 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_061, TestSize.Level0)
7237 {
7238     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
7239     ASSERT_NE(camManagerObj, nullptr);
7240 
7241     // CameraManager instance has been changed, need recover
7242     camManagerObj->SetServiceProxy(nullptr);
7243 
7244     std::string cameraId = "";
7245     dmDeviceInfo deviceInfo = {};
7246     sptr<CameraDevice> camdeviceObj_1 = new (std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
7247     ASSERT_NE(camdeviceObj_1, nullptr);
7248 
7249     cameraId = cameras_[0]->GetID();
7250     sptr<CameraDevice> camdeviceObj_2 = new (std::nothrow) CameraDevice(cameraId, g_metaResult, deviceInfo);
7251     ASSERT_NE(camdeviceObj_2, nullptr);
7252 
7253     sptr<CameraDevice> camdeviceObj_3 = nullptr;
7254     sptr<CaptureInput> camInput = camManagerObj->CreateCameraInput(camdeviceObj_3);
7255     EXPECT_EQ(camInput, nullptr);
7256 
7257     camInput = camManagerObj->CreateCameraInput(camdeviceObj_1);
7258     EXPECT_EQ(camInput, nullptr);
7259 
7260     sptr<CameraInfo> camera = nullptr;
7261     camInput = camManagerObj->CreateCameraInput(camera);
7262     EXPECT_EQ(camInput, nullptr);
7263 
7264     CameraPosition cameraPosition = cameras_[0]->GetPosition();
7265     CameraType cameraType = cameras_[0]->GetCameraType();
7266     camInput = camManagerObj->CreateCameraInput(cameraPosition, cameraType);
7267     EXPECT_EQ(camInput, nullptr);
7268 
7269     sptr<CameraInput> input_2 = (sptr<CameraInput>&)input_;
7270     sptr<ICameraDeviceService> deviceObj_2 = input_2->GetCameraDevice();
7271     ASSERT_NE(deviceObj_2, nullptr);
7272 
7273     input_2 = new (std::nothrow) CameraInput(deviceObj_2, camdeviceObj_3);
7274     ASSERT_NE(input_2, nullptr);
7275     // CameraManager recovered
7276     camManagerObj->InitCameraManager();
7277 }
7278 
7279 /*
7280  * Feature: Framework
7281  * Function: Test anomalous branch
7282  * SubFunction: NA
7283  * FunctionPoints: NA
7284  * EnvConditions: NA
7285  * CaseDescription: Test abnormal branches with get device from empty id
7286  */
7287 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_062, TestSize.Level0)
7288 {
7289     std::string cameraId = "";
7290 
7291     sptr<CameraDevice> camDevice = manager_->GetCameraDeviceFromId(cameraId);
7292     EXPECT_EQ(camDevice, nullptr);
7293 }
7294 
7295 /*
7296  * Feature: Framework
7297  * Function: Test anomalous branch
7298  * SubFunction: NA
7299  * FunctionPoints: NA
7300  * EnvConditions: NA
7301  * CaseDescription: Test IsSessionCommited with CaptureSession null
7302  */
7303 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_063, TestSize.Level0)
7304 {
7305     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
7306     ASSERT_NE(camSession, nullptr);
7307 
7308     std::shared_ptr<CameraManagerCallback> camMnagerCallback = std::make_shared<AppCallback>();
7309     camMnagerCallback = nullptr;
7310     manager_->SetCallback(camMnagerCallback);
7311 
7312     int32_t intResult = camSession->Release();
7313     EXPECT_EQ(intResult, 0);
7314 
7315     bool isSessionCommited = camSession->IsSessionCommited();
7316     EXPECT_EQ(isSessionCommited, false);
7317 }
7318 
7319 /*
7320  * Feature: Framework
7321  * Function: Test anomalous branch.
7322  * SubFunction: NA
7323  * FunctionPoints: NA
7324  * EnvConditions: NA
7325  * CaseDescription: Test metadataOutput with anomalous branch.
7326  */
7327 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_064, TestSize.Level0)
7328 {
7329     EXPECT_EQ(session_->BeginConfig(), 0);
7330     EXPECT_EQ(session_->AddInput(input_), 0);
7331 
7332     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7333     ASSERT_NE(previewOutput, nullptr);
7334 
7335     EXPECT_EQ(session_->AddOutput(previewOutput), 0);
7336 
7337     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
7338     ASSERT_NE(metadatOutput, nullptr);
7339 
7340     EXPECT_EQ(session_->AddOutput(metadatOutput), 0);
7341 
7342     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
7343 
7344     EXPECT_EQ(session_->CommitConfig(), 0);
7345     EXPECT_EQ(session_->Start(), 0);
7346 
7347     sleep(WAIT_TIME_AFTER_START);
7348 
7349     session_->innerInputDevice_ = nullptr;
7350     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
7351     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
7352 
7353     session_->Release();
7354 
7355     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
7356 
7357     metaOutput->Release();
7358     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
7359 }
7360 
7361 /*
7362  * Feature: Framework
7363  * Function: Test anomalous branch.
7364  * SubFunction: NA
7365  * FunctionPoints: NA
7366  * EnvConditions: NA
7367  * CaseDescription: Test PhotoOutput with anomalous branch.
7368  */
7369 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_065, TestSize.Level0)
7370 {
7371     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
7372     EXPECT_EQ(session_->BeginConfig(), 0);
7373     EXPECT_EQ(session_->AddInput(input_), 0);
7374 
7375     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7376     ASSERT_NE(previewOutput, nullptr);
7377 
7378     EXPECT_EQ(session_->AddOutput(previewOutput), 0);
7379 
7380     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
7381     ASSERT_NE(photoOutput, nullptr);
7382 
7383     EXPECT_EQ(session_->AddOutput(photoOutput), 0);
7384 
7385     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
7386 
7387     EXPECT_EQ(session_->CommitConfig(), 0);
7388     EXPECT_EQ(session_->Start(), 0);
7389 
7390     sleep(WAIT_TIME_AFTER_START);
7391 
7392     EXPECT_EQ(((sptr<PhotoOutput>&)photoOutput)->Capture(), 0);
7393     sleep(WAIT_TIME_AFTER_CAPTURE);
7394 
7395     session_->innerInputDevice_ = nullptr;
7396     EXPECT_EQ(photoOutput_1->IsQuickThumbnailSupported(), 7400104);
7397     EXPECT_EQ(photoOutput_1->IsMirrorSupported(), false);
7398     EXPECT_EQ(photoOutput_1->SetThumbnail(false), 7400104);
7399 
7400     photoOutput_1->Release();
7401     EXPECT_EQ(photoOutput_1->Capture(photoSetting), 7400104);
7402 }
7403 
7404 /*
7405  * Feature: Framework
7406  * Function: Test anomalous branch.
7407  * SubFunction: NA
7408  * FunctionPoints: NA
7409  * EnvConditions: NA
7410  * CaseDescription: Test metadataOutput Getstream branch with CaptureOutput nullptr.
7411  */
7412 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_066, TestSize.Level0)
7413 {
7414     EXPECT_EQ(session_->BeginConfig(), 0);
7415     EXPECT_EQ(session_->AddInput(input_), 0);
7416 
7417     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7418     ASSERT_NE(previewOutput, nullptr);
7419 
7420     EXPECT_EQ(session_->AddOutput(previewOutput), 0);
7421 
7422     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
7423     ASSERT_NE(metadatOutput, nullptr);
7424 
7425     EXPECT_EQ(session_->AddOutput(metadatOutput), 0);
7426 
7427     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
7428 
7429     EXPECT_EQ(session_->CommitConfig(), 0);
7430     EXPECT_EQ(session_->Start(), 0);
7431 
7432     sleep(WAIT_TIME_AFTER_START);
7433 
7434     metadatOutput->Release();
7435     metaOutput->SetSession(session_);
7436 }
7437 
7438 /*
7439  * Feature: Framework
7440  * Function: Test anomalous branch.
7441  * SubFunction: NA
7442  * FunctionPoints: NA
7443  * EnvConditions: NA
7444  * CaseDescription: Test PreviewOutput/PhotoOutput/VideoOutput Getstream branch with CaptureOutput nullptr.
7445  */
7446 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_067, TestSize.Level0)
7447 {
7448     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
7449     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
7450     std::shared_ptr<AppVideoCallback> callback_2 = std::make_shared<AppVideoCallback>();
7451 
7452     EXPECT_EQ(session_->BeginConfig(), 0);
7453     EXPECT_EQ(session_->AddInput(input_), 0);
7454 
7455     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7456     ASSERT_NE(previewOutput, nullptr);
7457 
7458     EXPECT_EQ(session_->AddOutput(previewOutput), 0);
7459 
7460     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
7461     ASSERT_NE(photoOutput, nullptr);
7462 
7463     EXPECT_EQ(session_->AddOutput(photoOutput), 0);
7464 
7465     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
7466     ASSERT_NE(videoOutput, nullptr);
7467 
7468     EXPECT_EQ(session_->AddOutput(videoOutput), 0);
7469 
7470     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput>&)videoOutput;
7471     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
7472     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
7473 
7474     EXPECT_EQ(session_->CommitConfig(), 0);
7475     EXPECT_EQ(session_->Start(), 0);
7476 
7477     photoOutput->Release();
7478     photoOutput_1->SetSession(session_);
7479     EXPECT_EQ(photoOutput_1->Capture(photoSetting), 7400201);
7480     EXPECT_EQ(photoOutput_1->Capture(), 7400201);
7481     EXPECT_EQ(photoOutput_1->CancelCapture(), 7400201);
7482 
7483     previewOutput->Release();
7484     previewOutput_1->SetSession(session_);
7485     EXPECT_EQ(previewOutput_1->Start(), 7400201);
7486     EXPECT_EQ(previewOutput_1->Stop(), 7400201);
7487     previewOutput_1->SetCallback(callback);
7488 
7489     videoOutput->Release();
7490     videoOutput_1->SetSession(session_);
7491     EXPECT_EQ(videoOutput_1->Start(), 7400201);
7492     EXPECT_EQ(videoOutput_1->Stop(), 7400201);
7493     EXPECT_EQ(videoOutput_1->Resume(), 7400201);
7494     EXPECT_EQ(videoOutput_1->Pause(), 7400201);
7495     videoOutput_1->SetCallback(callback_2);
7496 }
7497 
7498 /*
7499  * Feature: Framework
7500  * Function: Test anomalous branch.
7501  * SubFunction: NA
7502  * FunctionPoints: NA
7503  * EnvConditions: NA
7504  * CaseDescription: Test IsSessionCommited branch with capturesession object null.
7505  */
7506 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_068, TestSize.Level0)
7507 {
7508     session_->~CaptureSession();
7509     EXPECT_EQ(session_->Start(), 7400103);
7510 
7511     VideoStabilizationMode mode;
7512     EXPECT_EQ(session_->GetActiveVideoStabilizationMode(mode), 7400103);
7513     EXPECT_EQ(session_->SetVideoStabilizationMode(OFF), 7400103);
7514 
7515     bool isSupported;
7516     EXPECT_EQ(session_->IsVideoStabilizationModeSupported(OFF, isSupported), 7400103);
7517     EXPECT_EQ((session_->GetSupportedStabilizationMode()).empty(), true);
7518 
7519     std::vector<VideoStabilizationMode> stabilizationModes = {};
7520     EXPECT_EQ(session_->GetSupportedStabilizationMode(stabilizationModes), 7400103);
7521     EXPECT_EQ(session_->IsExposureModeSupported(EXPOSURE_MODE_AUTO, isSupported), 7400103);
7522     EXPECT_EQ((session_->GetSupportedExposureModes()).empty(), true);
7523 
7524     std::vector<ExposureMode> supportedExposureModes = {};
7525     EXPECT_EQ(session_->GetSupportedExposureModes(supportedExposureModes), 7400103);
7526     EXPECT_EQ(session_->SetExposureMode(EXPOSURE_MODE_AUTO), 7400103);
7527     EXPECT_EQ(session_->GetExposureMode(), EXPOSURE_MODE_UNSUPPORTED);
7528 
7529     ExposureMode exposureMode;
7530     EXPECT_EQ(session_->GetExposureMode(exposureMode), 7400103);
7531 
7532     Point exposurePointGet = session_->GetMeteringPoint();
7533     EXPECT_EQ(session_->SetMeteringPoint(exposurePointGet), 7400103);
7534 
7535     EXPECT_EQ((session_->GetMeteringPoint()).x, 0);
7536     EXPECT_EQ((session_->GetMeteringPoint()).y, 0);
7537 
7538     EXPECT_EQ(session_->GetMeteringPoint(exposurePointGet), 7400103);
7539     EXPECT_EQ((session_->GetExposureBiasRange()).empty(), true);
7540 
7541     std::vector<float> exposureBiasRange = {};
7542     EXPECT_EQ(session_->GetExposureBiasRange(exposureBiasRange), 7400103);
7543     EXPECT_EQ(session_->SetExposureBias(0), 7400103);
7544 }
7545 
7546 /*
7547  * Feature: Framework
7548  * Function: Test anomalous branch.
7549  * SubFunction: NA
7550  * FunctionPoints: NA
7551  * EnvConditions: NA
7552  * CaseDescription: Test IsSessionCommited branch with capturesession object null.
7553  */
7554 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_069, TestSize.Level0)
7555 {
7556     float exposureValue;
7557     EXPECT_EQ(session_->GetExposureValue(), 0);
7558     EXPECT_EQ(session_->GetExposureValue(exposureValue), 7400103);
7559     EXPECT_EQ((session_->GetSupportedFocusModes()).empty(), true);
7560 
7561     std::vector<FocusMode> supportedFocusModes;
7562     EXPECT_EQ(session_->GetSupportedFocusModes(supportedFocusModes), 7400103);
7563 
7564     bool isSupported;
7565     EXPECT_EQ(session_->IsFocusModeSupported(FOCUS_MODE_AUTO, isSupported), 7400103);
7566     EXPECT_EQ(session_->SetFocusMode(FOCUS_MODE_AUTO), 7400103);
7567     EXPECT_EQ(session_->GetFocusMode(), FOCUS_MODE_MANUAL);
7568 
7569     FocusMode focusMode;
7570     EXPECT_EQ(session_->GetFocusMode(focusMode), 7400103);
7571 
7572     Point exposurePointGet = session_->GetMeteringPoint();
7573     EXPECT_EQ(session_->SetFocusPoint(exposurePointGet), 7400103);
7574 
7575     EXPECT_EQ((session_->GetFocusPoint()).x, 0);
7576     EXPECT_EQ((session_->GetFocusPoint()).y, 0);
7577 
7578     Point focusPoint;
7579     EXPECT_EQ(session_->GetFocusPoint(focusPoint), 7400103);
7580     EXPECT_EQ(session_->GetFocalLength(), 0);
7581 
7582     float focalLength;
7583     EXPECT_EQ(session_->GetFocalLength(focalLength), 7400103);
7584     EXPECT_EQ((session_->GetSupportedFlashModes()).empty(), true);
7585 
7586     std::vector<FlashMode> supportedFlashModes;
7587     EXPECT_EQ(session_->GetSupportedFlashModes(supportedFlashModes), 7400103);
7588     EXPECT_EQ(session_->GetFlashMode(), FLASH_MODE_CLOSE);
7589 
7590     FlashMode flashMode;
7591     EXPECT_EQ(session_->GetFlashMode(flashMode), 7400103);
7592     EXPECT_EQ(session_->SetFlashMode(FLASH_MODE_CLOSE), 7400103);
7593     EXPECT_EQ(session_->IsFlashModeSupported(FLASH_MODE_CLOSE, isSupported), 7400103);
7594     EXPECT_EQ(session_->HasFlash(isSupported), 7400103);
7595     EXPECT_EQ((session_->GetZoomRatioRange()).empty(), true);
7596 
7597     std::vector<float> exposureBiasRange = {};
7598     EXPECT_EQ(session_->GetZoomRatioRange(exposureBiasRange), 7400103);
7599     EXPECT_EQ(session_->GetZoomRatio(), 0);
7600 
7601     float zoomRatio;
7602     EXPECT_EQ(session_->GetZoomRatio(zoomRatio), 7400103);
7603     EXPECT_EQ(session_->SetZoomRatio(0), 7400103);
7604 }
7605 
7606 /*
7607  * Feature: Framework
7608  * Function: Test anomalous branch.
7609  * SubFunction: NA
7610  * FunctionPoints: NA
7611  * EnvConditions: NA
7612  * CaseDescription: Test IsSessionConfiged branch with innerCaptureSession object null.
7613  */
7614 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_070, TestSize.Level0)
7615 {
7616     session_->innerCaptureSession_ = nullptr;
7617 
7618     EXPECT_EQ(session_->CommitConfig(), 7400102);
7619 
7620     sptr<CaptureInput> input;
7621     EXPECT_EQ(session_->AddInput(input), 7400102);
7622 
7623     sptr<CaptureOutput> output;
7624     EXPECT_EQ(session_->RemoveInput(input), 7400102);
7625     EXPECT_EQ(session_->RemoveOutput(output), 7400102);
7626 }
7627 
7628 /*
7629  * Feature: Framework
7630  * Function: Test HStreamRepeat
7631  * SubFunction: NA
7632  * FunctionPoints: NA
7633  * EnvConditions: NA
7634  * CaseDescription: test HStreamRepeat with producer is null
7635  */
7636 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_071, TestSize.Level0)
7637 {
7638     sptr<IRemoteObject> object = nullptr;
7639     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
7640     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
7641 
7642     sptr<IStreamRepeatCallback> repeatCallback = iface_cast<IStreamRepeatCallback>(object);
7643     ASSERT_NE(repeatCallback, nullptr);
7644 
7645     int32_t format = 0;
7646     int32_t width = 0;
7647     int32_t height = 0;
7648     sptr<HStreamRepeat> streamRepeat =
7649         new (std::nothrow) HStreamRepeat(nullptr, format, width, height, RepeatStreamType::PREVIEW);
7650     ASSERT_NE(streamRepeat, nullptr);
7651     EXPECT_EQ(streamRepeat->SetCallback(repeatCallback), CAMERA_OK);
7652     EXPECT_EQ(streamRepeat->OnFrameError(BUFFER_LOST), CAMERA_OK);
7653     EXPECT_EQ(streamRepeat->OnFrameError(0), CAMERA_OK);
7654 }
7655 
7656 /*
7657  * Feature: Framework
7658  * Function: Test HStreamCapture
7659  * SubFunction: NA
7660  * FunctionPoints: NA
7661  * EnvConditions: NA
7662  * CaseDescription: test HStreamCapture with abnormal branches
7663  */
7664 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_072, TestSize.Level0)
7665 {
7666     sptr<IRemoteObject> object = nullptr;
7667     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
7668     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
7669 
7670     sptr<IStreamCaptureCallback> captureCallback = iface_cast<IStreamCaptureCallback>(object);
7671     ASSERT_NE(captureCallback, nullptr);
7672 
7673     int32_t format = 0;
7674     int32_t width = 0;
7675     int32_t height = 0;
7676     int32_t captureId = 0;
7677     int32_t frameCount = 0;
7678     uint64_t timestamp = 0;
7679     sptr<IConsumerSurface> Surface = IConsumerSurface::Create();
7680     sptr<IBufferProducer> producer = Surface->GetProducer();
7681     sptr<HStreamCapture> streamCapture = new (std::nothrow) HStreamCapture(producer, format, width, height);
7682     ASSERT_NE(streamCapture, nullptr);
7683     EXPECT_EQ(streamCapture->SetCallback(captureCallback), CAMERA_OK);
7684     EXPECT_EQ(streamCapture->OnCaptureEnded(captureId, frameCount), CAMERA_OK);
7685     EXPECT_EQ(streamCapture->OnCaptureError(captureId, frameCount), CAMERA_OK);
7686     EXPECT_EQ(streamCapture->OnCaptureError(captureId, BUFFER_LOST), CAMERA_OK);
7687     EXPECT_EQ(streamCapture->OnFrameShutter(captureId, timestamp), CAMERA_OK);
7688     EXPECT_EQ(streamCapture->OnFrameShutterEnd(captureId, timestamp), CAMERA_OK);
7689     EXPECT_EQ(streamCapture->OnCaptureReady(captureId, timestamp), CAMERA_OK);
7690 }
7691 
7692 
7693 /*
7694  * Feature: Framework
7695  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7696  * SubFunction: NA
7697  * FunctionPoints: NA
7698  * EnvConditions: NA
7699  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in CaptureSession
7700  */
7701 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_078, TestSize.Level0)
7702 {
7703     EXPECT_EQ((session_->GetSupportedColorEffects()).empty(), true);
7704     int32_t intResult = session_->BeginConfig();
7705     EXPECT_EQ(intResult, 0);
7706     intResult = session_->AddInput(input_);
7707     EXPECT_EQ(intResult, 0);
7708     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7709     ASSERT_NE(previewOutput, nullptr);
7710     intResult = session_->AddOutput(previewOutput);
7711     EXPECT_EQ(intResult, 0);
7712     EXPECT_EQ(session_->GetFilter(), FilterType::NONE);
7713     EXPECT_EQ(session_->GetSupportedFilters().empty(), true);
7714     EXPECT_EQ(session_->GetSupportedBeautyTypes().empty(), true);
7715     session_->SetBeauty(AUTO_TYPE, 0);
7716     EXPECT_EQ(session_->GetBeauty(AUTO_TYPE), -1);
7717     session_->SetFilter(NONE);
7718     std::vector<ColorSpace> supportedColorSpaces = session_->GetSupportedColorSpaces();
7719     auto it = std::find(supportedColorSpaces.begin(), supportedColorSpaces.end(), COLOR_SPACE_UNKNOWN);
7720     bool isSupportSet = (it != supportedColorSpaces.end());
7721     EXPECT_EQ(session_->SetColorSpace(COLOR_SPACE_UNKNOWN), isSupportSet ? CAMERA_OK : INVALID_ARGUMENT);
7722     EXPECT_EQ(session_->VerifyAbility(0), CAMERA_INVALID_ARG);
7723 
7724     intResult = session_->CommitConfig();
7725     EXPECT_EQ(intResult, 0);
7726     session_->SetBeauty(AUTO_TYPE, 0);
7727     EXPECT_EQ(session_->GetBeauty(AUTO_TYPE), -1);
7728     session_->SetFilter(NONE);
7729     EXPECT_EQ(session_->SetColorSpace(COLOR_SPACE_UNKNOWN), isSupportSet ? CAMERA_OK : INVALID_ARGUMENT);
7730     EXPECT_EQ((session_->GetSupportedColorEffects()).empty(), false);
7731     intResult = session_->Release();
7732     EXPECT_EQ(intResult, 0);
7733 }
7734 
7735 /*
7736  * Feature: Framework
7737  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7738  * SubFunction: NA
7739  * FunctionPoints: NA
7740  * EnvConditions: NA
7741  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in CaptureSession
7742  */
7743 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_079, TestSize.Level0)
7744 {
7745     int32_t intResult = session_->BeginConfig();
7746     EXPECT_EQ(intResult, 0);
7747 
7748     intResult = session_->AddInput(input_);
7749     EXPECT_EQ(intResult, 0);
7750 
7751     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7752     ASSERT_NE(previewOutput, nullptr);
7753 
7754     intResult = session_->AddOutput(previewOutput);
7755     EXPECT_EQ(intResult, 0);
7756 
7757     intResult = session_->CommitConfig();
7758     EXPECT_EQ(intResult, 0);
7759 
7760     session_->innerInputDevice_ = nullptr;
7761 
7762     EXPECT_EQ(session_->GetSupportedFilters().empty(), true);
7763     EXPECT_EQ(session_->GetFilter(), FilterType::NONE);
7764     EXPECT_EQ(session_->GetSupportedBeautyTypes().empty(), true);
7765 
7766     BeautyType beautyType = AUTO_TYPE;
7767     EXPECT_EQ(session_->GetSupportedBeautyRange(beautyType).empty(), true);
7768     EXPECT_EQ(session_->GetBeauty(beautyType), -1);
7769     EXPECT_EQ(session_->GetColorEffect(), ColorEffect::COLOR_EFFECT_NORMAL);
7770     EXPECT_EQ(session_->GetSupportedColorEffects().empty(), true);
7771 
7772     intResult = session_->Release();
7773     EXPECT_EQ(intResult, 0);
7774 }
7775 
7776 /*
7777  * Feature: Framework
7778  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7779  * SubFunction: NA
7780  * FunctionPoints: NA
7781  * EnvConditions: NA
7782  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in CaptureSession
7783  */
7784 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_080, TestSize.Level0)
7785 {
7786     EXPECT_EQ(session_->GetSupportedFilters().empty(), true);
7787     EXPECT_EQ(session_->GetFilter(), FilterType::NONE);
7788     EXPECT_EQ(session_->GetSupportedBeautyTypes().empty(), true);
7789     int32_t intResult = session_->BeginConfig();
7790     EXPECT_EQ(intResult, 0);
7791     intResult = session_->AddInput(input_);
7792     EXPECT_EQ(intResult, 0);
7793     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7794     ASSERT_NE(previewOutput, nullptr);
7795     intResult = session_->AddOutput(previewOutput);
7796     EXPECT_EQ(intResult, 0);
7797     EXPECT_EQ(session_->GetSupportedFilters().empty(), true);
7798     EXPECT_EQ(session_->GetFilter(), FilterType::NONE);
7799     EXPECT_EQ(session_->GetSupportedBeautyTypes().empty(), true);
7800     intResult = session_->CommitConfig();
7801     EXPECT_EQ(intResult, 0);
7802     session_->innerInputDevice_ = nullptr;
7803     EXPECT_EQ(session_->GetSupportedFilters().empty(), true);
7804     EXPECT_EQ(session_->GetFilter(), FilterType::NONE);
7805     EXPECT_EQ(session_->GetSupportedBeautyTypes().empty(), true);
7806     EXPECT_EQ(session_->Release(), 0);
7807 }
7808 
7809 /*
7810  * Feature: Framework
7811  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7812  * SubFunction: NA
7813  * FunctionPoints: NA
7814  * EnvConditions: NA
7815  * CaseDescription: test Commited() || Configed() with abnormal branches in CaptureSession in CaptureSession
7816  */
7817 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_081, TestSize.Level0)
7818 {
7819     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
7820     ASSERT_NE(camSession, nullptr);
7821     ColorSpace colorSpace = COLOR_SPACE_UNKNOWN;
7822     camSession->~CaptureSession();
7823     EXPECT_EQ(camSession->GetSupportedFilters().empty(), true);
7824     EXPECT_EQ(camSession->GetFilter(), FilterType::NONE);
7825     EXPECT_EQ(camSession->GetSupportedBeautyTypes().empty(), true);
7826     BeautyType beautyType = AUTO_TYPE;
7827     EXPECT_EQ(camSession->GetSupportedBeautyRange(beautyType).empty(), true);
7828     EXPECT_EQ(camSession->GetBeauty(AUTO_TYPE), CameraErrorCode::SESSION_NOT_CONFIG);
7829     EXPECT_EQ(camSession->GetColorEffect(), ColorEffect::COLOR_EFFECT_NORMAL);
7830     EXPECT_EQ(camSession->GetSupportedColorEffects().empty(), true);
7831     camSession->SetFilter(NONE);
7832     camSession->SetBeauty(beautyType, 0);
7833     EXPECT_EQ(camSession->GetSupportedColorSpaces().empty(), true);
7834     EXPECT_EQ(camSession->SetColorSpace(COLOR_SPACE_UNKNOWN), CameraErrorCode::SESSION_NOT_CONFIG);
7835     camSession->SetMode(SceneMode::NORMAL);
7836     EXPECT_EQ(camSession->VerifyAbility(0), CAMERA_INVALID_ARG);
7837     EXPECT_EQ(camSession->GetActiveColorSpace(colorSpace), CameraErrorCode::SESSION_NOT_CONFIG);
7838     camSession->SetColorEffect(COLOR_EFFECT_NORMAL);
7839 }
7840 
7841 /*
7842  * Feature: Framework
7843  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7844  * SubFunction: NA
7845  * FunctionPoints: NA
7846  * EnvConditions: NA
7847  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in CaptureSession
7848  */
7849 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_082, TestSize.Level0)
7850 {
7851     ColorSpace colorSpace = COLOR_SPACE_UNKNOWN;
7852     int32_t intResult = session_->BeginConfig();
7853     EXPECT_EQ(intResult, 0);
7854     intResult = session_->AddInput(input_);
7855     EXPECT_EQ(intResult, 0);
7856     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7857     ASSERT_NE(previewOutput, nullptr);
7858     intResult = session_->AddOutput(previewOutput);
7859     EXPECT_EQ(intResult, 0);
7860     session_->SetMode(SceneMode::PORTRAIT);
7861     EXPECT_EQ(session_->VerifyAbility(0), CAMERA_INVALID_ARG);
7862     EXPECT_EQ(session_->GetActiveColorSpace(colorSpace), CAMERA_OK);
7863     session_->SetColorEffect(COLOR_EFFECT_NORMAL);
7864     intResult = session_->CommitConfig();
7865     EXPECT_EQ(intResult, 0);
7866     if (session_->IsMacroSupported()) {
7867         session_->LockForControl();
7868         intResult = session_->EnableMacro(false);
7869         session_->UnlockForControl();
7870         EXPECT_EQ(intResult, 0);
7871     }
7872     EXPECT_EQ(session_->GetActiveColorSpace(colorSpace), CAMERA_OK);
7873     session_->SetColorEffect(COLOR_EFFECT_NORMAL);
7874     session_->innerInputDevice_ = nullptr;
7875     EXPECT_EQ(session_->VerifyAbility(0), CAMERA_INVALID_ARG);
7876     EXPECT_EQ(session_->Release(), 0);
7877 }
7878 
7879 /*
7880  * Feature: Framework
7881  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7882  * SubFunction: NA
7883  * FunctionPoints: NA
7884  * EnvConditions: NA
7885  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in NightSession
7886  */
7887 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_083, TestSize.Level0)
7888 {
7889     SceneMode nightMode = SceneMode::NIGHT;
7890     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(nightMode);
7891     auto nightSession = static_cast<NightSession*>(captureSession.GetRefPtr());
7892     ASSERT_NE(nightSession, nullptr);
7893     int32_t intResult = nightSession->BeginConfig();
7894     EXPECT_EQ(intResult, 0);
7895     intResult = nightSession->AddInput(input_);
7896     EXPECT_EQ(intResult, 0);
7897     std::vector<uint32_t> exposureRange;
7898     uint32_t exposureValue = 0;
7899     EXPECT_EQ(nightSession->GetExposureRange(exposureRange), SESSION_NOT_CONFIG);
7900     EXPECT_EQ(nightSession->SetExposure(0), SESSION_NOT_CONFIG);
7901     EXPECT_EQ(nightSession->GetExposure(exposureValue), SESSION_NOT_CONFIG);
7902 }
7903 
7904 /*
7905  * Feature: Framework
7906  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7907  * SubFunction: NA
7908  * FunctionPoints: NA
7909  * EnvConditions: NA
7910  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in NightSession
7911  */
7912 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_084, TestSize.Level0)
7913 {
7914     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
7915     ASSERT_NE(camSession, nullptr);
7916     SceneMode nightMode = SceneMode::NIGHT;
7917     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(nightMode);
7918     auto nightSession = static_cast<NightSession*>(captureSession.GetRefPtr());
7919     nightSession->~NightSession();
7920     uint32_t exposureValue = 0;
7921     std::vector<uint32_t> exposureRange;
7922     EXPECT_EQ(nightSession->GetExposureRange(exposureRange), SESSION_NOT_CONFIG);
7923     EXPECT_EQ(nightSession->GetExposure(exposureValue), SESSION_NOT_CONFIG);
7924     EXPECT_EQ(nightSession->SetExposure(0), SESSION_NOT_CONFIG);
7925 }
7926 
7927 /*
7928  * Feature: Framework
7929  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7930  * SubFunction: NA
7931  * FunctionPoints: NA
7932  * EnvConditions: NA
7933  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in PortraitSession
7934  */
7935 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_087, TestSize.Level0)
7936 {
7937     SceneMode portraitMode = SceneMode::PORTRAIT;
7938     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(portraitMode);
7939     auto portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
7940     ASSERT_NE(portraitSession, nullptr);
7941     EXPECT_EQ(portraitSession->GetSupportedPortraitEffects().empty(), true);
7942     EXPECT_EQ(portraitSession->GetPortraitEffect(), OFF_EFFECT);
7943     portraitSession->SetPortraitEffect(OFF_EFFECT);
7944     int32_t intResult = portraitSession->BeginConfig();
7945     EXPECT_EQ(intResult, 0);
7946     EXPECT_EQ(portraitSession->GetSupportedPortraitEffects().empty(), true);
7947     EXPECT_EQ(portraitSession->GetPortraitEffect(), OFF_EFFECT);
7948     portraitSession->SetPortraitEffect(OFF_EFFECT);
7949 }
7950 
7951 /*
7952  * Feature: Framework
7953  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
7954  * SubFunction: NA
7955  * FunctionPoints: NA
7956  * EnvConditions: NA
7957  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with PortraitSession is nullptr
7958  */
7959 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_088, TestSize.Level0)
7960 {
7961     SceneMode portraitMode = SceneMode::PORTRAIT;
7962     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(portraitMode);
7963     auto portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
7964     ASSERT_NE(portraitSession, nullptr);
7965     portraitSession->~PortraitSession();
7966     EXPECT_EQ(portraitSession->GetSupportedPortraitEffects().empty(), true);
7967     EXPECT_EQ(portraitSession->GetPortraitEffect(), OFF_EFFECT);
7968     portraitSession->SetPortraitEffect(OFF_EFFECT);
7969 }
7970 
7971 /*
7972  * Feature: Framework
7973  * Function: Test OnSketchStatusChanged
7974  * SubFunction: NA
7975  * FunctionPoints: NA
7976  * EnvConditions: NA
7977  * CaseDescription: test PreviewOutputCallbackImpl:OnSketchStatusChanged with abnormal branches
7978  */
7979 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_089, TestSize.Level0)
7980 {
7981     int32_t intResult = session_->BeginConfig();
7982     EXPECT_EQ(intResult, 0);
7983     intResult = session_->AddInput(input_);
7984     EXPECT_EQ(intResult, 0);
7985     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
7986     ASSERT_NE(previewOutput, nullptr);
7987     intResult = session_->AddOutput(previewOutput);
7988     EXPECT_EQ(intResult, 0);
7989     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
7990     ASSERT_NE(previewOutput_1, nullptr);
7991     auto previewOutputCallbackImpl = new (std::nothrow) PreviewOutputCallbackImpl(previewOutput_1.GetRefPtr());
7992     ASSERT_NE(previewOutputCallbackImpl, nullptr);
7993     EXPECT_EQ(previewOutputCallbackImpl->OnSketchStatusChanged(SketchStatus::STOPED), CAMERA_OK);
7994     auto previewOutputCallbackImpl1 = new (std::nothrow) PreviewOutputCallbackImpl();
7995     ASSERT_NE(previewOutputCallbackImpl1, nullptr);
7996     EXPECT_EQ(previewOutputCallbackImpl1->OnSketchStatusChanged(SketchStatus::STOPED), CAMERA_OK);
7997     intResult = session_->CommitConfig();
7998     EXPECT_EQ(intResult, 0);
7999     session_->innerInputDevice_ = nullptr;
8000     EXPECT_EQ(session_->Release(), 0);
8001 }
8002 
8003 /*
8004  * Feature: Framework
8005  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
8006  * SubFunction: NA
8007  * FunctionPoints: NA
8008  * EnvConditions: NA
8009  * CaseDescription: test !IsSessionCommited() && !IsSessionConfiged() with abnormal branches in CaptureSession
8010  */
8011 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_090, TestSize.Level0)
8012 {
8013     BeautyType beautyType = AUTO_TYPE;
8014     EXPECT_EQ(session_->GetSupportedBeautyRange(beautyType).empty(), true);
8015     EXPECT_EQ(session_->GetBeauty(beautyType), CameraErrorCode::SESSION_NOT_CONFIG);
8016     EXPECT_EQ(session_->GetColorEffect(), ColorEffect::COLOR_EFFECT_NORMAL);
8017     EXPECT_EQ(session_->GetSupportedColorEffects().empty(), true);
8018     EXPECT_EQ(session_->GetSupportedColorSpaces().empty(), true);
8019     session_->SetBeauty(beautyType, 0);
8020     session_->SetFilter(NONE);
8021     EXPECT_EQ(session_->SetColorSpace(COLOR_SPACE_UNKNOWN), SESSION_NOT_CONFIG);
8022     int32_t intResult = session_->BeginConfig();
8023     EXPECT_EQ(intResult, 0);
8024     intResult = session_->AddInput(input_);
8025     EXPECT_EQ(intResult, 0);
8026     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8027     ASSERT_NE(previewOutput, nullptr);
8028     intResult = session_->AddOutput(previewOutput);
8029     EXPECT_EQ(intResult, 0);
8030     EXPECT_EQ(session_->GetSupportedBeautyRange(beautyType).empty(), true);
8031     EXPECT_EQ(session_->GetBeauty(beautyType), -1);
8032     EXPECT_EQ(session_->GetColorEffect(), COLOR_EFFECT_NORMAL);
8033     session_->SetBeauty(beautyType, 0);
8034     session_->SetFilter(NONE);
8035     EXPECT_EQ(session_->SetColorSpace(COLOR_SPACE_UNKNOWN), 7400101);
8036     intResult = session_->CommitConfig();
8037     EXPECT_EQ(intResult, 0);
8038     session_->innerInputDevice_ = nullptr;
8039     EXPECT_EQ(session_->GetSupportedBeautyRange(beautyType).empty(), true);
8040     EXPECT_EQ(session_->GetBeauty(beautyType), -1);
8041     EXPECT_EQ(session_->GetColorEffect(), COLOR_EFFECT_NORMAL);
8042     EXPECT_EQ(session_->GetSupportedColorEffects().empty(), true);
8043     EXPECT_EQ(session_->GetSupportedColorSpaces().empty(), true);
8044     session_->SetBeauty(beautyType, 0);
8045     session_->SetFilter(NONE);
8046     EXPECT_EQ(session_->SetColorSpace(COLOR_SPACE_UNKNOWN), CAMERA_OK);
8047     EXPECT_EQ(session_->Release(), 0);
8048 }
8049 
8050 /*
8051  * Feature: Framework
8052  * Function: Test errorCode
8053  * SubFunction: NA
8054  * FunctionPoints: NA
8055  * EnvConditions: NA
8056  * CaseDescription: test errorCode with abnormal branches
8057  */
8058 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_091, TestSize.Level0)
8059 {
8060     sptr<IRemoteObject> object = nullptr;
8061     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8062     ASSERT_NE(samgr, nullptr);
8063     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8064     HCameraServiceProxy *hCameraServiceProxy = new (std::nothrow) HCameraServiceProxy(object);
8065     ASSERT_NE(hCameraServiceProxy, nullptr);
8066     EffectParam effectParam = {0, 0, 0};
8067 
8068     sptr<ICameraDeviceService> device = nullptr;
8069     sptr<ITorchServiceCallback> torchSvcCallback = nullptr;
8070     bool canOpenCamera = true;
8071     EXPECT_EQ(hCameraServiceProxy->CreateCameraDevice(cameras_[0]->GetID(), device), -1);
8072     hCameraServiceProxy->SetTorchCallback(torchSvcCallback);
8073     torchSvcCallback = new(std::nothrow) TorchServiceCallback(nullptr);
8074     ASSERT_NE(torchSvcCallback, nullptr);
8075     hCameraServiceProxy->SetTorchCallback(torchSvcCallback);
8076     hCameraServiceProxy->MuteCamera(true);
8077     hCameraServiceProxy->MuteCamera(false);
8078     hCameraServiceProxy->PrelaunchCamera();
8079     hCameraServiceProxy->SetPrelaunchConfig(cameras_[0]->GetID(), NO_NEED_RESTORE_PARAM_OHOS, 0, effectParam);
8080     hCameraServiceProxy->SetTorchLevel(0);
8081     hCameraServiceProxy->AllowOpenByOHSide(cameras_[0]->GetID(), 0, canOpenCamera);
8082     hCameraServiceProxy->NotifyCameraState(cameras_[0]->GetID(), 0);
8083 }
8084 
8085 /*
8086  * Feature: Framework
8087  * Function: Test errorCode
8088  * SubFunction: NA
8089  * FunctionPoints: NA
8090  * EnvConditions: NA
8091  * CaseDescription: test errorCode with abnormal branches
8092  */
8093 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_092, TestSize.Level0)
8094 {
8095     sptr<IRemoteObject> object = nullptr;
8096     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8097     ASSERT_NE(samgr, nullptr);
8098     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8099     HCameraServiceCallbackProxy *hCameraServiceCallbackProxy = new (std::nothrow) HCameraServiceCallbackProxy(object);
8100     ASSERT_NE(hCameraServiceCallbackProxy, nullptr);
8101     auto hCameraMuteServiceCallbackProxy = new (std::nothrow) HCameraMuteServiceCallbackProxy(object);
8102     ASSERT_NE(hCameraMuteServiceCallbackProxy, nullptr);
8103     HTorchServiceCallbackProxy *hTorchServiceCallbackProxy = new (std::nothrow) HTorchServiceCallbackProxy(object);
8104     ASSERT_NE(hTorchServiceCallbackProxy, nullptr);
8105 
8106     hCameraServiceCallbackProxy->OnFlashlightStatusChanged(cameras_[0]->GetID(), FLASH_STATUS_OFF);
8107     hCameraMuteServiceCallbackProxy->OnCameraMute(true);
8108     hCameraMuteServiceCallbackProxy->OnCameraMute(false);
8109     hTorchServiceCallbackProxy->OnTorchStatusChange(TORCH_STATUS_OFF);
8110 }
8111 
8112 /*
8113  * Feature: Framework
8114  * Function: Test errorCode, width and height, if sketchRatio > SKETCH_RATIO_MAX_VALUE
8115  * SubFunction: NA
8116  * FunctionPoints: NA
8117  * EnvConditions: NA
8118  * CaseDescription: test errorCode, width and height, if sketchRatio > SKETCH_RATIO_MAX_VALUE with abnormal branches
8119  */
8120 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_093, TestSize.Level0)
8121 {
8122     sptr<IRemoteObject> object = nullptr;
8123     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8124     ASSERT_NE(samgr, nullptr);
8125     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8126     sptr<IStreamRepeat> repeat = iface_cast<IStreamRepeat>(object);
8127     ASSERT_NE(repeat, nullptr);
8128     HStreamRepeatProxy *hStreamRepeatProxy = new (std::nothrow) HStreamRepeatProxy(object);
8129     ASSERT_NE(hStreamRepeatProxy, nullptr);
8130 
8131     hStreamRepeatProxy->ForkSketchStreamRepeat(0, 0, repeat, 0);
8132     hStreamRepeatProxy->ForkSketchStreamRepeat(1, 0, repeat, 0);
8133     hStreamRepeatProxy->ForkSketchStreamRepeat(1, 1, repeat, 0);
8134     hStreamRepeatProxy->UpdateSketchRatio(0.0f);
8135     hStreamRepeatProxy->UpdateSketchRatio(200.0f);
8136     hStreamRepeatProxy->UpdateSketchRatio(90.0f);
8137     hStreamRepeatProxy->RemoveSketchStreamRepeat();
8138 }
8139 
8140 /*
8141  * Feature: Framework
8142  * Function: Test errorCode, width and height, if sketchRatio > SKETCH_RATIO_MAX_VALUE
8143  * SubFunction: NA
8144  * FunctionPoints: NA
8145  * EnvConditions: NA
8146  * CaseDescription: test errorCode, width and height, if sketchRatio > SKETCH_RATIO_MAX_VALUE with abnormal branches
8147  */
8148 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_094, TestSize.Level0)
8149 {
8150     sptr<IRemoteObject> object = nullptr;
8151     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8152     ASSERT_NE(samgr, nullptr);
8153     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8154     sptr<IStreamRepeat> repeat = iface_cast<IStreamRepeat>(object);
8155     ASSERT_NE(repeat, nullptr);
8156     HStreamRepeatProxy *hStreamRepeatProxy = new (std::nothrow) HStreamRepeatProxy(object);
8157     ASSERT_NE(hStreamRepeatProxy, nullptr);
8158 
8159     hStreamRepeatProxy->UpdateSketchRatio(0.0f);
8160     hStreamRepeatProxy->UpdateSketchRatio(200.0f);
8161     hStreamRepeatProxy->UpdateSketchRatio(90.0f);
8162     hStreamRepeatProxy->RemoveSketchStreamRepeat();
8163 }
8164 
8165 /*
8166  * Feature: Framework
8167  * Function: Test errorCode
8168  * SubFunction: NA
8169  * FunctionPoints: NA
8170  * EnvConditions: NA
8171  * CaseDescription: test errorCode with abnormal branches
8172  */
8173 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_095, TestSize.Level0)
8174 {
8175     sptr<IRemoteObject> object = nullptr;
8176     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8177     ASSERT_NE(samgr, nullptr);
8178     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8179     HStreamCaptureCallbackProxy *hStreamCaptureCallbackProxy = new (std::nothrow) HStreamCaptureCallbackProxy(object);
8180     ASSERT_NE(hStreamCaptureCallbackProxy, nullptr);
8181 
8182     hStreamCaptureCallbackProxy->OnCaptureStarted(0);
8183     hStreamCaptureCallbackProxy->OnCaptureStarted(0, 0);
8184     hStreamCaptureCallbackProxy->OnCaptureEnded(0, 0);
8185     hStreamCaptureCallbackProxy->OnCaptureError(0, 0);
8186     hStreamCaptureCallbackProxy->OnFrameShutter(0, 0);
8187     hStreamCaptureCallbackProxy->OnFrameShutterEnd(0, 0);
8188     hStreamCaptureCallbackProxy->OnCaptureReady(0, 0);
8189 }
8190 
8191 /*
8192  * Feature: Framework
8193  * Function: Test errorCode
8194  * SubFunction: NA
8195  * FunctionPoints: NA
8196  * EnvConditions: NA
8197  * CaseDescription: test errorCode with abnormal branches
8198  */
8199 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_096, TestSize.Level0)
8200 {
8201     sptr<IRemoteObject> object = nullptr;
8202     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8203     ASSERT_NE(samgr, nullptr);
8204     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8205     HStreamRepeatCallbackProxy *hStreamRepeatCallbackProxy = new (std::nothrow) HStreamRepeatCallbackProxy(object);
8206     ASSERT_NE(hStreamRepeatCallbackProxy, nullptr);
8207 
8208     hStreamRepeatCallbackProxy->OnSketchStatusChanged(SketchStatus::STOPED);
8209     hStreamRepeatCallbackProxy->OnFrameStarted();
8210     hStreamRepeatCallbackProxy->OnFrameEnded(0);
8211     hStreamRepeatCallbackProxy->OnFrameError(0);
8212 }
8213 
8214 
8215 /*
8216  * Feature: Framework
8217  * Function: Test errorCode
8218  * SubFunction: NA
8219  * FunctionPoints: NA
8220  * EnvConditions: NA
8221  * CaseDescription: test errorCode with abnormal branches
8222  */
8223 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_097, TestSize.Level0)
8224 {
8225     sptr<IRemoteObject> object = nullptr;
8226     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8227     ASSERT_NE(samgr, nullptr);
8228     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8229     auto hCaptureSessionCallbackProxy = new (std::nothrow) HCaptureSessionCallbackProxy(object);
8230     ASSERT_NE(hCaptureSessionCallbackProxy, nullptr);
8231     hCaptureSessionCallbackProxy->OnError(0);
8232 }
8233 
8234 /*
8235  * Feature: Framework
8236  * Function: Test errorCode
8237  * SubFunction: NA
8238  * FunctionPoints: NA
8239  * EnvConditions: NA
8240  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches
8241  */
8242 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_098, TestSize.Level0)
8243 {
8244     auto photoOutput1 = CreatePhotoOutput();
8245     auto photoOutput = static_cast<PhotoOutput*>(photoOutput1.GetRefPtr());
8246     photoOutput->ConfirmCapture();
8247     photoOutput->SetSession(nullptr);
8248     photoOutput->ConfirmCapture();
8249     photoOutput->SetSession(session_);
8250 
8251     int32_t intResult = session_->BeginConfig();
8252     EXPECT_EQ(intResult, 0);
8253     intResult = session_->AddInput(input_);
8254     EXPECT_EQ(intResult, 0);
8255     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8256     ASSERT_NE(previewOutput, nullptr);
8257     intResult = session_->AddOutput(previewOutput);
8258     EXPECT_EQ(intResult, 0);
8259     intResult = session_->CommitConfig();
8260     EXPECT_EQ(intResult, 0);
8261     photoOutput->ConfirmCapture();
8262 }
8263 
8264 /*
8265  * Feature: Framework
8266  * Function: Test errorCode
8267  * SubFunction: NA
8268  * FunctionPoints: NA
8269  * EnvConditions: NA
8270  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches
8271  */
8272 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_099, TestSize.Level0)
8273 {
8274     auto photoOutput1 = CreatePhotoOutput();
8275     auto photoOutput = static_cast<PhotoOutput*>(photoOutput1.GetRefPtr());
8276     photoOutput->Release();
8277     photoOutput->ConfirmCapture();
8278 }
8279 
8280 /*
8281  * Feature: Framework
8282  * Function: Test errorCode
8283  * SubFunction: NA
8284  * FunctionPoints: NA
8285  * EnvConditions: NA
8286  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches
8287  */
8288 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_100, TestSize.Level0)
8289 {
8290     std::shared_ptr<HStreamCaptureCallbackImpl> captureCallback = std::make_shared<HStreamCaptureCallbackImpl>(nullptr);
8291     int32_t captureId = 2001;
8292     int32_t intResult = captureCallback->OnCaptureStarted(captureId, 0);
8293     EXPECT_EQ(intResult, 0);
8294 }
8295 
8296 /*
8297  * Feature: Framework
8298  * Function: Test anomalous branch.
8299  * SubFunction: NA
8300  * FunctionPoints: NA
8301  * EnvConditions: NA
8302  * CaseDescription: Test GetMetaSetting with existing metaTag.
8303  */
8304 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_101, TestSize.Level0)
8305 {
8306     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
8307 
8308     std::shared_ptr<camera_metadata_item_t> metadataItem = nullptr;
8309     metadataItem = camInput->GetMetaSetting(OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS);
8310     ASSERT_NE(metadataItem, nullptr);
8311 
8312     std::vector<vendorTag_t> infos = {};
8313     EXPECT_EQ((camInput->GetCameraAllVendorTags(infos)), 0);
8314 
8315     sptr<ICameraDeviceService> deviceObj = camInput->GetCameraDevice();
8316     ASSERT_NE(deviceObj, nullptr);
8317 
8318     sptr<CameraDevice> camdeviceObj = nullptr;
8319     sptr<CameraInput> camInput_1 = new (std::nothrow) CameraInput(deviceObj, camdeviceObj);
8320     ASSERT_NE(camInput_1, nullptr);
8321 
8322     metadataItem = camInput_1->GetMetaSetting(OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS);
8323     EXPECT_EQ(metadataItem, nullptr);
8324 
8325     metadataItem = camInput->GetMetaSetting(-1);
8326     EXPECT_EQ(metadataItem, nullptr);
8327 
8328     if (!IsSupportNow()) {
8329         return;
8330     }
8331 
8332     std::shared_ptr<OHOS::Camera::CameraMetadata> metadata = cameras_[1]->GetMetadata();
8333 
8334     std::string cameraId = cameras_[1]->GetID();
8335     sptr<CameraDevice> camdeviceObj_2 = new (std::nothrow) CameraDevice(cameraId, metadata);
8336     ASSERT_NE(camdeviceObj_2, nullptr);
8337 
8338     EXPECT_EQ(camdeviceObj_2->GetPosition(), CAMERA_POSITION_FRONT);
8339 }
8340 
8341 /*
8342  * Feature: Framework
8343  * Function: Test anomalous branch.
8344  * SubFunction: NA
8345  * FunctionPoints: NA
8346  * EnvConditions: NA
8347  * CaseDescription: Test Torch with anomalous branch.
8348  */
8349 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_102, TestSize.Level0)
8350 {
8351     EXPECT_EQ(input_->Close(), 0);
8352     sleep(WAIT_TIME_AFTER_CLOSE);
8353 
8354     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
8355 
8356     if (!(manager_->IsTorchSupported())) {
8357         return;
8358     }
8359 
8360     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
8361     camManagerObj->RegisterTorchListener(callback);
8362     EXPECT_EQ(camManagerObj->IsTorchModeSupported(TORCH_MODE_AUTO), false);
8363 
8364     int32_t intResult = camManagerObj->SetTorchMode(TORCH_MODE_AUTO);
8365     EXPECT_EQ(intResult, 7400102);
8366 
8367     EXPECT_EQ(camManagerObj->IsTorchModeSupported(TORCH_MODE_ON), true);
8368     intResult = camManagerObj->SetTorchMode(TORCH_MODE_ON);
8369     EXPECT_EQ(intResult, 0);
8370     sleep(WAIT_TIME_CALLBACK);
8371 
8372     EXPECT_EQ(camManagerObj->IsTorchModeSupported(TORCH_MODE_OFF), true);
8373 
8374     intResult = camManagerObj->SetTorchMode(TORCH_MODE_OFF);
8375     EXPECT_EQ(intResult, 0);
8376 
8377     sleep(WAIT_TIME_CALLBACK);
8378 
8379     // CameraManager instance has been changed, need recover
8380     camManagerObj->SetServiceProxy(nullptr);
8381     intResult = camManagerObj->SetTorchMode(TORCH_MODE_OFF);
8382     EXPECT_EQ(intResult, 7400201);
8383     // CameraManager recovered
8384     camManagerObj->InitCameraManager();
8385 }
8386 
8387 /*
8388  * Feature: Framework
8389  * Function: Test Metadata
8390  * SubFunction: NA
8391  * FunctionPoints: NA
8392  * EnvConditions: NA
8393  * CaseDescription: Test Metadata
8394  */
8395 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_103, TestSize.Level0)
8396 {
8397     int32_t intResult = session_->BeginConfig();
8398     EXPECT_EQ(intResult, 0);
8399 
8400     intResult = session_->AddInput(input_);
8401     EXPECT_EQ(intResult, 0);
8402 
8403     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8404     ASSERT_NE(previewOutput, nullptr);
8405 
8406     intResult = session_->AddOutput(previewOutput);
8407     EXPECT_EQ(intResult, 0);
8408 
8409     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
8410     ASSERT_NE(metadatOutput, nullptr);
8411 
8412     intResult = session_->AddOutput(metadatOutput);
8413     EXPECT_EQ(intResult, 0);
8414 
8415     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
8416     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
8417     if (metadataObjectTypes.size() == 0) {
8418         return;
8419     }
8420 
8421     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> { MetadataObjectType::FACE });
8422 
8423     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
8424     metaOutput->SetCallback(metadataObjectCallback);
8425     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
8426     metaOutput->SetCallback(metadataStateCallback);
8427 
8428     pid_t pid = 0;
8429     metaOutput->CameraServerDied(pid);
8430 }
8431 
8432 /*
8433  * Feature: Framework
8434  * Function: Test Metadata
8435  * SubFunction: NA
8436  * FunctionPoints: NA
8437  * EnvConditions: NA
8438  * CaseDescription: Test Metadata
8439  */
8440 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_104, TestSize.Level0)
8441 {
8442     int32_t intResult = session_->BeginConfig();
8443     EXPECT_EQ(intResult, 0);
8444 
8445     intResult = session_->AddInput(input_);
8446     EXPECT_EQ(intResult, 0);
8447 
8448     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8449     ASSERT_NE(previewOutput, nullptr);
8450 
8451     intResult = session_->AddOutput(previewOutput);
8452     EXPECT_EQ(intResult, 0);
8453 
8454     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
8455     ASSERT_NE(metadatOutput, nullptr);
8456 
8457     intResult = session_->AddOutput(metadatOutput);
8458     EXPECT_EQ(intResult, 0);
8459 
8460     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
8461     std::vector<MetadataObjectType> metadataObjectTypes = metaOutput->GetSupportedMetadataObjectTypes();
8462     if (metadataObjectTypes.size() == 0) {
8463         return;
8464     }
8465 
8466     metaOutput->SetCapturingMetadataObjectTypes(std::vector<MetadataObjectType> {});
8467 }
8468 
8469 /*
8470  * Feature: Framework
8471  * Function: Test errorCode
8472  * SubFunction: NA
8473  * FunctionPoints: NA
8474  * EnvConditions: NA
8475  * CaseDescription: test errorCode with abnormal branches
8476  */
8477 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_105, TestSize.Level0)
8478 {
8479     sptr<IRemoteObject> object = nullptr;
8480     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8481     ASSERT_NE(samgr, nullptr);
8482     object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
8483     HCameraServiceProxy *hCameraServiceProxy = new (std::nothrow) HCameraServiceProxy(object);
8484     ASSERT_NE(hCameraServiceProxy, nullptr);
8485     EffectParam effectParam = {0, 0, 0};
8486 
8487     sptr<ICameraDeviceService> device = nullptr;
8488     sptr<ITorchServiceCallback> torchSvcCallback = nullptr;
8489     hCameraServiceProxy->CreateCameraDevice(cameras_[0]->GetID(), device);
8490     hCameraServiceProxy->SetTorchCallback(torchSvcCallback);
8491     torchSvcCallback = new(std::nothrow) TorchServiceCallback(nullptr);
8492     ASSERT_NE(torchSvcCallback, nullptr);
8493     hCameraServiceProxy->SetTorchCallback(torchSvcCallback);
8494     hCameraServiceProxy->MuteCamera(true);
8495     hCameraServiceProxy->MuteCamera(false);
8496     hCameraServiceProxy->PrelaunchCamera();
8497     hCameraServiceProxy->SetPrelaunchConfig(cameras_[0]->GetID(), NO_NEED_RESTORE_PARAM_OHOS, 0, effectParam);
8498     hCameraServiceProxy->SetTorchLevel(0);
8499 }
8500 
8501 /*
8502  * Feature: Framework
8503  * Function: Test errorCode
8504  * SubFunction: NA
8505  * FunctionPoints: NA
8506  * EnvConditions: NA
8507  * CaseDescription: test errorCode with abnormal branches
8508  */
8509 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_106, TestSize.Level0)
8510 {
8511     sptr<IRemoteObject> object = nullptr;
8512     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8513     ASSERT_NE(samgr, nullptr);
8514     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8515     HCameraServiceCallbackProxy *hCameraServiceCallbackProxy = new (std::nothrow) HCameraServiceCallbackProxy(object);
8516     ASSERT_NE(hCameraServiceCallbackProxy, nullptr);
8517     HCameraMuteServiceCallbackProxy *hCameraMuteServiceCallbackProxy =
8518         new (std::nothrow) HCameraMuteServiceCallbackProxy(object);
8519     ASSERT_NE(hCameraMuteServiceCallbackProxy, nullptr);
8520     HTorchServiceCallbackProxy *hTorchServiceCallbackProxy = new (std::nothrow) HTorchServiceCallbackProxy(object);
8521     ASSERT_NE(hTorchServiceCallbackProxy, nullptr);
8522 
8523     hCameraServiceCallbackProxy->OnFlashlightStatusChanged(cameras_[0]->GetID(), FLASH_STATUS_OFF);
8524     hCameraMuteServiceCallbackProxy->OnCameraMute(true);
8525     hCameraMuteServiceCallbackProxy->OnCameraMute(false);
8526     hTorchServiceCallbackProxy->OnTorchStatusChange(TORCH_STATUS_OFF);
8527 }
8528 
8529 /*
8530  * Feature: Framework
8531  * Function: Test errorCode
8532  * SubFunction: NA
8533  * FunctionPoints: NA
8534  * EnvConditions: NA
8535  * CaseDescription: test errorCode with abnormal branches
8536  */
8537 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_107, TestSize.Level0)
8538 {
8539     sptr<IRemoteObject> object = nullptr;
8540     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8541     ASSERT_NE(samgr, nullptr);
8542     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8543     HStreamCaptureCallbackProxy *hStreamCaptureCallbackProxy = new (std::nothrow) HStreamCaptureCallbackProxy(object);
8544     ASSERT_NE(hStreamCaptureCallbackProxy, nullptr);
8545 
8546     hStreamCaptureCallbackProxy->OnCaptureStarted(0);
8547     hStreamCaptureCallbackProxy->OnCaptureStarted(0, 0);
8548     hStreamCaptureCallbackProxy->OnCaptureEnded(0, 0);
8549     hStreamCaptureCallbackProxy->OnCaptureError(0, 0);
8550     hStreamCaptureCallbackProxy->OnFrameShutter(0, 0);
8551     hStreamCaptureCallbackProxy->OnFrameShutterEnd(0, 0);
8552     hStreamCaptureCallbackProxy->OnCaptureReady(0, 0);
8553 }
8554 
8555 /*
8556  * Feature: Framework
8557  * Function: Test errorCode
8558  * SubFunction: NA
8559  * FunctionPoints: NA
8560  * EnvConditions: NA
8561  * CaseDescription: test errorCode with abnormal branches
8562  */
8563 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_108, TestSize.Level0)
8564 {
8565     sptr<IRemoteObject> object = nullptr;
8566     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8567     ASSERT_NE(samgr, nullptr);
8568     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8569     HStreamRepeatCallbackProxy *hStreamRepeatCallbackProxy = new (std::nothrow) HStreamRepeatCallbackProxy(object);
8570     ASSERT_NE(hStreamRepeatCallbackProxy, nullptr);
8571 
8572     hStreamRepeatCallbackProxy->OnSketchStatusChanged(SketchStatus::STOPED);
8573     hStreamRepeatCallbackProxy->OnFrameStarted();
8574     hStreamRepeatCallbackProxy->OnFrameEnded(0);
8575     hStreamRepeatCallbackProxy->OnFrameError(0);
8576 }
8577 
8578 /*
8579  * Feature: Framework
8580  * Function: Test errorCode
8581  * SubFunction: NA
8582  * FunctionPoints: NA
8583  * EnvConditions: NA
8584  * CaseDescription: test errorCode with abnormal branches
8585  */
8586 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_109, TestSize.Level0)
8587 {
8588     sptr<IRemoteObject> object = nullptr;
8589     auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
8590     ASSERT_NE(samgr, nullptr);
8591     object = samgr->GetSystemAbility(AUDIO_POLICY_SERVICE_ID);
8592     HCaptureSessionCallbackProxy *hCaptureSessionCallbackProxy =
8593         new (std::nothrow) HCaptureSessionCallbackProxy(object);
8594     ASSERT_NE(hCaptureSessionCallbackProxy, nullptr);
8595     hCaptureSessionCallbackProxy->OnError(0);
8596 }
8597 
8598 /* Feature: Framework
8599  * Function: Test CreateCaptureSession
8600  * SubFunction: NA
8601  * FunctionPoints: NA
8602  * EnvConditions: NA
8603  * CaseDescription: Test CreateCaptureSession
8604  */
8605 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_110, TestSize.Level0)
8606 {
8607     SceneMode mode = SceneMode::CAPTURE;
8608     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
8609     ASSERT_NE(modeManagerObj, nullptr);
8610 
8611     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(mode);
8612     ASSERT_NE(captureSession, nullptr);
8613 }
8614 
8615 /* Feature: Framework
8616  * Function: Test CreateCaptureSession
8617  * SubFunction: NA
8618  * FunctionPoints: NA
8619  * EnvConditions: NA
8620  * CaseDescription: Test CreateCaptureSession
8621  */
8622 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_111, TestSize.Level0)
8623 {
8624     SceneMode mode = SceneMode::SCAN;
8625     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
8626     ASSERT_NE(modeManagerObj, nullptr);
8627 
8628     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(mode);
8629     ASSERT_NE(captureSession, nullptr);
8630 }
8631 
8632 /* Feature: Framework
8633  * Function: Test CreateCaptureSession
8634  * SubFunction: NA
8635  * FunctionPoints: NA
8636  * EnvConditions: NA
8637  * CaseDescription: Test CreateCaptureSession
8638  */
8639 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_112, TestSize.Level0)
8640 {
8641     SceneMode mode = SceneMode::CAPTURE_MACRO;
8642     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
8643     ASSERT_NE(modeManagerObj, nullptr);
8644 
8645     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(mode);
8646     ASSERT_NE(captureSession, nullptr);
8647 }
8648 
8649 /* Feature: Framework
8650  * Function: Test CreateCaptureSession
8651  * SubFunction: NA
8652  * FunctionPoints: NA
8653  * EnvConditions: NA
8654  * CaseDescription: Test CreateCaptureSession
8655  */
8656 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_113, TestSize.Level0)
8657 {
8658     SceneMode mode = SceneMode::CAPTURE_MACRO;
8659     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
8660     ASSERT_NE(modeManagerObj, nullptr);
8661 
8662     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(mode);
8663     ASSERT_NE(captureSession, nullptr);
8664 }
8665 
8666 /* Feature: Framework
8667  * Function: Test CreateCaptureSession
8668  * SubFunction: NA
8669  * FunctionPoints: NA
8670  * EnvConditions: NA
8671  * CaseDescription: Test CreateCaptureSession
8672  */
8673 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_114, TestSize.Level0)
8674 {
8675     SceneMode mode = SceneMode::VIDEO;
8676     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
8677     ASSERT_NE(modeManagerObj, nullptr);
8678 
8679     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(mode);
8680     ASSERT_NE(captureSession, nullptr);
8681 }
8682 
8683 /*
8684 * Feature: Framework
8685 * Function: Test SetExposureBias && GetFeaturesMode && SetBeautyValue && GetSubFeatureMods
8686 * SubFunction: NA
8687 * FunctionPoints: NA
8688 * EnvConditions: NA
8689 * CaseDescription: test SetExposureBias && GetFeaturesMode && SetBeautyValue && GetSubFeatureMods
8690 */
8691 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_115, TestSize.Level0)
8692 {
8693     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
8694     ASSERT_NE(camSession, nullptr);
8695 
8696     int32_t intResult = camSession->BeginConfig();
8697     EXPECT_EQ(intResult, 0);
8698 
8699     intResult = camSession->AddInput(input_);
8700     EXPECT_EQ(intResult, 0);
8701 
8702     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8703     ASSERT_NE(previewOutput, nullptr);
8704 
8705     intResult = camSession->AddOutput(previewOutput);
8706     EXPECT_EQ(intResult, 0);
8707 
8708     intResult = camSession->CommitConfig();
8709     EXPECT_EQ(intResult, 0);
8710 
8711     camSession->LockForControl();
8712     EXPECT_EQ(camSession->SetExposureBias(100.0f), CameraErrorCode::SUCCESS);
8713     intResult = camSession->UnlockForControl();
8714 
8715     camSession->isSetMacroEnable_ = true;
8716     camSession->currentMode_ = SceneMode::VIDEO;
8717 
8718     SceneFeaturesMode videoMacroMode(SceneMode::VIDEO, { SceneFeature::FEATURE_MACRO });
8719     bool isMatchSubFeatureMode = false;
8720     auto vec = camSession->GetSubFeatureMods();
8721     for (auto& sceneFeaturesMode : vec) {
8722         if (sceneFeaturesMode == videoMacroMode) {
8723             isMatchSubFeatureMode = true;
8724             break;
8725         }
8726     }
8727     EXPECT_TRUE(isMatchSubFeatureMode);
8728 
8729     auto mode = camSession->GetFeaturesMode();
8730     EXPECT_TRUE(mode == videoMacroMode);
8731 
8732     camSession->currentMode_ = SceneMode::CAPTURE;
8733     mode = camSession->GetFeaturesMode();
8734     SceneFeaturesMode captureMacroMode(SceneMode::CAPTURE, { SceneFeature::FEATURE_MACRO });
8735     EXPECT_TRUE(mode == captureMacroMode);
8736 
8737     isMatchSubFeatureMode = false;
8738     vec = camSession->GetSubFeatureMods();
8739     for (auto& sceneFeaturesMode : vec) {
8740         if (sceneFeaturesMode == captureMacroMode) {
8741             isMatchSubFeatureMode = true;
8742             break;
8743         }
8744     }
8745     EXPECT_TRUE(isMatchSubFeatureMode);
8746 
8747     bool boolResult = camSession->SetBeautyValue(BeautyType::SKIN_TONE, 0);
8748     EXPECT_FALSE(boolResult);
8749 }
8750 
8751 /*
8752  * Feature: Framework
8753  * Function: Test anomalous branch.
8754  * SubFunction: NA
8755  * FunctionPoints: NA
8756  * EnvConditions: NA
8757  * CaseDescription: Test captureCallback with anomalous branch.
8758  */
8759 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_116, TestSize.Level0)
8760 {
8761     std::shared_ptr<HStreamCaptureCallbackImpl> captureCallback = std::make_shared<HStreamCaptureCallbackImpl>(nullptr);
8762 
8763     int32_t captureId = 2001;
8764     uint64_t timestamp = 10;
8765 
8766     int32_t intResult = captureCallback->OnFrameShutterEnd(captureId, timestamp);
8767     EXPECT_EQ(intResult, 0);
8768 
8769     intResult = captureCallback->OnCaptureReady(captureId, timestamp);
8770     EXPECT_EQ(intResult, 0);
8771 
8772     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
8773     ASSERT_NE(camSession, nullptr);
8774 
8775     intResult = camSession->BeginConfig();
8776     EXPECT_EQ(intResult, 0);
8777 
8778     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
8779     ASSERT_NE(input, nullptr);
8780 
8781     intResult = camSession->AddInput(input);
8782     EXPECT_EQ(intResult, 0);
8783 
8784     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8785     intResult = camSession->AddOutput(previewOutput);
8786     EXPECT_EQ(intResult, 0);
8787 
8788     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
8789     intResult = camSession->AddOutput(photoOutput);
8790     EXPECT_EQ(intResult, 0);
8791 
8792     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
8793 
8794     intResult = camSession->CommitConfig();
8795     EXPECT_EQ(intResult, 0);
8796 
8797     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
8798     photoOutput_1->SetCallback(callback);
8799 
8800     sptr<HStreamCaptureCallbackImpl> captureCallback_2 = new (std::nothrow) HStreamCaptureCallbackImpl(photoOutput_1);
8801     ASSERT_NE(captureCallback_2, nullptr);
8802 
8803     intResult = captureCallback_2->OnFrameShutterEnd(captureId, timestamp);
8804     EXPECT_EQ(intResult, 0);
8805 
8806     intResult = captureCallback_2->OnCaptureReady(captureId, timestamp);
8807     EXPECT_EQ(intResult, 0);
8808 }
8809 
8810 /*
8811  * Feature: Framework
8812  * Function: Test anomalous branch
8813  * SubFunction: NA
8814  * FunctionPoints: NA
8815  * EnvConditions: NA
8816  * CaseDescription: test prelaunch the camera with PERSISTENT_DEFAULT_PARAM_OHOS anomalous branch
8817  */
8818 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_117, TestSize.Level0)
8819 {
8820     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
8821     ASSERT_NE(camManagerObj, nullptr);
8822 
8823     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
8824     std::string cameraId = camInput->GetCameraId();
8825     int activeTime = 0;
8826     EffectParam effectParam = {0, 0, 0};
8827 
8828     int32_t intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::PERSISTENT_DEFAULT_PARAM_OHOS,
8829         activeTime, effectParam);
8830     if (!IsSupportNow()) {
8831         EXPECT_EQ(intResult, 7400201);
8832     } else {
8833         EXPECT_EQ(intResult, 0);
8834     }
8835 
8836     intResult = camManagerObj->PrelaunchCamera();
8837     EXPECT_EQ(intResult, 0);
8838 }
8839 
8840 /*
8841  * Feature: Framework
8842  * Function: Test anomalous branch
8843  * SubFunction: NA
8844  * FunctionPoints: NA
8845  * EnvConditions: NA
8846  * CaseDescription: test prelaunch the camera with NO_NEED_RESTORE_PARAM_OHOS anomalous branch
8847  */
8848 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_118, TestSize.Level0)
8849 {
8850     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
8851     ASSERT_NE(camManagerObj, nullptr);
8852 
8853     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
8854     std::string cameraId = camInput->GetCameraId();
8855     int activeTime = 15;
8856     EffectParam effectParam = {5, 0, 0};
8857 
8858     int32_t intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::NO_NEED_RESTORE_PARAM_OHOS,
8859         activeTime, effectParam);
8860     if (!IsSupportNow()) {
8861         EXPECT_EQ(intResult, 7400201);
8862     } else {
8863         EXPECT_EQ(intResult, 0);
8864     }
8865 }
8866 
8867 /*
8868  * Feature: Framework
8869  * Function: Test anomalous branch
8870  * SubFunction: NA
8871  * FunctionPoints: NA
8872  * EnvConditions: NA
8873  * CaseDescription: test prelaunch the camera with abnormal cameraid branch
8874  */
8875 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_119, TestSize.Level0)
8876 {
8877     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
8878     ASSERT_NE(camManagerObj, nullptr);
8879 
8880     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
8881     std::string cameraId = camInput->GetCameraId();
8882     int activeTime = 15;
8883     EffectParam effectParam = {0, 0, 0};
8884 
8885     cameraId = "";
8886     int32_t intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::TRANSIENT_ACTIVE_PARAM_OHOS,
8887         activeTime, effectParam);
8888     EXPECT_EQ(intResult, 7400201);
8889 }
8890 
8891 /*
8892  * Feature: Framework
8893  * Function: Test anomalous branch
8894  * SubFunction: NA
8895  * FunctionPoints: NA
8896  * EnvConditions: NA
8897  * CaseDescription: test prelaunch the camera with abnormal setting branch
8898  */
8899 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_120, TestSize.Level0)
8900 {
8901     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
8902     ASSERT_NE(camManagerObj, nullptr);
8903 
8904     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
8905     std::string cameraId = camInput->GetCameraId();
8906     int activeTime = 15;
8907     EffectParam effectParam = {-1, -1, -1};
8908     int32_t intResult = camManagerObj->SetPrelaunchConfig(cameraId, RestoreParamTypeOhos::NO_NEED_RESTORE_PARAM_OHOS,
8909         activeTime, effectParam);
8910     if (!IsSupportNow()) {
8911         EXPECT_EQ(intResult, 7400201);
8912     } else {
8913         EXPECT_EQ(intResult, 0);
8914     }
8915 }
8916 
8917 /*
8918  * Feature: Framework
8919  * Function: Test anomalous branch
8920  * SubFunction: NA
8921  * FunctionPoints: NA
8922  * EnvConditions: NA
8923  * CaseDescription: test low light boost
8924  */
8925 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_scenefeature_test_001, TestSize.Level0)
8926 {
8927 
8928     session_->SetMode(SceneMode::CAPTURE);
8929     int32_t intResult = session_->BeginConfig();
8930 
8931     EXPECT_EQ(intResult, 0);
8932 
8933     intResult = session_->AddInput(input_);
8934     EXPECT_EQ(intResult, 0);
8935 
8936     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
8937     ASSERT_NE(previewOutput, nullptr);
8938 
8939     intResult = session_->AddOutput(previewOutput);
8940     EXPECT_EQ(intResult, 0);
8941 
8942     bool isLowLightBoostSupported = session_->IsFeatureSupported(FEATURE_LOW_LIGHT_BOOST);
8943 
8944     if (isLowLightBoostSupported) {
8945         intResult = session_->EnableFeature(FEATURE_LOW_LIGHT_BOOST, true);
8946         EXPECT_EQ(intResult, 7400103);
8947     }
8948 
8949     intResult = session_->CommitConfig();
8950     EXPECT_EQ(intResult, 0);
8951 
8952     isLowLightBoostSupported = session_->IsFeatureSupported(FEATURE_LOW_LIGHT_BOOST);
8953     if (isLowLightBoostSupported) {
8954         session_->SetFeatureDetectionStatusCallback(std::make_shared<AppCallback>());
8955         session_->LockForControl();
8956         intResult = session_->EnableLowLightDetection(true);
8957         session_->UnlockForControl();
8958         EXPECT_EQ(intResult, 0);
8959     }
8960 
8961     intResult = session_->Start();
8962     EXPECT_EQ(intResult, 0);
8963 
8964     sleep(WAIT_TIME_AFTER_START);
8965 
8966     intResult = session_->Stop();
8967     EXPECT_EQ(intResult, 0);
8968 }
8969 
8970 /*
8971  * Feature: Framework
8972  * Function: Test anomalous branch
8973  * SubFunction: NA
8974  * FunctionPoints: NA
8975  * EnvConditions: NA
8976  * CaseDescription: test focus distance the camera with abnormal setting branch
8977  */
8978 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_121, TestSize.Level0)
8979 {
8980     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
8981     ASSERT_NE(camSession, nullptr);
8982     float recnum = 0.0f;
8983     int32_t intResult = camSession->GetFocusDistance(recnum);
8984     EXPECT_EQ(intResult, 7400103);
8985     EXPECT_EQ(recnum, 0.0f);
8986 
8987     camSession->LockForControl();
8988     float num = 1.0f;
8989     intResult = camSession->SetFocusDistance(num);
8990     EXPECT_EQ(intResult, 7400103);
8991     camSession->UnlockForControl();
8992 
8993     intResult = camSession->BeginConfig();
8994     EXPECT_EQ(intResult, 0);
8995 
8996     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
8997     ASSERT_NE(input, nullptr);
8998 
8999     intResult = camSession->AddInput(input);
9000     EXPECT_EQ(intResult, 0);
9001 
9002     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9003     ASSERT_NE(previewOutput, nullptr);
9004 
9005     intResult = camSession->AddOutput(previewOutput);
9006     EXPECT_EQ(intResult, 0);
9007 
9008     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9009     ASSERT_NE(photoOutput, nullptr);
9010 
9011     intResult = camSession->AddOutput(photoOutput);
9012     EXPECT_EQ(intResult, 0);
9013 
9014     intResult = camSession->CommitConfig();
9015     EXPECT_EQ(intResult, 0);
9016 
9017     intResult = camSession->GetFocusDistance(recnum);
9018     EXPECT_EQ(recnum, 0.0f);
9019     camSession->LockForControl();
9020     intResult = camSession->SetFocusDistance(num);
9021     EXPECT_EQ(intResult, 0);
9022     camSession->UnlockForControl();
9023     intResult = camSession->GetFocusDistance(recnum);
9024     EXPECT_EQ(recnum, 1.0f);
9025 
9026     ReleaseInput();
9027 
9028     intResult = camSession->GetFocusDistance(recnum);
9029     EXPECT_EQ(intResult, 0);
9030 }
9031 
9032 /*
9033  * Feature: Framework
9034  * Function: Test anomalous branch
9035  * SubFunction: NA
9036  * FunctionPoints: NA
9037  * EnvConditions: NA
9038  * CaseDescription: test CaptureSession GetZoomPointInfos  with abnormal setting branch
9039  */
9040 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_122, TestSize.Level0)
9041 {
9042     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
9043     ASSERT_NE(camSession, nullptr);
9044     std::vector<ZoomPointInfo> zoomPointInfoList = {};
9045     int32_t intResult = camSession->GetZoomPointInfos(zoomPointInfoList);
9046     EXPECT_EQ(intResult, 7400103);
9047     EXPECT_EQ(zoomPointInfoList.empty(), true);
9048 
9049     intResult = camSession->BeginConfig();
9050     EXPECT_EQ(intResult, 0);
9051 
9052     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
9053     ASSERT_NE(input, nullptr);
9054 
9055     intResult = camSession->AddInput(input);
9056     EXPECT_EQ(intResult, 0);
9057 
9058     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9059     ASSERT_NE(previewOutput, nullptr);
9060 
9061     intResult = camSession->AddOutput(previewOutput);
9062     EXPECT_EQ(intResult, 0);
9063 
9064     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9065     ASSERT_NE(photoOutput, nullptr);
9066 
9067     intResult = camSession->AddOutput(photoOutput);
9068     EXPECT_EQ(intResult, 0);
9069 
9070     intResult = camSession->CommitConfig();
9071     EXPECT_EQ(intResult, 0);
9072 
9073     intResult = camSession->GetZoomPointInfos(zoomPointInfoList);
9074     EXPECT_EQ(intResult, 0);
9075 
9076     ReleaseInput();
9077 
9078     intResult = camSession->GetZoomPointInfos(zoomPointInfoList);
9079     EXPECT_EQ(intResult, 0);
9080 }
9081 
9082 /*
9083  * Feature: Framework
9084  * Function: Test anomalous branch
9085  * SubFunction: NA
9086  * FunctionPoints: NA
9087  * EnvConditions: NA
9088  * CaseDescription: test CaptureSession GetSensorExposureTime  with abnormal setting branch
9089  */
9090 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_123, TestSize.Level0)
9091 {
9092     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
9093     ASSERT_NE(camSession, nullptr);
9094     std::vector<uint32_t> exposureTimeRange = {};
9095     int32_t intResult = camSession->GetSensorExposureTimeRange(exposureTimeRange);
9096     EXPECT_EQ(intResult, 7400103);
9097     EXPECT_EQ(exposureTimeRange.empty(), true);
9098 
9099     uint32_t recSensorExposureTime = 0;
9100     intResult = camSession->GetSensorExposureTime(recSensorExposureTime);
9101     EXPECT_EQ(intResult, 7400103);
9102     EXPECT_EQ(recSensorExposureTime, 0);
9103 
9104     camSession->LockForControl();
9105     uint32_t exposureTime = 1;
9106     intResult = camSession->SetSensorExposureTime(exposureTime);
9107     EXPECT_EQ(intResult, 7400103);
9108     camSession->UnlockForControl();
9109 
9110     intResult = camSession->BeginConfig();
9111     EXPECT_EQ(intResult, 0);
9112 
9113     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
9114     ASSERT_NE(input, nullptr);
9115 
9116     intResult = camSession->AddInput(input);
9117     EXPECT_EQ(intResult, 0);
9118 
9119     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9120     ASSERT_NE(previewOutput, nullptr);
9121 
9122     intResult = camSession->AddOutput(previewOutput);
9123     EXPECT_EQ(intResult, 0);
9124 
9125     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9126     ASSERT_NE(photoOutput, nullptr);
9127 
9128     intResult = camSession->AddOutput(photoOutput);
9129     EXPECT_EQ(intResult, 0);
9130 
9131     intResult = camSession->CommitConfig();
9132     EXPECT_EQ(intResult, 0);
9133 
9134     intResult = camSession->GetSensorExposureTimeRange(exposureTimeRange);
9135     EXPECT_EQ(intResult, 0);
9136 
9137     camSession->LockForControl();
9138     intResult = camSession->SetSensorExposureTime(exposureTimeRange[0]);
9139     EXPECT_EQ(intResult, 0);
9140     camSession->UnlockForControl();
9141 
9142     intResult = camSession->GetSensorExposureTime(recSensorExposureTime);
9143     EXPECT_EQ(intResult, 0);
9144 
9145     ReleaseInput();
9146 
9147     intResult = camSession->GetSensorExposureTimeRange(exposureTimeRange);
9148     EXPECT_EQ(intResult, 7400101);
9149 
9150     intResult = camSession->GetSensorExposureTime(recSensorExposureTime);
9151     EXPECT_EQ(intResult, 7400101);
9152 
9153     camSession->LockForControl();
9154     intResult = camSession->SetSensorExposureTime(exposureTimeRange[0]);
9155     EXPECT_EQ(intResult, 7400102);
9156     camSession->UnlockForControl();
9157 }
9158 
9159 /*
9160  * Feature: Framework
9161  * Function: Test anomalous branch
9162  * SubFunction: NA
9163  * FunctionPoints: NA
9164  * EnvConditions: NA
9165  * CaseDescription: test focus distance the camera with abnormal setting branch
9166  */
9167 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_124, TestSize.Level0)
9168 {
9169     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
9170     ASSERT_NE(camSession, nullptr);
9171     std::vector<WhiteBalanceMode> supportedWhiteBalanceModes = {};
9172     int32_t intResult = camSession->GetSupportedWhiteBalanceModes(supportedWhiteBalanceModes);
9173     EXPECT_EQ(intResult, 7400103);
9174     EXPECT_EQ(supportedWhiteBalanceModes.empty(), true);
9175 
9176     bool isSupported = false;
9177     WhiteBalanceMode currMode = WhiteBalanceMode::AWB_MODE_OFF;
9178     intResult = camSession->IsWhiteBalanceModeSupported(currMode, isSupported);
9179     EXPECT_EQ(intResult, 7400103);
9180 
9181     camSession->LockForControl();
9182     intResult = camSession->SetWhiteBalanceMode(currMode);
9183     EXPECT_EQ(intResult, 7400103);
9184     camSession->UnlockForControl();
9185 
9186     WhiteBalanceMode retMode;
9187     intResult = camSession->GetWhiteBalanceMode(retMode);
9188     EXPECT_EQ(intResult, 7400103);
9189 
9190     intResult = camSession->BeginConfig();
9191     EXPECT_EQ(intResult, 0);
9192 
9193     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
9194     ASSERT_NE(input, nullptr);
9195 
9196     intResult = camSession->AddInput(input);
9197     EXPECT_EQ(intResult, 0);
9198 
9199     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9200     ASSERT_NE(previewOutput, nullptr);
9201 
9202     intResult = camSession->AddOutput(previewOutput);
9203     EXPECT_EQ(intResult, 0);
9204 
9205     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9206     ASSERT_NE(photoOutput, nullptr);
9207 
9208     intResult = camSession->AddOutput(photoOutput);
9209     EXPECT_EQ(intResult, 0);
9210 
9211     intResult = camSession->CommitConfig();
9212     EXPECT_EQ(intResult, 0);
9213 
9214     camSession->GetSupportedWhiteBalanceModes(supportedWhiteBalanceModes);
9215     if (!supportedWhiteBalanceModes.empty()) {
9216         camSession->IsWhiteBalanceModeSupported(supportedWhiteBalanceModes[0], isSupported);
9217         ASSERT_EQ(isSupported, true);
9218         camSession->LockForControl();
9219         intResult = camSession->SetWhiteBalanceMode(supportedWhiteBalanceModes[0]);
9220         ASSERT_EQ(isSupported, 0);
9221         camSession->UnlockForControl();
9222         WhiteBalanceMode currentMode;
9223         camSession->GetWhiteBalanceMode(currentMode);
9224         ASSERT_EQ(currentMode, supportedWhiteBalanceModes[0]);
9225     }
9226 
9227     ReleaseInput();
9228 
9229     intResult = camSession->GetSupportedWhiteBalanceModes(supportedWhiteBalanceModes);
9230     EXPECT_EQ(intResult, 0);
9231 
9232     intResult = camSession->IsWhiteBalanceModeSupported(currMode, isSupported);
9233     EXPECT_EQ(intResult, 0);
9234     camSession->LockForControl();
9235     intResult = camSession->SetWhiteBalanceMode(currMode);
9236     EXPECT_EQ(intResult, 0);
9237     camSession->UnlockForControl();
9238 
9239     intResult = camSession->GetWhiteBalanceMode(retMode);
9240     EXPECT_EQ(intResult, 0);
9241 }
9242 
9243 /*
9244  * Feature: Framework
9245  * Function: Test anomalous branch
9246  * SubFunction: NA
9247  * FunctionPoints: NA
9248  * EnvConditions: NA
9249  * CaseDescription: test manaul WhiteBalance the camera with abnormal setting branch
9250  */
9251 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_125, TestSize.Level0)
9252 {
9253     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
9254     ASSERT_NE(camSession, nullptr);
9255     std::vector<int32_t> manualWhiteBalanceRange = {};
9256     int32_t intResult = camSession->GetManualWhiteBalanceRange(manualWhiteBalanceRange);
9257     EXPECT_EQ(intResult, 7400103);
9258     EXPECT_EQ(manualWhiteBalanceRange.empty(), true);
9259 
9260     bool isSupported = false;
9261     intResult = camSession->IsManualWhiteBalanceSupported(isSupported);
9262     EXPECT_EQ(intResult, 7400103);
9263 
9264     int32_t wbValue = 0;
9265     camSession->LockForControl();
9266     intResult = camSession->SetManualWhiteBalance(wbValue);
9267     EXPECT_EQ(intResult, 7400103);
9268     camSession->UnlockForControl();
9269 
9270     intResult = camSession->GetManualWhiteBalance(wbValue);
9271     EXPECT_EQ(intResult, 7400103);
9272 
9273     intResult = camSession->BeginConfig();
9274     EXPECT_EQ(intResult, 0);
9275 
9276     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
9277     ASSERT_NE(input, nullptr);
9278 
9279     intResult = camSession->AddInput(input);
9280     EXPECT_EQ(intResult, 0);
9281 
9282     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9283     ASSERT_NE(previewOutput, nullptr);
9284 
9285     intResult = camSession->AddOutput(previewOutput);
9286     EXPECT_EQ(intResult, 0);
9287 
9288     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9289     ASSERT_NE(photoOutput, nullptr);
9290 
9291     intResult = camSession->AddOutput(photoOutput);
9292     EXPECT_EQ(intResult, 0);
9293 
9294     intResult = camSession->CommitConfig();
9295     EXPECT_EQ(intResult, 0);
9296 
9297     camSession->GetManualWhiteBalanceRange(manualWhiteBalanceRange);
9298     if (!manualWhiteBalanceRange.empty()) {
9299         camSession->IsManualWhiteBalanceSupported(isSupported);
9300         ASSERT_EQ(isSupported, true);
9301         camSession->LockForControl();
9302         intResult = camSession->SetManualWhiteBalance(manualWhiteBalanceRange[0]);
9303         camSession->UnlockForControl();
9304         camSession->GetManualWhiteBalance(wbValue);
9305         ASSERT_EQ(wbValue, manualWhiteBalanceRange[0]);
9306     }
9307 
9308     ReleaseInput();
9309 
9310     intResult = camSession->GetManualWhiteBalanceRange(manualWhiteBalanceRange);
9311     EXPECT_EQ(intResult, 0);
9312 
9313     intResult = camSession->IsManualWhiteBalanceSupported(isSupported);
9314     EXPECT_EQ(intResult, 0);
9315     camSession->LockForControl();
9316     intResult = camSession->SetManualWhiteBalance(wbValue);
9317     EXPECT_EQ(intResult, 7400102);
9318     camSession->UnlockForControl();
9319 
9320     intResult = camSession->GetManualWhiteBalance(wbValue);
9321     EXPECT_EQ(intResult, 0);
9322 }
9323 
9324 /* Feature: Framework
9325  * Function: Test anomalous branch
9326  * SubFunction: NA
9327  * FunctionPoints: NA
9328  * EnvConditions: NA
9329  * CaseDescription: Test abnormal branches with empty inputDevice and empty metadata
9330  */
9331 HWTEST_F(CameraFrameworkModuleTest, camera_fwcoverage_moduletest_126, TestSize.Level0)
9332 {
9333     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
9334     ASSERT_NE(camSession, nullptr);
9335     std::vector<std::vector<float>> supportedPhysicalApertures;
9336     int32_t intResult = camSession->GetSupportedPhysicalApertures(supportedPhysicalApertures);
9337     EXPECT_EQ(intResult, 7400103);
9338     EXPECT_EQ(supportedPhysicalApertures.empty(), true);
9339 
9340     float getAperture = 0.0f;
9341     intResult = camSession->GetPhysicalAperture(getAperture);
9342     EXPECT_EQ(intResult, 7400103);
9343     EXPECT_EQ(getAperture, 0.0f);
9344 
9345     camSession->LockForControl();
9346     float setAperture = 1.0f;
9347     intResult = camSession->SetPhysicalAperture(setAperture);
9348     EXPECT_EQ(intResult, 7400103);
9349     camSession->UnlockForControl();
9350 
9351     intResult = camSession->BeginConfig();
9352     EXPECT_EQ(intResult, 0);
9353 
9354     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
9355     ASSERT_NE(input, nullptr);
9356 
9357     intResult = camSession->AddInput(input);
9358     EXPECT_EQ(intResult, 0);
9359 
9360     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9361     ASSERT_NE(previewOutput, nullptr);
9362 
9363     intResult = camSession->AddOutput(previewOutput);
9364     EXPECT_EQ(intResult, 0);
9365 
9366     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
9367     ASSERT_NE(photoOutput, nullptr);
9368 
9369     intResult = camSession->AddOutput(photoOutput);
9370     EXPECT_EQ(intResult, 0);
9371 
9372     intResult = camSession->CommitConfig();
9373     EXPECT_EQ(intResult, 0);
9374 
9375     intResult = camSession->GetSupportedPhysicalApertures(supportedPhysicalApertures);
9376     EXPECT_EQ(intResult, 0);
9377     intResult = camSession->GetPhysicalAperture(getAperture);
9378     EXPECT_EQ(intResult, 0);
9379 
9380     camSession->LockForControl();
9381     intResult = camSession->SetPhysicalAperture(setAperture);
9382     EXPECT_EQ(intResult, 0);
9383     camSession->UnlockForControl();
9384     intResult = camSession->GetPhysicalAperture(getAperture);
9385     EXPECT_EQ(intResult, 0);
9386 
9387     ReleaseInput();
9388 
9389     intResult = camSession->GetSupportedPhysicalApertures(supportedPhysicalApertures);
9390     EXPECT_EQ(intResult, 0);
9391     intResult = camSession->GetPhysicalAperture(getAperture);
9392     EXPECT_EQ(intResult, 0);
9393 }
9394 
9395 
9396 /*
9397  * Feature: Framework
9398  * Function: Test camera preempted.
9399  * SubFunction: NA
9400  * FunctionPoints: NA
9401  * EnvConditions: NA
9402  * CaseDescription: Test camera preempted.
9403  * @tc.require: SR000GVTU0
9404  */
9405 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_044, TestSize.Level0)
9406 {
9407     if (!IsSupportNow()) {
9408         return;
9409     }
9410     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
9411     sptr<CameraInput> camInput_2 = (sptr<CameraInput>&)input_;
9412     camInput_2->Open();
9413 
9414     camInput_2->SetErrorCallback(callback);
9415 
9416     sptr<CaptureSession> session_2 = manager_->CreateCaptureSession();
9417     ASSERT_NE(session_2, nullptr);
9418 
9419     int32_t intResult = session_2->BeginConfig();
9420     EXPECT_EQ(intResult, 0);
9421 
9422     intResult = session_2->AddInput(input_);
9423     EXPECT_EQ(intResult, 0);
9424 
9425     sptr<CaptureOutput> previewOutput_2 = CreatePreviewOutput();
9426     ASSERT_NE(previewOutput_2, nullptr);
9427 
9428     intResult = session_2->AddOutput(previewOutput_2);
9429     EXPECT_EQ(intResult, 0);
9430 
9431     intResult = session_2->CommitConfig();
9432     EXPECT_EQ(intResult, 0);
9433 
9434     intResult = session_2->Start();
9435     EXPECT_EQ(intResult, 0);
9436 
9437     sleep(WAIT_TIME_AFTER_START);
9438     camInput_2->Close();
9439 
9440     if (cameras_.size() < 2) {
9441         return;
9442     }
9443 
9444     sptr<CaptureInput> input_3 = manager_->CreateCameraInput(cameras_[1]);
9445     ASSERT_NE(input_3, nullptr);
9446 
9447     sptr<CameraInput> camInput_3 = (sptr<CameraInput>&)input_3;
9448     camInput_3->Open();
9449 
9450     sptr<CaptureSession> session_3 = manager_->CreateCaptureSession();
9451     ASSERT_NE(session_3, nullptr);
9452 
9453     intResult = session_3->BeginConfig();
9454     EXPECT_EQ(intResult, 0);
9455 
9456     intResult = session_3->AddInput(input_3);
9457     EXPECT_EQ(intResult, 0);
9458 
9459     sptr<CaptureOutput> previewOutput_3 = CreatePreviewOutput();
9460     ASSERT_NE(previewOutput_3, nullptr);
9461 
9462     intResult = session_3->AddOutput(previewOutput_3);
9463     EXPECT_EQ(intResult, 0);
9464 
9465     intResult = session_3->CommitConfig();
9466     EXPECT_EQ(intResult, 0);
9467 
9468     camInput_3->Close();
9469     session_3->Stop();
9470 }
9471 
9472 /*
9473  * Feature: Framework
9474  * Function: Test capture session with Video Stabilization Mode
9475  * SubFunction: NA
9476  * FunctionPoints: NA
9477  * EnvConditions: NA
9478  * CaseDescription: Test capture session with Video Stabilization Mode
9479  */
9480 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_049, TestSize.Level0)
9481 {
9482     int32_t intResult = session_->BeginConfig();
9483     EXPECT_EQ(intResult, 0);
9484 
9485     intResult = session_->AddInput(input_);
9486     EXPECT_EQ(intResult, 0);
9487 
9488     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9489     ASSERT_NE(previewOutput, nullptr);
9490 
9491     intResult = session_->AddOutput(previewOutput);
9492     EXPECT_EQ(intResult, 0);
9493 
9494     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
9495     ASSERT_NE(videoOutput, nullptr);
9496 
9497     intResult = session_->AddOutput(videoOutput);
9498     EXPECT_EQ(intResult, 0);
9499 
9500     intResult = session_->CommitConfig();
9501     EXPECT_EQ(intResult, 0);
9502 
9503     std::vector<VideoStabilizationMode> stabilizationmodes = session_->GetSupportedStabilizationMode();
9504     if (stabilizationmodes.empty()) {
9505         return;
9506     }
9507     ASSERT_EQ(stabilizationmodes.empty(), false);
9508 
9509     VideoStabilizationMode stabilizationMode = stabilizationmodes.back();
9510     if (session_->IsVideoStabilizationModeSupported(stabilizationMode)) {
9511         session_->SetVideoStabilizationMode(stabilizationMode);
9512         EXPECT_EQ(session_->GetActiveVideoStabilizationMode(), stabilizationMode);
9513     }
9514 
9515     intResult = session_->Start();
9516     EXPECT_EQ(intResult, 0);
9517 
9518     sleep(WAIT_TIME_AFTER_START);
9519 
9520     intResult = ((sptr<VideoOutput>&)videoOutput)->Start();
9521     EXPECT_EQ(intResult, 0);
9522 
9523     sleep(WAIT_TIME_AFTER_START);
9524 
9525     intResult = ((sptr<VideoOutput>&)videoOutput)->Stop();
9526     EXPECT_EQ(intResult, 0);
9527 
9528     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
9529 
9530     sleep(WAIT_TIME_BEFORE_STOP);
9531     session_->Stop();
9532 }
9533 
9534 /*
9535  * Feature: Framework
9536  * Function: Test sketch functions.
9537  * SubFunction: NA
9538  * FunctionPoints: NA
9539  * EnvConditions: NA
9540  * CaseDescription: Test sketch functions.
9541  */
9542 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_050, TestSize.Level0)
9543 {
9544     auto previewProfile = GetSketchPreviewProfile();
9545     if (previewProfile == nullptr) {
9546         EXPECT_EQ(previewProfile.get(), nullptr);
9547         return;
9548     }
9549     auto output = CreatePreviewOutput(*previewProfile);
9550     ASSERT_NE(output, nullptr);
9551 
9552     session_->SetMode(SceneMode::CAPTURE);
9553     int32_t intResult = session_->BeginConfig();
9554     EXPECT_EQ(intResult, 0);
9555 
9556     intResult = session_->AddInput(input_);
9557     EXPECT_EQ(intResult, 0);
9558 
9559     intResult = session_->AddOutput(output);
9560     EXPECT_EQ(intResult, 0);
9561 
9562     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9563     bool isSketchSupport = previewOutput->IsSketchSupported();
9564     if (!isSketchSupport) {
9565         return;
9566     }
9567 
9568     int sketchEnableRatio = previewOutput->GetSketchRatio();
9569     EXPECT_GT(sketchEnableRatio, 0);
9570 
9571     intResult = previewOutput->EnableSketch(true);
9572     EXPECT_EQ(intResult, 0);
9573 
9574     intResult = session_->CommitConfig();
9575     EXPECT_EQ(intResult, 0);
9576 
9577     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
9578     EXPECT_EQ(intResult, 0);
9579 
9580     intResult = session_->Start();
9581     EXPECT_EQ(intResult, 0);
9582 
9583     sleep(WAIT_TIME_AFTER_START);
9584 
9585     intResult = session_->Stop();
9586     EXPECT_EQ(intResult, 0);
9587 }
9588 
9589 /*
9590  * Feature: Framework
9591  * Function: Test sketch functions callback.
9592  * SubFunction: NA
9593  * FunctionPoints: NA
9594  * EnvConditions: NA
9595  * CaseDescription: Test sketch functions.
9596  */
9597 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_051, TestSize.Level0)
9598 {
9599     auto previewProfile = GetSketchPreviewProfile();
9600     if (previewProfile == nullptr) {
9601         EXPECT_EQ(previewProfile.get(), nullptr);
9602         return;
9603     }
9604     auto output = CreatePreviewOutput(*previewProfile);
9605     ASSERT_NE(output, nullptr);
9606 
9607     session_->SetMode(SceneMode::CAPTURE);
9608     int32_t intResult = session_->BeginConfig();
9609     EXPECT_EQ(intResult, 0);
9610 
9611     intResult = session_->AddInput(input_);
9612     EXPECT_EQ(intResult, 0);
9613 
9614     intResult = session_->AddOutput(output);
9615     EXPECT_EQ(intResult, 0);
9616 
9617     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9618     bool isSketchSupport = previewOutput->IsSketchSupported();
9619     if (!isSketchSupport) {
9620         return;
9621     }
9622 
9623     previewOutput->SetCallback(std::make_shared<AppCallback>());
9624 
9625     int sketchEnableRatio = previewOutput->GetSketchRatio();
9626     EXPECT_GT(sketchEnableRatio, 0);
9627 
9628     intResult = previewOutput->EnableSketch(true);
9629     EXPECT_EQ(intResult, 0);
9630 
9631     intResult = session_->CommitConfig();
9632     EXPECT_EQ(intResult, 0);
9633 
9634     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
9635     EXPECT_EQ(intResult, 0);
9636 
9637     intResult = session_->Start();
9638     EXPECT_EQ(intResult, 0);
9639 
9640     sleep(WAIT_TIME_AFTER_START);
9641 
9642     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
9643 
9644     session_->LockForControl();
9645     intResult = session_->SetZoomRatio(30.0f);
9646     EXPECT_EQ(intResult, 0);
9647     session_->UnlockForControl();
9648 
9649     sleep(WAIT_TIME_AFTER_START);
9650 
9651     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 1);
9652     g_previewEvents.reset();
9653 
9654     sleep(WAIT_TIME_AFTER_START);
9655     auto statusSize = g_sketchStatus.size();
9656     EXPECT_EQ(statusSize, 2);
9657     if (statusSize == 2) {
9658         EXPECT_EQ(g_sketchStatus.front(), 3);
9659         g_sketchStatus.pop_front();
9660         EXPECT_EQ(g_sketchStatus.front(), 1);
9661         g_sketchStatus.pop_front();
9662     }
9663 
9664     sleep(1);
9665     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
9666 
9667     intResult = session_->Stop();
9668     EXPECT_EQ(intResult, 0);
9669 }
9670 
9671 /*
9672  * Feature: Framework
9673  * Function: Test sketch anomalous branch.
9674  * SubFunction: NA
9675  * FunctionPoints: NA
9676  * EnvConditions: NA
9677  * CaseDescription: Test sketch anomalous branch.
9678  */
9679 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_052, TestSize.Level0)
9680 {
9681     auto previewProfile = GetSketchPreviewProfile();
9682     if (previewProfile == nullptr) {
9683         EXPECT_EQ(previewProfile.get(), nullptr);
9684         return;
9685     }
9686     auto output = CreatePreviewOutput(*previewProfile);
9687     ASSERT_NE(output, nullptr);
9688 
9689     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9690     bool isSketchSupport = previewOutput->IsSketchSupported();
9691     ASSERT_FALSE(isSketchSupport);
9692 
9693     session_->SetMode(SceneMode::CAPTURE);
9694     int32_t intResult = session_->BeginConfig();
9695 
9696     EXPECT_EQ(intResult, 0);
9697 
9698     intResult = session_->AddInput(input_);
9699     EXPECT_EQ(intResult, 0);
9700 
9701     intResult = session_->AddOutput(output);
9702     EXPECT_EQ(intResult, 0);
9703 
9704     isSketchSupport = previewOutput->IsSketchSupported();
9705     if (!isSketchSupport) {
9706         return;
9707     }
9708 
9709     session_->SetMode(SceneMode::PORTRAIT);
9710     int sketchEnableRatio = previewOutput->GetSketchRatio();
9711     EXPECT_LT(sketchEnableRatio, 0);
9712 
9713     session_->SetMode(SceneMode::CAPTURE);
9714     sketchEnableRatio = previewOutput->GetSketchRatio();
9715     EXPECT_GT(sketchEnableRatio, 0);
9716 
9717     auto sketchSurface = CreateSketchSurface(previewProfile->GetCameraFormat());
9718 
9719     intResult = previewOutput->EnableSketch(true);
9720     EXPECT_EQ(intResult, 0);
9721 
9722     intResult = previewOutput->AttachSketchSurface(sketchSurface);
9723     EXPECT_EQ(intResult, 7400103);
9724 
9725     intResult = session_->CommitConfig();
9726     EXPECT_EQ(intResult, 0);
9727 
9728     intResult = previewOutput->AttachSketchSurface(sketchSurface);
9729     EXPECT_EQ(intResult, 0);
9730 
9731     intResult = session_->Start();
9732     EXPECT_EQ(intResult, 0);
9733 
9734     intResult = previewOutput->EnableSketch(true);
9735     EXPECT_EQ(intResult, 7400103);
9736 
9737     sleep(WAIT_TIME_AFTER_START);
9738 
9739     intResult = previewOutput->AttachSketchSurface(sketchSurface);
9740     EXPECT_EQ(intResult, 0);
9741 
9742     intResult = session_->Stop();
9743     EXPECT_EQ(intResult, 0);
9744 }
9745 
9746 /*
9747  * Feature: Framework
9748  * Function: Test sketch functions auto start sketch while zoom set.
9749  * SubFunction: NA
9750  * FunctionPoints: NA
9751  * EnvConditions: NA
9752  * CaseDescription: Test sketch functions auto start sketch while zoom set.
9753  */
9754 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_053, TestSize.Level0)
9755 {
9756     auto previewProfile = GetSketchPreviewProfile();
9757     if (previewProfile == nullptr) {
9758         EXPECT_EQ(previewProfile.get(), nullptr);
9759         return;
9760     }
9761     auto output = CreatePreviewOutput(*previewProfile);
9762     ASSERT_NE(output, nullptr);
9763 
9764     session_->SetMode(SceneMode::CAPTURE);
9765     int32_t intResult = session_->BeginConfig();
9766     EXPECT_EQ(intResult, 0);
9767 
9768     intResult = session_->AddInput(input_);
9769     EXPECT_EQ(intResult, 0);
9770 
9771     intResult = session_->AddOutput(output);
9772     EXPECT_EQ(intResult, 0);
9773 
9774     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9775     previewOutput->SetCallback(std::make_shared<AppCallback>());
9776     bool isSketchSupport = previewOutput->IsSketchSupported();
9777     if (!isSketchSupport) {
9778         return;
9779     }
9780 
9781     int sketchEnableRatio = previewOutput->GetSketchRatio();
9782     EXPECT_GT(sketchEnableRatio, 0);
9783 
9784     intResult = previewOutput->EnableSketch(true);
9785     EXPECT_EQ(intResult, 0);
9786 
9787     intResult = session_->CommitConfig();
9788     EXPECT_EQ(intResult, 0);
9789 
9790     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
9791     EXPECT_EQ(intResult, 0);
9792 
9793     session_->LockForControl();
9794     intResult = session_->SetZoomRatio(30.0f);
9795     EXPECT_EQ(intResult, 0);
9796     session_->UnlockForControl();
9797 
9798     intResult = session_->Start();
9799     EXPECT_EQ(intResult, 0);
9800 
9801     sleep(WAIT_TIME_AFTER_START);
9802     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 1);
9803     g_previewEvents.reset();
9804 
9805     auto statusSize = g_sketchStatus.size();
9806     EXPECT_EQ(statusSize, 3);
9807     if (statusSize == 3) {
9808         EXPECT_EQ(g_sketchStatus.front(), 0);
9809         g_sketchStatus.pop_front();
9810         EXPECT_EQ(g_sketchStatus.front(), 3);
9811         g_sketchStatus.pop_front();
9812         EXPECT_EQ(g_sketchStatus.front(), 1);
9813         g_sketchStatus.pop_front();
9814     }
9815 
9816     sleep(WAIT_TIME_AFTER_START);
9817     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
9818     g_previewEvents.reset();
9819 
9820     session_->LockForControl();
9821     intResult = session_->SetZoomRatio(1.0f);
9822     EXPECT_EQ(intResult, 0);
9823     session_->UnlockForControl();
9824 
9825     sleep(WAIT_TIME_AFTER_START);
9826     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 1);
9827     g_previewEvents.reset();
9828 
9829     statusSize = g_sketchStatus.size();
9830     EXPECT_EQ(statusSize, 2);
9831     if (statusSize == 2) {
9832         EXPECT_EQ(g_sketchStatus.front(), 2);
9833         g_sketchStatus.pop_front();
9834         EXPECT_EQ(g_sketchStatus.front(), 0);
9835         g_sketchStatus.pop_front();
9836     }
9837 
9838     sleep(WAIT_TIME_AFTER_START);
9839     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
9840     g_previewEvents.reset();
9841 
9842     intResult = session_->Stop();
9843     EXPECT_EQ(intResult, 0);
9844 }
9845 
9846 /*
9847  * Feature: Framework
9848  * Function: Test macro function.
9849  * SubFunction: NA
9850  * FunctionPoints: NA
9851  * EnvConditions: NA
9852  * CaseDescription: Test macro function.
9853  */
9854 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_054, TestSize.Level0)
9855 {
9856     auto previewProfile = GetSketchPreviewProfile();
9857     if (previewProfile == nullptr) {
9858         EXPECT_EQ(previewProfile.get(), nullptr);
9859         return;
9860     }
9861     auto output = CreatePreviewOutput(*previewProfile);
9862     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9863     ASSERT_NE(output, nullptr);
9864 
9865     session_->SetMode(SceneMode::CAPTURE);
9866     int32_t intResult = session_->BeginConfig();
9867 
9868     EXPECT_EQ(intResult, 0);
9869 
9870     intResult = session_->AddInput(input_);
9871     EXPECT_EQ(intResult, 0);
9872 
9873     intResult = session_->AddOutput(output);
9874     EXPECT_EQ(intResult, 0);
9875 
9876     intResult = session_->CommitConfig();
9877     EXPECT_EQ(intResult, 0);
9878 
9879     session_->SetMacroStatusCallback(std::make_shared<AppCallback>());
9880 
9881     g_macroEvents.reset();
9882     intResult = session_->Start();
9883     EXPECT_EQ(intResult, 0);
9884 
9885     sleep(WAIT_TIME_AFTER_START);
9886 
9887     bool isMacroSupported = session_->IsMacroSupported();
9888     if (isMacroSupported) {
9889         EXPECT_EQ(g_macroEvents.count(), 1);
9890         if (g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_ACTIVE)] == 1) {
9891             session_->LockForControl();
9892             intResult = session_->EnableMacro(true);
9893             EXPECT_EQ(intResult, 0);
9894             session_->UnlockForControl();
9895         }
9896         if (g_macroEvents[static_cast<int>(CAM_MACRO_DETECT_EVENTS::CAM_MACRO_EVENT_IDLE)] == 1) {
9897             session_->LockForControl();
9898             intResult = session_->EnableMacro(false);
9899             EXPECT_EQ(intResult, 0);
9900             session_->UnlockForControl();
9901         }
9902     }
9903 
9904     sleep(WAIT_TIME_AFTER_START);
9905 
9906     intResult = session_->Stop();
9907     EXPECT_EQ(intResult, 0);
9908 }
9909 
9910 /*
9911  * Feature: Framework
9912  * Function: Test macro function anomalous branch..
9913  * SubFunction: NA
9914  * FunctionPoints: NA
9915  * EnvConditions: NA
9916  * CaseDescription: Test macro function anomalous branch..
9917  */
9918 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_055, TestSize.Level0)
9919 {
9920     auto previewProfile = GetSketchPreviewProfile();
9921     if (previewProfile == nullptr) {
9922         EXPECT_EQ(previewProfile.get(), nullptr);
9923         return;
9924     }
9925     auto output = CreatePreviewOutput(*previewProfile);
9926     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
9927     ASSERT_NE(output, nullptr);
9928 
9929     session_->SetMode(SceneMode::CAPTURE);
9930     int32_t intResult = session_->BeginConfig();
9931 
9932     EXPECT_EQ(intResult, 0);
9933 
9934     intResult = session_->AddInput(input_);
9935     EXPECT_EQ(intResult, 0);
9936 
9937     intResult = session_->AddOutput(output);
9938     EXPECT_EQ(intResult, 0);
9939 
9940     intResult = session_->EnableMacro(true);
9941     EXPECT_EQ(intResult, 7400102);
9942 
9943     intResult = session_->EnableMacro(false);
9944     EXPECT_EQ(intResult, 7400102);
9945 
9946     intResult = session_->CommitConfig();
9947     EXPECT_EQ(intResult, 0);
9948 
9949     if (session_->IsMacroSupported()) {
9950         session_->LockForControl();
9951         intResult = session_->EnableMacro(false);
9952         session_->UnlockForControl();
9953         EXPECT_EQ(intResult, 0);
9954     }
9955     session_->SetMacroStatusCallback(std::make_shared<AppCallback>());
9956 
9957     intResult = session_->Start();
9958     EXPECT_EQ(intResult, 0);
9959 
9960     g_macroEvents.reset();
9961 
9962     sleep(WAIT_TIME_AFTER_START);
9963 
9964     intResult = session_->Stop();
9965     EXPECT_EQ(intResult, 0);
9966 }
9967 
9968 /*
9969  * Feature: Device preemption
9970  * Function: Test device open twice
9971  * SubFunction: NA
9972  * FunctionPoints: NA
9973  * EnvConditions: NA
9974  * CaseDescription: Test device open twice
9975  */
9976 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_056, TestSize.Level0)
9977 {
9978     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
9979     camInput->Open();
9980 
9981     int32_t intResult = session_->BeginConfig();
9982     EXPECT_EQ(intResult, 0);
9983 
9984     intResult = session_->AddInput(input_);
9985     EXPECT_EQ(intResult, 0);
9986 
9987     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
9988     ASSERT_NE(previewOutput, nullptr);
9989 
9990     intResult = session_->AddOutput(previewOutput);
9991     EXPECT_EQ(intResult, 0);
9992 
9993     intResult = session_->CommitConfig();
9994     EXPECT_EQ(intResult, 0);
9995 
9996     intResult = session_->Start();
9997     EXPECT_EQ(intResult, 0);
9998 
9999     sleep(WAIT_TIME_AFTER_START);
10000 
10001     intResult = session_->Stop();
10002     EXPECT_EQ(intResult, 0);
10003 }
10004 
10005 /* Feature: Framework
10006  * Function: Test preview/capture with portrait session's beauty
10007  * SubFunction: NA
10008  * FunctionPoints: NA
10009  * EnvConditions: NA
10010  * CaseDescription: Test preview/capture with portrait session's beauty
10011  */
10012 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_057, TestSize.Level0)
10013 {
10014     SceneMode portraitMode = SceneMode::PORTRAIT;
10015     if (!IsSupportMode(portraitMode)) {
10016         return;
10017     }
10018     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
10019     ASSERT_NE(modeManagerObj, nullptr);
10020 
10021     std::vector<SceneMode> modes = modeManagerObj->GetSupportedModes(cameras_[0]);
10022     ASSERT_TRUE(modes.size() != 0);
10023 
10024     sptr<CameraOutputCapability> modeAbility =
10025         modeManagerObj->GetSupportedOutputCapability(cameras_[0], portraitMode);
10026     ASSERT_NE(modeAbility, nullptr);
10027 
10028     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(portraitMode);
10029     ASSERT_NE(captureSession, nullptr);
10030     sptr<PortraitSession> portraitSession = static_cast<PortraitSession*>(captureSession.GetRefPtr());
10031     ASSERT_NE(portraitSession, nullptr);
10032 
10033     int32_t intResult = portraitSession->BeginConfig();
10034     EXPECT_EQ(intResult, 0);
10035 
10036     intResult = portraitSession->AddInput(input_);
10037     EXPECT_EQ(intResult, 0);
10038 
10039     float ratioWidth = 16;
10040     float ratioHeight = 9;
10041     float ratio = ratioWidth / ratioHeight;
10042 
10043     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
10044     ASSERT_NE(profile.format_, -1);
10045     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
10046     ASSERT_NE(photoOutput, nullptr);
10047     intResult = portraitSession->AddOutput(photoOutput);
10048     EXPECT_EQ(intResult, 0);
10049 
10050     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
10051     ASSERT_NE(profile.format_, -1);
10052     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
10053     ASSERT_NE(previewOutput, nullptr);
10054     intResult = portraitSession->AddOutput(previewOutput);
10055     EXPECT_EQ(intResult, 0);
10056 
10057     intResult = portraitSession->CommitConfig();
10058     EXPECT_EQ(intResult, 0);
10059 
10060     portraitSession->LockForControl();
10061 
10062     std::vector<BeautyType> beautyLists = portraitSession->GetSupportedBeautyTypes();
10063     EXPECT_GE(beautyLists.size(), 0);
10064 
10065     if (beautyLists.size() == 1) {
10066         std::vector<int32_t> rangeLists = portraitSession->GetSupportedBeautyRange(beautyLists[0]);
10067         EXPECT_NE(rangeLists.size(), 0);
10068         bool boolResult = portraitSession->SetBeautyValue(beautyLists[0], rangeLists[0]);
10069         EXPECT_TRUE(boolResult);
10070     }
10071 
10072     portraitSession->UnlockForControl();
10073 }
10074 
10075 /* Feature: Framework
10076  * Function: Test preview/capture with portrait session's beauty
10077  * SubFunction: NA
10078  * FunctionPoints: NA
10079  * EnvConditions: NA
10080  * CaseDescription: Test preview/capture with portrait session's beauty
10081  */
10082 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_058, TestSize.Level0)
10083 {
10084     SceneMode nightMode = SceneMode::NIGHT;
10085     if (!IsSupportMode(nightMode)) {
10086         return;
10087     }
10088     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
10089     ASSERT_NE(modeManagerObj, nullptr);
10090 
10091     std::vector<SceneMode> modes = modeManagerObj->GetSupportedModes(cameras_[0]);
10092     ASSERT_TRUE(modes.size() != 0);
10093 
10094     sptr<CameraOutputCapability> modeAbility =
10095         modeManagerObj->GetSupportedOutputCapability(cameras_[0], nightMode);
10096     ASSERT_NE(modeAbility, nullptr);
10097 
10098     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(nightMode);
10099     ASSERT_NE(captureSession, nullptr);
10100     sptr<NightSession> nightSession = static_cast<NightSession*>(captureSession.GetRefPtr());
10101     ASSERT_NE(nightSession, nullptr);
10102 
10103     int32_t intResult = nightSession->BeginConfig();
10104     EXPECT_EQ(intResult, 0);
10105 
10106     intResult = nightSession->AddInput(input_);
10107     EXPECT_EQ(intResult, 0);
10108 
10109     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
10110     ASSERT_NE(photoOutput, nullptr);
10111 
10112     intResult = nightSession->AddOutput(photoOutput);
10113     EXPECT_EQ(intResult, 0);
10114 
10115     intResult = nightSession->CommitConfig();
10116     EXPECT_EQ(intResult, 0);
10117 
10118     std::vector<uint32_t> exposureRange = {};
10119 
10120     intResult = nightSession->GetExposureRange(exposureRange);
10121     EXPECT_EQ(intResult, 0);
10122 
10123     EXPECT_NE(exposureRange.size(), 0);
10124 
10125     if (!exposureRange.empty()) {
10126         nightSession->LockForControl();
10127         EXPECT_EQ(nightSession->SetExposure(exposureRange[0]), 0);
10128         nightSession->UnlockForControl();
10129         uint32_t manulExposure = 0;
10130         EXPECT_EQ(nightSession->GetExposure(manulExposure), 0);
10131         EXPECT_EQ(manulExposure, exposureRange[0]);
10132     }
10133 }
10134 
10135 /*
10136  * Feature: Framework
10137  * Function: Test set default color space
10138  * SubFunction: NA
10139  * FunctionPoints: NA
10140  * EnvConditions: NA
10141  * CaseDescription: Test set default color space
10142  */
10143 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_059, TestSize.Level0)
10144 {
10145     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
10146     camInput->Open();
10147 
10148     session_->SetMode(SceneMode::CAPTURE);
10149     int32_t intResult = session_->BeginConfig();
10150 
10151     EXPECT_EQ(intResult, 0);
10152 
10153     intResult = session_->AddInput(input_);
10154     EXPECT_EQ(intResult, 0);
10155 
10156     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
10157     ASSERT_NE(previewOutput, nullptr);
10158 
10159     intResult = session_->AddOutput(previewOutput);
10160     EXPECT_EQ(intResult, 0);
10161 
10162     intResult = session_->CommitConfig();
10163     EXPECT_EQ(intResult, 0);
10164 
10165     std::vector<ColorSpace> colorSpaceLists = session_->GetSupportedColorSpaces();
10166     if (colorSpaceLists.size() != 0) {
10167         ColorSpace colorSpace;
10168         intResult = session_->GetActiveColorSpace(colorSpace);
10169         EXPECT_EQ(intResult, 0);
10170         EXPECT_EQ(colorSpaceLists[0], colorSpace);
10171     }
10172 
10173     intResult = session_->Start();
10174     EXPECT_EQ(intResult, 0);
10175 
10176     sleep(WAIT_TIME_AFTER_START);
10177 
10178     intResult = session_->Stop();
10179     EXPECT_EQ(intResult, 0);
10180 }
10181 
10182 /*
10183  * Feature: Framework
10184  * Function: Test set color space before commitConfig
10185  * SubFunction: NA
10186  * FunctionPoints: NA
10187  * EnvConditions: NA
10188  * CaseDescription: Test set default color space
10189  */
10190 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_060, TestSize.Level0)
10191 {
10192     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
10193     camInput->Open();
10194 
10195     session_->SetMode(SceneMode::CAPTURE);
10196     int32_t intResult = session_->BeginConfig();
10197 
10198     EXPECT_EQ(intResult, 0);
10199 
10200     intResult = session_->AddInput(input_);
10201     EXPECT_EQ(intResult, 0);
10202 
10203     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
10204     ASSERT_NE(previewOutput, nullptr);
10205 
10206     intResult = session_->AddOutput(previewOutput);
10207     EXPECT_EQ(intResult, 0);
10208 
10209     std::vector<ColorSpace> colorSpaceLists = session_->GetSupportedColorSpaces();
10210     if (colorSpaceLists.size() != 0) {
10211         intResult = session_->SetColorSpace(colorSpaceLists[1]);
10212         EXPECT_EQ(intResult, 0);
10213         ColorSpace colorSpace;
10214         intResult = session_->GetActiveColorSpace(colorSpace);
10215         EXPECT_EQ(intResult, 0);
10216         EXPECT_EQ(colorSpaceLists[1], colorSpace);
10217     }
10218 
10219     intResult = session_->CommitConfig();
10220     EXPECT_EQ(intResult, 0);
10221 
10222     intResult = session_->Start();
10223     EXPECT_EQ(intResult, 0);
10224 
10225     sleep(WAIT_TIME_AFTER_START);
10226 
10227     intResult = session_->Stop();
10228     EXPECT_EQ(intResult, 0);
10229 }
10230 
10231 /*
10232  * Feature: Framework
10233  * Function: Test set color space after commitConfig
10234  * SubFunction: NA
10235  * FunctionPoints: NA
10236  * EnvConditions: NA
10237  * CaseDescription: Test set default color space
10238  */
10239 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_061, TestSize.Level0)
10240 {
10241     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
10242     camInput->Open();
10243 
10244     session_->SetMode(SceneMode::CAPTURE);
10245     int32_t intResult = session_->BeginConfig();
10246 
10247     EXPECT_EQ(intResult, 0);
10248 
10249     intResult = session_->AddInput(input_);
10250     EXPECT_EQ(intResult, 0);
10251 
10252     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
10253     ASSERT_NE(previewOutput, nullptr);
10254 
10255     intResult = session_->AddOutput(previewOutput);
10256     EXPECT_EQ(intResult, 0);
10257 
10258     intResult = session_->CommitConfig();
10259     EXPECT_EQ(intResult, 0);
10260 
10261 
10262     std::vector<ColorSpace> colorSpaceLists = session_->GetSupportedColorSpaces();
10263     if (colorSpaceLists.size() != 0) {
10264         intResult = session_->SetColorSpace(colorSpaceLists[1]);
10265         EXPECT_EQ(intResult, 0);
10266         ColorSpace colorSpace;
10267         intResult = session_->GetActiveColorSpace(colorSpace);
10268         EXPECT_EQ(intResult, 0);
10269         EXPECT_EQ(colorSpaceLists[1], colorSpace);
10270     }
10271 
10272     intResult = session_->Start();
10273     EXPECT_EQ(intResult, 0);
10274 
10275     sleep(WAIT_TIME_AFTER_START);
10276 
10277     intResult = session_->Stop();
10278     EXPECT_EQ(intResult, 0);
10279 }
10280 
10281 /*
10282  * Feature: Framework
10283  * Function: Test set color space after session start
10284  * SubFunction: NA
10285  * FunctionPoints: NA
10286  * EnvConditions: NA
10287  * CaseDescription: Test set default color space
10288  */
10289 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_062, TestSize.Level0)
10290 {
10291     sptr<CameraInput> camInput = (sptr<CameraInput>&)input_;
10292     camInput->Open();
10293 
10294     session_->SetMode(SceneMode::CAPTURE);
10295     int32_t intResult = session_->BeginConfig();
10296 
10297     EXPECT_EQ(intResult, 0);
10298 
10299     intResult = session_->AddInput(input_);
10300     EXPECT_EQ(intResult, 0);
10301 
10302     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
10303     ASSERT_NE(previewOutput, nullptr);
10304 
10305     intResult = session_->AddOutput(previewOutput);
10306     EXPECT_EQ(intResult, 0);
10307 
10308     intResult = session_->CommitConfig();
10309     EXPECT_EQ(intResult, 0);
10310 
10311     intResult = session_->Start();
10312     EXPECT_EQ(intResult, 0);
10313 
10314     std::vector<ColorSpace> colorSpaceLists = session_->GetSupportedColorSpaces();
10315     if (colorSpaceLists.size() != 0) {
10316         intResult = session_->SetColorSpace(colorSpaceLists[1]);
10317         EXPECT_EQ(intResult, 0);
10318         ColorSpace colorSpace;
10319         intResult = session_->GetActiveColorSpace(colorSpace);
10320         EXPECT_EQ(intResult, 0);
10321         EXPECT_EQ(colorSpaceLists[1], colorSpace);
10322     }
10323 
10324     sleep(WAIT_TIME_AFTER_START);
10325 
10326     intResult = session_->Stop();
10327     EXPECT_EQ(intResult, 0);
10328 }
10329 
10330 /*
10331  * Feature: Framework
10332  * Function: Test macro and sketch function.
10333  * SubFunction: NA
10334  * FunctionPoints: NA
10335  * EnvConditions: NA
10336  * CaseDescription: Test macro and sketch function.
10337  */
10338 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_063, TestSize.Level0)
10339 {
10340     auto previewProfile = GetSketchPreviewProfile();
10341     if (previewProfile == nullptr) {
10342         EXPECT_EQ(previewProfile.get(), nullptr);
10343         return;
10344     }
10345     auto output = CreatePreviewOutput(*previewProfile);
10346     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10347     ASSERT_NE(output, nullptr);
10348 
10349     session_->SetMode(SceneMode::VIDEO);
10350     int32_t intResult = session_->BeginConfig();
10351 
10352     EXPECT_EQ(intResult, 0);
10353 
10354     intResult = session_->AddInput(input_);
10355     EXPECT_EQ(intResult, 0);
10356 
10357     intResult = session_->AddOutput(output);
10358     EXPECT_EQ(intResult, 0);
10359 
10360     bool isSketchSupported = previewOutput->IsSketchSupported();
10361     if (!isSketchSupported) {
10362         return;
10363     }
10364 
10365     previewOutput->EnableSketch(true);
10366     EXPECT_EQ(intResult, 0);
10367 
10368     intResult = session_->CommitConfig();
10369     EXPECT_EQ(intResult, 0);
10370 
10371     bool isMacroSupported = session_->IsMacroSupported();
10372     if (!isMacroSupported) {
10373         return;
10374     }
10375 
10376     intResult = session_->Start();
10377     EXPECT_EQ(intResult, 0);
10378 
10379     sleep(WAIT_TIME_AFTER_START);
10380 
10381     // Video mode don't support sketch, but MacroVideo mode supported.
10382     float sketchRatio = previewOutput->GetSketchRatio();
10383     EXPECT_LT(sketchRatio, 0);
10384 
10385     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10386     EXPECT_EQ(intResult, 0);
10387 
10388     session_->LockForControl();
10389     intResult = session_->EnableMacro(true);
10390     session_->UnlockForControl();
10391     EXPECT_EQ(intResult, 0);
10392 
10393     sleep(WAIT_TIME_AFTER_START);
10394 
10395     // Now we are in MacroVideo mode
10396     sketchRatio = previewOutput->GetSketchRatio();
10397     EXPECT_GT(sketchRatio, 0);
10398 
10399     session_->LockForControl();
10400     intResult = session_->EnableMacro(false);
10401     session_->UnlockForControl();
10402     EXPECT_EQ(intResult, 0);
10403 
10404     sleep(WAIT_TIME_AFTER_START);
10405 
10406     // Now we are in Video mode
10407     sketchRatio = previewOutput->GetSketchRatio();
10408     EXPECT_LT(sketchRatio, 0);
10409 
10410     sleep(WAIT_TIME_AFTER_START);
10411 
10412     intResult = session_->Stop();
10413     EXPECT_EQ(intResult, 0);
10414 }
10415 
10416 /*
10417  * Feature: Camera pre_switch test
10418  * Function: Test preSwitch interface
10419  * SubFunction: NA
10420  * FunctionPoints: NA
10421  * EnvConditions: NA
10422  * CaseDescription: Test preSwitch interface
10423  */
10424 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_064, TestSize.Level0)
10425 {
10426     if (cameras_.size() <= 1) {
10427         EXPECT_LT(cameras_.size(), 2);
10428         return;
10429     }
10430 
10431     manager_->PreSwitchCamera(cameras_[1]->GetID());
10432 
10433     int32_t intResult = session_->BeginConfig();
10434     EXPECT_EQ(intResult, 0);
10435 
10436     intResult = session_->AddInput(input_);
10437     EXPECT_EQ(intResult, 0);
10438 
10439     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
10440     ASSERT_NE(previewOutput, nullptr);
10441 
10442     intResult = session_->AddOutput(previewOutput);
10443     EXPECT_EQ(intResult, 0);
10444 
10445     intResult = session_->CommitConfig();
10446     EXPECT_EQ(intResult, 0);
10447 
10448     intResult = session_->Start();
10449     EXPECT_EQ(intResult, 0);
10450 
10451     sleep(WAIT_TIME_AFTER_START);
10452 
10453     intResult = session_->Stop();
10454     EXPECT_EQ(intResult, 0);
10455 }
10456 
10457 /*
10458  * Feature: Camera sketch add output output with guess mode
10459  * Function: Test sketch add output with guess mode
10460  * SubFunction: NA
10461  * FunctionPoints: NA
10462  * EnvConditions: NA
10463  * CaseDescription: Test sketch add output with guess mode
10464  */
10465 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_065, TestSize.Level0)
10466 {
10467     auto previewProfile = GetSketchPreviewProfile();
10468     if (previewProfile == nullptr) {
10469         EXPECT_EQ(previewProfile.get(), nullptr);
10470         return;
10471     }
10472     auto output = CreatePreviewOutput(*previewProfile);
10473     ASSERT_NE(output, nullptr);
10474 
10475     int32_t intResult = session_->BeginConfig();
10476     EXPECT_EQ(intResult, 0);
10477 
10478     intResult = session_->AddInput(input_);
10479     EXPECT_EQ(intResult, 0);
10480 
10481     intResult = session_->AddOutput(output);
10482     EXPECT_EQ(intResult, 0);
10483 
10484     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10485     bool isSketchSupport = previewOutput->IsSketchSupported();
10486     if (!isSketchSupport) {
10487         return;
10488     }
10489 
10490     int sketchEnableRatio = previewOutput->GetSketchRatio();
10491     EXPECT_GT(sketchEnableRatio, 0);
10492 
10493     intResult = previewOutput->EnableSketch(true);
10494     EXPECT_EQ(intResult, 0);
10495 
10496     intResult = session_->CommitConfig();
10497     EXPECT_EQ(intResult, 0);
10498 
10499     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10500     EXPECT_EQ(intResult, 0);
10501 
10502     intResult = session_->Start();
10503     EXPECT_EQ(intResult, 0);
10504 
10505     sleep(WAIT_TIME_AFTER_START);
10506 
10507     intResult = session_->Stop();
10508     EXPECT_EQ(intResult, 0);
10509 }
10510 
10511 /*
10512  * Feature: Test add released output
10513  * Function: Test add released output
10514  * SubFunction: NA
10515  * FunctionPoints: NA
10516  * EnvConditions: NA
10517  * CaseDescription: Test add released output
10518  */
10519 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_066, TestSize.Level0)
10520 {
10521     auto previewProfile = GetSketchPreviewProfile();
10522     if (previewProfile == nullptr) {
10523         EXPECT_EQ(previewProfile.get(), nullptr);
10524         return;
10525     }
10526     auto previewOutput = CreatePreviewOutput(*previewProfile);
10527     ASSERT_NE(previewOutput, nullptr);
10528 
10529     auto captureOutput = CreatePhotoOutput();
10530     EXPECT_NE(captureOutput, nullptr);
10531 
10532     int32_t intResult = session_->BeginConfig();
10533     EXPECT_EQ(intResult, 0);
10534 
10535     intResult = session_->AddInput(input_);
10536     EXPECT_EQ(intResult, 0);
10537 
10538     intResult = session_->AddOutput(previewOutput);
10539     EXPECT_EQ(intResult, 0);
10540 
10541     intResult = session_->AddOutput(captureOutput);
10542     EXPECT_EQ(intResult, 0);
10543 
10544     intResult = session_->CommitConfig();
10545     EXPECT_EQ(intResult, 0);
10546 
10547     intResult = session_->Start();
10548     EXPECT_EQ(intResult, 0);
10549 
10550     sleep(WAIT_TIME_AFTER_START);
10551 
10552     intResult = session_->Stop();
10553     EXPECT_EQ(intResult, 0);
10554 
10555     intResult = session_->BeginConfig();
10556     EXPECT_EQ(intResult, 0);
10557 
10558     intResult = session_->RemoveOutput(captureOutput);
10559     EXPECT_EQ(intResult, 0);
10560 
10561     intResult = captureOutput->Release();
10562     EXPECT_EQ(intResult, 0);
10563 
10564     intResult = session_->AddOutput(captureOutput);
10565     EXPECT_EQ(intResult, 7400201);
10566 }
10567 
10568 /*
10569  * Feature: Framework
10570  * Function: Test smooth zoom and sketch functions callback.
10571  * SubFunction: NA
10572  * FunctionPoints: NA
10573  * EnvConditions: NA
10574  * CaseDescription: Test smooth zoom and sketch functions.
10575  */
10576 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_067, TestSize.Level0)
10577 {
10578     auto previewProfile = GetSketchPreviewProfile();
10579     if (previewProfile == nullptr) {
10580         EXPECT_EQ(previewProfile.get(), nullptr);
10581         return;
10582     }
10583     auto output = CreatePreviewOutput(*previewProfile);
10584     ASSERT_NE(output, nullptr);
10585 
10586     session_->SetMode(SceneMode::CAPTURE);
10587     int32_t intResult = session_->BeginConfig();
10588     EXPECT_EQ(intResult, 0);
10589 
10590     intResult = session_->AddInput(input_);
10591     EXPECT_EQ(intResult, 0);
10592 
10593     intResult = session_->AddOutput(output);
10594     EXPECT_EQ(intResult, 0);
10595 
10596     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10597     bool isSketchSupport = previewOutput->IsSketchSupported();
10598     if (!isSketchSupport) {
10599         return;
10600     }
10601 
10602     previewOutput->SetCallback(std::make_shared<AppCallback>());
10603 
10604     int sketchEnableRatio = previewOutput->GetSketchRatio();
10605     EXPECT_GT(sketchEnableRatio, 0);
10606 
10607     intResult = previewOutput->EnableSketch(true);
10608     EXPECT_EQ(intResult, 0);
10609 
10610     intResult = session_->CommitConfig();
10611     EXPECT_EQ(intResult, 0);
10612 
10613     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10614     EXPECT_EQ(intResult, 0);
10615 
10616     intResult = session_->Start();
10617     EXPECT_EQ(intResult, 0);
10618 
10619     sleep(WAIT_TIME_AFTER_START);
10620 
10621     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
10622 
10623     session_->LockForControl();
10624     intResult = session_->SetSmoothZoom(30.0f, 0);
10625     EXPECT_EQ(intResult, 0);
10626     session_->UnlockForControl();
10627 
10628     sleep(WAIT_TIME_AFTER_START);
10629 
10630     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 1);
10631     g_previewEvents.reset();
10632 
10633     sleep(WAIT_TIME_AFTER_START);
10634     auto statusSize = g_sketchStatus.size();
10635     EXPECT_EQ(statusSize, 2);
10636     if (statusSize == 2) {
10637         EXPECT_EQ(g_sketchStatus.front(), 3);
10638         g_sketchStatus.pop_front();
10639         EXPECT_EQ(g_sketchStatus.front(), 1);
10640         g_sketchStatus.pop_front();
10641     }
10642 
10643     sleep(1);
10644     EXPECT_EQ(g_previewEvents[static_cast<int>(CAM_PREVIEW_EVENTS::CAM_PREVIEW_SKETCH_STATUS_CHANGED)], 0);
10645 
10646     intResult = session_->Stop();
10647     EXPECT_EQ(intResult, 0);
10648 }
10649 
10650 
10651 /*
10652  * Feature: Framework
10653  * Function: Test moon capture boost function.
10654  * SubFunction: NA
10655  * FunctionPoints: NA
10656  * EnvConditions: NA
10657  * CaseDescription: Test moon capture boost function.
10658  */
10659 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_068, TestSize.Level0)
10660 {
10661     auto previewProfile = GetSketchPreviewProfile();
10662     if (previewProfile == nullptr) {
10663         EXPECT_EQ(previewProfile.get(), nullptr);
10664         return;
10665     }
10666     auto output = CreatePreviewOutput(*previewProfile);
10667     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10668     ASSERT_NE(output, nullptr);
10669 
10670     session_->SetMode(SceneMode::CAPTURE);
10671     int32_t intResult = session_->BeginConfig();
10672 
10673     EXPECT_EQ(intResult, 0);
10674 
10675     intResult = session_->AddInput(input_);
10676     EXPECT_EQ(intResult, 0);
10677 
10678     intResult = session_->AddOutput(output);
10679     EXPECT_EQ(intResult, 0);
10680 
10681     intResult = session_->CommitConfig();
10682     EXPECT_EQ(intResult, 0);
10683 
10684     session_->SetFeatureDetectionStatusCallback(std::make_shared<AppCallback>());
10685 
10686     g_moonCaptureBoostEvents.reset();
10687     intResult = session_->Start();
10688     EXPECT_EQ(intResult, 0);
10689 
10690     sleep(WAIT_TIME_AFTER_START);
10691 
10692     bool isMoonCaptureBoostSupported = session_->IsFeatureSupported(FEATURE_MOON_CAPTURE_BOOST);
10693     if (isMoonCaptureBoostSupported) {
10694         EXPECT_EQ(g_moonCaptureBoostEvents.count(), 1);
10695         if (g_moonCaptureBoostEvents[static_cast<int>(
10696                 CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_ACTIVE)] == 1) {
10697             intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, true);
10698             EXPECT_EQ(intResult, 0);
10699         }
10700         if (g_moonCaptureBoostEvents[static_cast<int>(
10701                 CAM_MOON_CAPTURE_BOOST_EVENTS::CAM_MOON_CAPTURE_BOOST_EVENT_IDLE)] == 1) {
10702             intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, false);
10703             EXPECT_EQ(intResult, 0);
10704         }
10705     }
10706 
10707     sleep(WAIT_TIME_AFTER_START);
10708 
10709     intResult = session_->Stop();
10710     EXPECT_EQ(intResult, 0);
10711 }
10712 
10713 /*
10714  * Feature: Framework
10715  * Function: Test moon capture boost function anomalous branch..
10716  * SubFunction: NA
10717  * FunctionPoints: NA
10718  * EnvConditions: NA
10719  * CaseDescription: Test moon capture boost function anomalous branch..
10720  */
10721 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_069, TestSize.Level0)
10722 {
10723     auto previewProfile = GetSketchPreviewProfile();
10724     if (previewProfile == nullptr) {
10725         EXPECT_EQ(previewProfile.get(), nullptr);
10726         return;
10727     }
10728     auto output = CreatePreviewOutput(*previewProfile);
10729     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10730     ASSERT_NE(output, nullptr);
10731 
10732     session_->SetMode(SceneMode::VIDEO);
10733     int32_t intResult = session_->BeginConfig();
10734 
10735     EXPECT_EQ(intResult, 0);
10736 
10737     intResult = session_->AddInput(input_);
10738     EXPECT_EQ(intResult, 0);
10739 
10740     intResult = session_->AddOutput(output);
10741     EXPECT_EQ(intResult, 0);
10742 
10743     bool isMoonCaptureBoostSupported = session_->IsFeatureSupported(FEATURE_MOON_CAPTURE_BOOST);
10744     EXPECT_FALSE(isMoonCaptureBoostSupported);
10745 
10746     intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, true);
10747     EXPECT_EQ(intResult, 7400102);
10748 
10749     intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, false);
10750     EXPECT_EQ(intResult, 7400102);
10751 
10752     session_->SetMode(SceneMode::CAPTURE);
10753     isMoonCaptureBoostSupported = session_->IsFeatureSupported(FEATURE_MOON_CAPTURE_BOOST);
10754     if (isMoonCaptureBoostSupported) {
10755         intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, true);
10756         EXPECT_EQ(intResult, 7400103);
10757     }
10758 
10759     intResult = session_->CommitConfig();
10760     EXPECT_EQ(intResult, 0);
10761 
10762     isMoonCaptureBoostSupported = session_->IsFeatureSupported(FEATURE_MOON_CAPTURE_BOOST);
10763     if (!isMoonCaptureBoostSupported) {
10764         intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, true);
10765         EXPECT_EQ(intResult, 7400102);
10766     }
10767     session_->SetFeatureDetectionStatusCallback(std::make_shared<AppCallback>());
10768 
10769     intResult = session_->Start();
10770     EXPECT_EQ(intResult, 0);
10771 
10772     sleep(WAIT_TIME_AFTER_START);
10773 
10774     intResult = session_->Stop();
10775     EXPECT_EQ(intResult, 0);
10776 }
10777 
10778 /*
10779  * Feature: Framework
10780  * Function: Test moon capture boost and sketch function.
10781  * SubFunction: NA
10782  * FunctionPoints: NA
10783  * EnvConditions: NA
10784  * CaseDescription: Test moon capture boost and sketch function.
10785  */
10786 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_070, TestSize.Level0)
10787 {
10788     auto previewProfile = GetSketchPreviewProfile();
10789     if (previewProfile == nullptr) {
10790         EXPECT_EQ(previewProfile.get(), nullptr);
10791         return;
10792     }
10793     auto output = CreatePreviewOutput(*previewProfile);
10794     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10795     ASSERT_NE(output, nullptr);
10796 
10797     session_->SetMode(SceneMode::NORMAL);
10798     int32_t intResult = session_->BeginConfig();
10799 
10800     EXPECT_EQ(intResult, 0);
10801 
10802     intResult = session_->AddInput(input_);
10803     EXPECT_EQ(intResult, 0);
10804 
10805     intResult = session_->AddOutput(output);
10806     EXPECT_EQ(intResult, 0);
10807 
10808     bool isSketchSupported = previewOutput->IsSketchSupported();
10809     if (!isSketchSupported) {
10810         return;
10811     }
10812 
10813     previewOutput->EnableSketch(true);
10814     EXPECT_EQ(intResult, 0);
10815 
10816     intResult = session_->CommitConfig();
10817     EXPECT_EQ(intResult, 0);
10818 
10819     bool isMoonCaptureBoostSupported = session_->IsFeatureSupported(FEATURE_MOON_CAPTURE_BOOST);
10820     if (!isMoonCaptureBoostSupported) {
10821         return;
10822     }
10823 
10824     intResult = session_->Start();
10825     EXPECT_EQ(intResult, 0);
10826 
10827     sleep(WAIT_TIME_AFTER_START);
10828 
10829     float sketchRatio = previewOutput->GetSketchRatio();
10830     EXPECT_GT(sketchRatio, 0);
10831 
10832     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10833     EXPECT_EQ(intResult, 0);
10834 
10835     intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, true);
10836     EXPECT_EQ(intResult, 0);
10837 
10838     sleep(WAIT_TIME_AFTER_START);
10839 
10840     sketchRatio = previewOutput->GetSketchRatio();
10841     EXPECT_GT(sketchRatio, 0);
10842 
10843     intResult = session_->EnableFeature(FEATURE_MOON_CAPTURE_BOOST, false);
10844     EXPECT_EQ(intResult, 0);
10845 
10846     sleep(WAIT_TIME_AFTER_START);
10847 
10848     sketchRatio = previewOutput->GetSketchRatio();
10849     EXPECT_GT(sketchRatio, 0);
10850 
10851     sleep(WAIT_TIME_AFTER_START);
10852 
10853     intResult = session_->Stop();
10854     EXPECT_EQ(intResult, 0);
10855 }
10856 
10857 /*
10858  * Feature: Framework
10859  * Function: Test super macro photo session.
10860  * SubFunction: NA
10861  * FunctionPoints: NA
10862  * EnvConditions: NA
10863  * CaseDescription: Test super macro photo session.
10864  */
10865 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_071, TestSize.Level0)
10866 {
10867     auto previewProfile = GetSketchPreviewProfile();
10868     if (previewProfile == nullptr) {
10869         EXPECT_EQ(previewProfile.get(), nullptr);
10870         return;
10871     }
10872     auto output = CreatePreviewOutput(*previewProfile);
10873     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10874     ASSERT_NE(output, nullptr);
10875 
10876     session_ = manager_->CreateCaptureSession(SceneMode::CAPTURE_MACRO);
10877     int32_t intResult = session_->BeginConfig();
10878 
10879     EXPECT_EQ(intResult, 0);
10880 
10881     intResult = session_->AddInput(input_);
10882     EXPECT_EQ(intResult, 0);
10883 
10884     intResult = session_->AddOutput(output);
10885     EXPECT_EQ(intResult, 0);
10886 
10887     bool isSketchSupported = previewOutput->IsSketchSupported();
10888     EXPECT_TRUE(isSketchSupported);
10889     if (!isSketchSupported) {
10890         return;
10891     }
10892 
10893     previewOutput->EnableSketch(true);
10894     EXPECT_EQ(intResult, 0);
10895 
10896     intResult = session_->CommitConfig();
10897     EXPECT_EQ(intResult, 0);
10898 
10899     intResult = session_->Start();
10900     EXPECT_EQ(intResult, 0);
10901 
10902     sleep(WAIT_TIME_AFTER_START);
10903 
10904     float sketchRatio = previewOutput->GetSketchRatio();
10905     EXPECT_GT(sketchRatio, 0);
10906 
10907     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10908     EXPECT_EQ(intResult, 0);
10909 
10910     sleep(WAIT_TIME_AFTER_START);
10911 
10912     intResult = session_->Stop();
10913     EXPECT_EQ(intResult, 0);
10914 }
10915 
10916 /*
10917  * Feature: Framework
10918  * Function: Test super macro video session.
10919  * SubFunction: NA
10920  * FunctionPoints: NA
10921  * EnvConditions: NA
10922  * CaseDescription: Test super macro video session.
10923  */
10924 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_072, TestSize.Level0)
10925 {
10926     auto previewProfile = GetSketchPreviewProfile();
10927     if (previewProfile == nullptr) {
10928         EXPECT_EQ(previewProfile.get(), nullptr);
10929         return;
10930     }
10931     auto output = CreatePreviewOutput(*previewProfile);
10932     sptr<PreviewOutput> previewOutput = (sptr<PreviewOutput>&)output;
10933     ASSERT_NE(output, nullptr);
10934 
10935     sptr<CaptureOutput> videoOutput = CreateVideoOutput();
10936     ASSERT_NE(videoOutput, nullptr);
10937 
10938     session_ = manager_->CreateCaptureSession(SceneMode::VIDEO_MACRO);
10939     int32_t intResult = session_->BeginConfig();
10940 
10941     EXPECT_EQ(intResult, 0);
10942 
10943     intResult = session_->AddInput(input_);
10944     EXPECT_EQ(intResult, 0);
10945 
10946     intResult = session_->AddOutput(output);
10947     EXPECT_EQ(intResult, 0);
10948 
10949     intResult = session_->AddOutput(videoOutput);
10950     EXPECT_EQ(intResult, 0);
10951 
10952     bool isSketchSupported = previewOutput->IsSketchSupported();
10953     EXPECT_TRUE(isSketchSupported);
10954     if (!isSketchSupported) {
10955         return;
10956     }
10957 
10958     previewOutput->EnableSketch(true);
10959     EXPECT_EQ(intResult, 0);
10960 
10961     intResult = session_->CommitConfig();
10962     EXPECT_EQ(intResult, 0);
10963 
10964     intResult = session_->Start();
10965     EXPECT_EQ(intResult, 0);
10966 
10967     sleep(WAIT_TIME_AFTER_START);
10968 
10969     float sketchRatio = previewOutput->GetSketchRatio();
10970     EXPECT_GT(sketchRatio, 0);
10971 
10972     intResult = previewOutput->AttachSketchSurface(CreateSketchSurface(previewProfile->GetCameraFormat()));
10973     EXPECT_EQ(intResult, 0);
10974 
10975     sleep(WAIT_TIME_AFTER_START);
10976 
10977     intResult = session_->Stop();
10978     EXPECT_EQ(intResult, 0);
10979 }
10980 
10981 /*
10982  * Feature: Framework
10983  * Function: Test high-res photo session.
10984  * SubFunction: NA
10985  * FunctionPoints: NA
10986  * EnvConditions: NA
10987  * CaseDescription: Test high-res photo session capture.
10988  */
10989 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_073, TestSize.Level0)
10990 {
10991     if (!IsSupportNow()) {
10992         return;
10993     }
10994     sptr<CaptureOutput> previewOutput;
10995     sptr<CaptureOutput> photoOutput;
10996     ConfigHighResSession(previewOutput, photoOutput);
10997 
10998     int32_t intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
10999     EXPECT_EQ(intResult, 0);
11000 
11001     sleep(WAIT_TIME_AFTER_START);
11002 
11003     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
11004     EXPECT_EQ(intResult, 0);
11005 
11006     sleep(WAIT_TIME_AFTER_START);
11007 
11008     intResult = ((sptr<PreviewOutput>&)previewOutput)->Stop();
11009     EXPECT_EQ(intResult, 0);
11010 
11011     intResult = highResSession_->Release();
11012     EXPECT_EQ(intResult, 0);
11013 }
11014 
11015 /*
11016  * Feature: Framework
11017  * Function: Test high-res photo session.
11018  * SubFunction: NA
11019  * FunctionPoints: NA
11020  * EnvConditions: NA
11021  * CaseDescription: Test high-res photo session setFocusPoint.
11022  */
11023 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_074, TestSize.Level0)
11024 {
11025     if (!IsSupportNow()) {
11026         return;
11027     }
11028     sptr<CaptureOutput> previewOutput;
11029     sptr<CaptureOutput> photoOutput;
11030     ConfigHighResSession(previewOutput, photoOutput);
11031 
11032     Point point = { 1, 1 };
11033     highResSession_->LockForControl();
11034     int32_t setFocusMode = highResSession_->SetFocusPoint(point);
11035     EXPECT_EQ(setFocusMode, 0);
11036     highResSession_->UnlockForControl();
11037 
11038     Point focusPointGet = highResSession_->GetFocusPoint();
11039     EXPECT_EQ(focusPointGet.x, 1);
11040     EXPECT_EQ(focusPointGet.y, 1);
11041 
11042     int32_t intResult = ((sptr<PreviewOutput>&)previewOutput)->Start();
11043     EXPECT_EQ(intResult, 0);
11044 
11045     sleep(WAIT_TIME_AFTER_START);
11046 
11047     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
11048     EXPECT_EQ(intResult, 0);
11049 
11050     sleep(WAIT_TIME_AFTER_START);
11051 
11052     intResult = ((sptr<PreviewOutput>&)previewOutput)->Stop();
11053     EXPECT_EQ(intResult, 0);
11054 
11055     intResult = highResSession_->Release();
11056     EXPECT_EQ(intResult, 0);
11057 }
11058 
11059 /* Feature: Framework
11060  * Function: Test AR Mode
11061  * SubFunction: NA
11062  * FunctionPoints: NA
11063  * EnvConditions: NA
11064  * CaseDescription: Test AR Mode
11065  */
11066 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_075, TestSize.Level0)
11067 {
11068     int32_t intResult = session_->BeginConfig();
11069     EXPECT_EQ(intResult, 0);
11070 
11071     intResult = session_->AddInput(input_);
11072     EXPECT_EQ(intResult, 0);
11073 
11074     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
11075     ASSERT_NE(photoOutput, nullptr);
11076 
11077     intResult = session_->AddOutput(photoOutput);
11078     EXPECT_EQ(intResult, 0);
11079 
11080     uint32_t moduleType;
11081     intResult = session_->GetModuleType(moduleType);
11082     EXPECT_EQ(intResult, 0);
11083 
11084     uint32_t cam0ModuleType = cameras_[0]->GetModuleType();
11085     EXPECT_EQ(moduleType, cam0ModuleType);
11086 
11087     intResult = session_->CommitConfig();
11088     EXPECT_EQ(intResult, 0);
11089 
11090     float minimumFocusDistance = session_->GetMinimumFocusDistance();
11091     MEDIA_INFO_LOG("minimumFocusDistance=%{public}f", minimumFocusDistance);
11092 
11093     std::vector<uint32_t> exposureTimeRange;
11094     intResult = session_->GetSensorExposureTimeRange(exposureTimeRange);
11095     EXPECT_EQ(intResult, 0);
11096 
11097     std::vector<int32_t> sensitivityRange;
11098     intResult = session_->GetSensorSensitivityRange(sensitivityRange);
11099     EXPECT_EQ(intResult, 0);
11100 
11101     session_->LockForControl();
11102 
11103     intResult = session_->SetARMode(true);
11104     EXPECT_EQ(intResult, 0);
11105 
11106     float num = 1.0f;
11107     intResult = session_->SetFocusDistance(num);
11108     EXPECT_EQ(intResult, 0);
11109 
11110     intResult = session_->SetSensorSensitivity(sensitivityRange[0]);
11111     EXPECT_EQ(intResult, 0);
11112 
11113     intResult = session_->SetSensorExposureTime(exposureTimeRange[0]);
11114     EXPECT_EQ(intResult, 0);
11115 
11116     session_->UnlockForControl();
11117 
11118     float recnum;
11119     intResult = session_->GetFocusDistance(recnum);
11120     EXPECT_EQ(intResult, 0);
11121 
11122     uint32_t recSensorExposureTime;
11123     intResult = session_->GetSensorExposureTime(recSensorExposureTime);
11124     EXPECT_EQ(intResult, 0);
11125 }
11126 
11127 /*
11128  * Feature: Framework
11129  * Function: Test set preview frame rate range dynamical
11130  * SubFunction: NA
11131  * FunctionPoints: NA
11132  * EnvConditions: NA
11133  * CaseDescription: Test set preview frame rate range dynamical
11134  */
11135 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_076, TestSize.Level0)
11136 {
11137     sptr<CaptureOutput> previewOutput;
11138     sptr<CaptureOutput> videoOutput;
11139     ConfigVideoSession(previewOutput, videoOutput);
11140     ASSERT_NE(previewOutput, nullptr);
11141     ASSERT_NE(videoOutput, nullptr);
11142 
11143     int32_t intResult = videoSession_->AddOutput(previewOutput);
11144     EXPECT_EQ(intResult, 0);
11145 
11146     intResult = videoSession_->CommitConfig();
11147     EXPECT_EQ(intResult, 0);
11148 
11149     sptr<PreviewOutput> previewOutputTrans = ((sptr<PreviewOutput>&)previewOutput);
11150     intResult = previewOutputTrans->Start();
11151     EXPECT_EQ(intResult, 0);
11152 
11153     sleep(WAIT_TIME_AFTER_START);
11154 
11155     std::vector<std::vector<int32_t>> supportedFrameRateArray = previewOutputTrans->GetSupportedFrameRates();
11156     ASSERT_NE(supportedFrameRateArray.size(), 0);
11157     int32_t maxFpsTobeSet = 0;
11158     for (auto item : supportedFrameRateArray) {
11159         if (item[1] != 0) {
11160             maxFpsTobeSet = item[1];
11161         }
11162         cout << "supported: " << item[0] << item[1] <<endl;
11163     }
11164 
11165     std::vector<int32_t> activeFrameRateRange = previewOutputTrans->GetFrameRateRange();
11166     ASSERT_NE(activeFrameRateRange.size(), 0);
11167     EXPECT_EQ(activeFrameRateRange[0], 0);
11168     EXPECT_EQ(activeFrameRateRange[1], 0);
11169 
11170     intResult = previewOutputTrans->SetFrameRate(maxFpsTobeSet, maxFpsTobeSet);
11171     EXPECT_EQ(intResult, 0);
11172 
11173     std::cout<< "set: "<<maxFpsTobeSet<<maxFpsTobeSet<<std::endl;
11174     std::vector<int32_t> currentFrameRateRange = previewOutputTrans->GetFrameRateRange();
11175     EXPECT_EQ(currentFrameRateRange[0], maxFpsTobeSet);
11176     EXPECT_EQ(currentFrameRateRange[1], maxFpsTobeSet);
11177     sleep(WAIT_TIME_AFTER_START);
11178 
11179     intResult = previewOutputTrans->SetFrameRate(15, 15);
11180     EXPECT_EQ(intResult, 0);
11181 
11182     std::cout<< "set: "<<15<<15<<std::endl;
11183     currentFrameRateRange = previewOutputTrans->GetFrameRateRange();
11184     EXPECT_EQ(currentFrameRateRange[0], 15);
11185     EXPECT_EQ(currentFrameRateRange[1], 15);
11186     sleep(WAIT_TIME_AFTER_START);
11187 
11188     intResult = previewOutputTrans->Stop();
11189     EXPECT_EQ(intResult, 0);
11190 
11191     intResult = videoSession_->Start();
11192     EXPECT_EQ(intResult, 0);
11193     sleep(WAIT_TIME_AFTER_START);
11194     intResult = videoSession_->Stop();
11195     EXPECT_EQ(intResult, 0);
11196 }
11197 
11198 /*
11199 * Feature: Framework
11200 * Function: Test normal branch for secure camera
11201 * SubFunction: NA
11202 * FunctionPoints: NA
11203 * EnvConditions: NA
11204 * CaseDescription: Test normal branch for secure camera
11205 */
11206 HWTEST_F(CameraFrameworkModuleTest, camera_framework_securecamera_moduleTest_001, TestSize.Level0)
11207 {
11208     SceneMode secureMode = SceneMode::SECURE;
11209     if (!IsSupportMode(secureMode)) {
11210         return;
11211     }
11212     std::this_thread::sleep_for(std::chrono::seconds(1));
11213     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
11214 
11215     for (sptr<CameraDevice> camDevice : cameras) {
11216         std::vector<SceneMode> modes = manager_->GetSupportedModes(camDevice);
11217         ASSERT_TRUE(modes.size() != 0);
11218 
11219         if (find(modes.begin(), modes.end(), SceneMode::SECURE) != modes.end()) {
11220             sptr<CameraOutputCapability> ability = manager_->
11221             GetSupportedOutputCapability(camDevice, SceneMode::SECURE);
11222             ASSERT_NE(ability, nullptr);
11223 
11224             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::SECURE);
11225             ASSERT_NE(captureSession, nullptr);
11226             sptr<SecureCameraSession> secureSession = nullptr;
11227             secureSession = static_cast<SecureCameraSession *> (captureSession.GetRefPtr());
11228             ASSERT_NE(secureSession, nullptr);
11229             sptr<CaptureInput> inputSecure = manager_->CreateCameraInput(camDevice);
11230             ASSERT_NE(inputSecure, nullptr);
11231 
11232             sptr<CameraInput> inputSecure_ = (sptr<CameraInput>&)inputSecure;
11233             uint64_t secureSeqId = 0;
11234             int intResult = inputSecure_->Open(true, &secureSeqId);
11235             EXPECT_EQ(intResult, 0);
11236             EXPECT_NE(secureSeqId, 0);
11237             std::this_thread::sleep_for(std::chrono::seconds(3));
11238             sptr<CaptureOutput> preview = CreatePreviewOutput();
11239             ASSERT_NE(preview, nullptr);
11240 
11241             EXPECT_EQ(secureSession->BeginConfig(), 0);
11242             EXPECT_EQ(secureSession->AddInput(inputSecure), 0);
11243             EXPECT_EQ(secureSession->AddOutput(preview), 0);
11244             EXPECT_EQ(secureSession->AddSecureOutput(preview), 0);
11245             EXPECT_EQ(secureSession->CommitConfig(), 0);
11246             secureSession->Release();
11247             inputSecure_->Close();
11248             break;
11249         }
11250     }
11251 }
11252 
11253 /*
11254 * Feature: Framework
11255 * Function: Test abnormal branch that is non-securemode while opening securecamera
11256 * SubFunction: NA
11257 * FunctionPoints: NA
11258 * EnvConditions: NA
11259 * CaseDescription: Test abnormal branch that is non-securemode while opening securecamera
11260 */
11261 HWTEST_F(CameraFrameworkModuleTest, camera_framework_securecamera_moduleTest_002, TestSize.Level0)
11262 {
11263     SceneMode secureMode = SceneMode::SECURE;
11264     if (!IsSupportMode(secureMode)) {
11265         return;
11266     }
11267     std::this_thread::sleep_for(std::chrono::seconds(1));
11268     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
11269 
11270     for (sptr<CameraDevice> camDevice : cameras) {
11271         std::vector<SceneMode> modes = manager_->GetSupportedModes(camDevice);
11272         ASSERT_TRUE(modes.size() != 0);
11273 
11274         if (find(modes.begin(), modes.end(), SceneMode::SECURE) != modes.end()) {
11275             sptr<CameraOutputCapability> ability = manager_->
11276                 GetSupportedOutputCapability(camDevice, SceneMode::SECURE);
11277             ASSERT_NE(ability, nullptr);
11278 
11279             sptr<CaptureInput> inputSecure = manager_->CreateCameraInput(camDevice);
11280             ASSERT_NE(inputSecure, nullptr);
11281             sptr<CameraInput> inputSecure_ = (sptr<CameraInput>&)inputSecure;
11282             uint64_t secureSeqId = 0;
11283             int intResult = inputSecure_->Open(true, &secureSeqId);
11284             EXPECT_EQ(intResult, 0);
11285             EXPECT_NE(secureSeqId, 0);
11286 
11287             sptr<CaptureOutput> preview = CreatePreviewOutput();
11288             ASSERT_NE(preview, nullptr);
11289             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::NORMAL);
11290             ASSERT_NE(captureSession, nullptr);
11291 
11292             EXPECT_EQ(captureSession->BeginConfig(), 0);
11293             EXPECT_EQ(captureSession->AddInput(inputSecure), 0);
11294             EXPECT_EQ(captureSession->AddOutput(preview), 0);
11295             EXPECT_EQ(captureSession->CommitConfig(), 7400102);
11296             captureSession->Release();
11297             inputSecure_->Close();
11298             break;
11299         }
11300     }
11301 }
11302 
11303 /*
11304 * Feature: Framework
11305 * Function: Test abnormal branch that is add secure output flag twice
11306 * SubFunction: NA
11307 * FunctionPoints: NA
11308 * EnvConditions: NA
11309 * CaseDescription: Test abnormal branch that is add secure output flag twice
11310 */
11311 HWTEST_F(CameraFrameworkModuleTest, camera_framework_securecamera_moduleTest_003, TestSize.Level0)
11312 {
11313     SceneMode secureMode = SceneMode::SECURE;
11314     if (!IsSupportMode(secureMode)) {
11315         return;
11316     }
11317     std::this_thread::sleep_for(std::chrono::seconds(1));
11318     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
11319 
11320     for (sptr<CameraDevice> camDevice : cameras) {
11321         std::vector<SceneMode> modes = manager_->GetSupportedModes(camDevice);
11322         ASSERT_TRUE(modes.size() != 0);
11323 
11324         if (find(modes.begin(), modes.end(), SceneMode::SECURE) != modes.end()) {
11325             sptr<CameraOutputCapability> ability = manager_->
11326                 GetSupportedOutputCapability(camDevice, SceneMode::SECURE);
11327             ASSERT_NE(ability, nullptr);
11328 
11329             sptr<CaptureInput> inputSecure = manager_->CreateCameraInput(camDevice);
11330             ASSERT_NE(inputSecure, nullptr);
11331             sptr<CameraInput> inputSecure_ = (sptr<CameraInput>&)inputSecure;
11332             uint64_t secureSeqId = 0;
11333             int intResult = inputSecure_->Open(true, &secureSeqId);
11334             EXPECT_EQ(intResult, 0);
11335             EXPECT_NE(secureSeqId, 0);
11336 
11337             sptr<CaptureOutput> preview1 = CreatePreviewOutput();
11338             ASSERT_NE(preview1, nullptr);
11339             sptr<CaptureOutput> preview2 = CreatePreviewOutput();
11340             ASSERT_NE(preview2, nullptr);
11341             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::SECURE);
11342             ASSERT_NE(captureSession, nullptr);
11343             sptr<SecureCameraSession> secureSession = nullptr;
11344             secureSession = static_cast<SecureCameraSession *> (captureSession.GetRefPtr());
11345             ASSERT_NE(secureSession, nullptr);
11346 
11347             EXPECT_EQ(secureSession->BeginConfig(), 0);
11348             EXPECT_EQ(secureSession->AddInput(inputSecure), 0);
11349             EXPECT_EQ(secureSession->AddOutput(preview1), 0);
11350             EXPECT_EQ(secureSession->AddOutput(preview2), 0);
11351             EXPECT_EQ(secureSession->AddSecureOutput(preview1), 0);
11352             EXPECT_EQ(secureSession->AddSecureOutput(preview2), CAMERA_OPERATION_NOT_ALLOWED);
11353             EXPECT_EQ(secureSession->CommitConfig(), 0);
11354             secureSession->Release();
11355             inputSecure_->Close();
11356             break;
11357         }
11358     }
11359 }
11360 
11361 /*
11362 * Feature: Framework
11363 * Function: Test abnormal branch that secure output is added after commiting
11364 * SubFunction: NA
11365 * FunctionPoints: NA
11366 * EnvConditions: NA
11367 * CaseDescription: Test abnormal branch that secure output is added after commiting
11368 */
11369 HWTEST_F(CameraFrameworkModuleTest, camera_framework_securecamera_moduleTest_004, TestSize.Level0)
11370 {
11371     SceneMode secureMode = SceneMode::SECURE;
11372     if (!IsSupportMode(secureMode)) {
11373         return;
11374     }
11375     std::this_thread::sleep_for(std::chrono::seconds(1));
11376     std::vector<sptr<CameraDevice>> cameras = manager_->GetSupportedCameras();
11377 
11378     for (sptr<CameraDevice> camDevice : cameras) {
11379         std::vector<SceneMode> modes = manager_->GetSupportedModes(camDevice);
11380         ASSERT_TRUE(modes.size() != 0);
11381 
11382         if (find(modes.begin(), modes.end(), SceneMode::SECURE) != modes.end()) {
11383             sptr<CameraOutputCapability> ability = manager_->
11384                 GetSupportedOutputCapability(camDevice, SceneMode::SECURE);
11385             ASSERT_NE(ability, nullptr);
11386 
11387             sptr<CaptureInput> inputSecure = manager_->CreateCameraInput(camDevice);
11388             ASSERT_NE(inputSecure, nullptr);
11389             sptr<CameraInput> inputSecure_ = (sptr<CameraInput>&)inputSecure;
11390             uint64_t secureSeqId = 0;
11391             int intResult = inputSecure_->Open(true, &secureSeqId);
11392             EXPECT_EQ(intResult, 0);
11393             EXPECT_NE(secureSeqId, 0);
11394 
11395             sptr<CaptureOutput> preview = CreatePreviewOutput();
11396             ASSERT_NE(preview, nullptr);
11397             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::SECURE);
11398             ASSERT_NE(captureSession, nullptr);
11399             sptr<SecureCameraSession> secureSession = nullptr;
11400             secureSession = static_cast<SecureCameraSession *> (captureSession.GetRefPtr());
11401             ASSERT_NE(secureSession, nullptr);
11402 
11403             EXPECT_EQ(secureSession->BeginConfig(), 0);
11404             EXPECT_EQ(secureSession->AddInput(inputSecure), 0);
11405             EXPECT_EQ(secureSession->AddOutput(preview), 0);
11406             EXPECT_EQ(secureSession->CommitConfig(), 0);
11407             EXPECT_EQ(secureSession->AddSecureOutput(preview), CAMERA_OPERATION_NOT_ALLOWED);
11408             secureSession->Release();
11409             inputSecure_->Close();
11410             break;
11411         }
11412     }
11413 }
11414 
11415 /*
11416  * Feature: Framework
11417  * Function: Test deferred photo
11418  * SubFunction: NA
11419  * FunctionPoints: NA
11420  * EnvConditions: NA
11421  * CaseDescription: Test deferred photo support and enable
11422  */
11423 HWTEST_F(CameraFrameworkModuleTest, deferred_photo_enable, TestSize.Level0)
11424 {
11425     int32_t intResult = session_->BeginConfig();
11426     EXPECT_EQ(intResult, 0);
11427 
11428     intResult = session_->AddInput(input_);
11429     EXPECT_EQ(intResult, 0);
11430 
11431     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
11432     ASSERT_NE(photoOutput, nullptr);
11433 
11434     intResult = session_->AddOutput(photoOutput);
11435     EXPECT_EQ(intResult, 0);
11436 
11437     intResult = ((sptr<PhotoOutput>&)photoOutput)->IsDeferredImageDeliverySupported(
11438         DeferredDeliveryImageType::DELIVERY_PHOTO);
11439     if (intResult != 0) {
11440         MEDIA_DEBUG_LOG("device not support deferred_photo");
11441         return;
11442     }
11443 
11444     ((sptr<PhotoOutput>&)photoOutput)->DeferImageDeliveryFor(DeferredDeliveryImageType::DELIVERY_PHOTO);
11445 
11446     intResult = ((sptr<PhotoOutput>&)photoOutput)->IsDeferredImageDeliveryEnabled(
11447         DeferredDeliveryImageType::DELIVERY_PHOTO);
11448     EXPECT_EQ(intResult, 0);
11449 
11450     intResult = session_->CommitConfig();
11451     EXPECT_EQ(intResult, 0);
11452 
11453     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
11454     EXPECT_EQ(intResult, 0);
11455     sleep(WAIT_TIME_AFTER_DEFERRED_CAPTURE);
11456 
11457     ((sptr<PhotoOutput>&)photoOutput)->Release();
11458 }
11459 
11460 /*
11461  * Feature: Framework
11462  * Function: Test master ai
11463  * SubFunction: NA
11464  * FunctionPoints: NA
11465  * EnvConditions: NA
11466  * CaseDescription: Test master ai
11467  */
11468 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_077, TestSize.Level0)
11469 {
11470     if (!IsSupportNow()) {
11471         return;
11472     }
11473     int32_t intResult = session_->BeginConfig();
11474     EXPECT_EQ(intResult, 0);
11475 
11476     intResult = session_->AddInput(input_);
11477     EXPECT_EQ(intResult, 0);
11478 
11479     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
11480     ASSERT_NE(photoOutput, nullptr);
11481 
11482     intResult = session_->AddOutput(photoOutput);
11483     EXPECT_EQ(intResult, 0);
11484 
11485     intResult = session_->CommitConfig();
11486     EXPECT_EQ(intResult, 0);
11487 
11488     if (session_->IsEffectSuggestionSupported()) {
11489 
11490         std::vector<EffectSuggestionType> supportedTypeList = session_->GetSupportedEffectSuggestionType();
11491         EXPECT_NE(supportedTypeList.size(), 0);
11492 
11493         session_->LockForControl();
11494 
11495         intResult = session_->EnableEffectSuggestion(true);
11496         EXPECT_EQ(intResult, 0);
11497 
11498         std::vector<EffectSuggestionStatus> effectSuggestionStatusList =
11499             {{EffectSuggestionType::EFFECT_SUGGESTION_NONE, false},
11500              {EffectSuggestionType::EFFECT_SUGGESTION_PORTRAIT, true},
11501              {EffectSuggestionType::EFFECT_SUGGESTION_FOOD, false},
11502              {EffectSuggestionType::EFFECT_SUGGESTION_SKY, false},
11503              {EffectSuggestionType::EFFECT_SUGGESTION_SUNRISE_SUNSET, false}};
11504         intResult = session_->SetEffectSuggestionStatus(effectSuggestionStatusList);
11505         EXPECT_EQ(intResult, 0);
11506 
11507         intResult = session_->UpdateEffectSuggestion(EffectSuggestionType::EFFECT_SUGGESTION_PORTRAIT, false);
11508         EXPECT_EQ(intResult, 0);
11509 
11510         session_->UnlockForControl();
11511     }
11512 }
11513 
11514 /*
11515  * Feature: Framework
11516  * Function: Test quick shot photo session create.
11517  * SubFunction: NA
11518  * FunctionPoints: NA
11519  * EnvConditions: NA
11520  * CaseDescription: Test quick shot session photo create.
11521  */
11522 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_078, TestSize.Level0)
11523 {
11524     auto modes = manager_->GetSupportedModes(cameras_[0]);
__anon0f1f2f4b0302(auto& mode) 11525     auto it = std::find_if(modes.begin(), modes.end(), [](auto& mode) { return mode == SceneMode::QUICK_SHOT_PHOTO; });
11526     if (it == modes.end()) {
11527         ASSERT_TRUE(true);
11528         return;
11529     }
11530 
11531     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::QUICK_SHOT_PHOTO);
11532     auto quickShotPhotoSession = static_cast<QuickShotPhotoSession*>(captureSession.GetRefPtr());
11533     ASSERT_NE(quickShotPhotoSession, nullptr);
11534     int32_t intResult = quickShotPhotoSession->BeginConfig();
11535     EXPECT_EQ(intResult, 0);
11536     intResult = quickShotPhotoSession->AddInput(input_);
11537     EXPECT_EQ(intResult, 0);
11538 
11539     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
11540     ASSERT_NE(previewOutput, nullptr);
11541 
11542     intResult = quickShotPhotoSession->AddOutput(previewOutput);
11543     EXPECT_EQ(intResult, 0);
11544 
11545     intResult = quickShotPhotoSession->CommitConfig();
11546     EXPECT_EQ(intResult, 0);
11547 
11548     intResult = quickShotPhotoSession->Start();
11549     EXPECT_EQ(intResult, 0);
11550 
11551     sleep(WAIT_TIME_AFTER_START);
11552 
11553     intResult = quickShotPhotoSession->Stop();
11554     EXPECT_EQ(intResult, 0);
11555 }
11556 
11557 /*
11558  * Feature: Framework
11559  * Function: Test cameraStatus with bundleName
11560  * SubFunction: NA
11561  * FunctionPoints: NA
11562  * EnvConditions: NA
11563  * CaseDescription: Test master ai
11564  */
11565 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_079, TestSize.Level0)
11566 {
11567     if (!IsSupportNow()) {
11568         return;
11569     }
11570     constexpr int32_t waitForCallbackTime = 5;
11571     sleep(waitForCallbackTime);
11572 }
11573 
11574 /*
11575  * Feature: Framework
11576  * Function: Test aperture video session create.
11577  * SubFunction: NA
11578  * FunctionPoints: NA
11579  * EnvConditions: NA
11580  * CaseDescription: Test aperture video session create.
11581  */
11582 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_080, TestSize.Level0)
11583 {
11584     auto modes = manager_->GetSupportedModes(cameras_[0]);
__anon0f1f2f4b0402(auto& mode) 11585     auto it = std::find_if(modes.begin(), modes.end(), [](auto& mode) { return mode == SceneMode::APERTURE_VIDEO; });
11586     if (it == modes.end()) {
11587         ASSERT_TRUE(true);
11588         return;
11589     }
11590     auto outputCapability = manager_->GetSupportedOutputCapability(cameras_[0], SceneMode::APERTURE_VIDEO);
11591     ASSERT_NE(outputCapability, nullptr);
11592     auto previewProfiles = outputCapability->GetPreviewProfiles();
11593     ASSERT_TRUE(!previewProfiles.empty());
11594 
11595     auto videoProfiles = outputCapability->GetVideoProfiles();
11596     ASSERT_TRUE(!videoProfiles.empty());
11597 
11598     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::APERTURE_VIDEO);
11599     auto apertureVideoSession = static_cast<ApertureVideoSession*>(captureSession.GetRefPtr());
11600     ASSERT_NE(apertureVideoSession, nullptr);
11601     int32_t intResult = apertureVideoSession->BeginConfig();
11602     EXPECT_EQ(intResult, 0);
11603     intResult = apertureVideoSession->AddInput(input_);
11604     EXPECT_EQ(intResult, 0);
11605 
11606     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(previewProfiles[0]);
11607     ASSERT_NE(previewOutput, nullptr);
11608 
11609     intResult = apertureVideoSession->AddOutput(previewOutput);
11610     EXPECT_EQ(intResult, 0);
11611 
11612     sptr<CaptureOutput> videoOutput = CreateVideoOutput(videoProfiles[0]);
11613     ASSERT_NE(videoOutput, nullptr);
11614 
11615     intResult = apertureVideoSession->AddOutput(videoOutput);
11616     EXPECT_EQ(intResult, 0);
11617 
11618     intResult = apertureVideoSession->CommitConfig();
11619     EXPECT_EQ(intResult, 0);
11620 
11621     intResult = apertureVideoSession->Start();
11622     EXPECT_EQ(intResult, 0);
11623 
11624     sleep(WAIT_TIME_AFTER_START);
11625 
11626     intResult = apertureVideoSession->Stop();
11627     EXPECT_EQ(intResult, 0);
11628 }
11629 
11630 /*
11631  * Feature: Framework
11632  * Function: Test photo session preconfig.
11633  * SubFunction: NA
11634  * FunctionPoints: NA
11635  * EnvConditions: NA
11636  * CaseDescription: Test photoSession CanPreconfig interface.
11637  */
11638 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_081, TestSize.Level0)
11639 {
11640     if (!IsSupportNow()) {
11641         return;
11642     }
11643     PreconfigType preconfigTypes[] = { PRECONFIG_720P, PRECONFIG_1080P, PRECONFIG_4K, PRECONFIG_HIGH_QUALITY };
11644     ProfileSizeRatio preconfigRatios[] = { UNSPECIFIED, RATIO_1_1, RATIO_4_3, RATIO_16_9 };
11645     int ret;
11646     for (auto type : preconfigTypes) {
11647         for (auto ratio : preconfigRatios) {
11648             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::CAPTURE);
11649             auto photoSession = static_cast<PhotoSession*>(captureSession.GetRefPtr());
11650             ASSERT_NE(photoSession, nullptr);
11651             if (photoSession->CanPreconfig(type, ratio)) {
11652                 ret = photoSession->Preconfig(type, ratio);
11653                 EXPECT_EQ(ret, 0);
11654 
11655                 ret = photoSession->BeginConfig();
11656                 EXPECT_EQ(ret, 0);
11657 
11658                 ret = photoSession->AddInput(input_);
11659                 EXPECT_EQ(ret, 0);
11660 
11661                 sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
11662                 sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
11663                 sptr<Surface> producerPreviewSurface = Surface::CreateSurfaceAsProducer(previewProducer);
11664                 sptr<PreviewOutput> previewOutput = nullptr;
11665                 ret = manager_->CreatePreviewOutputWithoutProfile(producerPreviewSurface, &previewOutput);
11666                 EXPECT_EQ(ret, 0);
11667                 sptr<CaptureOutput> capturePreviewOutput = previewOutput;
11668                 ret = photoSession->AddOutput(capturePreviewOutput);
11669                 EXPECT_EQ(ret, 0);
11670 
11671                 sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create();
11672                 sptr<IBufferProducer> photoProducer = photoSurface->GetProducer();
11673                 sptr<PhotoOutput> photoOutput = nullptr;
11674                 ret = manager_->CreatePhotoOutputWithoutProfile(photoProducer, &photoOutput);
11675                 EXPECT_EQ(ret, 0);
11676                 sptr<CaptureOutput> capturePhotoOutput = photoOutput;
11677                 ret = photoSession->AddOutput(capturePhotoOutput);
11678                 EXPECT_EQ(ret, 0);
11679 
11680                 ret = photoSession->CommitConfig();
11681                 EXPECT_EQ(ret, 0);
11682 
11683                 ret = photoSession->BeginConfig();
11684                 EXPECT_EQ(ret, 0);
11685 
11686                 ret = photoSession->RemoveInput(input_);
11687                 EXPECT_EQ(ret, 0);
11688             }
11689             ret = photoSession->Release();
11690             EXPECT_EQ(ret, 0);
11691         }
11692     }
11693 }
11694 
11695 /*
11696  * Feature: Framework
11697  * Function: Test video session preconfig.
11698  * SubFunction: NA
11699  * FunctionPoints: NA
11700  * EnvConditions: NA
11701  * CaseDescription: Test videoSession CanPreconfig interface.
11702  */
11703 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_082, TestSize.Level0)
11704 {
11705     if (!IsSupportNow()) {
11706         return;
11707     }
11708     PreconfigType preconfigTypes[] = { PRECONFIG_720P, PRECONFIG_1080P, PRECONFIG_4K, PRECONFIG_HIGH_QUALITY };
11709     ProfileSizeRatio preconfigRatios[] = { UNSPECIFIED, RATIO_1_1, RATIO_4_3, RATIO_16_9 };
11710     int ret;
11711     for (auto type : preconfigTypes) {
11712         for (auto ratio : preconfigRatios) {
11713             sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::VIDEO);
11714             auto videoSession = static_cast<VideoSession*>(captureSession.GetRefPtr());
11715             ASSERT_NE(videoSession, nullptr);
11716             if (videoSession->CanPreconfig(type, ratio)) {
11717                 ret = videoSession->Preconfig(type, ratio);
11718                 ASSERT_EQ(ret, 0);
11719 
11720                 ret = videoSession->BeginConfig();
11721                 EXPECT_EQ(ret, 0);
11722 
11723                 ret = videoSession->AddInput(input_);
11724                 EXPECT_EQ(ret, 0);
11725 
11726                 sptr<IConsumerSurface> previewSurface = IConsumerSurface::Create();
11727                 sptr<IBufferProducer> previewProducer = previewSurface->GetProducer();
11728                 sptr<Surface> producerPreviewSurface = Surface::CreateSurfaceAsProducer(previewProducer);
11729                 sptr<PreviewOutput> previewOutput = nullptr;
11730                 ret = manager_->CreatePreviewOutputWithoutProfile(producerPreviewSurface, &previewOutput);
11731                 EXPECT_EQ(ret, 0);
11732                 sptr<CaptureOutput> capturePreviewOutput = previewOutput;
11733                 ret = videoSession->AddOutput(capturePreviewOutput);
11734                 EXPECT_EQ(ret, 0);
11735 
11736                 sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create();
11737                 sptr<IBufferProducer> photoProducer = photoSurface->GetProducer();
11738                 sptr<PhotoOutput> photoOutput = nullptr;
11739                 ret = manager_->CreatePhotoOutputWithoutProfile(photoProducer, &photoOutput);
11740                 EXPECT_EQ(ret, 0);
11741                 sptr<CaptureOutput> capturePhotoOutput = photoOutput;
11742                 ret = videoSession->AddOutput(capturePhotoOutput);
11743                 EXPECT_EQ(ret, 0);
11744 
11745                 sptr<IConsumerSurface> videoSurface = IConsumerSurface::Create();
11746                 sptr<IBufferProducer> videoProducer = previewSurface->GetProducer();
11747                 sptr<Surface> captureVideoSurface = Surface::CreateSurfaceAsProducer(videoProducer);
11748                 sptr<VideoOutput> videoOutput = nullptr;
11749                 ret = manager_->CreateVideoOutputWithoutProfile(captureVideoSurface, &videoOutput);
11750                 EXPECT_EQ(ret, 0);
11751                 sptr<CaptureOutput> captureVideoOutput = videoOutput;
11752                 ret = videoSession->AddOutput(captureVideoOutput);
11753                 EXPECT_EQ(ret, 0);
11754 
11755                 ret = videoSession->CommitConfig();
11756                 EXPECT_EQ(ret, 0);
11757 
11758                 ret = videoSession->BeginConfig();
11759                 EXPECT_EQ(ret, 0);
11760 
11761                 ret = videoSession->RemoveInput(input_);
11762                 EXPECT_EQ(ret, 0);
11763             }
11764             ret = videoSession->Release();
11765             EXPECT_EQ(ret, 0);
11766         }
11767     }
11768 }
11769 
11770 /*
11771  * Feature: Framework
11772  * Function: Test moving photo
11773  * SubFunction: NA
11774  * FunctionPoints: NA
11775  * EnvConditions: NA
11776  * CaseDescription: Test can moving photo with normal branch
11777  */
11778 HWTEST_F(CameraFrameworkModuleTest, test_moving_photo, TestSize.Level0)
11779 {
11780     session_ = manager_->CreateCaptureSession(SceneMode::CAPTURE);
11781     ASSERT_NE(session_, nullptr);
11782 
11783     bool isSupported = session_->IsMovingPhotoSupported();
11784     EXPECT_EQ(isSupported, false);
11785 
11786     int32_t intResult = session_->BeginConfig();
11787     EXPECT_EQ(intResult, 0);
11788 
11789     intResult = session_->AddInput(input_);
11790     EXPECT_EQ(intResult, 0);
11791 
11792     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
11793     ASSERT_NE(previewOutput, nullptr);
11794 
11795     intResult = session_->AddOutput(previewOutput);
11796     EXPECT_EQ(intResult, 0);
11797 
11798     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
11799     ASSERT_NE(photoOutput, nullptr);
11800 
11801     intResult = session_->AddOutput(photoOutput);
11802     EXPECT_EQ(intResult, 0);
11803 
11804     intResult = session_->CommitConfig();
11805     EXPECT_EQ(intResult, 0);
11806 
11807     isSupported = session_->IsMovingPhotoSupported();
11808     EXPECT_EQ(isSupported, true);
11809 
11810     intResult = session_->Start();
11811     EXPECT_EQ(intResult, 0);
11812     sleep(WAIT_TIME_AFTER_START);
11813 
11814     session_->LockForControl();
11815     intResult = session_->EnableMovingPhoto(true);
11816     EXPECT_EQ(intResult, 0);
11817     session_->UnlockForControl();
11818 
11819     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
11820     EXPECT_EQ(intResult, 0);
11821     sleep(WAIT_TIME_AFTER_CAPTURE);
11822 }
11823 
11824 /*
11825  * Feature: Framework
11826  * Function: Test can add input
11827  * SubFunction: NA
11828  * FunctionPoints: NA
11829  * EnvConditions: NA
11830  * CaseDescription: Test can add input with normal and abnormal branch
11831  */
11832 HWTEST_F(CameraFrameworkModuleTest, test_CanAddInput, TestSize.Level0)
11833 {
11834     session_ = manager_->CreateCaptureSession(SceneMode::CAPTURE);
11835     ASSERT_NE(session_, nullptr);
11836 
11837     bool canAddInput = session_->CanAddInput(input_);
11838     EXPECT_EQ(canAddInput, false);
11839 
11840     int32_t intResult = session_->BeginConfig();
11841     EXPECT_EQ(intResult, 0);
11842 
11843     canAddInput = session_->CanAddInput(input_);
11844     EXPECT_EQ(canAddInput, true);
11845 
11846     intResult = session_->AddInput(input_);
11847     EXPECT_EQ(intResult, 0);
11848 }
11849 
11850 /*
11851  * Feature: Framework
11852  * Function: Test !IsSessionCommited() && !IsSessionConfiged()
11853  * SubFunction: NA
11854  * FunctionPoints: NA
11855  * EnvConditions: NA
11856  * CaseDescription: test IsSessionCommited() || IsSessionConfiged() with abnormal branches in PortraitSession.
11857  */
11858 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_086, TestSize.Level0)
11859 {
11860     if (!IsSupportNow()) {
11861         return;
11862     }
11863     sptr<CaptureSession> captureSession = manager_->CreateCaptureSession(SceneMode::CAPTURE);
11864     ASSERT_NE(captureSession, nullptr);
11865     std::vector<float> virtualApertures  = {};
11866     float aperture;
11867     EXPECT_EQ(captureSession->GetSupportedVirtualApertures(virtualApertures), SESSION_NOT_CONFIG);
11868     EXPECT_EQ(captureSession->GetVirtualAperture(aperture), SESSION_NOT_CONFIG);
11869     EXPECT_EQ(captureSession->SetVirtualAperture(aperture), SESSION_NOT_CONFIG);
11870 }
11871 
11872 /* Feature: Framework
11873  * Function: Test preview/capture with capture session's VirtualAperture
11874  * SubFunction: NA
11875  * FunctionPoints: NA
11876  * EnvConditions: NA
11877  * CaseDescription: Test preview/capture with capture session's VirtualAperture
11878  */
11879 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_087, TestSize.Level0)
11880 {
11881     SceneMode captureMode = SceneMode::CAPTURE;
11882     if (!IsSupportMode(captureMode)) {
11883         return;
11884     }
11885     sptr<CameraManager> modeManagerObj = CameraManager::GetInstance();
11886     ASSERT_NE(modeManagerObj, nullptr);
11887 
11888     std::vector<SceneMode> modes = modeManagerObj->GetSupportedModes(cameras_[0]);
11889     ASSERT_TRUE(modes.size() != 0);
11890 
11891     sptr<CameraOutputCapability> modeAbility =
11892         modeManagerObj->GetSupportedOutputCapability(cameras_[0], captureMode);
11893     ASSERT_NE(modeAbility, nullptr);
11894 
11895     sptr<CaptureSession> captureSession = modeManagerObj->CreateCaptureSession(captureMode);
11896     ASSERT_NE(captureSession, nullptr);
11897 
11898     int32_t intResult = captureSession->BeginConfig();
11899     EXPECT_EQ(intResult, 0);
11900 
11901     intResult = captureSession->AddInput(input_);
11902     EXPECT_EQ(intResult, 0);
11903 
11904     float ratioWidth = 16;
11905     float ratioHeight = 9;
11906     float ratio = ratioWidth / ratioHeight;
11907 
11908     Profile profile = SelectProfileByRatioAndFormat(modeAbility, ratio, photoFormat_);
11909     ASSERT_NE(profile.format_, -1);
11910 
11911     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(profile);
11912     ASSERT_NE(photoOutput, nullptr);
11913 
11914     intResult = captureSession->AddOutput(photoOutput);
11915     EXPECT_EQ(intResult, 0);
11916 
11917     profile = SelectProfileByRatioAndFormat(modeAbility, ratio, previewFormat_);
11918     ASSERT_NE(profile.format_, -1);
11919 
11920     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profile);
11921     ASSERT_NE(previewOutput, nullptr);
11922 
11923     intResult = captureSession->AddOutput(previewOutput);
11924     EXPECT_EQ(intResult, 0);
11925 
11926     intResult = captureSession->CommitConfig();
11927     EXPECT_EQ(intResult, 0);
11928 
11929     captureSession->LockForControl();
11930     std::vector<float> virtualApertures =  {};
11931     EXPECT_EQ(captureSession->GetSupportedVirtualApertures(virtualApertures), 0);
11932     EXPECT_EQ(captureSession->SetVirtualAperture(virtualApertures[0]), 0);
11933     captureSession->UnlockForControl();
11934     float aperture;
11935     EXPECT_EQ(captureSession->GetVirtualAperture(aperture), 0);
11936     EXPECT_EQ(aperture, virtualApertures[0]);
11937 
11938     intResult = captureSession->Start();
11939     EXPECT_EQ(intResult, 0);
11940     sleep(WAIT_TIME_AFTER_START);
11941 
11942     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture();
11943     EXPECT_EQ(intResult, 0);
11944     sleep(WAIT_TIME_AFTER_CAPTURE);
11945 
11946     captureSession->Stop();
11947 }
11948 
11949 /* Feature: Framework
11950  * Function: Test anomalous branch
11951  * SubFunction: NA
11952  * FunctionPoints: NA
11953  * EnvConditions: NA
11954  * CaseDescription: Test abnormal branches with empty inputDevice and empty metadata
11955  */
11956 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_088, TestSize.Level0)
11957 {
11958     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
11959     ASSERT_NE(camSession, nullptr);
11960     float getAperture = 0.0f;
11961     int32_t intResult = camSession->GetVirtualAperture(getAperture);
11962     EXPECT_EQ(intResult, 7400103);
11963     EXPECT_EQ(getAperture, 0.0f);
11964 
11965     camSession->LockForControl();
11966     float setAperture = 1.0f;
11967     intResult = camSession->SetVirtualAperture(setAperture);
11968     EXPECT_EQ(intResult, 7400103);
11969     camSession->UnlockForControl();
11970 
11971     intResult = camSession->BeginConfig();
11972     EXPECT_EQ(intResult, 0);
11973 
11974     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
11975     ASSERT_NE(input, nullptr);
11976 
11977     intResult = camSession->AddInput(input);
11978     EXPECT_EQ(intResult, 0);
11979 
11980     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
11981     ASSERT_NE(previewOutput, nullptr);
11982 
11983     intResult = camSession->AddOutput(previewOutput);
11984     EXPECT_EQ(intResult, 0);
11985 
11986     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
11987     ASSERT_NE(photoOutput, nullptr);
11988 
11989     intResult = camSession->AddOutput(photoOutput);
11990     EXPECT_EQ(intResult, 0);
11991 
11992     intResult = camSession->CommitConfig();
11993     EXPECT_EQ(intResult, 0);
11994 
11995     intResult = camSession->GetVirtualAperture(getAperture);
11996     EXPECT_EQ(intResult, 0);
11997     EXPECT_EQ(getAperture, 0.95f);
11998 
11999     camSession->LockForControl();
12000     intResult = camSession->SetVirtualAperture(setAperture);
12001     EXPECT_EQ(intResult, 0);
12002     camSession->UnlockForControl();
12003     intResult = camSession->GetVirtualAperture(getAperture);
12004     EXPECT_EQ(getAperture, 0.95f);
12005 
12006     ReleaseInput();
12007 
12008     intResult = camSession->GetVirtualAperture(getAperture);
12009     EXPECT_EQ(intResult, 0);
12010 }
12011 
12012 /*
12013 * Feature: Framework
12014 * Function: Test TimeLapsePhoto Init Session
12015 * SubFunction: NA
12016 * FunctionPoints: NA
12017 * EnvConditions: NA
12018 * CaseDescription: Test TimeLapsePhoto Init Session
12019 */
12020 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_timelapsephoto_001, TestSize.Level0)
12021 {
12022     SceneMode sceneMode = SceneMode::TIMELAPSE_PHOTO;
12023     if (!IsSupportMode(sceneMode)) {
12024         return;
12025     }
12026     if (session_) {
12027         session_->Release();
12028         session_.clear();
12029     }
12030     sptr<CameraManager> cameraManager = CameraManager::GetInstance();
12031     ASSERT_NE(cameraManager, nullptr);
12032     auto cameras = cameraManager->GetSupportedCameras();
12033     ASSERT_NE(cameras.size(), 0);
12034     sptr<CameraDevice> camera = cameras[0];
12035     ASSERT_NE(camera, nullptr);
12036     sptr<CameraOutputCapability> capability = cameraManager->GetSupportedOutputCapability(camera, sceneMode);
12037     ASSERT_NE(capability, nullptr);
12038     SelectProfiles wanted;
12039     wanted.preview.size_ = {640, 480};
12040     wanted.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
12041     wanted.photo.size_ = {640, 480};
12042     wanted.photo.format_ = CAMERA_FORMAT_JPEG;
12043     wanted.video.size_ = {640, 480};
12044     wanted.video.format_ = CAMERA_FORMAT_YUV_420_SP;
12045     wanted.video.framerates_ = {30, 30};
12046     sptr<CaptureSession> captureSession = cameraManager->CreateCaptureSession(sceneMode);
12047     ASSERT_NE(captureSession, nullptr);
12048     sptr<TimeLapsePhotoSession> session = reinterpret_cast<TimeLapsePhotoSession*>(captureSession.GetRefPtr());
12049     ASSERT_NE(session, nullptr);
12050     int32_t status = session->BeginConfig();
12051     EXPECT_EQ(status, 0);
12052     sptr<CaptureInput> input = cameraManager->CreateCameraInput(camera);
12053     ASSERT_NE(input, nullptr);
12054     status = input->Open();
12055     EXPECT_EQ(status, 0);
12056     status = session->AddInput(input);
12057     EXPECT_EQ(status, 0);
12058     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(wanted.preview);
12059     ASSERT_NE(previewOutput, nullptr);
12060     status = session->AddOutput(previewOutput);
12061     EXPECT_EQ(status, 0);
12062     sptr<CaptureOutput> photoOutput = CreatePhotoOutput(wanted.photo);
12063     ASSERT_NE(photoOutput, nullptr);
12064     status = session->AddOutput(photoOutput);
12065     EXPECT_EQ(status, 0);
12066     status = session->CommitConfig();
12067     EXPECT_EQ(status, 0);
12068     class ExposureInfoCallbackMock : public ExposureInfoCallback {
12069     public:
OnExposureInfoChanged(ExposureInfo info)12070         void OnExposureInfoChanged(ExposureInfo info) override
12071         {
12072             EXPECT_EQ(info.exposureDurationValue, 1);
12073         }
12074     };
12075     session->SetExposureInfoCallback(make_shared<ExposureInfoCallbackMock>());
12076     static const camera_rational_t r = {
12077         .denominator = 1000000,
12078         .numerator = 1,
12079     };
12080     auto meta = make_shared<OHOS::Camera::CameraMetadata>(10, 100);
12081     EXPECT_EQ(meta->addEntry(OHOS_STATUS_SENSOR_EXPOSURE_TIME, &r, 1), true);
12082     session->ProcessExposureChange(meta);
12083 
12084     class IsoInfoCallbackMock : public IsoInfoCallback {
12085     public:
OnIsoInfoChanged(IsoInfo info)12086         void OnIsoInfoChanged(IsoInfo info) override
12087         {
12088             EXPECT_EQ(info.isoValue, 1);
12089         }
12090     };
12091     session->SetIsoInfoCallback(make_shared<IsoInfoCallbackMock>());
12092     static const uint32_t iso = 1;
12093     EXPECT_EQ(meta->addEntry(OHOS_STATUS_ISO_VALUE, &iso, 1), true);
12094     session->ProcessIsoInfoChange(meta);
12095 
12096     static const uint32_t lumination = 256;
12097     class LuminationInfoCallbackMock : public LuminationInfoCallback {
12098     public:
OnLuminationInfoChanged(LuminationInfo info)12099         void OnLuminationInfoChanged(LuminationInfo info) override
12100         {
12101             EXPECT_EQ((int32_t)info.luminationValue, 1);
12102         }
12103     };
12104     session->SetLuminationInfoCallback(make_shared<LuminationInfoCallbackMock>());
12105     EXPECT_EQ(meta->addEntry(OHOS_STATUS_ALGO_MEAN_Y, &lumination, 1), true);
12106     session->ProcessLuminationChange(meta);
12107 
12108     static const int32_t value = 1;
12109     class TryAEInfoCallbackMock : public TryAEInfoCallback {
12110     public:
OnTryAEInfoChanged(TryAEInfo info)12111         void OnTryAEInfoChanged(TryAEInfo info) override
12112         {
12113             EXPECT_EQ(info.isTryAEDone, true);
12114             EXPECT_EQ(info.isTryAEHintNeeded, true);
12115             EXPECT_EQ(info.previewType, TimeLapsePreviewType::DARK);
12116             EXPECT_EQ(info.captureInterval, 1);
12117         }
12118     };
12119     session->SetTryAEInfoCallback(make_shared<TryAEInfoCallbackMock>());
12120     EXPECT_EQ(meta->addEntry(OHOS_STATUS_TIME_LAPSE_TRYAE_DONE, &value, 1), true);
12121     EXPECT_EQ(meta->addEntry(OHOS_STATUS_TIME_LAPSE_TRYAE_HINT, &value, 1), true);
12122     EXPECT_EQ(meta->addEntry(OHOS_STATUS_TIME_LAPSE_PREVIEW_TYPE, &value, 1), true);
12123     EXPECT_EQ(meta->addEntry(OHOS_STATUS_TIME_LAPSE_CAPTURE_INTERVAL, &value, 1), true);
12124     session->ProcessSetTryAEChange(meta);
12125 
12126     EXPECT_EQ(meta->addEntry(OHOS_CAMERA_MACRO_STATUS, &value, 1), true);
12127     session->ProcessPhysicalCameraSwitch(meta);
12128 
12129     bool isTryAENeeded;
12130     status = session->IsTryAENeeded(isTryAENeeded);
12131     EXPECT_EQ(status, 0);
12132     if (isTryAENeeded) {
12133         session->LockForControl();
12134         status = session->StartTryAE();
12135         session->UnlockForControl();
12136         EXPECT_EQ(status, 0);
12137         session->LockForControl();
12138         status = session->StopTryAE();
12139         session->UnlockForControl();
12140         EXPECT_EQ(status, 0);
12141     }
12142     vector<int32_t> range;
12143     status = session->GetSupportedTimeLapseIntervalRange(range);
12144     EXPECT_EQ(status, 0);
12145     if (!range.empty()) {
12146         session->LockForControl();
12147         status = session->SetTimeLapseInterval(range[0]);
12148         session->UnlockForControl();
12149         EXPECT_EQ(status, 0);
12150         int32_t interval;
12151         status = session->GetTimeLapseInterval(interval);
12152         EXPECT_EQ(status, 0);
12153         EXPECT_EQ(interval, range[0]);
12154     }
12155     session->LockForControl();
12156     status = session->SetTimeLapseRecordState(TimeLapseRecordState::RECORDING);
12157     session->UnlockForControl();
12158     EXPECT_EQ(status, 0);
12159     session->LockForControl();
12160     status = session->SetTimeLapsePreviewType(TimeLapsePreviewType::DARK);
12161     session->UnlockForControl();
12162     EXPECT_EQ(status, 0);
12163     session->LockForControl();
12164     status = session->SetExposureHintMode(ExposureHintMode::EXPOSURE_HINT_MODE_OFF);
12165     session->UnlockForControl();
12166     EXPECT_EQ(status, 0);
12167     // ManualExposure
12168     vector<uint32_t> exposureRange;
12169     status = session->GetSupportedExposureRange(exposureRange);
12170     EXPECT_EQ(status, 0);
12171     if (!exposureRange.empty()) {
12172         session->LockForControl();
12173         status = session->SetExposure(exposureRange[0]);
12174         session->UnlockForControl();
12175         EXPECT_EQ(status, 0);
12176         uint32_t exposure;
12177         status = session->GetExposure(exposure);
12178         EXPECT_EQ(status, 0);
12179         EXPECT_EQ(exposure, exposureRange[0]);
12180     }
12181     vector<MeteringMode> modes;
12182     status = session->GetSupportedMeteringModes(modes);
12183     EXPECT_EQ(status, 0);
12184     if (!modes.empty()) {
12185         bool supported;
12186         int32_t i = METERING_MODE_CENTER_WEIGHTED;
12187         for (;i <= METERING_MODE_SPOT; i++) {
12188             status = session->IsExposureMeteringModeSupported(METERING_MODE_CENTER_WEIGHTED, supported);
12189             EXPECT_EQ(status, 0);
12190             if (status == 0 && supported) {
12191                 break;
12192             }
12193         }
12194         if (supported) {
12195             session->LockForControl();
12196             status = session->SetExposureMeteringMode(static_cast<MeteringMode>(i));
12197             session->UnlockForControl();
12198             EXPECT_EQ(status, 0);
12199             MeteringMode mode;
12200             status = session->GetExposureMeteringMode(mode);
12201             EXPECT_EQ(status, 0);
12202             EXPECT_EQ(mode, i);
12203         }
12204     }
12205     // ManualIso
12206     bool isManualIsoSupported;
12207     status = session->IsManualIsoSupported(isManualIsoSupported);
12208     EXPECT_EQ(status, 0);
12209     if (isManualIsoSupported) {
12210         vector<int32_t> isoRange;
12211         status = session->GetIsoRange(isoRange);
12212         EXPECT_EQ(status, 0);
12213         if (!isoRange.empty()) {
12214             session->LockForControl();
12215             status = session->SetIso(isoRange[0]);
12216             session->UnlockForControl();
12217             EXPECT_EQ(status, 0);
12218             int32_t iso;
12219             status = session->GetIso(iso);
12220             EXPECT_EQ(status, 0);
12221             EXPECT_EQ(iso, isoRange[0]);
12222         }
12223     }
12224     // WhiteBalance
12225     vector<WhiteBalanceMode> wbModes;
12226     status = session->GetSupportedWhiteBalanceModes(wbModes);
12227     EXPECT_EQ(status, 0);
12228     if (!wbModes.empty()) {
12229         bool isWhiteBalanceModeSupported;
12230         status = session->IsWhiteBalanceModeSupported(wbModes[0], isWhiteBalanceModeSupported);
12231         EXPECT_EQ(status, 0);
12232         if (isWhiteBalanceModeSupported) {
12233             session->LockForControl();
12234             status = session->SetWhiteBalanceMode(wbModes[0]);
12235             session->UnlockForControl();
12236             EXPECT_EQ(status, 0);
12237             WhiteBalanceMode mode;
12238             status = session->GetWhiteBalanceMode(mode);
12239             EXPECT_EQ(status, 0);
12240             EXPECT_EQ(mode, wbModes[0]);
12241         }
12242     }
12243     vector<int32_t> wbRange;
12244     status = session->GetWhiteBalanceRange(wbRange);
12245     EXPECT_EQ(status, 0);
12246     if (!wbRange.empty()) {
12247         session->LockForControl();
12248         status = session->SetWhiteBalance(wbRange[0]);
12249         session->UnlockForControl();
12250         EXPECT_EQ(status, 0);
12251         int32_t wb;
12252         status = session->GetWhiteBalance(wb);
12253         EXPECT_EQ(status, 0);
12254         EXPECT_EQ(wb, wbRange[0]);
12255     }
12256     session->Release();
12257 }
12258 
12259 /*
12260  * Feature: Framework
12261  * Function: Test set video frame rate range dynamical
12262  * SubFunction: NA
12263  * FunctionPoints: NA
12264  * EnvConditions: NA
12265  * CaseDescription: Test set video frame rate range dynamical
12266  */
12267 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_083, TestSize.Level0)
12268 {
12269     sptr<CaptureOutput> previewOutput;
12270     sptr<CaptureOutput> videoOutput;
12271     ConfigVideoSession(previewOutput, videoOutput);
12272     ASSERT_NE(previewOutput, nullptr);
12273     ASSERT_NE(videoOutput, nullptr);
12274 
12275     int32_t intResult = videoSession_->AddOutput(videoOutput);
12276     EXPECT_EQ(intResult, 0);
12277 
12278     intResult = videoSession_->CommitConfig();
12279     EXPECT_EQ(intResult, 0);
12280 
12281     sptr<VideoOutput> videoOutputTrans = ((sptr<VideoOutput>&)videoOutput);
12282     intResult = videoOutputTrans->Start();
12283     EXPECT_EQ(intResult, 0);
12284 
12285     sleep(WAIT_TIME_AFTER_START);
12286 
12287     std::vector<std::vector<int32_t>> supportedFrameRateArray = videoOutputTrans->GetSupportedFrameRates();
12288     ASSERT_NE(supportedFrameRateArray.size(), 0);
12289     int32_t maxFpsTobeSet = 0;
12290     for (auto item : supportedFrameRateArray) {
12291         if (item[1] != 0) {
12292             maxFpsTobeSet = item[1];
12293         }
12294         cout << "supported: " << item[0] << item[1] <<endl;
12295     }
12296 
12297     std::vector<int32_t> activeFrameRateRange = videoOutputTrans->GetFrameRateRange();
12298     ASSERT_NE(activeFrameRateRange.size(), 0);
12299     EXPECT_EQ(activeFrameRateRange[0], 0);
12300     EXPECT_EQ(activeFrameRateRange[1], 0);
12301 
12302     intResult = videoOutputTrans->SetFrameRate(maxFpsTobeSet, maxFpsTobeSet);
12303     EXPECT_EQ(intResult, 0);
12304 
12305     std::cout<< "set: " << maxFpsTobeSet << maxFpsTobeSet << std::endl;
12306     std::vector<int32_t> currentFrameRateRange = videoOutputTrans->GetFrameRateRange();
12307     EXPECT_EQ(currentFrameRateRange[0], maxFpsTobeSet);
12308     EXPECT_EQ(currentFrameRateRange[1], maxFpsTobeSet);
12309     sleep(WAIT_TIME_AFTER_START);
12310 
12311     intResult = videoOutputTrans->SetFrameRate(MIN_FRAME_RATE, MAX_FRAME_RATE);
12312     EXPECT_EQ(intResult, 0);
12313 
12314     std::cout<< "set: "<< MIN_FRAME_RATE << MAX_FRAME_RATE << std::endl;
12315     currentFrameRateRange = videoOutputTrans->GetFrameRateRange();
12316     EXPECT_EQ(currentFrameRateRange[0], MIN_FRAME_RATE);
12317     EXPECT_EQ(currentFrameRateRange[1], MAX_FRAME_RATE);
12318     sleep(WAIT_TIME_AFTER_START);
12319 
12320     intResult = videoOutputTrans->Stop();
12321     EXPECT_EQ(intResult, 0);
12322 
12323     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
12324 
12325     sleep(WAIT_TIME_BEFORE_STOP);
12326 }
12327 
12328 /*
12329  * Feature: Framework
12330  * Function: Test video frame rate
12331  * SubFunction: NA
12332  * FunctionPoints: NA
12333  * EnvConditions: NA
12334  * CaseDescription: test video frame rate with normal setting branch
12335  */
12336 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_084, TestSize.Level0)
12337 {
12338     SceneMode sceneMode = SceneMode::LIGHT_PAINTING;
12339     if (!IsSupportMode(sceneMode)) {
12340         return;
12341     }
12342     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
12343     ASSERT_NE(cameraManagerObj, nullptr);
12344 
12345     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
12346     ASSERT_TRUE(sceneModes.size() != 0);
12347 
12348     sptr<CameraOutputCapability> modeAbility =
12349         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
12350     ASSERT_NE(modeAbility, nullptr);
12351 
12352     SelectProfiles profiles;
12353     profiles.preview.size_ = {1920, 1080};
12354     profiles.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
12355 
12356     ASSERT_NE(profiles.preview.format_, CAMERA_FORMAT_INVALID);
12357 
12358     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
12359     ASSERT_NE(captureSession, nullptr);
12360     sptr<LightPaintingSession> session = static_cast<LightPaintingSession*>(captureSession.GetRefPtr());
12361     ASSERT_NE(session, nullptr);
12362 
12363     int32_t intResult = session->BeginConfig();
12364     EXPECT_EQ(intResult, 0);
12365 
12366     intResult = session->AddInput(input_);
12367     EXPECT_EQ(intResult, 0);
12368 
12369     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profiles.preview);
12370     ASSERT_NE(previewOutput, nullptr);
12371 
12372     intResult = session->AddOutput(previewOutput);
12373     EXPECT_EQ(intResult, 0);
12374 
12375     intResult = session->CommitConfig();
12376     EXPECT_EQ(intResult, 0);
12377 
12378     std::vector<LightPaintingType> supportedType;
12379     session->GetSupportedLightPaintings(supportedType);
12380     EXPECT_NE(supportedType.size(), 0);
12381 
12382     LightPaintingType setType = LightPaintingType::LIGHT;
12383     session->LockForControl();
12384     intResult = session->SetLightPainting(setType);
12385     session->UnlockForControl();
12386     EXPECT_EQ(intResult, 0);
12387 
12388     LightPaintingType defaultType;
12389     intResult = session->GetLightPainting(defaultType);
12390     EXPECT_EQ(defaultType, setType);
12391 
12392     session->LockForControl();
12393     intResult = session->TriggerLighting();
12394     session->UnlockForControl();
12395     EXPECT_EQ(intResult, 0);
12396 }
12397 
12398 /*
12399  * Feature: Framework
12400  * Function: Test Callback for Occlusion Detection
12401  * SubFunction: NA
12402  * FunctionPoints: NA
12403  * EnvConditions: NA
12404  * CaseDescription: Test Callback for Occlusion Detection
12405  */
12406 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_085, TestSize.Level0)
12407 {
12408     sptr<CameraInput> input = (sptr<CameraInput>&)input_;
12409     sptr<ICameraDeviceService> deviceObj = input->GetCameraDevice();
12410     ASSERT_NE(deviceObj, nullptr);
12411 
12412     sptr<CameraDevice> camdeviceObj = nullptr;
12413     sptr<CameraInput> camInput_1 = new CameraInput(deviceObj, camdeviceObj);
12414     ASSERT_NE(camInput_1, nullptr);
12415 
12416     sptr<CameraDeviceServiceCallback> callback = new CameraDeviceServiceCallback(camInput_1);
12417 
12418     uint64_t timestamp = 10;
12419     const int32_t DEFAULT_ITEMS = 10;
12420     const int32_t DEFAULT_DATA_LENGTH = 100;
12421     int32_t count = 1;
12422     int32_t isOcclusionDetected = 1;
12423     std::shared_ptr<OHOS::Camera::CameraMetadata> result =
12424         std::make_shared<OHOS::Camera::CameraMetadata>(DEFAULT_ITEMS, DEFAULT_DATA_LENGTH);
12425     bool status = result->addEntry(OHOS_STATUS_CAMERA_OCCLUSION_DETECTION, &isOcclusionDetected, count);
12426     ASSERT_TRUE(status);
12427 
12428     int32_t intResult = callback->OnResult(timestamp, result);
12429     sleep(WAIT_TIME_AFTER_START);
12430     EXPECT_EQ(intResult, 0);
12431 
12432     result = std::make_shared<OHOS::Camera::CameraMetadata>(DEFAULT_ITEMS, DEFAULT_DATA_LENGTH);
12433     intResult = callback->OnResult(timestamp, result);
12434     EXPECT_EQ(intResult, 0);
12435 }
12436 
12437 /*
12438  * Feature: Framework
12439  * Function: Test video frame rate
12440  * SubFunction: NA
12441  * FunctionPoints: NA
12442  * EnvConditions: NA
12443  * CaseDescription: test video frame rate with abnormal setting branch
12444  */
12445 HWTEST_F(CameraFrameworkModuleTest, test_video_frame_rate, TestSize.Level0)
12446 {
12447     sptr<CaptureOutput> previewOutput;
12448     sptr<CaptureOutput> videoOutput;
12449     ConfigVideoSession(previewOutput, videoOutput);
12450     ASSERT_NE(previewOutput, nullptr);
12451     ASSERT_NE(videoOutput, nullptr);
12452 
12453     int32_t intResult = videoSession_->AddOutput(videoOutput);
12454     EXPECT_EQ(intResult, 0);
12455 
12456     intResult = videoSession_->CommitConfig();
12457     EXPECT_EQ(intResult, 0);
12458 
12459     sptr<VideoOutput> videoOutputTrans = ((sptr<VideoOutput>&)videoOutput);
12460     intResult = videoOutputTrans->Start();
12461     EXPECT_EQ(intResult, 0);
12462 
12463     sleep(WAIT_TIME_AFTER_START);
12464 
12465     std::vector<std::vector<int32_t>> supportedFrameRateArray = videoOutputTrans->GetSupportedFrameRates();
12466     ASSERT_NE(supportedFrameRateArray.size(), 0);
12467     int32_t maxFpsTobeSet = 0;
12468     for (auto item : supportedFrameRateArray) {
12469         if (item[1] != 0) {
12470             maxFpsTobeSet = item[1];
12471         }
12472         cout << "supported: " << item[0] << item[1] <<endl;
12473     }
12474 
12475     std::vector<int32_t> activeFrameRateRange = videoOutputTrans->GetFrameRateRange();
12476     ASSERT_NE(activeFrameRateRange.size(), 0);
12477     EXPECT_EQ(activeFrameRateRange[0], 0);
12478     EXPECT_EQ(activeFrameRateRange[1], 0);
12479 
12480     intResult = videoOutputTrans->SetFrameRate(maxFpsTobeSet, maxFpsTobeSet);
12481     EXPECT_EQ(intResult, 0);
12482 
12483     std::cout<< "set: "<<maxFpsTobeSet<<maxFpsTobeSet<<std::endl;
12484     std::vector<int32_t> currentFrameRateRange = videoOutputTrans->GetFrameRateRange();
12485     EXPECT_EQ(currentFrameRateRange[0], maxFpsTobeSet);
12486     EXPECT_EQ(currentFrameRateRange[1], maxFpsTobeSet);
12487     sleep(WAIT_TIME_AFTER_START);
12488 
12489     intResult = videoOutputTrans->SetFrameRate(15, 15);
12490     EXPECT_EQ(intResult, 0);
12491 
12492     std::cout<< "set: "<<15<<15<<std::endl;
12493     currentFrameRateRange = videoOutputTrans->GetFrameRateRange();
12494     EXPECT_EQ(currentFrameRateRange[0], 15);
12495     EXPECT_EQ(currentFrameRateRange[1], 15);
12496     sleep(WAIT_TIME_AFTER_START);
12497 
12498     intResult = videoOutputTrans->Stop();
12499     EXPECT_EQ(intResult, 0);
12500 }
12501 
12502 /*
12503  * Feature: Framework
12504  * Function: Test anomalous branch
12505  * SubFunction: NA
12506  * FunctionPoints: NA
12507  * EnvConditions: NA
12508  * CaseDescription: test HighQualityPhoto with anomalous branch
12509  */
12510 HWTEST_F(CameraFrameworkModuleTest, test_high_quality_Photo_enable, TestSize.Level0)
12511 {
12512     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
12513     ASSERT_NE(camSession, nullptr);
12514 
12515     bool isEnabled = false;
12516     int32_t intResult = camSession->EnableAutoHighQualityPhoto(isEnabled);
12517     EXPECT_EQ(intResult, 0);
12518 
12519     intResult = camSession->BeginConfig();
12520     EXPECT_EQ(intResult, 0);
12521 
12522     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
12523     ASSERT_NE(input, nullptr);
12524 
12525     intResult = camSession->AddInput(input);
12526     EXPECT_EQ(intResult, 0);
12527 
12528     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
12529     ASSERT_NE(previewOutput, nullptr);
12530 
12531     intResult = camSession->AddOutput(previewOutput);
12532     EXPECT_EQ(intResult, 0);
12533 
12534     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
12535     ASSERT_NE(photoOutput, nullptr);
12536 
12537     intResult = camSession->AddOutput(photoOutput);
12538     EXPECT_EQ(intResult, 0);
12539 
12540     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
12541 
12542     intResult = camSession->CommitConfig();
12543     EXPECT_EQ(intResult, 0);
12544 
12545     int32_t isAutoHighQualityPhotoSupported;
12546     intResult = photoOutput_1->IsAutoHighQualityPhotoSupported(isAutoHighQualityPhotoSupported);
12547 
12548     if (!IsSupportNow()) {
12549         EXPECT_EQ(intResult, -1);
12550     } else {
12551         EXPECT_EQ(intResult, 0);
12552     }
12553 
12554     intResult = photoOutput_1->EnableAutoHighQualityPhoto(isEnabled);
12555     EXPECT_EQ(intResult, 7400101);
12556 
12557     intResult = camSession->EnableAutoHighQualityPhoto(isEnabled);
12558     EXPECT_EQ(intResult, 0);
12559 
12560     intResult = photoOutput_1->Release();
12561     EXPECT_EQ(intResult, 0);
12562 
12563     intResult = photoOutput_1->IsAutoHighQualityPhotoSupported(isAutoHighQualityPhotoSupported);
12564     EXPECT_EQ(intResult, 7400104);
12565 
12566     intResult = photoOutput_1->EnableAutoHighQualityPhoto(isEnabled);
12567     EXPECT_EQ(intResult, 7400104);
12568 }
12569 
12570 
12571 /*
12572  * Feature: Framework
12573  * Function: Test slow motion callback
12574  * SubFunction: NA
12575  * FunctionPoints: NA
12576  * EnvConditions: NA
12577  * CaseDescription: Test slow motion callback
12578  */
12579 HWTEST_F(CameraFrameworkModuleTest, test_slow_motion_callback, TestSize.Level0)
12580 {
12581     sptr<CaptureOutput> previewOutput;
12582     sptr<CaptureOutput> videoOutput;
12583     ConfigSlowMotionSession(previewOutput, videoOutput);
12584     ASSERT_NE(previewOutput, nullptr);
12585     ASSERT_NE(videoOutput, nullptr);
12586 
12587     int32_t intResult = slowMotionSession_->AddOutput(previewOutput);
12588     EXPECT_EQ(intResult, 0);
12589 
12590     intResult = slowMotionSession_->CommitConfig();
12591     EXPECT_EQ(intResult, 0);
12592 
12593     sleep(WAIT_TIME_AFTER_START);
12594     intResult = slowMotionSession_->Start();
12595     EXPECT_EQ(intResult, 0);
12596 }
12597 
12598 /*
12599  * Feature: Framework
12600  * Function: Test Init PanoramaSession
12601  * SubFunction: NA
12602  * FunctionPoints: NA
12603  * EnvConditions: NA
12604  * CaseDescription: Test Init PanoramaSession
12605  */
12606 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_panorama, TestSize.Level0)
12607 {
12608     SceneMode sceneMode = SceneMode::PANORAMA_PHOTO;
12609     if (!IsSupportMode(sceneMode)) {
12610         return;
12611     }
12612     sptr<CameraManager> cameraManagerObj = CameraManager::GetInstance();
12613     ASSERT_NE(cameraManagerObj, nullptr);
12614 
12615     std::vector<SceneMode> sceneModes = cameraManagerObj->GetSupportedModes(cameras_[0]);
12616     ASSERT_TRUE(sceneModes.size() != 0);
12617 
12618     sptr<CameraOutputCapability> modeAbility =
12619         cameraManagerObj->GetSupportedOutputCapability(cameras_[0], sceneMode);
12620     ASSERT_NE(modeAbility, nullptr);
12621 
12622     SelectProfiles profiles;
12623     profiles.preview.size_ = {1920, 1080};
12624     profiles.preview.format_ = CAMERA_FORMAT_YUV_420_SP;
12625 
12626     ASSERT_NE(profiles.preview.format_, CAMERA_FORMAT_INVALID);
12627 
12628     sptr<CaptureSession> captureSession = cameraManagerObj->CreateCaptureSession(sceneMode);
12629     ASSERT_NE(captureSession, nullptr);
12630     sptr<PanoramaSession> session = static_cast<PanoramaSession*>(captureSession.GetRefPtr());
12631     ASSERT_NE(session, nullptr);
12632 
12633     int32_t intResult = session->BeginConfig();
12634     EXPECT_EQ(intResult, 0);
12635 
12636     intResult = session->AddInput(input_);
12637     EXPECT_EQ(intResult, 0);
12638 
12639     sptr<CaptureOutput> previewOutput = CreatePreviewOutput(profiles.preview);
12640     ASSERT_NE(previewOutput, nullptr);
12641 
12642     intResult = session->AddOutput(previewOutput);
12643     EXPECT_EQ(intResult, 0);
12644 
12645     intResult = session->CommitConfig();
12646     EXPECT_EQ(intResult, 0);
12647 
12648     intResult = session->Start();
12649     EXPECT_EQ(intResult, 0);
12650 
12651     intResult = session->Stop();
12652     EXPECT_EQ(intResult, 0);
12653 }
12654 
12655 /*
12656  * Feature: Framework
12657  * Function: Test burst capture
12658  * SubFunction: NA
12659  * FunctionPoints: NA
12660  * EnvConditions: NA
12661  * CaseDescription: Test burst capture
12662  */
12663 HWTEST_F(CameraFrameworkModuleTest, test_burst_capture, TestSize.Level0)
12664 {
12665     ASSERT_NE(session_, nullptr);
12666     int32_t intResult = session_->BeginConfig();
12667     EXPECT_EQ(intResult, 0);
12668 
12669     intResult = session_->AddInput(input_);
12670     EXPECT_EQ(intResult, 0);
12671 
12672     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
12673     ASSERT_NE(photoOutput, nullptr);
12674 
12675     intResult = session_->AddOutput(photoOutput);
12676     EXPECT_EQ(intResult, 0);
12677 
12678     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
12679     ASSERT_NE(previewOutput, nullptr);
12680 
12681     intResult = session_->AddOutput(previewOutput);
12682     EXPECT_EQ(intResult, 0);
12683 
12684     intResult = session_->CommitConfig();
12685     EXPECT_EQ(intResult, 0);
12686 
12687     intResult = session_->Start();
12688     EXPECT_EQ(intResult, 0);
12689     sleep(WAIT_TIME_AFTER_START);
12690 
12691     std::shared_ptr<PhotoCaptureSetting> photoSetting = std::make_shared<PhotoCaptureSetting>();
12692     photoSetting->SetBurstCaptureState(1);
12693 
12694     intResult = ((sptr<PhotoOutput>&)photoOutput)->Capture(photoSetting);
12695     EXPECT_EQ(intResult, 0);
12696     sleep(WAIT_TIME_AFTER_CAPTURE);
12697 
12698     intResult = ((sptr<PhotoOutput>&)photoOutput)->ConfirmCapture();
12699     EXPECT_EQ(intResult, 0);
12700 
12701     intResult = session_->Stop();
12702     EXPECT_EQ(intResult, 0);
12703 }
12704 
12705 /*
12706  * Feature: Framework
12707  * Function: Testing folded state callbacks
12708  * SubFunction: NA
12709  * FunctionPoints: NA
12710  * EnvConditions: NA
12711  * CaseDescription: Testing folded state callbacks
12712  */
12713 HWTEST_F(CameraFrameworkModuleTest, test_folded_state_callback, TestSize.Level0)
12714 {
12715     sptr<CameraManager> camManagerObj = CameraManager::GetInstance();
12716     camManagerObj->OnCameraServerAlive();
12717     std::shared_ptr<AppCallback> callback = std::make_shared<AppCallback>();
12718     camManagerObj->RegisterFoldListener(callback);
12719     EXPECT_EQ((camManagerObj->GetFoldListenerMap()).Size(), 1);
12720 }
12721 
12722 /*
12723  * Feature: Framework
12724  * Function: Test dynamic remove preview output
12725  * SubFunction: NA
12726  * FunctionPoints: NA
12727  * EnvConditions: NA
12728  * CaseDescription: Test dynamic remove preview output
12729  */
12730 HWTEST_F(CameraFrameworkModuleTest, test_dynamic_remove_previewoutput, TestSize.Level0)
12731 {
12732     auto previewOutput1 = CreatePreviewOutput();
12733     ASSERT_NE(previewOutput1, nullptr);
12734 
12735     auto previewOutput2 = CreatePreviewOutput();
12736     ASSERT_NE(previewOutput2, nullptr);
12737 
12738     auto captureOutput = CreatePhotoOutput();
12739     ASSERT_NE(captureOutput, nullptr);
12740 
12741     int32_t intResult = session_->BeginConfig();
12742     EXPECT_EQ(intResult, 0);
12743 
12744     intResult = session_->AddInput(input_);
12745     EXPECT_EQ(intResult, 0);
12746 
12747     intResult = session_->AddOutput(previewOutput1);
12748     EXPECT_EQ(intResult, 0);
12749 
12750     intResult = session_->AddOutput(previewOutput2);
12751     EXPECT_EQ(intResult, 0);
12752 
12753     intResult = session_->AddOutput(captureOutput);
12754     EXPECT_EQ(intResult, 0);
12755 
12756     intResult = session_->CommitConfig();
12757     EXPECT_EQ(intResult, 0);
12758 
12759     intResult = session_->Start();
12760     EXPECT_EQ(intResult, 0);
12761 
12762     sleep(WAIT_TIME_AFTER_START);
12763 
12764     intResult = session_->BeginConfig();
12765     EXPECT_EQ(intResult, 0);
12766 
12767     intResult = session_->RemoveOutput(previewOutput2);
12768     EXPECT_EQ(intResult, 0);
12769 
12770     ((sptr<PreviewOutput>&)previewOutput2)->Release();
12771 
12772     intResult = session_->CommitConfig();
12773     EXPECT_EQ(intResult, 0);
12774 }
12775 
12776 /*
12777  * Feature: Framework
12778  * Function: Test dynamic add preview output
12779  * SubFunction: NA
12780  * FunctionPoints: NA
12781  * EnvConditions: NA
12782  * CaseDescription: Test dynamic add preview output
12783  */
12784 HWTEST_F(CameraFrameworkModuleTest, test_dynamic_add_previewoutput, TestSize.Level0)
12785 {
12786     auto previewOutput1 = CreatePreviewOutput();
12787     ASSERT_NE(previewOutput1, nullptr);
12788 
12789     auto previewOutput2 = CreatePreviewOutput();
12790     ASSERT_NE(previewOutput2, nullptr);
12791 
12792     auto captureOutput = CreatePhotoOutput();
12793     ASSERT_NE(captureOutput, nullptr);
12794 
12795     int32_t intResult = session_->BeginConfig();
12796     EXPECT_EQ(intResult, 0);
12797 
12798     intResult = session_->AddInput(input_);
12799     EXPECT_EQ(intResult, 0);
12800 
12801     intResult = session_->AddOutput(previewOutput1);
12802     EXPECT_EQ(intResult, 0);
12803 
12804     intResult = session_->AddOutput(captureOutput);
12805     EXPECT_EQ(intResult, 0);
12806 
12807     intResult = session_->CommitConfig();
12808     EXPECT_EQ(intResult, 0);
12809 
12810     intResult = session_->Start();
12811     EXPECT_EQ(intResult, 0);
12812 
12813     sleep(WAIT_TIME_AFTER_START);
12814 
12815     intResult = session_->BeginConfig();
12816     EXPECT_EQ(intResult, 0);
12817 
12818     intResult = session_->AddOutput(previewOutput2);
12819     EXPECT_EQ(intResult, 0);
12820 
12821     intResult = session_->CommitConfig();
12822     EXPECT_EQ(intResult, 0);
12823 
12824     intResult = session_->Start();
12825     EXPECT_EQ(intResult, 0);
12826 
12827     sleep(WAIT_TIME_AFTER_START);
12828 
12829     intResult = session_->Stop();
12830     EXPECT_EQ(intResult, 0);
12831 }
12832 
12833 /*
12834  * Feature: Framework
12835  * Function: Test time machine dotting
12836  * SubFunction: NA
12837  * FunctionPoints: NA
12838  * EnvConditions: NA
12839  * CaseDescription: Test time machine dotting
12840  */
12841 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_time_machine, TestSize.Level0)
12842 {
12843     sptr<CaptureOutput> previewOutput;
12844     sptr<CaptureOutput> videoOutput;
12845     ConfigVideoSession(previewOutput, videoOutput);
12846     ASSERT_NE(previewOutput, nullptr);
12847     ASSERT_NE(videoOutput, nullptr);
12848 
12849     int32_t intResult = videoSession_->AddOutput(videoOutput);
12850     EXPECT_EQ(intResult, 0);
12851 
12852     sptr<VideoOutput> videoOutputTrans = ((sptr<VideoOutput>&)videoOutput);
12853     std::vector<VideoMetaType> supportedVideoMetaTypes = videoOutputTrans->GetSupportedVideoMetaTypes();
12854     ASSERT_NE(supportedVideoMetaTypes.size(), 0);
12855 
12856     sptr<IConsumerSurface> surface = IConsumerSurface::Create();
12857     ASSERT_NE(surface, nullptr);
12858     videoOutputTrans->AttachMetaSurface(surface, supportedVideoMetaTypes[0]);
12859 
12860     intResult = videoSession_->CommitConfig();
12861     EXPECT_EQ(intResult, 0);
12862 
12863     intResult = videoOutputTrans->Start();
12864     EXPECT_EQ(intResult, 0);
12865 
12866     sleep(WAIT_TIME_AFTER_START);
12867 
12868     intResult = videoOutputTrans->Stop();
12869     EXPECT_EQ(intResult, 0);
12870 
12871     TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
12872 
12873     sleep(WAIT_TIME_BEFORE_STOP);
12874 }
12875 
12876 /*
12877  * Feature: Framework
12878  * Function: Test camera rotation func
12879  * SubFunction: NA
12880  * FunctionPoints: NA
12881  * EnvConditions: NA
12882  * CaseDescription: Test camera rotation func
12883  */
12884 HWTEST_F(CameraFrameworkModuleTest, test_camera_rotation_func, TestSize.Level0)
12885 {
12886     auto previewProfile = GetSketchPreviewProfile();
12887     if (previewProfile == nullptr) {
12888         EXPECT_EQ(previewProfile.get(), nullptr);
12889         return;
12890     }
12891     auto previewOutput = CreatePreviewOutput(*previewProfile);
12892     ASSERT_NE(previewOutput, nullptr);
12893     auto photoOutput = CreatePhotoOutput();
12894     ASSERT_NE(photoOutput, nullptr);
12895     auto videoOutput = CreateVideoOutput();
12896     ASSERT_NE(videoOutput, nullptr);
12897 
12898     session_->SetMode(SceneMode::NORMAL);
12899     int32_t intResult = session_->BeginConfig();
12900     EXPECT_EQ(intResult, 0);
12901     intResult = session_->AddInput(input_);
12902     EXPECT_EQ(intResult, 0);
12903     intResult = session_->AddOutput(previewOutput);
12904     EXPECT_EQ(intResult, 0);
12905     intResult = session_->AddOutput(photoOutput);
12906     EXPECT_EQ(intResult, 0);
12907     intResult = session_->AddOutput(videoOutput);
12908     EXPECT_EQ(intResult, 0);
12909 
12910     sptr<PreviewOutput> previewOutput_1 = (sptr<PreviewOutput>&)previewOutput;
12911     int32_t previewRotation = previewOutput_1->GetPreviewRotation(PhotoCaptureSetting::RotationConfig::Rotation_0);
12912     EXPECT_EQ(previewRotation, PhotoCaptureSetting::RotationConfig::Rotation_90);
12913     sptr<VideoOutput> videoOutput_1 = (sptr<VideoOutput>&)videoOutput;
12914     int32_t videoRotation = videoOutput_1->GetVideoRotation(PhotoCaptureSetting::RotationConfig::Rotation_90);
12915     EXPECT_EQ(videoRotation, PhotoCaptureSetting::RotationConfig::Rotation_180);
12916     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
12917     int32_t photoRotation = photoOutput_1->GetPhotoRotation(PhotoCaptureSetting::RotationConfig::Rotation_180);
12918     EXPECT_EQ(photoRotation, PhotoCaptureSetting::RotationConfig::Rotation_270);
12919     intResult = previewOutput_1->SetPreviewRotation(previewRotation, false);
12920     EXPECT_EQ(intResult, 0);
12921 
12922     intResult = session_->CommitConfig();
12923     EXPECT_EQ(intResult, 0);
12924     intResult = session_->Start();
12925     EXPECT_EQ(intResult, 0);
12926     sleep(WAIT_TIME_AFTER_START);
12927     intResult = session_->Stop();
12928     EXPECT_EQ(intResult, 0);
12929 }
12930 
12931 /*
12932  * Feature: Framework
12933  * Function: Test abnormal branches Requirements for Meta Detection Types
12934  * SubFunction: NA
12935  * FunctionPoints: NA
12936  * EnvConditions: NA
12937  * CaseDescription: Test abnormal branches Requirements for Meta Detection Types
12938  */
12939 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_meta_abnormal, TestSize.Level0)
12940 {
12941     SetHapToken();
12942     int32_t intResult = session_->BeginConfig();
12943     EXPECT_EQ(intResult, 0);
12944 
12945     intResult = session_->AddInput(input_);
12946     EXPECT_EQ(intResult, 0);
12947 
12948     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
12949     ASSERT_NE(previewOutput, nullptr);
12950 
12951     intResult = session_->AddOutput(previewOutput);
12952     EXPECT_EQ(intResult, 0);
12953 
12954     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
12955     ASSERT_NE(metadatOutput, nullptr);
12956 
12957     intResult = session_->AddOutput(metadatOutput);
12958     EXPECT_EQ(intResult, 0);
12959 
12960     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
12961     std::vector<MetadataObjectType> typeToAdd = { MetadataObjectType::FACE, MetadataObjectType::HUMAN_BODY,
12962                                                   MetadataObjectType::CAT_FACE };
12963     intResult = metaOutput->AddMetadataObjectTypes(typeToAdd);
12964     EXPECT_EQ(intResult, CameraErrorCode::SESSION_NOT_CONFIG);
12965 
12966     intResult = metaOutput->RemoveMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::CAT_FACE});
12967     EXPECT_EQ(intResult, CameraErrorCode::SESSION_NOT_CONFIG);
12968     SetNativeToken();
12969 }
12970 
12971 /*
12972  * Feature: Framework
12973  * Function: Test Requirements for Meta Detection Types
12974  * SubFunction: NA
12975  * FunctionPoints: NA
12976  * EnvConditions: NA
12977  * CaseDescription: Test Requirements for Meta Detection Types
12978  */
12979 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_meta, TestSize.Level0)
12980 {
12981     SetHapToken();
12982     int32_t intResult = session_->BeginConfig();
12983     EXPECT_EQ(intResult, 0);
12984 
12985     intResult = session_->AddInput(input_);
12986     EXPECT_EQ(intResult, 0);
12987 
12988     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
12989     ASSERT_NE(previewOutput, nullptr);
12990 
12991     intResult = session_->AddOutput(previewOutput);
12992     EXPECT_EQ(intResult, 0);
12993 
12994     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
12995     ASSERT_NE(metadatOutput, nullptr);
12996 
12997     intResult = session_->AddOutput(metadatOutput);
12998     EXPECT_EQ(intResult, 0);
12999 
13000     intResult = session_->CommitConfig();
13001     EXPECT_EQ(intResult, 0);
13002 
13003     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
13004     std::vector<MetadataObjectType> typeToAdd = { MetadataObjectType::FACE, MetadataObjectType::HUMAN_BODY,
13005                                                   MetadataObjectType::CAT_FACE };
13006     intResult = metaOutput->AddMetadataObjectTypes(typeToAdd);
13007     EXPECT_EQ(intResult, 0);
13008 
13009     intResult = metaOutput->RemoveMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::CAT_FACE});
13010     EXPECT_EQ(intResult, 0);
13011 
13012     intResult = metaOutput->Start();
13013     EXPECT_EQ(intResult, 0);
13014 
13015     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
13016     metaOutput->SetCallback(metadataObjectCallback);
13017     std::shared_ptr<MetadataStateCallback> metadataStateCallback = std::make_shared<AppMetadataCallback>();
13018     metaOutput->SetCallback(metadataStateCallback);
13019 
13020     intResult = metaOutput->Stop();
13021     EXPECT_EQ(intResult, 0);
13022     SetNativeToken();
13023 }
13024 
13025 /*
13026  * Feature: Framework
13027  * Function: Test callback for Meta Detection Types
13028  * SubFunction: NA
13029  * FunctionPoints: NA
13030  * EnvConditions: NA
13031  * CaseDescription: Test callback for Meta Detection Types
13032  */
13033 HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_meta_callback, TestSize.Level0)
13034 {
13035     SetHapToken();
13036     int32_t intResult = session_->BeginConfig();
13037     EXPECT_EQ(intResult, 0);
13038 
13039     intResult = session_->AddInput(input_);
13040     EXPECT_EQ(intResult, 0);
13041 
13042     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
13043     ASSERT_NE(previewOutput, nullptr);
13044 
13045     intResult = session_->AddOutput(previewOutput);
13046     EXPECT_EQ(intResult, 0);
13047 
13048     sptr<CaptureOutput> metadatOutput = manager_->CreateMetadataOutput();
13049     ASSERT_NE(metadatOutput, nullptr);
13050 
13051     intResult = session_->AddOutput(metadatOutput);
13052     EXPECT_EQ(intResult, 0);
13053 
13054     intResult = session_->CommitConfig();
13055     EXPECT_EQ(intResult, 0);
13056 
13057     sptr<MetadataOutput> metaOutput = (sptr<MetadataOutput>&)metadatOutput;
13058     std::vector<MetadataObjectType> typeToAdd = { MetadataObjectType::FACE, MetadataObjectType::HUMAN_BODY,
13059                                                   MetadataObjectType::CAT_FACE };
13060     intResult = metaOutput->AddMetadataObjectTypes(typeToAdd);
13061     EXPECT_EQ(intResult, 0);
13062 
13063     intResult = metaOutput->RemoveMetadataObjectTypes(std::vector<MetadataObjectType> {MetadataObjectType::CAT_FACE});
13064     EXPECT_EQ(intResult, 0);
13065 
13066     std::shared_ptr<MetadataObjectCallback> metadataObjectCallback = std::make_shared<AppMetadataCallback>();
13067     metaOutput->SetCallback(metadataObjectCallback);
13068 
13069     sptr<HStreamMetadataCallbackImpl> cameraMetadataCallback_ =
13070         new HStreamMetadataCallbackImpl(metaOutput.GetRefPtr());
13071 
13072     const int32_t defaultItems = 10;
13073     const int32_t defaultDataLength = 100;
13074 
13075     std::shared_ptr<OHOS::Camera::CameraMetadata> mockMetaFromHal =
13076         std::make_shared<OHOS::Camera::CameraMetadata>(defaultItems, defaultDataLength);
13077     std::vector<uint8_t> mockHumanFaceTagfromHal = {
13078         0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
13079     std::vector<uint8_t> mockCatFaceTagFromHal = {2, 2, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
13080     std::vector<uint8_t> mockDogFaceTagFromHal = {4, 1, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
13081     bool status = mockMetaFromHal->addEntry(OHOS_STATISTICS_DETECT_HUMAN_FACE_INFOS, mockHumanFaceTagfromHal.data(), mockHumanFaceTagfromHal.size());
13082     ASSERT_TRUE(status);
13083     status = mockMetaFromHal->addEntry(OHOS_STATISTICS_DETECT_CAT_FACE_INFOS, mockCatFaceTagFromHal.data(), mockCatFaceTagFromHal.size());
13084     ASSERT_TRUE(status);
13085     status = mockMetaFromHal->addEntry(OHOS_STATISTICS_DETECT_DOG_FACE_INFOS, mockDogFaceTagFromHal.data(), mockDogFaceTagFromHal.size());
13086     ASSERT_TRUE(status);
13087 
13088     intResult = cameraMetadataCallback_->OnMetadataResult(0, mockMetaFromHal);
13089     EXPECT_EQ(intResult, 0);
13090     SetNativeToken();
13091 }
13092 /*
13093  * Feature: Framework
13094  * Function: Test cloud enhance
13095  * SubFunction: NA
13096  * FunctionPoints: NA
13097  * EnvConditions: NA
13098  * CaseDescription: test CloudImageEnhance enable
13099  */
13100 HWTEST_F(CameraFrameworkModuleTest, test_cloud_image_enhance_enable, TestSize.Level0)
13101 {
13102     sptr<CaptureSession> camSession = manager_->CreateCaptureSession();
13103     ASSERT_NE(camSession, nullptr);
13104 
13105     bool isEnabled = false;
13106     int32_t intResult = camSession->EnableAutoCloudImageEnhancement(isEnabled);
13107     EXPECT_EQ(intResult, 0);
13108 
13109     intResult = camSession->BeginConfig();
13110     EXPECT_EQ(intResult, 0);
13111 
13112     sptr<CaptureInput> input = (sptr<CaptureInput>&)input_;
13113     ASSERT_NE(input, nullptr);
13114 
13115     intResult = camSession->AddInput(input);
13116     EXPECT_EQ(intResult, 0);
13117 
13118     sptr<CaptureOutput> previewOutput = CreatePreviewOutput();
13119     ASSERT_NE(previewOutput, nullptr);
13120 
13121     intResult = camSession->AddOutput(previewOutput);
13122     EXPECT_EQ(intResult, 0);
13123 
13124     sptr<CaptureOutput> photoOutput = CreatePhotoOutput();
13125     ASSERT_NE(photoOutput, nullptr);
13126 
13127     intResult = camSession->AddOutput(photoOutput);
13128     EXPECT_EQ(intResult, 0);
13129 
13130     sptr<PhotoOutput> photoOutput_1 = (sptr<PhotoOutput>&)photoOutput;
13131 
13132     intResult = camSession->CommitConfig();
13133     EXPECT_EQ(intResult, 0);
13134 
13135     bool isAutoCloudImageEnhancementSupported;
13136     intResult = photoOutput_1->IsAutoCloudImageEnhancementSupported(isAutoCloudImageEnhancementSupported);
13137     EXPECT_EQ(isAutoCloudImageEnhancementSupported, true);
13138 
13139     intResult = photoOutput_1->EnableAutoCloudImageEnhancement(isEnabled);
13140     EXPECT_EQ(intResult, 0);
13141 
13142     intResult = photoOutput_1->Release();
13143     EXPECT_EQ(intResult, 0);
13144 
13145     intResult = photoOutput_1->IsAutoCloudImageEnhancementSupported(isAutoCloudImageEnhancementSupported);
13146     EXPECT_EQ(intResult, 7400201);
13147 
13148     intResult = photoOutput_1->EnableAutoCloudImageEnhancement(isEnabled);
13149     EXPECT_EQ(intResult, 7400201);
13150 }
13151 } // namespace CameraStandard
13152 } // namespace OHOS
13153