• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CAMERA_FRAMEWORK_MODULETEST_H
17 #define CAMERA_FRAMEWORK_MODULETEST_H
18 
19 #include "gtest/gtest.h"
20 #include "input/camera_device.h"
21 #include "input/camera_input.h"
22 #include "input/camera_manager.h"
23 #include "mode/mode_manager.h"
24 #include "session/capture_session.h"
25 
26 namespace OHOS {
27 namespace CameraStandard {
28 class CameraFrameworkModuleTest : public testing::Test {
29 public:
30     static const int32_t PHOTO_DEFAULT_WIDTH = 1280;
31     static const int32_t PHOTO_DEFAULT_HEIGHT = 960;
32     static const int32_t PREVIEW_DEFAULT_WIDTH = 640;
33     static const int32_t PREVIEW_DEFAULT_HEIGHT = 480;
34     static const int32_t VIDEO_DEFAULT_WIDTH = 640;
35     static const int32_t VIDEO_DEFAULT_HEIGHT = 360;
36     CameraFormat previewFormat_;
37     CameraFormat photoFormat_;
38     CameraFormat videoFormat_;
39     int32_t previewWidth_;
40     int32_t previewHeight_;
41     int32_t photoWidth_;
42     int32_t photoHeight_;
43     int32_t videoWidth_;
44     int32_t videoHeight_;
45     sptr<CameraManager> manager_;
46     sptr<CaptureSession> session_;
47     sptr<CaptureInput> input_;
48     std::vector<sptr<CameraDevice>> cameras_;
49     std::vector<CameraFormat> previewFormats_;
50     std::vector<CameraFormat> photoFormats_;
51     std::vector<CameraFormat> videoFormats_;
52     std::vector<Size> previewSizes_;
53     std::vector<Size> photoSizes_;
54     std::vector<Size> videoSizes_;
55     std::vector<int32_t> videoFrameRates_;
56 
57     std::vector<Profile> previewProfiles;
58     std::vector<Profile> photoProfiles;
59     std::vector<VideoProfile> videoProfiles;
60     /* SetUpTestCase:The preset action of the test suite is executed before the first TestCase */
61     static void SetUpTestCase(void);
62 
63     /* TearDownTestCase:The test suite cleanup action is executed after the last TestCase */
64     static void TearDownTestCase(void);
65 
66     /* SetUp:Execute before each test case */
67     void SetUpInit();
68     void SetUp();
69 
70     /* TearDown:Execute after each test case */
71     void TearDown();
72 
73     sptr<CaptureOutput> CreatePreviewOutput(int32_t width, int32_t height);
74     sptr<CaptureOutput> CreatePreviewOutput();
75     sptr<CaptureOutput> CreatePhotoOutput(int32_t width, int32_t height);
76     sptr<CaptureOutput> CreatePhotoOutput();
77     sptr<CaptureOutput> CreateVideoOutput(int32_t width, int32_t height);
78     sptr<CaptureOutput> CreateVideoOutput();
79     sptr<CaptureOutput> CreatePhotoOutput(Profile profile);
80     void GetSupportedOutputCapability();
81     void ReleaseInput();
82 
83     void SetCameraParameters(sptr<CaptureSession> &session, bool video);
84     void TestCallbacksSession(sptr<CaptureOutput> photoOutput,
85 		    sptr<CaptureOutput> videoOutput);
86     void TestCallbacks(sptr<CameraDevice> &cameraInfo, bool video);
87     void TestSupportedResolution(int32_t previewWidth, int32_t previewHeight, int32_t photoWidth,
88                                  int32_t photoHeight, int32_t videoWidth, int32_t videoHeight);
89     void TestUnSupportedResolution(int32_t previewWidth, int32_t previewHeight, int32_t photoWidth,
90                                    int32_t photoHeight, int32_t videoWidth, int32_t videoHeight);
91     bool IsSupportNow();
92 };
93 } // CameraStandard
94 } // OHOS
95 #endif // CAMERA_FRAMEWORK_MODULETEST_H
96