diff --git a/bundle.json b/bundle.json index 68c8d98..cec47fd 100755 --- a/bundle.json +++ b/bundle.json @@ -86,7 +86,8 @@ "//foundation/distributedhardware/distributed_input/services/source/inputinject/test:test", "//foundation/distributedhardware/distributed_input/services/source/sourcemanager/test:test", "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/test:test", - "//foundation/distributedhardware/distributed_input/utils/test:test" + "//foundation/distributedhardware/distributed_input/utils/test:test", + "//foundation/distributedhardware/distributed_input/dfx_utils/test:test" ] } } diff --git a/dfx_utils/test/BUILD.gn b/dfx_utils/test/BUILD.gn new file mode 100644 index 0000000..af7b3aa --- /dev/null +++ b/dfx_utils/test/BUILD.gn @@ -0,0 +1,18 @@ +# 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("test") { + testonly = true + + deps = [ "dfxtest:dfxtest" ] +} \ No newline at end of file diff --git a/dfx_utils/test/dfxtest/BUILD.gn b/dfx_utils/test/dfxtest/BUILD.gn new file mode 100644 index 0000000..2a831e9 --- /dev/null +++ b/dfx_utils/test/dfxtest/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/distributed_input/distributedinput.gni") +module_out_path = "distributed_input/dfx_utils" + +group("dfxtest") { + testonly = true + + deps = [ ":distributed_input_dfx_test" ] +} + +## IpcTest distributed_input_dfx_test {{{ +ohos_unittest("distributed_input_dfx_test") { + module_out_path = module_out_path + + include_dirs = [ + "include", + "${common_path}/include", + "//commonlibrary/c_utils/base/include", + "//utils/system/safwk/native/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "${frameworks_path}/include", + "${dfx_utils_path}/include", + "${service_common}/include", + "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", + ] + + sources = [ + "${dfx_utils_path}/src/hidumper.cpp", + "distributed_input_dfx_test.cpp", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + "-Dprivate=public", + "-Dprotected=public", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"distributedinpututtest\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "${fwk_utils_path}:distributedhardwareutils", + "//third_party/openssl:libcrypto_static", + ] + + external_deps = [ + "c_utils:utils", + "hisysevent_native:libhisysevent", + ] + + cflags_cc = [ "-DHILOG_ENABLE" ] +} +## UnitTest distributed_input_dfx_test }}} diff --git a/dfx_utils/test/dfxtest/distributed_input_dfx_test.cpp b/dfx_utils/test/dfxtest/distributed_input_dfx_test.cpp new file mode 100644 index 0000000..1caf0c8 --- /dev/null +++ b/dfx_utils/test/dfxtest/distributed_input_dfx_test.cpp @@ -0,0 +1,104 @@ +/* + * 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 "distributed_input_dfx_test.h" + +#include "system_ability_definition.h" + +#include "dinput_errcode.h" +#include "hidumper.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +void DInputDfxUtilsTest::SetUp() +{ +} + +void DInputDfxUtilsTest::TearDown() +{ +} + +void DInputDfxUtilsTest::SetUpTestCase() +{ +} + +void DInputDfxUtilsTest::TearDownTestCase() +{ +} + +HWTEST_F(DInputDfxUtilsTest, HiDump_001, testing::ext::TestSize.Level1) +{ + std::vector args; + std::string result = ""; + bool ret = HiDumper::GetInstance().HiDump(args, result); + EXPECT_EQ(false, ret); +} + +HWTEST_F(DInputDfxUtilsTest, HiDump_002, testing::ext::TestSize.Level1) +{ + std::vector args; + args.push_back("-h"); + std::string result = ""; + bool ret = HiDumper::GetInstance().HiDump(args, result); + EXPECT_EQ(true, ret); + + args.clear(); + args.push_back("-nodeinfo"); + ret = HiDumper::GetInstance().HiDump(args, result); + EXPECT_EQ(true, ret); + + args.clear(); + args.push_back("-sessioninfo"); + ret = HiDumper::GetInstance().HiDump(args, result); + EXPECT_EQ(true, ret); +} + +HWTEST_F(DInputDfxUtilsTest, GetAllNodeInfos_001, testing::ext::TestSize.Level1) +{ + std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + std::string nodeName = "DistributedInput_123456"; + HiDumper::GetInstance().SaveNodeInfo(devId, nodeName, dhId); + EXPECT_EQ(1, HiDumper::GetInstance().nodeInfos_.size()); + + std::string result = ""; + int32_t ret = HiDumper::GetInstance().GetAllNodeInfos(result); + EXPECT_EQ(DH_SUCCESS, ret); + + HiDumper::GetInstance().DeleteNodeInfo(devId, dhId); + EXPECT_EQ(0, HiDumper::GetInstance().nodeInfos_.size()); +} + +HWTEST_F(DInputDfxUtilsTest, GetSessionInfo_001, testing::ext::TestSize.Level1) +{ + std::string remoteDevId = "umkyu1b165e1be98151891erbe8r91ev"; + int32_t sessionId = 1; + std::string mySessionName = "mySessionName_test"; + std::string peerSessionName = "peerSessionName_test"; + SessionStatus sessionStatus = SessionStatus::OPENED; + HiDumper::GetInstance().CreateSessionInfo(remoteDevId, sessionId, mySessionName, peerSessionName, sessionStatus); + EXPECT_EQ(1, HiDumper::GetInstance().sessionInfos_.size()); + + sessionStatus = SessionStatus::CLOSED; + HiDumper::GetInstance().SetSessionStatus(remoteDevId, sessionStatus); + + std::string result = ""; + int32_t ret = HiDumper::GetInstance().GetSessionInfo(result); + EXPECT_EQ(DH_SUCCESS, ret); +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/dfx_utils/test/dfxtest/distributed_input_dfx_test.h b/dfx_utils/test/dfxtest/distributed_input_dfx_test.h new file mode 100644 index 0000000..c8c3ccc --- /dev/null +++ b/dfx_utils/test/dfxtest/distributed_input_dfx_test.h @@ -0,0 +1,45 @@ +/* + * 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 DISRIBUTED_INPUT_DFX_UTILS_TEST_H +#define DISRIBUTED_INPUT_DFX_UTILS_TEST_H + +#include +#include +#include +#include + +#include +#include "ipc_skeleton.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +class DInputDfxUtilsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS + +#endif // DISRIBUTED_INPUT_DFX_UTILS_TEST_H \ No newline at end of file diff --git a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp index 6526a23..4827ee0 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.cpp @@ -77,6 +77,14 @@ void DistributedInputInnerTest::TestStopDInputCallback::OnResult( return; } +void DistributedInputInnerTest::TestStartStopDInputCallback::OnResultDhids( + const std::string &devId, const int32_t &status) +{ + (void)devId; + (void)status; + return; +} + void DistributedInputInnerTest::TestInputNodeListener::OnNodeOnLine(const std::string srcDevId, const std::string sinkDevId, const std::string sinkNodeId, const std::string sinkNodeDesc) { @@ -96,8 +104,8 @@ void DistributedInputInnerTest::TestInputNodeListener::OnNodeOffLine(const std:: return; } -int32_t DistributedInputInnerTest::TestSimulationEventListenerStub::OnSimulationEvent(uint32_t type, uint32_t code, - int32_t value) +int32_t DistributedInputInnerTest::TestSimulationEventListenerStub::OnSimulationEvent( + uint32_t type, uint32_t code, int32_t value) { (void)type; (void)code; @@ -164,24 +172,26 @@ HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput01, testing::ext::TestSize HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput02, testing::ext::TestSize.Level0) { string deviceId = ""; - sptr callback = new TestPrepareDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput03, testing::ext::TestSize.Level0) { - string deviceId = "PrepareRemoteInput01"; - sptr callback = nullptr; - int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback); + std::string srcId = "PrepareRemoteInput_test"; + std::string sinkId = "PrepareRemoteInput_test"; + sptr callback = new TestPrepareDInputCallback(); + int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput04, testing::ext::TestSize.Level0) { - string deviceId = ""; + std::string srcId = ""; + std::string sinkId = ""; sptr callback = nullptr; - int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback); + int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -196,24 +206,26 @@ HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput01, testing::ext::TestSi HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput02, testing::ext::TestSize.Level0) { string deviceId = ""; - sptr callback = new TestUnprepareDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput03, testing::ext::TestSize.Level0) { - string deviceId = "UnprepareRemoteInput01"; - sptr callback = nullptr; - int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback); + std::string srcId = "PrepareRemoteInput_src"; + std::string sinkId = "PrepareRemoteInput_sink"; + sptr callback = new TestUnprepareDInputCallback(); + int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput04, testing::ext::TestSize.Level0) { - string deviceId = ""; + std::string srcId = ""; + std::string sinkId = ""; sptr callback = nullptr; - int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback); + int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -229,7 +241,7 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput01, testing::ext::TestSize.L HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.Level0) { string deviceId = ""; - sptr callback = new TestStartDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -237,19 +249,19 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.L HWTEST_F(DistributedInputInnerTest, StartRemoteInput03, testing::ext::TestSize.Level0) { - string deviceId = "StartRemoteInput01"; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); + std::string sinkId = "StartRemoteInput_sink"; + std::vector dhIds = {"dhIds_test"}; + sptr callback = new TestStartStopDInputCallback(); + int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, StartRemoteInput04, testing::ext::TestSize.Level0) { - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); + std::string sinkId = ""; + std::vector dhIds; + sptr callback = nullptr; + int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -267,7 +279,7 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput06, testing::ext::TestSize.L { string srcId = ""; string sinkId = ""; - sptr callback = new TestStartDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -275,11 +287,11 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput06, testing::ext::TestSize.L HWTEST_F(DistributedInputInnerTest, StartRemoteInput07, testing::ext::TestSize.Level0) { - string srcId = "StartRemoteInput03-src"; - string sinkId = "StartRemoteInput03-sink"; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); + string srcId = "StartRemoteInput01-src"; + string sinkId = "StartRemoteInput01-sink"; + std::vector dhIds = {"dhIds_test"}; + sptr callback = new TestStartStopDInputCallback(); + int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -287,9 +299,9 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput08, testing::ext::TestSize.L { string srcId = ""; string sinkId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); + std::vector dhIds; + sptr callback = nullptr; + int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -305,7 +317,7 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput01, testing::ext::TestSize.Le HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Level0) { string deviceId = ""; - sptr callback = new TestStopDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -313,19 +325,19 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Le HWTEST_F(DistributedInputInnerTest, StopRemoteInput03, testing::ext::TestSize.Level0) { - string deviceId = "StopRemoteInput01"; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); + std::string sinkId = "StartRemoteInput_test"; + std::vector dhIds = {"dhIds_test"}; + sptr callback = new TestStartStopDInputCallback(); + int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputInnerTest, StopRemoteInput04, testing::ext::TestSize.Level0) { - string deviceId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(deviceId, static_cast(DInputDeviceType::ALL), callback); + std::string sinkId = ""; + std::vector dhIds; + sptr callback = nullptr; + int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -343,7 +355,7 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput06, testing::ext::TestSize.Le { string srcId = ""; string sinkId = ""; - sptr callback = new TestStopDInputCallback(); + sptr callback = nullptr; int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -351,11 +363,11 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput06, testing::ext::TestSize.Le HWTEST_F(DistributedInputInnerTest, StopRemoteInput07, testing::ext::TestSize.Level0) { - string srcId = "StopRemoteInput03-src"; - string sinkId = "StopRemoteInput03-sink"; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); + string srcId = "StartRemoteInput01-src"; + string sinkId = "StartRemoteInput01-sink"; + std::vector dhIds = {"dhIds_test"}; + sptr callback = new TestStartStopDInputCallback(); + int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } @@ -363,9 +375,9 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput08, testing::ext::TestSize.Le { string srcId = ""; string sinkId = ""; - sptr callback = nullptr; - int32_t ret = - DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast(DInputDeviceType::ALL), callback); + std::vector dhIds; + sptr callback = nullptr; + int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback); EXPECT_EQ(DH_SUCCESS, ret); } diff --git a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h index dd9ccb8..3eb3cd1 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h @@ -31,6 +31,7 @@ #include "input_node_listener_stub.h" #include "i_distributed_sink_input.h" #include "i_distributed_source_input.h" +#include "start_stop_d_inputs_call_back_stub.h" #include "prepare_d_input_call_back_stub.h" #include "start_d_input_call_back_stub.h" #include "stop_d_input_call_back_stub.h" @@ -81,6 +82,14 @@ public: void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status); }; + class TestStartStopDInputCallback : public + OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { + public: + TestStartStopDInputCallback() = default; + virtual ~TestStartStopDInputCallback() = default; + void OnResultDhids(const std::string &devId, const int32_t &status); + }; + class TestInputNodeListener : public OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub { public: diff --git a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index 43a6d58..5fd70b4 100644 --- a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp +++ b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp @@ -117,24 +117,48 @@ int32_t DistributedInputClient::PrepareRemoteInput( return DH_SUCCESS; } +int32_t DistributedInputClient::PrepareRemoteInput( + const std::string &srcId, const std::string &sinkId, sptr callback) +{ + return DH_SUCCESS; +} + int32_t DistributedInputClient::UnprepareRemoteInput( const std::string& deviceId, sptr callback) { return DH_SUCCESS; } +int32_t DistributedInputClient::UnprepareRemoteInput( + const std::string &srcId, const std::string &sinkId, sptr callback) +{ + return DH_SUCCESS; +} + int32_t DistributedInputClient::StartRemoteInput( const std::string& deviceId, const uint32_t& inputTypes, sptr callback) { return DH_SUCCESS; } +int32_t DistributedInputClient::StartRemoteInput( + const std::string &sinkId, const std::vector &dhIds, sptr callback) +{ + return DH_SUCCESS; +} + int32_t DistributedInputClient::StopRemoteInput( const std::string& deviceId, const uint32_t& inputTypes, sptr callback) { return DH_SUCCESS; } +int32_t DistributedInputClient::StopRemoteInput( + const std::string &sinkId, const std::vector &dhIds, sptr callback) +{ + return DH_SUCCESS; +} + int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, sptr callback) { @@ -147,6 +171,18 @@ int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const return DH_SUCCESS; } +int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId, + const std::vector &dhIds, sptr callback) +{ + return DH_SUCCESS; +} + +int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const std::string &sinkId, + const std::vector &dhIds, sptr callback) +{ + return DH_SUCCESS; +} + bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const BusinessEvent& event) { return true; diff --git a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp index 32f0887..9dc3aaf 100644 --- a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp +++ b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.cpp @@ -89,6 +89,18 @@ HWTEST_F(DistributedInputCollectorTest, GetDeviceInfoByType, testing::ext::TestS DistributedInputCollector::GetInstance().GetDeviceInfoByType(inputTypes, deviceInfo); EXPECT_EQ(0, deviceInfo.size()); } + +HWTEST_F(DistributedInputCollectorTest, DistributedInputCollectorTest_001, testing::ext::TestSize.Level1) +{ + DistributedInputCollector::GetInstance().StartCollectEventsThread(); + std::vector sharingDhIds = {"1ds56v18e1v21v8v1erv15r1v8r1j1ty8"}; + std::vector noSharingDhIds = {"1ds56v18e1v21v8v1erv15r1v8r1j1ty8"}; + AffectDhIds dhIds {sharingDhIds, noSharingDhIds}; + std::string mouseNodePath = "mouseNodePath_test"; + std::string dhid = "dhid_test"; + DistributedInputCollector::GetInstance().ReportDhIdSharingState(dhIds); + DistributedInputCollector::GetInstance().GetMouseNodePath(sharingDhIds, mouseNodePath, dhid); +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp index 6fc0a21..7f1b21e 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -131,6 +131,14 @@ HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedHardware03, testin EXPECT_EQ(DH_SUCCESS, ret); } +HWTEST_F(DistributedInputSourceInjectTest, UnregisterDistributedHardware_001, testing::ext::TestSize.Level1) +{ + std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + int32_t ret = DistributedInputInject::GetInstance().UnregisterDistributedHardware(devId, dhId); + EXPECT_EQ(DH_SUCCESS, ret); +} + HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedEvent01, testing::ext::TestSize.Level1) { struct RawEvent writeBuffer[4]; @@ -261,6 +269,68 @@ HWTEST_F(DistributedInputSourceInjectTest, UnRegisterInputNodeListener, testing: EXPECT_EQ(DH_SUCCESS, ret); } +HWTEST_F(DistributedInputSourceInjectTest, GetDhIdsByInputType_001, testing::ext::TestSize.Level1) +{ + std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; + std::vector dhIds; + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + dhIds.push_back(dhId); + int32_t ret = DistributedInputInject::GetInstance().GetDhIdsByInputType(devId, + static_cast(DInputDeviceType::ALL), dhIds); + EXPECT_EQ(DH_SUCCESS, ret); +} + +HWTEST_F(DistributedInputSourceInjectTest, InputDeviceEventInject_001, testing::ext::TestSize.Level1) +{ + std::shared_ptr rawEvent = std::make_shared(); + DistributedInputInject::GetInstance().InputDeviceEventInject(rawEvent); +} + +HWTEST_F(DistributedInputSourceInjectTest, SyncNodeOnlineInfo_001, testing::ext::TestSize.Level1) +{ + std::string srcDevId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; + std::string sinkDevId = "umkyu1b165e1be98151891erbe8r91ev"; + std::string sinkNodeId = "usb-hiusb-ehci-2.1/input1"; + std::string sinkNodeDesc = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + DistributedInputInject::GetInstance().SyncNodeOnlineInfo(srcDevId, sinkDevId, sinkNodeId, sinkNodeDesc); +} + +HWTEST_F(DistributedInputSourceInjectTest, StartInjectThread_001, testing::ext::TestSize.Level1) +{ + DistributedInputInject::GetInstance().StartInjectThread(); +} + +HWTEST_F(DistributedInputSourceInjectTest, StopInjectThread_001, testing::ext::TestSize.Level1) +{ + DistributedInputInject::GetInstance().StopInjectThread(); +} + +HWTEST_F(DistributedInputSourceInjectTest, GenerateVirtualTouchScreenDHId_001, testing::ext::TestSize.Level1) +{ + std::string ret = DistributedInputInject::GetInstance().GenerateVirtualTouchScreenDHId(1, 1860, 980); + EXPECT_NE(0, ret.size()); +} + +HWTEST_F(DistributedInputSourceInjectTest, CreateVirtualTouchScreenNode_001, testing::ext::TestSize.Level1) +{ + std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + int32_t ret = DistributedInputInject::GetInstance().CreateVirtualTouchScreenNode(devId, dhId, 1, 1860, 980); + EXPECT_EQ(DH_SUCCESS, ret); +} + +HWTEST_F(DistributedInputSourceInjectTest, RemoveVirtualTouchScreenNode_001, testing::ext::TestSize.Level1) +{ + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + int32_t ret = DistributedInputInject::GetInstance().RemoveVirtualTouchScreenNode(dhId); + EXPECT_EQ(DH_SUCCESS, ret); +} + +HWTEST_F(DistributedInputSourceInjectTest, GetVirtualTouchScreenFd_001, testing::ext::TestSize.Level1) +{ + int32_t ret = DistributedInputInject::GetInstance().GetVirtualTouchScreenFd(); + EXPECT_NE(-1, ret); +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS