From afbf7a89500842def32850de373225fcb6b36705 Mon Sep 17 00:00:00 2001 From: joe49 Date: Mon, 10 Apr 2023 10:00:09 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E9=BB=84=E5=8C=BA=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=93=9D=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joe49 --- .../ipc/src/distributed_input_sink_stub.cpp | 4 +- sa_profile/dinput.cfg | 2 +- .../test/sinkmanagerunittest/BUILD.gn | 5 + .../distributed_input_sourceinject_test.cpp | 31 ++++- .../distributed_input_sourcemanager_test.cpp | 73 +++++++++++- .../distributed_input_sourcetrans_test.cpp | 106 ++++++++++++------ 6 files changed, 183 insertions(+), 38 deletions(-) diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 608b198..28ff506 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -52,7 +52,7 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel & auto iter = memberFuncMap_.find(code); if (iter == memberFuncMap_.end()) { DHLOGE("invalid request code is %d.", code); - return ERR_DH_INPUT_SA_REQUEST_CODE_INVALID; + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } DistributedInputSinkFunc &func = iter->second; return (this->*func)(data, reply, option); diff --git a/sa_profile/dinput.cfg b/sa_profile/dinput.cfg index 6d0c168..5aa5072 100644 --- a/sa_profile/dinput.cfg +++ b/sa_profile/dinput.cfg @@ -3,7 +3,7 @@ "name" : "dinput", "path" : ["/system/bin/sa_main", "/system/profile/dinput.xml"], "uid" : "dinput", - "gid" : ["dinput", "root", "uhid", "input"], + "gid" : ["dinput", "uhid", "input"], "ondemand" : true, "apl" : "system_basic", "permission" : ["ohos.permission.DISTRIBUTED_DATASYNC"], diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index ad0055b..3a954cc 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -65,6 +65,8 @@ ohos_unittest("distributed_input_sinkmanager_test") { "//base/security/access_token/interfaces/innerkits/token_setproc/include", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/", + "${sevices_source_path}/inputinject/include", + "//foundation/distributedhardware/distributed_input/inputdevicehandler/include", ] sources = [ @@ -76,6 +78,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp", + "//foundation/distributedhardware/distributed_input/services/transportbase/src/distributed_input_transport_base.cpp", "distributed_input_sinkmanager_test.cpp", "${common_path}/test/mock/session_mock.cpp", "${common_path}/test/mock/softbus_bus_center_mock.cpp", @@ -96,6 +99,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "HI_LOG_ENABLE", "DH_LOG_TAG=\"distributedinpututtest\"", "LOG_DOMAIN=0xD004100", + "COMPILE_TEST_MODE" ] deps = [ @@ -119,6 +123,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "hitrace_native:hitrace_meter", ] cflags_cc = [ "-DHILOG_ENABLE" ] 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 70c222b..415fb85 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -428,6 +428,35 @@ HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_001, testing::ext::Te std::string parameters = ""; int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); + + devId = ""; + parameters = "parameters_test"; + ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); + + devId = "umkyu1b165e1be98151891erbe8r91ev"; + dhId = ""; + ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); +} + +HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_002, testing::ext::TestSize.Level1) +{ + std::string devId(DEV_ID_LENGTH_MAX + 1. 'a'); + std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + std::string parameters = "parameters_test"; + int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); + + devId = "umkyu1b165e1be98151891erbe8r91ev"; + std::string dhIds(DEV_ID_LENGTH_MAX + 1. 'a'); + ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIds, parameters); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); + + std::string dhIdtest = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + std::string param(STRING_MAX_SIZE + 1, 'a'); + ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIdtest, param); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); } HWTEST_F(DistributedInputSourceInjectTest, GetDeviceInfo_001, testing::ext::TestSize.Level1) diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index b9a36c6..b3ecaa4 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -238,6 +238,15 @@ HWTEST_F(DistributedInputSourceManagerTest, Init01, testing::ext::TestSize.Level HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_01, testing::ext::TestSize.Level1) { + sourceManager_->UnregisterDHFwkPublisher(); + + sourceManager_->startDScreenListener_ = nullptr; + sourceManager_->stopDScreenListener_ = nullptr; + sourceManager_->deviceOfflineListener_ = nullptr; + sourceManager_->UnregisterDHFwkPublisher(); + + + std::string devId = ""; std::string dhId = ""; std::string parameters = ""; @@ -2125,6 +2134,68 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_02, tes int32_t ret = sourceManager_->Dump(fd, args); EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret); } + +HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_01, testing::ext::TestSize.Level1) +{ + DistributedInputSourceManager::StopDScreenListener stopListener; + + stopListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, "message_test"); + std::string messages = ""; + stopListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, messages); + + std::string sinkDevId = ""; + uint64_t sourceWinId = 0; + nlohmann::json jsonObj; + jsonObj[SINK_DEVICE_ID] = 100; + int32_t ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SINK_DEVICE_ID] = "asd4a65sd46as4da6s4d6asdasdafwebrb"; + jsonObj[SOURCE_WINDOW_ID] = "source_window_id_test"; + ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SOURCE_WINDOW_ID] = 100; + ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId); + EXPECT_EQ(DH_SUCCESS, ret); +} + +HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestSize.Level1) +{ + DistributedInputSourceManager::StartDScreenListener startListener; + + startListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, "message_test"); + std::string message = (SCREEN_MSG_MAX + 1, 'a'); + startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, message); + std::string messages = ""; + startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, messages); + + std::string sinkDevId = ""; + SrcScreenInfo srcScreenInfo = {}; + nlohmann::json jsonObj; + jsonObj[SINK_DEVICE_ID] = 100; + int32_t ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SINK_DEVICE_ID] = "asd4a65sd46as4da6s4d6asdasdafwebrb"; + jsonObj[SOURCE_WINDOW_ID] = "source_window_id_test"; + ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SOURCE_WINDOW_ID] = 100; + jsonPbj[SOURCE_WINDOW_WIDTH] = "source_window_width_test"; + ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SOURCE_WINDOW_WIDTH] = 100; + jsonPbj[SOURCE_WINDOW_HEIGHT] = "source_window_height_test"; + ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); + EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); + + jsonObj[SOURCE_WINDOW_HEIGHT] = 100; + ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); + EXPECT_EQ(DH_SUCCESS, ret); +} } // namespace DistributedInput } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp index 0812891..d0ac7ed 100644 --- a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp +++ b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -498,7 +498,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput01, te recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST] = false; DistributedInputSourceTransport::GetInstance().NotifyResponsePrepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(false, recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST].is_string()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput02, testing::ext::TestSize.Level0) @@ -508,7 +510,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput02, te recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST] = "false"; DistributedInputSourceTransport::GetInstance().NotifyResponsePrepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST].is_string()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput03, testing::ext::TestSize.Level0) @@ -524,7 +528,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput03, te std::make_shared(&srcMgr); DistributedInputSourceTransport::GetInstance().callback_ = srcListener; DistributedInputSourceTransport::GetInstance().NotifyResponsePrepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST].is_string()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); } @@ -547,7 +553,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseUnprepareRemoteInput01, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = false; DistributedInputSourceTransport::GetInstance().NotifyResponseUnprepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE].is_boolean()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStartRemoteInput01, testing::ext::TestSize.Level0) @@ -566,7 +574,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStartRemoteInput01, test std::string remoteId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInput(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE].is_boolean()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); } @@ -586,7 +596,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStopRemoteInput01, testi std::string remoteId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInput(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE].is_boolean()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); } @@ -603,7 +615,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStartRemoteInputDhid01, recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; DistributedInputSourceTransport::GetInstance().NotifyResponseStartRemoteInputDhid(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE].is_boolean()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStopRemoteInputDhid01, testing::ext::TestSize.Level0) @@ -619,7 +633,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseStopRemoteInputDhid01, t recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "Input_1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; DistributedInputSourceTransport::GetInstance().NotifyResponseStopRemoteInputDhid(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE].is_boolean()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseKeyState01, testing::ext::TestSize.Level0) @@ -647,8 +663,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseKeyState01, testing::ext std::string remoteId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyResponseKeyState(sessionId, recMsg); - EXPECT_EQ(true, recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_DHID].is_string()); - DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyReceivedEventRemoteInput01, testing::ext::TestSize.Level1) @@ -667,7 +684,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyReceivedEventRemoteInput01, test DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[remoteId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyReceivedEventRemoteInput(sessionId, recMsg); DistributedInputSourceTransport::GetInstance().CalculateLatency(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayUnprepare01, testing::ext::TestSize.Level1) @@ -681,7 +700,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayUnprepare01, testin std::string deviceId = "f6d4c08647073e02e7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID] = deviceId; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayUnprepare(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayPrepareRemoteInput01, testing::ext::TestSize.Level1) @@ -699,7 +720,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayPrepareRemoteInput0 DistributedInputSourceTransport::GetInstance().NotifyResponseRelayPrepareRemoteInput(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST] = "white_list_test"; DistributedInputSourceTransport::GetInstance().NotifyResponseRelayPrepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayUnprepareRemoteInput01, testing::ext::TestSize.Level1) @@ -716,7 +739,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayUnprepareRemoteInpu recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID] = sessionId; sessionId = 2; DistributedInputSourceTransport::GetInstance().NotifyResponseRelayUnprepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); } @@ -732,6 +757,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayPrepareResult01, testing:: DistributedInputSourceTransport::GetInstance().ReceiveRelayPrepareResult(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID] = "sink_devid_test"; DistributedInputSourceTransport::GetInstance().ReceiveRelayPrepareResult(sessionId, recMsg); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayUnprepareResult01, testing::ext::TestSize.Level1) @@ -761,10 +789,11 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStartDhid01, testin DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartDhid(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "vector_dhId_test"; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartDhid(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartDhid(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopDhid01, testing::ext::TestSize.Level1) @@ -782,7 +811,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopDhid01, testing EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopDhid(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStartDhidRemoteInput01, testing::ext::TestSize.Level1) @@ -802,7 +833,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStartDhidRemoteInpu DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartDhidRemoteInput(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartDhidRemoteInput(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStopDhidRemoteInput01, testing::ext::TestSize.Level1) @@ -822,7 +855,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStopDhidRemoteInput DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopDhidRemoteInput(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopDhidRemoteInput(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayStartDhidResult01, testing::ext::TestSize.Level1) @@ -840,8 +875,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayStartDhidResult01, testing DistributedInputSourceTransport::GetInstance().ReceiveRelayStartDhidResult(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = 1; DistributedInputSourceTransport::GetInstance().ReceiveRelayStartDhidResult(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "vector_dhId_test"; - EXPECT_EQ("vector_dhId_test", recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID]); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayStopDhidResult01, testing::ext::TestSize.Level1) @@ -859,8 +895,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayStopDhidResult01, testing: DistributedInputSourceTransport::GetInstance().ReceiveRelayStopDhidResult(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = 1; DistributedInputSourceTransport::GetInstance().ReceiveRelayStopDhidResult(sessionId, recMsg); - recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "vector_dhId_test"; - EXPECT_EQ("vector_dhId_test", recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID]); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStartType01, testing::ext::TestSize.Level1) @@ -877,7 +914,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStartType01, testin DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStartType(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopType01, testing::ext::TestSize.Level1) @@ -894,7 +933,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopType01, testing DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopType(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStartTypeRemoteInput01, testing::ext::TestSize.Level1) @@ -913,7 +954,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStartTypeRemoteInpu DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear(); DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStopTypeRemoteInput01, testing::ext::TestSize.Level1) @@ -933,7 +976,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponseRelayStopTypeRemoteInput DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; DistributedInputSourceTransport::GetInstance().NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, HandleData01, testing::ext::TestSize.Level1) @@ -946,12 +991,7 @@ HWTEST_F(DistributedInputSourceTransTest, HandleData01, testing::ext::TestSize.L DistributedInputSourceTransport::GetInstance().HandleData(sessionId, recMsg.dump()); DistributedInputSourceTransport::GetInstance().callback_ = nullptr; DistributedInputSourceTransport::GetInstance().HandleData(sessionId, recMsg.dump()); - EXPECT_EQ(1, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); -} -HWTEST_F(DistributedInputSourceTransTest, SendMessage01, testing::ext::TestSize.Level1) -{ - int32_t sessionId = 1; std::string message(MSG_MAX_SIZE + 1, 'a'); int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -- Gitee From fe0e83361c7342db7a598ee0ec571f0488178465 Mon Sep 17 00:00:00 2001 From: joe49 Date: Tue, 11 Apr 2023 08:56:40 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E9=BB=84=E8=93=9D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joe49 --- .../sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn | 3 +-- .../distributed_input_sourceinject_test.cpp | 4 ++-- .../distributed_input_sourcemanager_test.cpp | 8 +++----- .../distributed_input_sourcetrans_test.cpp | 9 ++++++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index 3a954cc..57cf202 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -65,7 +65,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "//base/security/access_token/interfaces/innerkits/token_setproc/include", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/", - "${sevices_source_path}/inputinject/include", + "${services_source_path}/inputinject/include", "//foundation/distributedhardware/distributed_input/inputdevicehandler/include", ] @@ -112,7 +112,6 @@ ohos_unittest("distributed_input_sinkmanager_test") { "${fwk_interfaces_path}:libdhfwk_sdk", "//foundation/window/window_manager/dm:libdm", "//foundation/distributedhardware/distributed_input/services/sink/transport:libdinput_sink_trans", - "//foundation/distributedhardware/distributed_input/services/transportbase:libdinput_trans_base", "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", 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 415fb85..cf29616 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -442,14 +442,14 @@ HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_001, testing::ext::Te HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_002, testing::ext::TestSize.Level1) { - std::string devId(DEV_ID_LENGTH_MAX + 1. 'a'); + std::string devId(DEV_ID_LENGTH_MAX + 1, 'a'); std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string parameters = "parameters_test"; int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); devId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhIds(DEV_ID_LENGTH_MAX + 1. 'a'); + std::string dhIds(DH_ID_LENGTH_MAX + 1. 'a'); ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIds, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index b3ecaa4..06044a3 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -245,8 +245,6 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_01, testing::ext: sourceManager_->deviceOfflineListener_ = nullptr; sourceManager_->UnregisterDHFwkPublisher(); - - std::string devId = ""; std::string dhId = ""; std::string parameters = ""; @@ -2165,7 +2163,7 @@ HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestS DistributedInputSourceManager::StartDScreenListener startListener; startListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, "message_test"); - std::string message = (SCREEN_MSG_MAX + 1, 'a'); + std::string message(SCREEN_MSG_MAX + 1, 'a'); startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, message); std::string messages = ""; startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, messages); @@ -2183,12 +2181,12 @@ HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestS EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); jsonObj[SOURCE_WINDOW_ID] = 100; - jsonPbj[SOURCE_WINDOW_WIDTH] = "source_window_width_test"; + jsonObj[SOURCE_WINDOW_WIDTH] = "source_window_width_test"; ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); jsonObj[SOURCE_WINDOW_WIDTH] = 100; - jsonPbj[SOURCE_WINDOW_HEIGHT] = "source_window_height_test"; + jsonObj[SOURCE_WINDOW_HEIGHT] = "source_window_height_test"; ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo); EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret); diff --git a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp index d0ac7ed..a985a71 100644 --- a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp +++ b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.cpp @@ -541,7 +541,9 @@ HWTEST_F(DistributedInputSourceTransTest, NotifyResponsePrepareRemoteInput04, te recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE] = "false"; recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST] = false; DistributedInputSourceTransport::GetInstance().NotifyResponsePrepareRemoteInput(sessionId, recMsg); - EXPECT_EQ(false, recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST].is_string()); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, NotifyResponseUnprepareRemoteInput01, testing::ext::TestSize.Level0) @@ -774,6 +776,9 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveRelayUnprepareResult01, testing DistributedInputSourceTransport::GetInstance().ReceiveRelayUnprepareResult(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID] = "sink_devid_test"; DistributedInputSourceTransport::GetInstance().ReceiveRelayUnprepareResult(sessionId, recMsg); + std::string message(MSG_MAX_SIZE + 1, 'a'); + int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); + EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); } HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStartDhid01, testing::ext::TestSize.Level1) @@ -808,7 +813,6 @@ HWTEST_F(DistributedInputSourceTransTest, ReceiveSrcTSrcRelayStopDhid01, testing DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopDhid(sessionId, recMsg); recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID] = "vector_dhId_test"; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopDhid(sessionId, recMsg); - EXPECT_EQ(0, DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.size()); DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[deviceId] = sessionId; DistributedInputSourceTransport::GetInstance().ReceiveSrcTSrcRelayStopDhid(sessionId, recMsg); std::string message(MSG_MAX_SIZE + 1, 'a'); @@ -991,7 +995,6 @@ HWTEST_F(DistributedInputSourceTransTest, HandleData01, testing::ext::TestSize.L DistributedInputSourceTransport::GetInstance().HandleData(sessionId, recMsg.dump()); DistributedInputSourceTransport::GetInstance().callback_ = nullptr; DistributedInputSourceTransport::GetInstance().HandleData(sessionId, recMsg.dump()); - std::string message(MSG_MAX_SIZE + 1, 'a'); int32_t ret = DistributedInputSourceTransport::GetInstance().SendMessage(sessionId, message); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_TRANSPORT_SENDMESSSAGE, ret); -- Gitee From 3aa655e6d0606c41e01d9ce7cc196239e0ff71aa Mon Sep 17 00:00:00 2001 From: joe49 Date: Tue, 11 Apr 2023 09:01:37 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E9=BB=84=E8=93=9D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joe49 --- .../distributed_input_sourceinject_test.cpp | 2 +- .../distributed_input_sourcemanager_test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 cf29616..3d2827e 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -449,7 +449,7 @@ HWTEST_F(DistributedInputSourceInjectTest, openDevicesNode_002, testing::ext::Te EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); devId = "umkyu1b165e1be98151891erbe8r91ev"; - std::string dhIds(DH_ID_LENGTH_MAX + 1. 'a'); + std::string dhIds(DH_ID_LENGTH_MAX + 1, 'a'); ret = DistributedInputInject::GetInstance().inputNodeManager_->openDevicesNode(devId, dhIds, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index 06044a3..db31c2a 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -2137,7 +2137,7 @@ HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_01, testing::ext::TestS { DistributedInputSourceManager::StopDScreenListener stopListener; - stopListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, "message_test"); + stopListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, "msessage_test"); std::string messages = ""; stopListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, messages); @@ -2162,7 +2162,7 @@ HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestS { DistributedInputSourceManager::StartDScreenListener startListener; - startListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, "message_test"); + startListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, "msessage_test"); std::string message(SCREEN_MSG_MAX + 1, 'a'); startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, message); std::string messages = ""; -- Gitee From 9d001c4977f43690762965d5d23474d5fd3f3630 Mon Sep 17 00:00:00 2001 From: joe49 Date: Sat, 15 Apr 2023 14:40:38 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joe49 --- services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index 57cf202..86ddb36 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -66,7 +66,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/", "${services_source_path}/inputinject/include", - "//foundation/distributedhardware/distributed_input/inputdevicehandler/include", + "${distributedinput_path}/inputdevicehandler/include", ] sources = [ @@ -78,7 +78,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp", - "//foundation/distributedhardware/distributed_input/services/transportbase/src/distributed_input_transport_base.cpp", + "${distributedinput_path}/services/transportbase/src/distributed_input_transport_base.cpp", "distributed_input_sinkmanager_test.cpp", "${common_path}/test/mock/session_mock.cpp", "${common_path}/test/mock/softbus_bus_center_mock.cpp", -- Gitee From d1991d5a5548b04d6911e8e25315adb933c03024 Mon Sep 17 00:00:00 2001 From: joe49 Date: Sat, 15 Apr 2023 16:57:25 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9gn=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joe49 --- .../test/sinkmanagerunittest/BUILD.gn | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index 86ddb36..020ffb7 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -14,6 +14,7 @@ import("//build/test.gni") import( "//foundation/distributedhardware/distributed_input/distributedinput.gni") + module_out_path = "distributed_input/sink_manager" group("sinkmanagerunittest") { @@ -72,19 +73,19 @@ ohos_unittest("distributed_input_sinkmanager_test") { sources = [ "${common_path}/include/input_hub.cpp", "${common_path}/include/white_list_util.cpp", + "${common_path}/test/mock/session_mock.cpp", + "${common_path}/test/mock/softbus_bus_center_mock.cpp", + "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp", + "${distributedinput_path}/services/transportbase/src/distributed_input_transport_base.cpp", "${ipc_path}/src/distributed_input_sink_stub.cpp", + "${ipc_path}/src/get_sink_screen_infos_call_back_stub.cpp", + "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${services_sink_path}/inputcollector/src/distributed_input_collector.cpp", "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp", "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp", "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp", - "${distributedinput_path}/services/transportbase/src/distributed_input_transport_base.cpp", "distributed_input_sinkmanager_test.cpp", - "${common_path}/test/mock/session_mock.cpp", - "${common_path}/test/mock/softbus_bus_center_mock.cpp", - "${ipc_path}/src/get_sink_screen_infos_call_back_stub.cpp", - "${ipc_path}/src/sharing_dhid_listener_stub.cpp", - "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp", ] cflags = [ @@ -99,30 +100,30 @@ ohos_unittest("distributed_input_sinkmanager_test") { "HI_LOG_ENABLE", "DH_LOG_TAG=\"distributedinpututtest\"", "LOG_DOMAIN=0xD004100", - "COMPILE_TEST_MODE" + "COMPILE_TEST_MODE", ] deps = [ "${dfx_utils_path}:libdinput_dfx_utils", + "${fwk_interfaces_path}:libdhfwk_sdk", "${fwk_utils_path}:distributedhardwareutils", "${utils_path}:libdinput_utils", "//base/notification/eventhandler/frameworks/eventhandler:libeventhandler", - "//third_party/libevdev:libevdev", - "//third_party/openssl:libcrypto_static", - "${fwk_interfaces_path}:libdhfwk_sdk", - "//foundation/window/window_manager/dm:libdm", - "//foundation/distributedhardware/distributed_input/services/sink/transport:libdinput_sink_trans", "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", + "//foundation/distributedhardware/distributed_input/services/sink/transport:libdinput_sink_trans", + "//foundation/window/window_manager/dm:libdm", + "//third_party/libevdev:libevdev", + "//third_party/openssl:libcrypto_static", ] external_deps = [ "c_utils:utils", + "hitrace_native:hitrace_meter", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hitrace_native:hitrace_meter", ] cflags_cc = [ "-DHILOG_ENABLE" ] -- Gitee From 0fa993e59a528387430a3457a2251cd4cc020af3 Mon Sep 17 00:00:00 2001 From: joe49 Date: Sat, 15 Apr 2023 17:20:10 +0800 Subject: [PATCH 6/9] gn format Signed-off-by: joe49 --- distributedinput.gni | 2 ++ .../test/sinkmanagerunittest/BUILD.gn | 20 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/distributedinput.gni b/distributedinput.gni index debbd2e..9505838 100644 --- a/distributedinput.gni +++ b/distributedinput.gni @@ -15,6 +15,8 @@ distributedinput_path = "//foundation/distributedhardware/distributed_input" distributedhardwarefwk_path = "//foundation/distributedhardware/distributed_hardware_fwk" +window_manager_path = "//foundation/window/window_manager" + common_path = "${distributedinput_path}/common" utils_path = "${distributedinput_path}/utils" diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index 020ffb7..7401e59 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -32,10 +32,10 @@ ohos_unittest("distributed_input_sinkmanager_test") { "${innerkits_path}/src", "${ipc_path}/include", "${ipc_path}/src", - "//foundation/distributedhardware/distributed_input/services/transportbase/include", - "//foundation/distributedhardware/distributed_input/services/sink/transport/include", - "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/include", - "//foundation/distributedhardware/distributed_input/frameworks/include", + "${distributedinput_path}services/transportbase/include", + "${distributedinput_path}services/sink/transport/include", + "${distributedinput_path}services/sink/sinkmanager/include", + "${distributedinput_path}frameworks/include", "//commonlibrary/c_utils/base/include", "//utils/system/safwk/native/include", "${common_path}/include", @@ -77,14 +77,14 @@ ohos_unittest("distributed_input_sinkmanager_test") { "${common_path}/test/mock/softbus_bus_center_mock.cpp", "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp", "${distributedinput_path}/services/transportbase/src/distributed_input_transport_base.cpp", + "${distributedinput_path}services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp", + "${distributedinput_path}services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", + "${distributedinput_path}services/sink/transport/src/distributed_input_sink_switch.cpp", + "${distributedinput_path}services/sink/transport/src/distributed_input_sink_transport.cpp", "${ipc_path}/src/distributed_input_sink_stub.cpp", "${ipc_path}/src/get_sink_screen_infos_call_back_stub.cpp", "${ipc_path}/src/sharing_dhid_listener_stub.cpp", "${services_sink_path}/inputcollector/src/distributed_input_collector.cpp", - "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp", - "//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", - "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_switch.cpp", - "//foundation/distributedhardware/distributed_input/services/sink/transport/src/distributed_input_sink_transport.cpp", "distributed_input_sinkmanager_test.cpp", ] @@ -105,15 +105,15 @@ ohos_unittest("distributed_input_sinkmanager_test") { deps = [ "${dfx_utils_path}:libdinput_dfx_utils", + "${distributedinput_path}services/sink/transport:libdinput_sink_trans", "${fwk_interfaces_path}:libdhfwk_sdk", "${fwk_utils_path}:distributedhardwareutils", "${utils_path}:libdinput_utils", + "${window_manager_path}/dm:libdm", "//base/notification/eventhandler/frameworks/eventhandler:libeventhandler", "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk", "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", - "//foundation/distributedhardware/distributed_input/services/sink/transport:libdinput_sink_trans", - "//foundation/window/window_manager/dm:libdm", "//third_party/libevdev:libevdev", "//third_party/openssl:libcrypto_static", ] -- Gitee From 1c7731a7f0c0e0e2a8287edca613052400d45e30 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 15 Apr 2023 09:25:50 +0000 Subject: [PATCH 7/9] update services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn. Signed-off-by: joe --- services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index 7401e59..bcb1023 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -105,7 +105,7 @@ ohos_unittest("distributed_input_sinkmanager_test") { deps = [ "${dfx_utils_path}:libdinput_dfx_utils", - "${distributedinput_path}services/sink/transport:libdinput_sink_trans", + "${distributedinput_path}/services/sink/transport:libdinput_sink_trans", "${fwk_interfaces_path}:libdhfwk_sdk", "${fwk_utils_path}:distributedhardwareutils", "${utils_path}:libdinput_utils", -- Gitee From 7fc03edcf4118941baf97366f4d311a0c539bdda Mon Sep 17 00:00:00 2001 From: joe49 Date: Sat, 15 Apr 2023 17:48:37 +0800 Subject: [PATCH 8/9] gn Signed-off-by: joe49 --- .../test/sinkmanagerunittest/BUILD.gn | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn index bcb1023..2d745e2 100755 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/BUILD.gn @@ -32,10 +32,10 @@ ohos_unittest("distributed_input_sinkmanager_test") { "${innerkits_path}/src", "${ipc_path}/include", "${ipc_path}/src", - "${distributedinput_path}services/transportbase/include", - "${distributedinput_path}services/sink/transport/include", - "${distributedinput_path}services/sink/sinkmanager/include", - "${distributedinput_path}frameworks/include", + "${distributedinput_path}/services/transportbase/include", + "${distributedinput_path}/services/sink/transport/include", + "${distributedinput_path}/services/sink/sinkmanager/include", + "${distributedinput_path}/frameworks/include", "//commonlibrary/c_utils/base/include", "//utils/system/safwk/native/include", "${common_path}/include", @@ -75,12 +75,12 @@ ohos_unittest("distributed_input_sinkmanager_test") { "${common_path}/include/white_list_util.cpp", "${common_path}/test/mock/session_mock.cpp", "${common_path}/test/mock/softbus_bus_center_mock.cpp", + "${distributedinput_path}/services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp", + "${distributedinput_path}/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp", + "${distributedinput_path}/services/sink/transport/src/distributed_input_sink_switch.cpp", + "${distributedinput_path}/services/sink/transport/src/distributed_input_sink_transport.cpp", "${distributedinput_path}/services/transportbase/src/distributed_input_transport_base.cpp", - "${distributedinput_path}services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp", - "${distributedinput_path}services/sink/sinkmanager/src/distributed_input_sink_manager.cpp", - "${distributedinput_path}services/sink/transport/src/distributed_input_sink_switch.cpp", - "${distributedinput_path}services/sink/transport/src/distributed_input_sink_transport.cpp", "${ipc_path}/src/distributed_input_sink_stub.cpp", "${ipc_path}/src/get_sink_screen_infos_call_back_stub.cpp", "${ipc_path}/src/sharing_dhid_listener_stub.cpp", -- Gitee From 36e074748c148b5228f301f2a6476afc8ddb65ee Mon Sep 17 00:00:00 2001 From: joe49 Date: Sat, 15 Apr 2023 17:59:31 +0800 Subject: [PATCH 9/9] gni Signed-off-by: joe49 --- distributedinput.gni | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/distributedinput.gni b/distributedinput.gni index 9505838..3a1a679 100644 --- a/distributedinput.gni +++ b/distributedinput.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 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 @@ -13,7 +13,8 @@ distributedinput_path = "//foundation/distributedhardware/distributed_input" -distributedhardwarefwk_path = "//foundation/distributedhardware/distributed_hardware_fwk" +distributedhardwarefwk_path = + "//foundation/distributedhardware/distributed_hardware_fwk" window_manager_path = "//foundation/window/window_manager" -- Gitee