• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 UTEST_CAMERA_HDI_BASE_H
17 #define UTEST_CAMERA_HDI_BASE_H
18 
19 #include <thread>
20 #include <unistd.h>
21 #include <vector>
22 #include <map>
23 #include <gtest/gtest.h>
24 #include <hdf_log.h>
25 #include <osal_mem.h>
26 #include "securec.h"
27 
28 #include "camera.h"
29 #include "camera_metadata_info.h"
30 #include "ibuffer.h"
31 #include "ioffline_stream_operator.h"
32 #include <surface.h>
33 #include <display_type.h>
34 #include <fcntl.h>
35 #include <stdio.h>
36 #include <sys/ioctl.h>
37 #include <sys/wait.h>
38 #include <unistd.h>
39 
40 #include "icamera_host.h"
41 #include "camera_host_callback.h"
42 #include "camera_device_callback.h"
43 #include "icamera_device.h"
44 #include "stream_operator_callback.h"
45 #include "istream_operator_callback.h"
46 
47 #ifdef CAMERA_BUILT_ON_OHOS_LITE
48 #include "camera_device.h"
49 #include "camera_host.h"
50 #include "stream_operator.h"
51 #else
52 #include "if_system_ability_manager.h"
53 #include "iservice_registry.h"
54 #include "camera_host_proxy.h"
55 #endif
56 
57 using namespace OHOS;
58 using namespace testing::ext;
59 using namespace OHOS::Camera;
60 
61 class CameraHdiBaseTest : public testing::Test {
62 public:
63     static void SetUpTestCase(void);
64     static void TearDownTestCase(void);
65 
66     void SetUp(void);
67     void TearDown(void);
68 
69 protected:
70     virtual bool InitCameraHost();
71     virtual bool GetCameraDevice();
72     virtual bool GetStreamOperator();
73     virtual bool GetCameraIds();
74     int32_t SaveToFile(const std::string path, const void* buffer, int32_t size);
75     uint64_t GetCurrentLocalTimeStamp();
76 
77 protected:
78 #ifdef CAMERA_BUILT_ON_OHOS_LITE
79     std::shared_ptr<CameraHost> cameraHost_ = nullptr;
80     std::shared_ptr<ICameraDevice> cameraDevice_ = nullptr;
81     std::shared_ptr<IStreamOperator> streamOperator_ = nullptr;
82 #else
83     sptr<ICameraHost> cameraHost_ = nullptr;
84     sptr<ICameraDevice> cameraDevice_ = nullptr;
85     sptr<IStreamOperator> streamOperator_ = nullptr;
86 #endif
87 
88     std::vector<std::string> cameraIds_;
89 };
90 #endif // UTEST_CAMERA_HDI_BASE_H
91