mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-21 05:45:23 -04:00
Description:add ut
Match-id-cc70c98d32f96551edaa16abe079d70979163705
This commit is contained in:
+2
-1
@@ -86,7 +86,8 @@
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/sourcemanager/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/utils/test:test"
|
||||
"//foundation/distributedhardware/distributed_input/utils/test:test",
|
||||
"//foundation/distributedhardware/distributed_input/dfx_utils/test:test"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
group("test") {
|
||||
testonly = true
|
||||
|
||||
deps = [ "dfxtest:dfxtest" ]
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import(
|
||||
"//foundation/distributedhardware/distributed_input/distributedinput.gni")
|
||||
module_out_path = "distributed_input/dfx_utils"
|
||||
|
||||
group("dfxtest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":distributed_input_dfx_test" ]
|
||||
}
|
||||
|
||||
## IpcTest distributed_input_dfx_test {{{
|
||||
ohos_unittest("distributed_input_dfx_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"//commonlibrary/c_utils/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${fwk_utils_path}/include",
|
||||
"${frameworks_path}/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${service_common}/include",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${dfx_utils_path}/src/hidumper.cpp",
|
||||
"distributed_input_dfx_test.cpp",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-g3",
|
||||
"-Dprivate=public",
|
||||
"-Dprotected=public",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"distributedinpututtest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hisysevent_native:libhisysevent",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
}
|
||||
## UnitTest distributed_input_dfx_test }}}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "distributed_input_dfx_test.h"
|
||||
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "hidumper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
void DInputDfxUtilsTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void DInputDfxUtilsTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void DInputDfxUtilsTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void DInputDfxUtilsTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(DInputDfxUtilsTest, HiDump_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
std::string result = "";
|
||||
bool ret = HiDumper::GetInstance().HiDump(args, result);
|
||||
EXPECT_EQ(false, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DInputDfxUtilsTest, HiDump_002, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
args.push_back("-h");
|
||||
std::string result = "";
|
||||
bool ret = HiDumper::GetInstance().HiDump(args, result);
|
||||
EXPECT_EQ(true, ret);
|
||||
|
||||
args.clear();
|
||||
args.push_back("-nodeinfo");
|
||||
ret = HiDumper::GetInstance().HiDump(args, result);
|
||||
EXPECT_EQ(true, ret);
|
||||
|
||||
args.clear();
|
||||
args.push_back("-sessioninfo");
|
||||
ret = HiDumper::GetInstance().HiDump(args, result);
|
||||
EXPECT_EQ(true, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DInputDfxUtilsTest, GetAllNodeInfos_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
std::string nodeName = "DistributedInput_123456";
|
||||
HiDumper::GetInstance().SaveNodeInfo(devId, nodeName, dhId);
|
||||
EXPECT_EQ(1, HiDumper::GetInstance().nodeInfos_.size());
|
||||
|
||||
std::string result = "";
|
||||
int32_t ret = HiDumper::GetInstance().GetAllNodeInfos(result);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
|
||||
HiDumper::GetInstance().DeleteNodeInfo(devId, dhId);
|
||||
EXPECT_EQ(0, HiDumper::GetInstance().nodeInfos_.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DInputDfxUtilsTest, GetSessionInfo_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string remoteDevId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
int32_t sessionId = 1;
|
||||
std::string mySessionName = "mySessionName_test";
|
||||
std::string peerSessionName = "peerSessionName_test";
|
||||
SessionStatus sessionStatus = SessionStatus::OPENED;
|
||||
HiDumper::GetInstance().CreateSessionInfo(remoteDevId, sessionId, mySessionName, peerSessionName, sessionStatus);
|
||||
EXPECT_EQ(1, HiDumper::GetInstance().sessionInfos_.size());
|
||||
|
||||
sessionStatus = SessionStatus::CLOSED;
|
||||
HiDumper::GetInstance().SetSessionStatus(remoteDevId, sessionStatus);
|
||||
|
||||
std::string result = "";
|
||||
int32_t ret = HiDumper::GetInstance().GetSessionInfo(result);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_INPUT_DFX_UTILS_TEST_H
|
||||
#define DISRIBUTED_INPUT_DFX_UTILS_TEST_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <refbase.h>
|
||||
#include <thread>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#include "constants_dinput.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
class DInputDfxUtilsTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // DISRIBUTED_INPUT_DFX_UTILS_TEST_H
|
||||
@@ -77,6 +77,14 @@ void DistributedInputInnerTest::TestStopDInputCallback::OnResult(
|
||||
return;
|
||||
}
|
||||
|
||||
void DistributedInputInnerTest::TestStartStopDInputCallback::OnResultDhids(
|
||||
const std::string &devId, const int32_t &status)
|
||||
{
|
||||
(void)devId;
|
||||
(void)status;
|
||||
return;
|
||||
}
|
||||
|
||||
void DistributedInputInnerTest::TestInputNodeListener::OnNodeOnLine(const std::string srcDevId,
|
||||
const std::string sinkDevId, const std::string sinkNodeId, const std::string sinkNodeDesc)
|
||||
{
|
||||
@@ -96,8 +104,8 @@ void DistributedInputInnerTest::TestInputNodeListener::OnNodeOffLine(const std::
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t DistributedInputInnerTest::TestSimulationEventListenerStub::OnSimulationEvent(uint32_t type, uint32_t code,
|
||||
int32_t value)
|
||||
int32_t DistributedInputInnerTest::TestSimulationEventListenerStub::OnSimulationEvent(
|
||||
uint32_t type, uint32_t code, int32_t value)
|
||||
{
|
||||
(void)type;
|
||||
(void)code;
|
||||
@@ -164,24 +172,26 @@ HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput01, testing::ext::TestSize
|
||||
HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput02, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestPrepareDInputCallback> callback = new TestPrepareDInputCallback();
|
||||
sptr<TestPrepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput03, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "PrepareRemoteInput01";
|
||||
sptr<TestPrepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback);
|
||||
std::string srcId = "PrepareRemoteInput_test";
|
||||
std::string sinkId = "PrepareRemoteInput_test";
|
||||
sptr<IPrepareDInputCallback> callback = new TestPrepareDInputCallback();
|
||||
int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, PrepareRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
std::string srcId = "";
|
||||
std::string sinkId = "";
|
||||
sptr<TestPrepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback);
|
||||
int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -196,24 +206,26 @@ HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput01, testing::ext::TestSi
|
||||
HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput02, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestUnprepareDInputCallback> callback = new TestUnprepareDInputCallback();
|
||||
sptr<TestUnprepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput03, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "UnprepareRemoteInput01";
|
||||
sptr<TestUnprepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback);
|
||||
std::string srcId = "PrepareRemoteInput_src";
|
||||
std::string sinkId = "PrepareRemoteInput_sink";
|
||||
sptr<TestUnprepareDInputCallback> callback = new TestUnprepareDInputCallback();
|
||||
int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, UnprepareRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
std::string srcId = "";
|
||||
std::string sinkId = "";
|
||||
sptr<TestUnprepareDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback);
|
||||
int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -229,7 +241,7 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput01, testing::ext::TestSize.L
|
||||
HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestStartDInputCallback> callback = new TestStartDInputCallback();
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
@@ -237,19 +249,19 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput02, testing::ext::TestSize.L
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StartRemoteInput03, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "StartRemoteInput01";
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::string sinkId = "StartRemoteInput_sink";
|
||||
std::vector<std::string> dhIds = {"dhIds_test"};
|
||||
sptr<TestStartStopDInputCallback> callback = new TestStartStopDInputCallback();
|
||||
int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StartRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::string sinkId = "";
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -267,7 +279,7 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput06, testing::ext::TestSize.L
|
||||
{
|
||||
string srcId = "";
|
||||
string sinkId = "";
|
||||
sptr<TestStartDInputCallback> callback = new TestStartDInputCallback();
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
@@ -275,11 +287,11 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput06, testing::ext::TestSize.L
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StartRemoteInput07, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string srcId = "StartRemoteInput03-src";
|
||||
string sinkId = "StartRemoteInput03-sink";
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
string srcId = "StartRemoteInput01-src";
|
||||
string sinkId = "StartRemoteInput01-sink";
|
||||
std::vector<std::string> dhIds = {"dhIds_test"};
|
||||
sptr<TestStartStopDInputCallback> callback = new TestStartStopDInputCallback();
|
||||
int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -287,9 +299,9 @@ HWTEST_F(DistributedInputInnerTest, StartRemoteInput08, testing::ext::TestSize.L
|
||||
{
|
||||
string srcId = "";
|
||||
string sinkId = "";
|
||||
sptr<TestStartDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -305,7 +317,7 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput01, testing::ext::TestSize.Le
|
||||
HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestStopDInputCallback> callback = new TestStopDInputCallback();
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
@@ -313,19 +325,19 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput02, testing::ext::TestSize.Le
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StopRemoteInput03, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "StopRemoteInput01";
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::string sinkId = "StartRemoteInput_test";
|
||||
std::vector<std::string> dhIds = {"dhIds_test"};
|
||||
sptr<TestStartStopDInputCallback> callback = new TestStartStopDInputCallback();
|
||||
int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StopRemoteInput04, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string deviceId = "";
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::string sinkId = "";
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -343,7 +355,7 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput06, testing::ext::TestSize.Le
|
||||
{
|
||||
string srcId = "";
|
||||
string sinkId = "";
|
||||
sptr<TestStopDInputCallback> callback = new TestStopDInputCallback();
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
@@ -351,11 +363,11 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput06, testing::ext::TestSize.Le
|
||||
|
||||
HWTEST_F(DistributedInputInnerTest, StopRemoteInput07, testing::ext::TestSize.Level0)
|
||||
{
|
||||
string srcId = "StopRemoteInput03-src";
|
||||
string sinkId = "StopRemoteInput03-sink";
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
string srcId = "StartRemoteInput01-src";
|
||||
string sinkId = "StartRemoteInput01-sink";
|
||||
std::vector<std::string> dhIds = {"dhIds_test"};
|
||||
sptr<TestStartStopDInputCallback> callback = new TestStartStopDInputCallback();
|
||||
int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
@@ -363,9 +375,9 @@ HWTEST_F(DistributedInputInnerTest, StopRemoteInput08, testing::ext::TestSize.Le
|
||||
{
|
||||
string srcId = "";
|
||||
string sinkId = "";
|
||||
sptr<TestStopDInputCallback> callback = nullptr;
|
||||
int32_t ret =
|
||||
DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
|
||||
std::vector<std::string> dhIds;
|
||||
sptr<TestStartStopDInputCallback> callback = nullptr;
|
||||
int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "input_node_listener_stub.h"
|
||||
#include "i_distributed_sink_input.h"
|
||||
#include "i_distributed_source_input.h"
|
||||
#include "start_stop_d_inputs_call_back_stub.h"
|
||||
#include "prepare_d_input_call_back_stub.h"
|
||||
#include "start_d_input_call_back_stub.h"
|
||||
#include "stop_d_input_call_back_stub.h"
|
||||
@@ -81,6 +82,14 @@ public:
|
||||
void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
|
||||
};
|
||||
|
||||
class TestStartStopDInputCallback : public
|
||||
OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub {
|
||||
public:
|
||||
TestStartStopDInputCallback() = default;
|
||||
virtual ~TestStartStopDInputCallback() = default;
|
||||
void OnResultDhids(const std::string &devId, const int32_t &status);
|
||||
};
|
||||
|
||||
class TestInputNodeListener : public
|
||||
OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub {
|
||||
public:
|
||||
|
||||
@@ -117,24 +117,48 @@ int32_t DistributedInputClient::PrepareRemoteInput(
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::PrepareRemoteInput(
|
||||
const std::string &srcId, const std::string &sinkId, sptr<IPrepareDInputCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::UnprepareRemoteInput(
|
||||
const std::string& deviceId, sptr<IUnprepareDInputCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::UnprepareRemoteInput(
|
||||
const std::string &srcId, const std::string &sinkId, sptr<IUnprepareDInputCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StartRemoteInput(
|
||||
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStartDInputCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StartRemoteInput(
|
||||
const std::string &sinkId, const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StopRemoteInput(
|
||||
const std::string& deviceId, const uint32_t& inputTypes, sptr<IStopDInputCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StopRemoteInput(
|
||||
const std::string &sinkId, const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId,
|
||||
const uint32_t &inputTypes, sptr<IStartDInputCallback> callback)
|
||||
{
|
||||
@@ -147,6 +171,18 @@ int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StartRemoteInput(const std::string &srcId, const std::string &sinkId,
|
||||
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputClient::StopRemoteInput(const std::string &srcId, const std::string &sinkId,
|
||||
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
|
||||
{
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const BusinessEvent& event)
|
||||
{
|
||||
return true;
|
||||
|
||||
+12
@@ -89,6 +89,18 @@ HWTEST_F(DistributedInputCollectorTest, GetDeviceInfoByType, testing::ext::TestS
|
||||
DistributedInputCollector::GetInstance().GetDeviceInfoByType(inputTypes, deviceInfo);
|
||||
EXPECT_EQ(0, deviceInfo.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputCollectorTest, DistributedInputCollectorTest_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
DistributedInputCollector::GetInstance().StartCollectEventsThread();
|
||||
std::vector<std::string> sharingDhIds = {"1ds56v18e1v21v8v1erv15r1v8r1j1ty8"};
|
||||
std::vector<std::string> noSharingDhIds = {"1ds56v18e1v21v8v1erv15r1v8r1j1ty8"};
|
||||
AffectDhIds dhIds {sharingDhIds, noSharingDhIds};
|
||||
std::string mouseNodePath = "mouseNodePath_test";
|
||||
std::string dhid = "dhid_test";
|
||||
DistributedInputCollector::GetInstance().ReportDhIdSharingState(dhIds);
|
||||
DistributedInputCollector::GetInstance().GetMouseNodePath(sharingDhIds, mouseNodePath, dhid);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
+70
@@ -131,6 +131,14 @@ HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedHardware03, testin
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, UnregisterDistributedHardware_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
int32_t ret = DistributedInputInject::GetInstance().UnregisterDistributedHardware(devId, dhId);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, RegisterDistributedEvent01, testing::ext::TestSize.Level1)
|
||||
{
|
||||
struct RawEvent writeBuffer[4];
|
||||
@@ -261,6 +269,68 @@ HWTEST_F(DistributedInputSourceInjectTest, UnRegisterInputNodeListener, testing:
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, GetDhIdsByInputType_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::vector<std::string> dhIds;
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
dhIds.push_back(dhId);
|
||||
int32_t ret = DistributedInputInject::GetInstance().GetDhIdsByInputType(devId,
|
||||
static_cast<uint32_t>(DInputDeviceType::ALL), dhIds);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, InputDeviceEventInject_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<RawEvent> rawEvent = std::make_shared<RawEvent>();
|
||||
DistributedInputInject::GetInstance().InputDeviceEventInject(rawEvent);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, SyncNodeOnlineInfo_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string srcDevId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
|
||||
std::string sinkDevId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string sinkNodeId = "usb-hiusb-ehci-2.1/input1";
|
||||
std::string sinkNodeDesc = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
DistributedInputInject::GetInstance().SyncNodeOnlineInfo(srcDevId, sinkDevId, sinkNodeId, sinkNodeDesc);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, StartInjectThread_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
DistributedInputInject::GetInstance().StartInjectThread();
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, StopInjectThread_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
DistributedInputInject::GetInstance().StopInjectThread();
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, GenerateVirtualTouchScreenDHId_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string ret = DistributedInputInject::GetInstance().GenerateVirtualTouchScreenDHId(1, 1860, 980);
|
||||
EXPECT_NE(0, ret.size());
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, CreateVirtualTouchScreenNode_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
int32_t ret = DistributedInputInject::GetInstance().CreateVirtualTouchScreenNode(devId, dhId, 1, 1860, 980);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, RemoveVirtualTouchScreenNode_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
|
||||
int32_t ret = DistributedInputInject::GetInstance().RemoveVirtualTouchScreenNode(dhId);
|
||||
EXPECT_EQ(DH_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DistributedInputSourceInjectTest, GetVirtualTouchScreenFd_001, testing::ext::TestSize.Level1)
|
||||
{
|
||||
int32_t ret = DistributedInputInject::GetInstance().GetVirtualTouchScreenFd();
|
||||
EXPECT_NE(-1, ret);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user