mirror of
https://gitee.com/openharmony/xts_hats
synced 2025-02-26 05:15:51 +00:00
<相机接口覆盖>
Signed-off-by: Yyyingchao <chenyingchao4@huawei.com>
This commit is contained in:
parent
20c2e4d554
commit
963ff50664
21
distributedhardware/BUILD.gn
Normal file
21
distributedhardware/BUILD.gn
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos_var.gni")
|
||||
|
||||
group("distributedhardware") {
|
||||
testonly = true
|
||||
if (is_standard_system) {
|
||||
deps = [ "distributedcameratest:HatsdisCameraProviderCase" ]
|
||||
}
|
||||
}
|
97
distributedhardware/distributedcameratest/BUILD.gn
Normal file
97
distributedhardware/distributedcameratest/BUILD.gn
Normal file
@ -0,0 +1,97 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//test/xts/tools/build/suite.gni")
|
||||
module_output_path = "hats/distributedhardware"
|
||||
|
||||
config("dcamera_hdf_demo_config") {
|
||||
visibility = [ ":*" ]
|
||||
}
|
||||
|
||||
ohos_moduletest_suite("HatsdisCameraProviderCase") {
|
||||
module_out_path = module_output_path
|
||||
install_enable = true
|
||||
sources = [
|
||||
"dcameraprovidercase.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr",
|
||||
"//drivers/peripheral/distributed_camera/hdi_service/include/dcamera_provider",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcamera",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerastate",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/cameraoperator/client/include",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/base/include",
|
||||
"//foundation/distributedhardware/distributed_camera/services/channel/include",
|
||||
"//foundation/distributedhardware/distributed_camera/services/data_process/include/pipeline",
|
||||
"//foundation/distributedhardware/distributed_camera/services/data_process/include/interfaces",
|
||||
"//foundation/distributedhardware/distributed_camera/services/data_process/include/utils",
|
||||
"//foundation/distributedhardware/distributed_camera/services/data_process/include/eventbus",
|
||||
"//foundation/distributedhardware/distributed_camera/common/include/constants",
|
||||
"//foundation/distributedhardware/distributed_camera/common/include/utils",
|
||||
|
||||
"//foundation/distributedhardware/distributed_camera/interfaces/inner_kits/native_cpp/camera_source/include",
|
||||
"//foundation/distributedhardware/distributed_camera/interfaces/inner_kits/native_cpp/camera_source/include/callback",
|
||||
"//foundation/distributedhardware/distributed_camera/interfaces/inner_kits/native_cpp/camera_sink/include",
|
||||
|
||||
"//foundation/distributedhardware/distributed_hardware_fwk/utils/include",
|
||||
"//foundation/distributedhardware/distributed_hardware_fwk/utils/include/eventbus",
|
||||
"//foundation/distributedhardware/distributed_hardware_fwk/common/utils/include",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//drivers/peripheral/base/",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//drivers/interface/camera/v1_0:libcamera_stub_1.0",
|
||||
"//drivers/peripheral/distributed_camera/hdi_service:libdistributed_camera_hdf_service_1.0",
|
||||
"//third_party/jsoncpp:jsoncpp",
|
||||
|
||||
"//foundation/distributedhardware/distributed_camera/common:distributed_camera_utils",
|
||||
"//foundation/distributedhardware/distributed_camera/services/cameraservice/sourceservice:distributed_camera_source",
|
||||
"//foundation/distributedhardware/distributed_camera/services/channel:distributed_camera_channel",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-fPIC",
|
||||
"-Wall",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"drivers_interface_camera:libcamera_proxy_1.0",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"c_utils:utils",
|
||||
"drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.0",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraHdfCase\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
cflags_cc = cflags
|
||||
subsystem_name = "hdf"
|
||||
part_name = "drivers_peripheral_distributed_camera"
|
||||
}
|
22
distributedhardware/distributedcameratest/Test.json
Normal file
22
distributedhardware/distributedcameratest/Test.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"description": "Config for disSreen test cases",
|
||||
"driver": {
|
||||
"module-name": "HatsdisCameraProviderCase",
|
||||
"native-test-timeout": "120000",
|
||||
"native-test-device-path": "/data/local/tmp",
|
||||
"runtime-hint": "1s",
|
||||
"type": "CppTest"
|
||||
},
|
||||
"kits": [
|
||||
{
|
||||
"post-push" : [
|
||||
"chmod -R 777 /data/local/tmp/*"
|
||||
],
|
||||
"push": [
|
||||
"HatsdisCameraProviderCase->/data/local/tmp/HatsdisCameraProviderCase"
|
||||
],
|
||||
"type": "PushKit"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "dcameraprovidercase.h"
|
||||
#include "dcameratest.h"
|
||||
#include "dcamera_provider_callback_impl.h"
|
||||
#include "dcamera_provider.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DCameraProviderTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
std::shared_ptr<DCameraSourceDev> camDev_;
|
||||
std::shared_ptr<ICameraStateListener> stateListener_;
|
||||
sptr<IDCameraProviderCallback> hdiCallback_;
|
||||
};
|
||||
|
||||
namespace {
|
||||
const std::string testDeviceId = "bb536a637105409e904d4da83790a4a7";
|
||||
const std::string testCameraDh = "camera_0";
|
||||
const std::string testReqId = "0xFFFF";
|
||||
const std::string testParam = R"({"CodecType": ["avenc_mpeg4"],
|
||||
"OutputFormat": {"Photo":[4], "Preview":[2, 3], "Video":[2, 3]},
|
||||
"Position": "BACK",
|
||||
"ProtocolVer": "1.0",
|
||||
"MetaData": "",
|
||||
"Resolution": {
|
||||
"2": ["1920*1080", "1504*720", "1440*1080", "1280*960", "1280*720", "1232*768", "1152*720", "960*720", "960*544",
|
||||
"880*720", "720*720", "720*480", "640*480", "352*288", "320*240"],
|
||||
"3": ["1920*1080", "1504*720", "1440*1080", "1280*960", "1280*720", "1232*768", "1152*720", "960*720", "960*544",
|
||||
"880*720", "720*720", "720*480", "640*480", "352*288", "320*240"],
|
||||
"4": ["3840*2160", "3264*2448", "3264*1840", "2304*1728", "2048*1536", "1920*1440", "1920*1080", "1744*1088",
|
||||
"1280*720", "1232*768", "1152*720", "640*480", "320*240"]}})";
|
||||
const int32_t TEST_WIDTH = 1920;
|
||||
const int32_t TEST_HEIGTH = 1080;
|
||||
const int32_t TEST_STREAMID = 2;
|
||||
}
|
||||
|
||||
std::vector<DCStreamInfo> streamInfos;
|
||||
std::vector<DCCaptureInfo> captureInfos;
|
||||
std::vector<DCameraSettings> settings;
|
||||
std::vector<int> streamIds;
|
||||
DCameraSettings result;
|
||||
DHBase dhBase;
|
||||
DCameraProvider cameraProvider;
|
||||
DCameraBuffer buffer;
|
||||
DCameraHDFEvent hdiEvent;
|
||||
|
||||
void DCameraProviderTest::SetUpTestCase(void)
|
||||
{
|
||||
dhBase.deviceId_ = testDeviceId;
|
||||
dhBase.dhId_ = testCameraDh;
|
||||
|
||||
hdiEvent.type_ = 0;
|
||||
hdiEvent.result_ = 1;
|
||||
hdiEvent.content_ = 9;
|
||||
|
||||
result.type_ = METADATA_RESULT;
|
||||
result.value_ = "SettingValue";
|
||||
|
||||
DCStreamInfo streamInfo1;
|
||||
streamInfo1.streamId_ = 1;
|
||||
streamInfo1.width_ = TEST_WIDTH;
|
||||
streamInfo1.height_ = TEST_HEIGTH;
|
||||
streamInfo1.stride_ = 1;
|
||||
streamInfo1.format_ = 1;
|
||||
streamInfo1.dataspace_ = 1;
|
||||
streamInfo1.encodeType_ = ENCODE_TYPE_JPEG;
|
||||
streamInfo1.type_ = SNAPSHOT_FRAME;
|
||||
streamInfos.push_back(streamInfo1);
|
||||
|
||||
streamIds.push_back(1);
|
||||
streamIds.push_back(TEST_STREAMID);
|
||||
|
||||
DCCaptureInfo captureInfo1;
|
||||
captureInfo1.streamIds_.push_back(1);
|
||||
captureInfo1.width_ = TEST_WIDTH;
|
||||
captureInfo1.height_ = TEST_HEIGTH;
|
||||
captureInfo1.stride_ = 1;
|
||||
captureInfo1.format_ = 1;
|
||||
captureInfo1.dataspace_ = 1;
|
||||
captureInfo1.encodeType_ = ENCODE_TYPE_H265;
|
||||
captureInfo1.type_ = CONTINUOUS_FRAME;
|
||||
captureInfos.push_back(captureInfo1);
|
||||
|
||||
settings.push_back(result);
|
||||
}
|
||||
|
||||
void DCameraProviderTest::TearDownTestCase(void) {}
|
||||
|
||||
void DCameraProviderTest::SetUp(void)
|
||||
{
|
||||
stateListener_ = std::make_shared<HdiDCameraSourceStateListener>();
|
||||
camDev_ = std::make_shared<HdiDCameraSourceDev>(testDeviceId, testCameraDh, stateListener_);
|
||||
hdiCallback_ = new (std::nothrow)DCameraProviderCallbackImpl(testDeviceId, testCameraDh, camDev_);
|
||||
}
|
||||
|
||||
void DCameraProviderTest::TearDown(void)
|
||||
{
|
||||
hdiCallback_ = nullptr;
|
||||
camDev_ = nullptr;
|
||||
stateListener_ = nullptr;
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0010, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.EnableDCameraDevice(dhBase, testParam, hdiCallback_);
|
||||
EXPECT_EQ(0, ret) << "EnableDCameraDevice fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0020, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.OpenSession(dhBase);
|
||||
EXPECT_NE(0, ret) << "OpenSession fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0030, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.ConfigureStreams(dhBase, streamInfos);
|
||||
EXPECT_NE(0, ret) << "ConfigureStreams fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0040, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.StartCapture(dhBase, captureInfos);
|
||||
EXPECT_NE(0, ret) << "StartCapture fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0050, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.Notify(dhBase, hdiEvent);
|
||||
EXPECT_EQ(0, ret) << "Notify fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0060, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.StopCapture(dhBase, streamIds);
|
||||
EXPECT_NE(0, ret) << "StopCapture fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0070, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.ReleaseStreams(dhBase, streamIds);
|
||||
EXPECT_NE(0, ret) << "ReleaseStreams fail";
|
||||
}
|
||||
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0080, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.CloseSession(dhBase);
|
||||
EXPECT_NE(0, ret) << "CloseSession fail";
|
||||
}
|
||||
|
||||
HWTEST_F(DCameraProviderTest, DCameraCase_0090, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = cameraProvider.DisableDCameraDevice(dhBase);
|
||||
EXPECT_EQ(0, ret) << "DisableDCameraDevice fail";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ID_CAMERA_PROVIDER_CASE_H_
|
||||
#define ID_CAMERA_PROVIDER_CASE_H_
|
||||
/*
|
||||
#include "dcamera_provider.h"
|
||||
#include "v1_0/id_camera_provider_callback.h"
|
||||
#include "v1_0/types.h"
|
||||
*/
|
||||
#include "dcamera_source_dev.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
#include "idistributed_camera_source.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class HdiDCameraSourceDev : public DCameraSourceDev {
|
||||
public:
|
||||
HdiDCameraSourceDev(std::string devId, std::string dhId, std::shared_ptr<ICameraStateListener>& stateLisener)
|
||||
: DCameraSourceDev(devId, dhId, stateLisener) {};
|
||||
~HdiDCameraSourceDev() = default;
|
||||
|
||||
int32_t Register(std::shared_ptr<DCameraRegistParam>& param)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t UnRegister(std::shared_ptr<DCameraRegistParam>& param)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t OpenCamera()
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t CloseCamera()
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t ConfigStreams(std::vector<std::shared_ptr<DCStreamInfo>>& streamInfos)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t ReleaseStreams(std::vector<int>& streamIds, bool& isAllRelease)
|
||||
{
|
||||
isAllRelease = true;
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t ReleaseAllStreams()
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t StartCapture(std::vector<std::shared_ptr<DCCaptureInfo>>& captureInfos)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t StopCapture(std::vector<int>& streamIds, bool& isAllStop)
|
||||
{
|
||||
isAllStop = true;
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t StopAllCapture()
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
int32_t CameraEventNotify(std::shared_ptr<DCameraEvent>& events)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string devId_;
|
||||
std::string dhId_;
|
||||
std::shared_ptr<ICameraStateListener> stateLisener_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
43
distributedhardware/distributedcameratest/dcameratest.h
Normal file
43
distributedhardware/distributedcameratest/dcameratest.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "icamera_state_listener.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class HdiDCameraSourceStateListener : public ICameraStateListener {
|
||||
public:
|
||||
HdiDCameraSourceStateListener() {};
|
||||
~HdiDCameraSourceStateListener() = default;
|
||||
|
||||
int32_t OnRegisterNotify(const std::string& devId, const std::string& dhId, const std::string& reqId,
|
||||
int32_t status, std::string& data)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
|
||||
int32_t OnUnregisterNotify(const std::string& devId, const std::string& dhId, const std::string& reqId,
|
||||
int32_t status, std::string& data)
|
||||
{
|
||||
return DCAMERA_OK;
|
||||
}
|
||||
|
||||
void SetCallback(sptr<IDCameraSourceCallback> callback)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
import("//test/xts/tools/build/suite.gni")
|
||||
|
||||
_all_test_packages = [
|
||||
"${HATS_ROOT}/distributedhardware:distributedhardware",
|
||||
"${HATS_ROOT}/hdf:hatshdftest",
|
||||
"${HATS_ROOT}/kernel:kernel",
|
||||
"${HATS_ROOT}/powermgr:powermgr",
|
||||
|
Loading…
x
Reference in New Issue
Block a user