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 #ifndef CAMERA_FRAMEWORK_UNITTEST_H
17 #define CAMERA_FRAMEWORK_UNITTEST_H
18 
19 #include "gtest/gtest.h"
20 #include "hcamera_service.h"
21 #include "input/camera_manager.h"
22 #include "output/sketch_wrapper.h"
23 #include "portrait_session.h"
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 class MockStreamOperator;
28 class MockCameraDevice;
29 class MockHCameraHostManager;
30 class MockCameraManager;
31 class CameraFrameworkUnitTest : public testing::Test {
32 public:
33     static const int32_t PHOTO_DEFAULT_WIDTH = 1280;
34     static const int32_t PHOTO_DEFAULT_HEIGHT = 960;
35     static const int32_t PREVIEW_DEFAULT_WIDTH = 640;
36     static const int32_t PREVIEW_DEFAULT_HEIGHT = 480;
37     static const int32_t VIDEO_DEFAULT_WIDTH = 640;
38     static const int32_t VIDEO_DEFAULT_HEIGHT = 360;
39     static const int32_t DEFAULT_MODE = 0;
40     static const int32_t PHOTO_MODE = 1;
41     static const int32_t VIDEO_MODE = 2;
42     static const int32_t PORTRAIT_MODE = 3;
43     static const int32_t NIGHT_MODE = 4;
44     static const int32_t SLOW_MODE = 6;
45     static const int32_t SCAN_MODE = 7;
46     static const int32_t MODE_FINISH = -1;
47     static const int32_t STREAM_FINISH = -1;
48     static const int32_t PREVIEW_STREAM = 0;
49     static const int32_t VIDEO_STREAM = 1;
50     static const int32_t PHOTO_STREAM = 2;
51     static const int32_t MAX_FRAMERATE = 0;
52     static const int32_t MIN_FRAMERATE = 0;
53     static const int32_t ABILITY_ID_ONE = 536870912;
54     static const int32_t ABILITY_ID_TWO = 536870914;
55     static const int32_t ABILITY_ID_THREE = 536870916;
56     static const int32_t ABILITY_ID_FOUR = 536870924;
57     static const int32_t ABILITY_FINISH = -1;
58     static const int32_t PREVIEW_FRAMERATE = 0;
59     static const int32_t VIDEO_FRAMERATE = 30;
60     static const int32_t PHOTO_FRAMERATE = 0;
61     uint64_t g_tokenId_;
62     int32_t g_uid_;
63     int32_t g_userId_;
64     sptr<MockStreamOperator> mockStreamOperator;
65     sptr<MockCameraDevice> mockCameraDevice;
66     sptr<MockHCameraHostManager> mockCameraHostManager;
67     sptr<CameraManager> cameraManager;
68     sptr<MockCameraManager> mockCameraManager;
69     /* SetUpTestCase:The preset action of the test suite is executed before the first TestCase */
70     static void SetUpTestCase(void);
71 
72     /* TearDownTestCase:The test suite cleanup action is executed after the last TestCase */
73     static void TearDownTestCase(void);
74 
75     /* SetUp:Execute before each test case */
76     void SetUp();
77 
78     /* TearDown:Execute after each test case */
79     void TearDown();
80     void NativeAuthorization();
81     void SessionCommit(sptr<CaptureSession> session);
82     void SessionControlParams(sptr<CaptureSession> session);
83     void PortraitSessionControlParams(sptr<PortraitSession> portraitSession);
84     void PortraitSessionEffectParams(sptr<PortraitSession> portraitSession);
85     void PortraitSessionFilterParams(sptr<PortraitSession> portraitSession);
86     void PortraitSessionBeautyParams(sptr<PortraitSession> portraitSession);
87     sptr<CaptureOutput> CreatePhotoOutput(int32_t width = PHOTO_DEFAULT_WIDTH, int32_t height = PHOTO_DEFAULT_HEIGHT);
88     sptr<CaptureOutput> CreatePreviewOutput(int32_t width = PREVIEW_DEFAULT_WIDTH,
89                                             int32_t height = PREVIEW_DEFAULT_HEIGHT);
90     sptr<CaptureOutput> CreateVideoOutput(int32_t width = VIDEO_DEFAULT_WIDTH, int32_t height = VIDEO_DEFAULT_HEIGHT);
91 
92     void TestPhotoSessionPreconfig(
93         sptr<CaptureInput>& input, PreconfigType preconfigType, ProfileSizeRatio profileSizeRatio);
94     void TestVideoSessionPreconfig(
95         sptr<CaptureInput>& input, PreconfigType preconfigType, ProfileSizeRatio profileSizeRatio);
96 };
97 } // CameraStandard
98 } // OHOS
99 #endif // CAMERA_FRAMEWORK_UNITTEST_H
100