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_input.h" 21 #include "input/camera_manager.h" 22 #include "session/capture_session.h" 23 24 namespace OHOS { 25 namespace CameraStandard { 26 class CameraFrameworkModuleTest : public testing::Test { 27 public: 28 static const int32_t PHOTO_DEFAULT_WIDTH = 1280; 29 static const int32_t PHOTO_DEFAULT_HEIGHT = 960; 30 static const int32_t PREVIEW_DEFAULT_WIDTH = 640; 31 static const int32_t PREVIEW_DEFAULT_HEIGHT = 480; 32 static const int32_t VIDEO_DEFAULT_WIDTH = 640; 33 static const int32_t VIDEO_DEFAULT_HEIGHT = 360; 34 CameraFormat previewFormat_; 35 CameraFormat photoFormat_; 36 CameraFormat videoFormat_; 37 int32_t previewWidth_; 38 int32_t previewHeight_; 39 int32_t photoWidth_; 40 int32_t photoHeight_; 41 int32_t videoWidth_; 42 int32_t videoHeight_; 43 sptr<CameraManager> manager_; 44 sptr<CaptureSession> session_; 45 sptr<CaptureInput> input_; 46 std::vector<sptr<CameraDevice>> cameras_; 47 std::vector<CameraFormat> previewFormats_; 48 std::vector<CameraFormat> photoFormats_; 49 std::vector<CameraFormat> videoFormats_; 50 std::vector<Size> previewSizes_; 51 std::vector<Size> photoSizes_; 52 std::vector<Size> videoSizes_; 53 std::vector<int32_t> videoFrameRates_; 54 55 /* SetUpTestCase:The preset action of the test suite is executed before the first TestCase */ 56 static void SetUpTestCase(void); 57 58 /* TearDownTestCase:The test suite cleanup action is executed after the last TestCase */ 59 static void TearDownTestCase(void); 60 61 /* SetUp:Execute before each test case */ 62 void SetUpInit(); 63 void SetUp(); 64 65 /* TearDown:Execute after each test case */ 66 void TearDown(); 67 68 sptr<CaptureOutput> CreatePreviewOutput(int32_t width, int32_t height); 69 sptr<CaptureOutput> CreatePreviewOutput(); 70 sptr<CaptureOutput> CreatePhotoOutput(int32_t width, int32_t height); 71 sptr<CaptureOutput> CreatePhotoOutput(); 72 sptr<CaptureOutput> CreateVideoOutput(int32_t width, int32_t height); 73 sptr<CaptureOutput> CreateVideoOutput(); 74 void SetCameraParameters(sptr<CaptureSession> &session, bool video); 75 void TestCallbacksSession(sptr<CaptureOutput> photoOutput, 76 sptr<CaptureOutput> videoOutput); 77 void TestCallbacks(sptr<CameraDevice> &cameraInfo, bool video); 78 void TestSupportedResolution(int32_t previewWidth, int32_t previewHeight, int32_t photoWidth, 79 int32_t photoHeight, int32_t videoWidth, int32_t videoHeight); 80 void TestUnSupportedResolution(int32_t previewWidth, int32_t previewHeight, int32_t photoWidth, 81 int32_t photoHeight, int32_t videoWidth, int32_t videoHeight); 82 }; 83 } // CameraStandard 84 } // OHOS 85 #endif // CAMERA_FRAMEWORK_MODULETEST_H 86