From c663c31a1b02f7cf245c841b7cc8829b9fa765f5 Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Fri, 25 Oct 2024 14:58:47 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../common/utils/dcamera_utils_tools_test.cpp | 16 +++- .../test/unittest/common/camera_sink/BUILD.gn | 1 + .../dcamera_sink_callback_stub_test.cpp | 92 +++++++++++++++++++ .../callback/dcamera_sink_callback_test.cpp | 5 + .../dcamera_sink_callback_proxy_test.cpp | 24 +++++ .../dcamera_source_callback_proxy_test.cpp | 64 +++++++++++++ ...distributed_camera_source_service_test.cpp | 11 ++- .../dcamera_source_dev_test.cpp | 17 ++++ 8 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp diff --git a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp index 98344dcf..1a97f923 100644 --- a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp +++ b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp @@ -16,6 +16,8 @@ #include #include +#include +#include #include "accesstoken_kit.h" #include "anonymous_string.h" @@ -187,16 +189,28 @@ HWTEST_F(DcameraUtilsToolsTest, GetAnonyInt32_001, TestSize.Level1) */ HWTEST_F(DcameraUtilsToolsTest, IsOverDumpSize_001, TestSize.Level1) { + std::string DUMP_FILE_NAME = "/data/dump.txt"; + std::ofstream ofs(DUMP_FILE_NAME, std::ios::out); + if (!ofs) { + DHLOGI("open file failed"); + } else { + ofs.close(); + } + std::string fileName = ""; uint8_t *buf = nullptr; size_t size = 0; DumpBufferToFile(fileName, buf, size); EXPECT_EQ(DCAMERA_INIT_ERR, IsUnderDumpMaxSize(fileName)); + fileName = "test"; uint8_t str[] = "test"; size = strlen(reinterpret_cast(str)); DumpBufferToFile(fileName, str, size); - IsUnderDumpMaxSize(fileName); + EXPECT_EQ(DCAMERA_INIT_ERR, IsUnderDumpMaxSize(fileName)); + + DumpBufferToFile(DUMP_FILE_NAME, str, size); + EXPECT_EQ(DCAMERA_OK, IsUnderDumpMaxSize(fileName)); } /** diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn index f34c1b8e..c83c4f36 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("DCameraSinkHandlerTest") { sources = [ "callback/dcamera_sink_callback_test.cpp", + "callback/dcamera_sink_callback_stub_test.cpp", "dcamera_sink_handler_ipc_test.cpp", "dcamera_sink_handler_test.cpp", ] diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp new file mode 100644 index 00000000..f99d8770 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 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 + +#include "dcamera_sink_callback_stub.h" +#include "dcamera_sink_callback.h" + +#include "anonymous_string.h" +#include "distributed_camera_errno.h" +#include "distributed_hardware_log.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class DCameraSinkCallbackStubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr sinkCallbackStub_; +}; + +void DCameraSinkCallbackStubTest::SetUpTestCase(void) +{ + DHLOGI("enter"); +} + +void DCameraSinkCallbackStubTest::TearDownTestCase(void) +{ + DHLOGI("enter"); +} + +void DCameraSinkCallbackStubTest::SetUp(void) +{ + DHLOGI("enter"); + sinkCallbackStub_ = std::make_shared(); +} + +void DCameraSinkCallbackStubTest::TearDown(void) +{ + DHLOGI("enter"); + sinkCallbackStub_ = nullptr; +} + +/** + * @tc.name: OnRemoteRequest_001 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: issue + + int32_t DCameraSinkCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) + */ +HWTEST_F(DCameraSinkCallbackStubTest, OnRemoteRequest_001, TestSize.Level1) +{ + DHLOGI("DCameraSinkCallbackStubTest OnRemoteRequest_001."); + EXPECT_EQ(false, sinkCallbackStub_ == nullptr); + + int32_t ret = DCAMERA_OK; + int32_t UNKNOW_TRANS_ERR = 305; + uint32_t code = 0; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + code = 1; + data.WriteInterfaceToken(DCameraSinkCallbackStub::GetDescriptor()); + ret = sinkCallbackStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(UNKNOW_TRANS_ERR, ret); + + data.WriteInterfaceToken(u""); + ret = sinkCallbackStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(DCAMERA_OK, ret); +} +} +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp index 33cb3bf4..8a1d83ab 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp @@ -104,6 +104,11 @@ HWTEST_F(DCameraSinkCallbackTest, dcamera_sink_callback_test_002, TestSize.Level bool isSameAccout = false; int32_t ret = sinkCallback_->OnNotifyResourceInfo(type, subType, networkId, isSensitive, isSameAccout); EXPECT_EQ(DCAMERA_OK, ret); + + std::shared_ptr callback = std::make_shared(); + sinkCallback_->PushPrivacyResCallback(callback); + ret = sinkCallback_->OnNotifyResourceInfo(type, subType, networkId, isSensitive, isSameAccout); + EXPECT_EQ(DCAMERA_OK, ret); } } } \ No newline at end of file diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp index 7ea1c2a3..720a467b 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp @@ -16,6 +16,7 @@ #include #include "dcamera_sink_callback_proxy.h" +#include "dcamera_sink_callback.h" #include "distributed_camera_errno.h" #include "distributed_camera_constants.h" #include "distributed_camera_sink_proxy.h" @@ -70,5 +71,28 @@ HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_001, Tes sptr callbackProxy(new DCameraSinkCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); } + +/** + * @tc.name: dcamera_sink_callback_proxy_test_002 + * @tc.desc: Verify the OnNotifyResourceInfo function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_002, TestSize.Level1) +{ + DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_002"); + sptr remoteObject = sptr(new DCameraSinkCallback()); + sptr callbackProxy(new DCameraSinkCallbackProxy(remoteObject)); + EXPECT_EQ(false, callbackProxy == nullptr); + + int32_t ret = DCAMERA_BAD_VALUE; + ResourceEventType type; + std::string subtype(""); + std::string newworkId(""); + bool isSensitive = false; + bool isSameAccout = false; + ret = callbackProxy->OnNotifyResourceInfo(type, subtype, newworkId, isSensitive, isSameAccout); + EXPECT_EQ(DCAMERA_OK, ret); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 49425de7..2f06edaf 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -16,6 +16,7 @@ #include #include "dcamera_source_callback_proxy.h" +#include "dcamera_source_callback.h" #include "distributed_camera_errno.h" #include "distributed_camera_constants.h" #include "distributed_camera_source_proxy.h" @@ -133,6 +134,37 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_003, EXPECT_EQ(DCAMERA_OK, status); } +/** + * @tc.name: dcamera_source_callback_proxy_test_004 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_004, TestSize.Level1) +{ + DHLOGI("DcameraSourceCallbackProxyTest::dcamera_source_callback_proxy_test_004"); + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); + sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); + EXPECT_EQ(false, callbackProxy == nullptr); + + int32_t status = 0; + const std::string maxdirstr(257, "1"); + const std::string testemptystr = ""; + const std::string teststr = "TESTSTR"; + std::string maxdirstr1(50 * 1024 * 1024 + 1, "1"); + std::string emptystr = ""; + + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(testemptystr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(maxdirstr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, maxdirstr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, maxdirstr, status, emptystr)); + EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, teststr, status, maxdirstr1)); +} + /** * @tc.name: CheckParams_001 * @tc.desc: Verify the CheckParams function. @@ -179,6 +211,22 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnDataSyncTrigger_001, TestSize.Level1) EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnDataSyncTrigger(devId)); } +/** + * @tc.name: OnDataSyncTrigger_002 + * @tc.desc: Verify the OnDataSyncTrigger function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSourceCallbackProxyTest, OnDataSyncTrigger_002, TestSize.Level1) +{ + DHLOGI("DcameraSourceCallbackProxyTest::OnDataSyncTrigger_002"); + + sptr remoteObject = sptr(new DCameraSourceCallback()); + auto instance = new DCameraSourceCallbackProxy(remoteObject); + + EXPECT_EQ(DCAMERA_BAD_VALUE, instance->OnDataSyncTrigger(TEST_DEVICE_ID)); +} + /** * @tc.name: OnHardwareStateChanged_001 * @tc.desc: Verify the OnHardwareStateChanged function. @@ -195,5 +243,21 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnHardwareStateChanged_001, TestSize.Le EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnHardwareStateChanged("", "", -1)); } + +/** + * @tc.name: OnHardwareStateChanged_002 + * @tc.desc: Verify the OnHardwareStateChanged function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSourceCallbackProxyTest, OnHardwareStateChanged_002, TestSize.Level1) +{ + DHLOGI("DcameraSourceCallbackProxyTest::OnHardwareStateChanged_002"); + + sptr remoteObject = sptr(new DCameraSourceCallback()); + auto instance = new DCameraSourceCallbackProxy(remoteObject); + + EXPECT_EQ(DCAMERA_BAD_VALUE, instance->OnHardwareStateChanged(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, 0)); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp index 57403d98..3f8b478f 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp @@ -123,6 +123,12 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_003, Te args.push_back(str); int ret = testSrcService_->Dump(fd, args); EXPECT_EQ(DCAMERA_OK, ret); + + for (int i=0; i<10242; i++) { + args.push_back(u""); + } + ret = testSrcService_->Dump(fd, args); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); } /** @@ -225,7 +231,10 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_009, Te DHLOGI("DistributedCameraSourceServiceTest::dcamera_source_service_test_009"); EXPECT_EQ(false, testSrcService_ == nullptr); - int32_t ret = testSrcService_->LoadDCameraHDF(); + int32_t ret = testSrcService_->UnLoadCameraHDF(); + EXPECT_EQ(DCAMERA_OK, ret); + + ret = testSrcService_->LoadDCameraHDF(); EXPECT_EQ(DCAMERA_OK, ret); ret = testSrcService_->UnLoadCameraHDF(); EXPECT_EQ(DCAMERA_OK, ret); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp index c5483978..fc39ae94 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp @@ -661,5 +661,22 @@ HWTEST_F(DCameraSourceDevTest, SetHicollieFlag_001, TestSize.Level1) camDev_->SetHicollieFlag(false); EXPECT_EQ(false, camDev_->GetHicollieFlag()); } + +/** + * @tc.name: SetHicollieFlag_001 + * @tc.desc: Verify source dev SetHicollieFlag. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DCameraSourceDevTest, GetFullCaps_001, TestSize.Level1) +{ + DHLOGI("DCameraSourceDevTest GetFullCaps_001"); + EXPECT_EQ(DCAMERA_OK, camDev_->GetFullCaps()); + + std::shared_ptr camDev1_; + std::shared_ptr stateListener1_; + camDev1_ = std::make_shared(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, stateListener1_); + EXPECT_EQ(DCAMERA_BAD_VALUE, camDev_->GetFullCaps()); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee From 333227f2a3e7dc781212efd80bf6a9b3f7aa22d0 Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Fri, 25 Oct 2024 15:13:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../distributed_camera_source_service_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp index 3f8b478f..418c0cdc 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp @@ -124,7 +124,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_003, Te int ret = testSrcService_->Dump(fd, args); EXPECT_EQ(DCAMERA_OK, ret); - for (int i=0; i<10242; i++) { + for (int i = 0; i < 10242; i++) { args.push_back(u""); } ret = testSrcService_->Dump(fd, args); -- Gitee From 9a1354e6f09b9377fdce7267ba92bc692f4357da Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Fri, 25 Oct 2024 15:32:56 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../native_cpp/test/unittest/common/camera_sink/BUILD.gn | 2 +- .../dcamera_source_callback_proxy_test.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn index c83c4f36..e4e9402a 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn @@ -33,8 +33,8 @@ ohos_unittest("DCameraSinkHandlerTest") { module_out_path = module_out_path sources = [ - "callback/dcamera_sink_callback_test.cpp", "callback/dcamera_sink_callback_stub_test.cpp", + "callback/dcamera_sink_callback_test.cpp", "dcamera_sink_handler_ipc_test.cpp", "dcamera_sink_handler_test.cpp", ] diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 2f06edaf..9bb1a118 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -222,9 +222,9 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnDataSyncTrigger_002, TestSize.Level1) DHLOGI("DcameraSourceCallbackProxyTest::OnDataSyncTrigger_002"); sptr remoteObject = sptr(new DCameraSourceCallback()); - auto instance = new DCameraSourceCallbackProxy(remoteObject); + sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); - EXPECT_EQ(DCAMERA_BAD_VALUE, instance->OnDataSyncTrigger(TEST_DEVICE_ID)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnDataSyncTrigger(TEST_DEVICE_ID)); } /** @@ -255,9 +255,9 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnHardwareStateChanged_002, TestSize.Le DHLOGI("DcameraSourceCallbackProxyTest::OnHardwareStateChanged_002"); sptr remoteObject = sptr(new DCameraSourceCallback()); - auto instance = new DCameraSourceCallbackProxy(remoteObject); + sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); - EXPECT_EQ(DCAMERA_BAD_VALUE, instance->OnHardwareStateChanged(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, 0)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnHardwareStateChanged(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, 0)); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee From c7386b7a9c22ad418075b8c4fd30b27ab585fd8a Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Fri, 25 Oct 2024 16:59:42 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../distributedcamera/dcamera_sink_callback_proxy_test.cpp | 2 +- .../distributedcamera/dcamera_source_callback_proxy_test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp index 720a467b..1dcd4b73 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp @@ -86,7 +86,7 @@ HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_002, Tes EXPECT_EQ(false, callbackProxy == nullptr); int32_t ret = DCAMERA_BAD_VALUE; - ResourceEventType type; + ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE; std::string subtype(""); std::string newworkId(""); bool isSensitive = false; diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 9bb1a118..5db09ccf 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -150,10 +150,10 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_004, EXPECT_EQ(false, callbackProxy == nullptr); int32_t status = 0; - const std::string maxdirstr(257, "1"); + const std::string maxdirstr(257, '1'); const std::string testemptystr = ""; const std::string teststr = "TESTSTR"; - std::string maxdirstr1(50 * 1024 * 1024 + 1, "1"); + std::string maxdirstr1(50 * 1024 * 1024 + 1, '1'); std::string emptystr = ""; EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(testemptystr, testemptystr, testemptystr, status, emptystr)); -- Gitee From f79ff4d4ddb2a4394b6c7f4fd0aa5dc748778d4d Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Sat, 26 Oct 2024 10:03:43 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../common/utils/dcamera_utils_tools_test.cpp | 2 +- .../callback/dcamera_sink_callback_stub_test.cpp | 2 +- .../dcamera_source_callback_proxy_test.cpp | 14 +++++++------- .../dcamera_source_dev_test.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp index 1a97f923..1e516c7c 100644 --- a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp +++ b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp @@ -210,7 +210,7 @@ HWTEST_F(DcameraUtilsToolsTest, IsOverDumpSize_001, TestSize.Level1) EXPECT_EQ(DCAMERA_INIT_ERR, IsUnderDumpMaxSize(fileName)); DumpBufferToFile(DUMP_FILE_NAME, str, size); - EXPECT_EQ(DCAMERA_OK, IsUnderDumpMaxSize(fileName)); + EXPECT_EQ(DCAMERA_OK, IsUnderDumpMaxSize(DUMP_FILE_NAME)); } /** diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp index f99d8770..6a955c8b 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_stub_test.cpp @@ -86,7 +86,7 @@ HWTEST_F(DCameraSinkCallbackStubTest, OnRemoteRequest_001, TestSize.Level1) data.WriteInterfaceToken(u""); ret = sinkCallbackStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(DCAMERA_OK, ret); + EXPECT_EQ(ERR_INVALID_DATA, ret); } } } \ No newline at end of file diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 5db09ccf..1ca40c49 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -156,13 +156,13 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_004, std::string maxdirstr1(50 * 1024 * 1024 + 1, '1'); std::string emptystr = ""; - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(testemptystr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(maxdirstr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, maxdirstr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, maxdirstr, status, emptystr)); - EXPECT_EQ(DCAMERA_OK, callbackProxy->OnNotifyRegResult(teststr, teststr, teststr, status, maxdirstr1)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(testemptystr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(maxdirstr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, maxdirstr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, maxdirstr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, teststr, status, maxdirstr1)); } /** diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp index fc39ae94..d0d351dc 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_dev_test.cpp @@ -676,7 +676,7 @@ HWTEST_F(DCameraSourceDevTest, GetFullCaps_001, TestSize.Level1) std::shared_ptr camDev1_; std::shared_ptr stateListener1_; camDev1_ = std::make_shared(TEST_DEVICE_ID, TEST_CAMERA_DH_ID_0, stateListener1_); - EXPECT_EQ(DCAMERA_BAD_VALUE, camDev_->GetFullCaps()); + EXPECT_EQ(DCAMERA_BAD_VALUE, camDev1_->GetFullCaps()); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file -- Gitee From 33e9c22f4c46eea7028f2e8290e3e130cdc03ef7 Mon Sep 17 00:00:00 2001 From: liqinglin <996260657@qq.com> Date: Sat, 26 Oct 2024 10:16:01 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liqinglin <996260657@qq.com> --- .../dcamera_source_callback_proxy_test.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 1ca40c49..6ba64b5d 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -156,13 +156,20 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_004, std::string maxdirstr1(50 * 1024 * 1024 + 1, '1'); std::string emptystr = ""; - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(testemptystr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(maxdirstr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, testemptystr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, maxdirstr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, testemptystr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, maxdirstr, status, emptystr)); - EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult(teststr, teststr, teststr, status, maxdirstr1)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + testemptystr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + maxdirstr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + teststr, testemptystr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + teststr, maxdirstr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + teststr, teststr, testemptystr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + teststr, teststr, maxdirstr, status, emptystr)); + EXPECT_EQ(DCAMERA_BAD_VALUE, callbackProxy->OnNotifyRegResult( + teststr, teststr, teststr, status, maxdirstr1)); } /** -- Gitee