From 099b366a3f06ee273ddc574add8174f7c6015c8c Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 14:56:06 +0800 Subject: [PATCH 1/9] add UT test. Signed-off-by: wangwenjun --- bundle.json | 2 + .../screen_sink/src/dscreen_sink_handler.cpp | 4 +- .../callback/dscreen_source_load_callback.cpp | 1 - .../src/dscreen_source_handler.cpp | 5 +- .../native_cpp/test/unittest/BUILD.gn | 20 ++ .../test/unittest/screensinktest/BUILD.gn | 74 +++++++ .../include/dscreen_sink_handler_test.h | 41 ++++ .../src/dscreen_sink_handler_test.cpp | 54 ++++++ .../test/unittest/screensourcetest/BUILD.gn | 77 ++++++++ .../callback/dscreen_source_callback_test.h | 39 ++++ .../include/dscreen_source_common.h | 93 +++++++++ .../include/dscreen_source_handler_test.h | 38 ++++ .../callback/dscreen_source_callback_test.cpp | 182 ++++++++++++++++++ .../src/dscreen_source_handler_test.cpp | 76 ++++++++ 14 files changed, 700 insertions(+), 6 deletions(-) create mode 100644 interfaces/innerkits/native_cpp/test/unittest/BUILD.gn create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensinktest/include/dscreen_sink_handler_test.h create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_handler_test.h create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp create mode 100644 interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp diff --git a/bundle.json b/bundle.json index b3f9f233..8d4b9fe8 100644 --- a/bundle.json +++ b/bundle.json @@ -81,6 +81,8 @@ "//foundation/distributedhardware/distributedscreen/services/screentransport/test/unittest:screen_transport_test", "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/unittest:SoftBusAdapterTest", "//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test", + "//foundation/distributedhardware/distributedscreen/services/screenservice/test/unittest:screen_service_test", + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/unittest:screen_interface_test", "//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest", diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 40390679..440e5537 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -44,6 +44,7 @@ DScreenSinkHandler::~DScreenSinkHandler() int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) { DHLOGD("InitSink"); + std::unique_lock lock(proxyMutex_); if (!dScreenSinkProxy_) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { @@ -59,7 +60,6 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) } } - std::unique_lock lock(proxyMutex_); auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), [this]() { return dScreenSinkProxy_ != nullptr; }); if (!waitStatus) { @@ -74,7 +74,7 @@ void DScreenSinkHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { DHLOGD("FinishStartSA"); - std::lock_guard lock(proxyMutex_); + std::unique_lock lock(proxyMutex_); remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(remoteObject); if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp index 9c7cdcb4..bd712611 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -31,7 +31,6 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( DHLOGE("remoteObject is nullptr"); return; } - DScreenSourceHandler::GetInstance().FinishStartSA(params_, remoteObject); } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index a45b0502..806d8e2f 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -49,7 +49,7 @@ DScreenSourceHandler::~DScreenSourceHandler() int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) { DHLOGD("InitSource"); - + std::unique_lock lock(proxyMutex_); if (!dScreenSourceProxy_) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { @@ -65,7 +65,6 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) } } - std::unique_lock lock(proxyMutex_); auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), [this]() { return (dScreenSourceProxy_ != nullptr); }); if (!waitStatus) { @@ -80,7 +79,7 @@ void DScreenSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { DHLOGD("FinishStartSA"); - std::lock_guard lock(proxyMutex_); + std::unique_lock lock(proxyMutex_); remoteObject->AddDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = iface_cast(remoteObject); if ((!dScreenSourceProxy_) || (!dScreenSourceProxy_->AsObject())) { diff --git a/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn new file mode 100644 index 00000000..802fff87 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn @@ -0,0 +1,20 @@ +# 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. + +group("screen_interface_test") { + testonly = true + deps = [ + "screensinktest:screen_sink_test", + "screensourcetest:screen_source_test", + ] +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn new file mode 100644 index 00000000..59a221b0 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn @@ -0,0 +1,74 @@ +# 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/test.gni") +import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +module_out_path = "distributed_screen/source_trans_test" + +config("module_private_config") { + visibility = [ ":*" ] + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensinktest/include", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + ] +} + +## UnitTest ScreenSinkTest +ohos_unittest("ScreenSinkTest") { + module_out_path = module_out_path + + sources = [ + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "//third_party/googletest:gmock", + "//third_party/googletest:gtest_main", + "${fwk_utils_path}:distributedhardwareutils", + "//utils/native/base:utils", + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +group("screen_sink_test") { + testonly = true + deps = [ ":ScreenSinkTest" ] +} diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/include/dscreen_sink_handler_test.h b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/include/dscreen_sink_handler_test.h new file mode 100644 index 00000000..4b58a495 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/include/dscreen_sink_handler_test.h @@ -0,0 +1,41 @@ +/* + * 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 DSCREEN_SINK_HANDLER_TEST_H +#define DSCREEN_SINK_HANDLER_TEST_H + +#include +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_log.h" +#include "dscreen_sink_handler.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSinkHandlerTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +} +} + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp new file mode 100644 index 00000000..7fa8be87 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#define private public +#include "dscreen_sink_handler_test.h" +#undef private + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +void DScreenSinkHandlerTest::SetUpTestCase(void) {} + +void DScreenSinkHandlerTest::TearDownTestCase(void) {} + +void DScreenSinkHandlerTest::SetUp(void) +{ + DScreenSinkHandler::GetInstance().InitSink("DScreenSinkHandlerTest"); +} + +void DScreenSinkHandlerTest::TearDown(void) +{ + DScreenSinkHandler::GetInstance().ReleaseSink(); +} +/** + * @tc.name: LocalHardware_001 + * @tc.desc: Verify the SubscribeLocalHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSinkHandlerTest, LocalHardware_001, TestSize.Level1) +{ + const std::string dhId = "DScreenSinkHandlerTest"; + const std::string param = "DScreenSinkHandlerTest"; + int32_t ret = DScreenSinkHandler::GetInstance().SubscribeLocalHardware(dhId, param); + EXPECT_EQ(DH_SUCCESS, ret); + ret = DScreenSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); + EXPECT_EQ(DH_SUCCESS, ret); +} +} +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn new file mode 100644 index 00000000..e78e9cfa --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn @@ -0,0 +1,77 @@ +# 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/test.gni") +import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") + +module_out_path = "distributed_screen/source_trans_test" + +config("module_private_config") { + visibility = [ ":*" ] + include_dirs = [ + "//third_party/json/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include", + ] + + include_dirs += [ + "./include", + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/include", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/include/callback", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + ] +} + +## UnitTest ScreenSourceTest +ohos_unittest("ScreenSourceTest") { + module_out_path = module_out_path + + sources = [ + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "//third_party/googletest:gmock", + "//third_party/googletest:gtest_main", + "${fwk_utils_path}:distributedhardwareutils", + "//utils/native/base:utils", + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + ] + + external_deps = [ + "dsoftbus_standard:softbus_client", + "hiviewdfx_hilog_native:libhilog", + "multimedia_media_standard:media_client", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +group("screen_source_test") { + testonly = true + deps = [ ":ScreenSourceTest" ] +} diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h new file mode 100644 index 00000000..24f1e2d6 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h @@ -0,0 +1,39 @@ +/* + * 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 OHOS_DSCREEN_SOURCE_CALLBACK_TEST_H +#define OHOS_DSCREEN_SOURCE_CALLBACK_TEST_H + +#include + +#include "dscreen_errcode.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_common.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSourceCallbackTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + sptr dScreenSourceCallback_ = nullptr; +}; +} +} + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h new file mode 100644 index 00000000..823afec6 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_common.h @@ -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 OHOS_DSCREEN_COMMON_H +#define OHOS_DSCREEN_COMMON_H + +#include + +#include "dscreen_source_callback.h" +#include "dscreen_source_callback_stub.h" +#include "dscreen_source_handler.h" +#include "dscreen_source_proxy.h" +#include "idscreen_source_callback.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSourceCallbackStubVTest : public DScreenSourceCallbackStub { +public: + ~DScreenSourceCallbackStubVTest() {} + int32_t OnNotifyRegResultInner(MessageParcel &data, MessageParcel &reply, + MessageOption &option) + { + return 0; + } + int32_t OnNotifyUnregResultInner(MessageParcel &data, MessageParcel &reply, + MessageOption &option) + { + return 0; + } +}; + +class IDScreenSourceCallbackTest : public IDScreenSourceCallback { +public: + ~IDScreenSourceCallbackTest() {} + sptr AsObject() + { + return nullptr; + } + + int32_t OnNotifyRegResult(const std::string &devId, const std::string &dhId, + const std::string &reqId, int32_t status, const std::string &data) + { + return 0; + } + + int32_t OnNotifyUnregResult(const std::string &devId, const std::string &dhId, + const std::string &reqId, int32_t status, const std::string &data) + { + return 0; + } +}; + +class RegisterCallbackTest : public RegisterCallback { +public: + RegisterCallbackTest() = default; + virtual ~RegisterCallbackTest() = default; + + int32_t OnRegisterResult(const std::string &uuid, const std::string &dhId, int32_t status, + const std::string &data) + { + return 0; + } +}; + + +class UnregisterCallbackTest : public UnregisterCallback { +public: + UnregisterCallbackTest() = default; + virtual ~UnregisterCallbackTest() = default; + + int32_t OnUnregisterResult(const std::string &uuid, const std::string &dhId, int32_t status, + const std::string &data) + { + return 0; + } +}; +} +} + + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_handler_test.h b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_handler_test.h new file mode 100644 index 00000000..8159566f --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/dscreen_source_handler_test.h @@ -0,0 +1,38 @@ +/* + * 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 OHOS_DSCREEN_SOURCE_HANDLER_TEST_H +#define OHOS_DSCREEN_SOURCE_HANDLER_TEST_H + +#include +#include + +#include "dscreen_errcode.h" +#include "dscreen_source_common.h" +#include "dscreen_source_handler.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSourceHandlerTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +} +} + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp new file mode 100644 index 00000000..42af7b80 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp @@ -0,0 +1,182 @@ +/* + * 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. + */ + +#define private public +#include "dscreen_source_callback_test.h" +#undef private + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +void DScreenSourceCallbackTest::SetUpTestCase(void) {} + +void DScreenSourceCallbackTest::TearDownTestCase(void) {} + +void DScreenSourceCallbackTest::SetUp(void) +{ + dScreenSourceCallback_ = new DScreenSourceCallback(); +} + +void DScreenSourceCallbackTest::TearDown(void) +{ + dScreenSourceCallback_ = nullptr; +} + +/** + * @tc.name: OnNotifyRegResult_001 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, OnNotifyRegResult_001, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + const std::string reqId = "reqIdReg"; + int32_t status = 0; + const std::string data = "data"; + std::shared_ptr callback = std::make_shared(); + dScreenSourceCallback_->PushRegRegisterCallback(reqId, callback); + int32_t ret = dScreenSourceCallback_->OnNotifyRegResult(devId, dhId, reqId, status, data); + dScreenSourceCallback_->PopRegRegisterCallback(reqId); + EXPECT_EQ(DH_SUCCESS, ret); +} + +/** + * @tc.name: OnNotifyRegResult_002 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, OnNotifyRegResult_002, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + const std::string reqId = "reqId"; + int32_t status = 0; + const std::string data = "data"; + int32_t ret = dScreenSourceCallback_->OnNotifyRegResult(devId, dhId, reqId, status, data); + EXPECT_EQ(ERR_DH_SCREEN_SA_REGISTERCALLBACK_NOT_FOUND, ret); +} + +/** + * @tc.name: OnNotifyUnregResult_001 + * @tc.desc: Verify the OnNotifyUnregResult function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, OnNotifyUnregResult_001, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + const std::string reqId = "reqIdUnreg"; + int32_t status = 0; + const std::string data = "data"; + std::shared_ptr callback = std::make_shared(); + dScreenSourceCallback_->PushUnregisterCallback(reqId, callback); + int32_t ret = dScreenSourceCallback_->OnNotifyUnregResult(devId, dhId, reqId, status, data); + dScreenSourceCallback_->PopUnregisterCallback(reqId); + EXPECT_EQ(DH_SUCCESS, ret); +} + +/** + * @tc.name: OnNotifyUnregResult_002 + * @tc.desc: Verify the OnNotifyUnregResult function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, OnNotifyUnregResult_002, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + const std::string reqId = "reqId"; + int32_t status = 0; + const std::string data = "data"; + int32_t ret = dScreenSourceCallback_->OnNotifyUnregResult(devId, dhId, reqId, status, data); + EXPECT_EQ(ERR_DH_SCREEN_SA_UNREGISTERCALLBACK_NOT_FOUND, ret); +} + +/** + * @tc.name: PushRegRegisterCallback_001 + * @tc.desc: Verify the PushRegRegisterCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, PushRegRegisterCallback_001, TestSize.Level1) +{ + const std::string reqId = "reqIdReg"; + std::shared_ptr callback = std::make_shared(); + int32_t sizeFront = dScreenSourceCallback_->registerCallbackMap_.size(); + dScreenSourceCallback_->PushRegRegisterCallback(reqId, callback); + int32_t sizeEnd = dScreenSourceCallback_->registerCallbackMap_.size(); + dScreenSourceCallback_->PopRegRegisterCallback(reqId); + EXPECT_GT(sizeEnd, sizeFront); +} + +/** + * @tc.name: PopRegRegisterCallback_001 + * @tc.desc: Verify the PopRegRegisterCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, PopRegRegisterCallback_001, TestSize.Level1) +{ + const std::string reqId = "reqId"; + std::shared_ptr callback = std::make_shared(); + dScreenSourceCallback_->PushRegRegisterCallback(reqId, callback); + int32_t sizeFront = dScreenSourceCallback_->registerCallbackMap_.size(); + dScreenSourceCallback_->PopRegRegisterCallback(reqId); + int32_t sizeEnd = dScreenSourceCallback_->registerCallbackMap_.size(); + EXPECT_GT(sizeFront, sizeEnd); +} + + +/** + * @tc.name: PushRegRegisterCallback_001 + * @tc.desc: Verify the PushRegRegisterCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, PushUnregRegisterCallback_001, TestSize.Level1) +{ + const std::string reqId = "reqIdUnreg"; + std::shared_ptr callback = std::make_shared(); + int32_t sizeFront = dScreenSourceCallback_->unregisterCallbackMap_.size(); + dScreenSourceCallback_->PushUnregisterCallback(reqId, callback); + int32_t sizeEnd = dScreenSourceCallback_->unregisterCallbackMap_.size(); + dScreenSourceCallback_->PopUnregisterCallback(reqId); + EXPECT_GT(sizeEnd, sizeFront); +} + +/** + * @tc.name: PopRegRegisterCallback_001 + * @tc.desc: Verify the PopRegRegisterCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceCallbackTest, PopUnregRegisterCallback_001, TestSize.Level1) +{ + const std::string reqId = "reqId"; + std::shared_ptr callback = std::make_shared(); + dScreenSourceCallback_->PushUnregisterCallback(reqId, callback); + int32_t sizeFront = dScreenSourceCallback_->unregisterCallbackMap_.size(); + dScreenSourceCallback_->PopUnregisterCallback(reqId); + int32_t sizeEnd = dScreenSourceCallback_->unregisterCallbackMap_.size(); + EXPECT_GT(sizeFront, sizeEnd); +} +} +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp new file mode 100644 index 00000000..c3c09eba --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -0,0 +1,76 @@ +/* + * 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. + */ + +#define private public +#include "dscreen_source_handler_test.h" +#undef private + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +void DScreenSourceHandlerTest::SetUpTestCase(void) +{ + DScreenSourceHandler::GetInstance().InitSource("DScreenSourceHandlerTest"); +} + +void DScreenSourceHandlerTest::TearDownTestCase(void) +{ + DScreenSourceHandler::GetInstance().ReleaseSource(); +} + +void DScreenSourceHandlerTest::SetUp(void) {} + +void DScreenSourceHandlerTest::TearDown(void) {} + +/** + * @tc.name: RegisterDistributedHardware_001 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = std::make_shared(); + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + EXPECT_EQ(DH_SUCCESS, ret); +} + +/** + * @tc.name: RegisterDistributedHardware_002 + * @tc.desc: Verify the RegisterDistributedHardware function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_002, TestSize.Level1) +{ + const std::string devId = "devId"; + const std::string dhId = "dhId"; + EnableParam param; + param.version = "1"; + param.attrs = "attrs"; + std::shared_ptr callback = std::make_shared(); + DScreenSourceHandler::GetInstance().dScreenSourceCallback_ = nullptr; + int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); + EXPECT_EQ(ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT, ret); +} +} +} \ No newline at end of file -- Gitee From f40dd5b645988e9582e1e57a805be112a65c468a Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 15:09:00 +0800 Subject: [PATCH 2/9] add UT test. Signed-off-by: wangwenjun --- bundle.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/bundle.json b/bundle.json index 8d4b9fe8..8a2ca0ea 100644 --- a/bundle.json +++ b/bundle.json @@ -50,8 +50,6 @@ "//foundation/distributedhardware/distributedscreen/screenhandler:distributed_screen_handler", "//foundation/distributedhardware/distributedscreen/services/screentransport/screensinktrans:distributed_screen_sinktrans", "//foundation/distributedhardware/distributedscreen/services/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", - "//foundation/distributedhardware/distributedscreen/services/screenservice/sourceservice:distributed_screen_source", "//foundation/distributedhardware/distributedscreen/sa_profile:dscreen_sa_profile", "//foundation/distributedhardware/distributedscreen/sa_profile:dscreen.cfg" ], -- Gitee From 3925201ce3b295478240eed4776c18dd7849cd39 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 15:16:21 +0800 Subject: [PATCH 3/9] add UT test. Signed-off-by: wangwenjun --- .../screensourcetest/src/dscreen_source_handler_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index c3c09eba..66a4c38a 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -22,12 +22,12 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -void DScreenSourceHandlerTest::SetUpTestCase(void) +void DScreenSourceHandlerTest::SetUpTestCase(void) { DScreenSourceHandler::GetInstance().InitSource("DScreenSourceHandlerTest"); } -void DScreenSourceHandlerTest::TearDownTestCase(void) +void DScreenSourceHandlerTest::TearDownTestCase(void) { DScreenSourceHandler::GetInstance().ReleaseSource(); } -- Gitee From 730bfad490515f5fbbbbaedb52132d680cdb5da2 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 15:31:19 +0800 Subject: [PATCH 4/9] add UT test. Signed-off-by: wangwenjun --- bundle.json | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle.json b/bundle.json index 8a2ca0ea..07590c28 100644 --- a/bundle.json +++ b/bundle.json @@ -79,7 +79,6 @@ "//foundation/distributedhardware/distributedscreen/services/screentransport/test/unittest:screen_transport_test", "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/unittest:SoftBusAdapterTest", "//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test", - "//foundation/distributedhardware/distributedscreen/services/screenservice/test/unittest:screen_service_test", "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/unittest:screen_interface_test", "//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", -- Gitee From c0c5faae44efbb2e866370543acc143c98208192 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 15:48:04 +0800 Subject: [PATCH 5/9] add UT test. Signed-off-by: wangwenjun --- interfaces/innerkits/native_cpp/test/unittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn index 802fff87..6cc313b8 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/BUILD.gn @@ -17,4 +17,4 @@ group("screen_interface_test") { "screensinktest:screen_sink_test", "screensourcetest:screen_source_test", ] -} \ No newline at end of file +} -- Gitee From 489d4d758c3d5c4f7828d0de6bcbd4fef099fa19 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 16:21:18 +0800 Subject: [PATCH 6/9] add UT test. Signed-off-by: wangwenjun --- .../test/unittest/screensinktest/BUILD.gn | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn index 59a221b0..7a36a109 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") module_out_path = "distributed_screen/source_trans_test" @@ -42,27 +43,25 @@ config("module_private_config") { ohos_unittest("ScreenSinkTest") { module_out_path = module_out_path - sources = [ - "${interfaces_path}/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp", - ] + sources = [ "${interfaces_path}/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp" ] configs = [ ":module_private_config" ] deps = [ - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", "${fwk_utils_path}:distributedhardwareutils", - "//utils/native/base:utils", - "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", ] external_deps = [ "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", "ipc:ipc_core", + "multimedia_media_standard:media_client", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] -- Gitee From 03a62b542275cd16373c15166d3b347b309db137 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 17:10:04 +0800 Subject: [PATCH 7/9] add UT test. Signed-off-by: wangwenjun --- .../native_cpp/screen_sink/include/dscreen_sink_handler.h | 2 +- .../native_cpp/screen_source/include/dscreen_source_handler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h index 400e5106..5bd71c44 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h @@ -34,7 +34,6 @@ public: int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; int32_t UnsubscribeLocalHardware(const std::string &dhId) override; void OnRemoteSinkSvrDied(const wptr &remote); - void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSinkSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -43,6 +42,7 @@ private: DScreenSinkHandler(); ~DScreenSinkHandler(); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); std::mutex proxyMutex_; std::condition_variable proxyConVar_; diff --git a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h index a602ab61..f46347a8 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h @@ -38,7 +38,6 @@ public: int32_t ConfigDistributedHardware(const std::string &devId, const std::string &dhId, const std::string &key, const std::string &value) override; void OnRemoteSourceSvrDied(const wptr &remote); - void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSourceSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -47,6 +46,7 @@ private: DScreenSourceHandler(); ~DScreenSourceHandler(); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); std::mutex proxyMutex_; std::condition_variable proxyConVar_; -- Gitee From bb75da72a1d320ff6617989b9bba90f0cf680fcf Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 17:44:12 +0800 Subject: [PATCH 8/9] add UT test. Signed-off-by: wangwenjun --- .../native_cpp/screen_sink/include/dscreen_sink_handler.h | 2 +- .../native_cpp/screen_source/include/dscreen_source_handler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h index 5bd71c44..400e5106 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h @@ -34,6 +34,7 @@ public: int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; int32_t UnsubscribeLocalHardware(const std::string &dhId) override; void OnRemoteSinkSvrDied(const wptr &remote); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSinkSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -42,7 +43,6 @@ private: DScreenSinkHandler(); ~DScreenSinkHandler(); - void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); std::mutex proxyMutex_; std::condition_variable proxyConVar_; diff --git a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h index f46347a8..a602ab61 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h @@ -38,6 +38,7 @@ public: int32_t ConfigDistributedHardware(const std::string &devId, const std::string &dhId, const std::string &key, const std::string &value) override; void OnRemoteSourceSvrDied(const wptr &remote); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSourceSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -46,7 +47,6 @@ private: DScreenSourceHandler(); ~DScreenSourceHandler(); - void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); std::mutex proxyMutex_; std::condition_variable proxyConVar_; -- Gitee From 8ff802c0c4bb56bb98bb1717def37b380e5c2dc9 Mon Sep 17 00:00:00 2001 From: wangwenjun Date: Mon, 9 May 2022 18:00:32 +0800 Subject: [PATCH 9/9] add UT test. Signed-off-by: wangwenjun --- .../test/unittest/screensourcetest/BUILD.gn | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn index e78e9cfa..540b1a8e 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") module_out_path = "distributed_screen/source_trans_test" @@ -45,27 +46,27 @@ ohos_unittest("ScreenSourceTest") { module_out_path = module_out_path sources = [ - "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp", - "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp", + "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp", ] configs = [ ":module_private_config" ] deps = [ - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", "${fwk_utils_path}:distributedhardwareutils", - "//utils/native/base:utils", - "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", + "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", ] external_deps = [ "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", "ipc:ipc_core", + "multimedia_media_standard:media_client", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", ] -- Gitee