diff --git a/distributedinput.gni b/distributedinput.gni index debbd2e71d7aa598bb0f6b4aa35648252c45fc09..3a1a679fe3666073e2ca864724df4f7f5d5d0c1f 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,10 @@ 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" common_path = "${distributedinput_path}/common" diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 608b1981b6866487d54dc9e472869ec209bc4aa5..28ff50687baaab782d68b28ec1c429f55dfa7270 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 6d0c168142fe73bba52b5b2229d4dd00c37ff9f9..5aa5072ff5afe460dffc43d4c4eb2e1077840973 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 ad0055b62025a023ca11406d78d0976c932de924..2d745e23bdb941cb27f91867d600715e66455e04 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") { @@ -31,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", @@ -65,23 +66,26 @@ 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/", + "${services_source_path}/inputinject/include", + "${distributedinput_path}/inputdevicehandler/include", ] sources = [ "${common_path}/include/input_hub.cpp", "${common_path}/include/white_list_util.cpp", - "${ipc_path}/src/distributed_input_sink_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", "${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", + "${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", - "${distributedinput_path}/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp", + "${services_sink_path}/inputcollector/src/distributed_input_collector.cpp", + "distributed_input_sinkmanager_test.cpp", ] cflags = [ @@ -96,26 +100,27 @@ ohos_unittest("distributed_input_sinkmanager_test") { "HI_LOG_ENABLE", "DH_LOG_TAG=\"distributedinpututtest\"", "LOG_DOMAIN=0xD004100", + "COMPILE_TEST_MODE", ] 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", - "//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", - "//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", + "//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", 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 70c222b7b305b5d26e610235cdc81c5ec33acb83..3d2827ec129d1830bcd5d55ef5cdcaead74e056b 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(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); + + 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 b9a36c6283612b9b1c486418155013629a3befe6..db31c2a1c9752cd79887359f4f4abf3a52eb5e7e 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,13 @@ 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 +2132,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, "msessage_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, "msessage_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; + 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; + jsonObj[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 081289143873f0b148211d5c9b7ca80c017b0a63..a985a71522943770998de176e275a30b74af6634 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(); } @@ -535,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) @@ -547,7 +555,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 +576,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 +598,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 +617,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 +635,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 +665,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 +686,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 +702,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 +722,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 +741,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 +759,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) @@ -746,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) @@ -761,10 +794,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) @@ -779,10 +813,11 @@ 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); - 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 +837,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 +859,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 +879,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 +899,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 +918,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 +937,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 +958,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 +980,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 +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()); - 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);