• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_FORMAT_YUV_MODULETEST_H
17 #define CAMERA_FORMAT_YUV_MODULETEST_H
18 
19 #include <algorithm>
20 #include <cinttypes>
21 #include <cstdint>
22 #include <memory>
23 #include <vector>
24 #include <thread>
25 
26 #include "accesstoken_kit.h"
27 #include "camera_error_code.h"
28 #include "camera_log.h"
29 #include "gtest/gtest.h"
30 #include "hap_token_info.h"
31 #include "nativetoken_kit.h"
32 #include "surface.h"
33 #include "test_common.h"
34 #include "token_setproc.h"
35 
36 namespace OHOS {
37 namespace CameraStandard {
38 
39 const int32_t WAIT_TIME_AFTER_CAPTURE = 1;
40 const int32_t WAIT_TIME_AFTER_START = 2;
41 
42 class AppAbilityCallback : public AbilityCallback {
43 public:
OnAbilityChange()44     void OnAbilityChange() override {}
45 };
46 
47 class AppSessionCallback : public SessionCallback {
48 public:
OnError(int32_t errorCode)49     void OnError(int32_t errorCode)
50     {
51         MEDIA_DEBUG_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
52         return;
53     }
54 };
55 
56 class CameraformatYUVModuleTest : public testing::Test {
57 public:
58     uint64_t tokenId_ = 0;
59     int32_t uid_ = 0;
60     int32_t userId_ = 0;
61     sptr<CameraManager> cameraManager_ = nullptr;
62     sptr<CaptureInput> input_;
63     sptr<CaptureOutput> preview_;
64     sptr<CaptureSession> session_;
65     std::vector<sptr<CameraDevice>> cameras_;
66 
67     /* SetUpTestCase:The preset action of the test suite is executed before the first TestCase */
68     static void SetUpTestCase(void);
69 
70     /* TearDownTestCase:The test suite cleanup action is executed after the last TestCase */
71     static void TearDownTestCase(void);
72 
73     /* SetUp:Execute before each test case */
74     void SetUpInit();
75     void SetUp();
76 
77     /* TearDown:Execute after each test case */
78     void TearDown();
79 
80     void UpdateCameraOutputCapability(int32_t modeName = 0);
81 
82     void UpdateCameraOutputCapabilitySrc(int32_t modeName = 0);
83 
84 protected:
85     std::vector<Profile> previewProfile_ = {};
86     std::vector<Profile> photoProfile_ = {};
87 };
88 } // namespace CameraStandard
89 } // namespace OHOS
90 
91 #endif // CAMERA_FORMAT_YUV_MODULETEST_H