黄区同步蓝区

Signed-off-by: joe49 <liqiao49@huawei.com>
This commit is contained in:
joe49
2023-04-10 10:00:09 +08:00
parent 5bb87fc0f7
commit 2eeeda9797
6 changed files with 183 additions and 38 deletions
@@ -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);
+1 -1
View File
@@ -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"],
@@ -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" ]
@@ -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)
@@ -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
@@ -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<DistributedInputSourceManager::DInputSourceListener>(&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);