10704ebd2Sopenharmony_ci/*
20704ebd2Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
30704ebd2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40704ebd2Sopenharmony_ci * you may not use this file except in compliance with the License.
50704ebd2Sopenharmony_ci * You may obtain a copy of the License at
60704ebd2Sopenharmony_ci *
70704ebd2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80704ebd2Sopenharmony_ci *
90704ebd2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100704ebd2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110704ebd2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120704ebd2Sopenharmony_ci * See the License for the specific language governing permissions and
130704ebd2Sopenharmony_ci * limitations under the License.
140704ebd2Sopenharmony_ci */
150704ebd2Sopenharmony_ci
160704ebd2Sopenharmony_ci#include "distributed_input_test.h"
170704ebd2Sopenharmony_ci#include "system_ability_definition.h"
180704ebd2Sopenharmony_ci#include "dinput_context.h"
190704ebd2Sopenharmony_ci#include "dinput_errcode.h"
200704ebd2Sopenharmony_ci
210704ebd2Sopenharmony_ciusing namespace testing::ext;
220704ebd2Sopenharmony_ciusing namespace OHOS::DistributedHardware::DistributedInput;
230704ebd2Sopenharmony_ciusing namespace OHOS::DistributedHardware;
240704ebd2Sopenharmony_ciusing namespace std;
250704ebd2Sopenharmony_ciusing namespace OHOS;
260704ebd2Sopenharmony_ci
270704ebd2Sopenharmony_civoid DistributedInputTest::SetUp()
280704ebd2Sopenharmony_ci{
290704ebd2Sopenharmony_ci}
300704ebd2Sopenharmony_ci
310704ebd2Sopenharmony_civoid DistributedInputTest::TearDown()
320704ebd2Sopenharmony_ci{
330704ebd2Sopenharmony_ci}
340704ebd2Sopenharmony_ci
350704ebd2Sopenharmony_civoid DistributedInputTest::SetUpTestCase()
360704ebd2Sopenharmony_ci{
370704ebd2Sopenharmony_ci}
380704ebd2Sopenharmony_ci
390704ebd2Sopenharmony_civoid DistributedInputTest::TearDownTestCase()
400704ebd2Sopenharmony_ci{
410704ebd2Sopenharmony_ci}
420704ebd2Sopenharmony_ci
430704ebd2Sopenharmony_civoid DistributedInputTest::TestPrepareDInputCallback::OnResult(
440704ebd2Sopenharmony_ci    const std::string& deviceId, const int32_t& status)
450704ebd2Sopenharmony_ci{
460704ebd2Sopenharmony_ci    (void)deviceId;
470704ebd2Sopenharmony_ci    (void)status;
480704ebd2Sopenharmony_ci    return;
490704ebd2Sopenharmony_ci}
500704ebd2Sopenharmony_ci
510704ebd2Sopenharmony_civoid DistributedInputTest::TestUnprepareDInputCallback::OnResult(
520704ebd2Sopenharmony_ci    const std::string& deviceId, const int32_t& status)
530704ebd2Sopenharmony_ci{
540704ebd2Sopenharmony_ci    (void)deviceId;
550704ebd2Sopenharmony_ci    (void)status;
560704ebd2Sopenharmony_ci    return;
570704ebd2Sopenharmony_ci}
580704ebd2Sopenharmony_ci
590704ebd2Sopenharmony_civoid DistributedInputTest::TestStartDInputCallback::OnResult(
600704ebd2Sopenharmony_ci    const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
610704ebd2Sopenharmony_ci{
620704ebd2Sopenharmony_ci    (void)deviceId;
630704ebd2Sopenharmony_ci    (void)inputTypes;
640704ebd2Sopenharmony_ci    (void)status;
650704ebd2Sopenharmony_ci    return;
660704ebd2Sopenharmony_ci}
670704ebd2Sopenharmony_ci
680704ebd2Sopenharmony_civoid DistributedInputTest::TestStopDInputCallback::OnResult(
690704ebd2Sopenharmony_ci    const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status)
700704ebd2Sopenharmony_ci{
710704ebd2Sopenharmony_ci    (void)deviceId;
720704ebd2Sopenharmony_ci    (void)inputTypes;
730704ebd2Sopenharmony_ci    (void)status;
740704ebd2Sopenharmony_ci    return;
750704ebd2Sopenharmony_ci}
760704ebd2Sopenharmony_ci
770704ebd2Sopenharmony_civoid DistributedInputTest::TestStartStopDInputCallback::OnResultDhids(
780704ebd2Sopenharmony_ci    const std::string &devId, const int32_t &status)
790704ebd2Sopenharmony_ci{
800704ebd2Sopenharmony_ci    (void)devId;
810704ebd2Sopenharmony_ci    (void)status;
820704ebd2Sopenharmony_ci    return;
830704ebd2Sopenharmony_ci}
840704ebd2Sopenharmony_ci
850704ebd2Sopenharmony_civoid DistributedInputTest::TestInputNodeListener::OnNodeOnLine(const std::string &srcDevId,
860704ebd2Sopenharmony_ci    const std::string &sinkDevId, const std::string &sinkNodeId, const std::string &sinkNodeDesc)
870704ebd2Sopenharmony_ci{
880704ebd2Sopenharmony_ci    (void)srcDevId;
890704ebd2Sopenharmony_ci    (void)sinkDevId;
900704ebd2Sopenharmony_ci    (void)sinkNodeId;
910704ebd2Sopenharmony_ci    (void)sinkNodeDesc;
920704ebd2Sopenharmony_ci    return;
930704ebd2Sopenharmony_ci}
940704ebd2Sopenharmony_ci
950704ebd2Sopenharmony_civoid DistributedInputTest::TestInputNodeListener::OnNodeOffLine(const std::string &srcDevId,
960704ebd2Sopenharmony_ci    const std::string &sinkDevId, const std::string &sinkNodeId)
970704ebd2Sopenharmony_ci{
980704ebd2Sopenharmony_ci    (void)srcDevId;
990704ebd2Sopenharmony_ci    (void)sinkDevId;
1000704ebd2Sopenharmony_ci    (void)sinkNodeId;
1010704ebd2Sopenharmony_ci    return;
1020704ebd2Sopenharmony_ci}
1030704ebd2Sopenharmony_ci
1040704ebd2Sopenharmony_ciint32_t DistributedInputTest::TestSimulationEventListenerStub::OnSimulationEvent(
1050704ebd2Sopenharmony_ci    uint32_t type, uint32_t code, int32_t value)
1060704ebd2Sopenharmony_ci{
1070704ebd2Sopenharmony_ci    (void)type;
1080704ebd2Sopenharmony_ci    (void)code;
1090704ebd2Sopenharmony_ci    (void)value;
1100704ebd2Sopenharmony_ci    return DH_SUCCESS;
1110704ebd2Sopenharmony_ci}
1120704ebd2Sopenharmony_ci
1130704ebd2Sopenharmony_ciint DistributedInputTest::CheckSourceProxy() const
1140704ebd2Sopenharmony_ci{
1150704ebd2Sopenharmony_ci    OHOS::sptr<OHOS::ISystemAbilityManager> systemAbilityManager =
1160704ebd2Sopenharmony_ci        OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1170704ebd2Sopenharmony_ci    if (!systemAbilityManager) {
1180704ebd2Sopenharmony_ci        return DH_SUCCESS;
1190704ebd2Sopenharmony_ci    }
1200704ebd2Sopenharmony_ci
1210704ebd2Sopenharmony_ci    OHOS::sptr<OHOS::IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
1220704ebd2Sopenharmony_ci        DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID);
1230704ebd2Sopenharmony_ci    if (!remoteObject) {
1240704ebd2Sopenharmony_ci        return DH_SUCCESS;
1250704ebd2Sopenharmony_ci    }
1260704ebd2Sopenharmony_ci
1270704ebd2Sopenharmony_ci    OHOS::sptr<IDistributedSourceInput> proxyTest;
1280704ebd2Sopenharmony_ci
1290704ebd2Sopenharmony_ci    proxyTest = OHOS::iface_cast<IDistributedSourceInput>(remoteObject);
1300704ebd2Sopenharmony_ci    if ((!proxyTest) || (!proxyTest->AsObject())) {
1310704ebd2Sopenharmony_ci        return DH_SUCCESS;
1320704ebd2Sopenharmony_ci    }
1330704ebd2Sopenharmony_ci
1340704ebd2Sopenharmony_ci    return DH_SUCCESS;
1350704ebd2Sopenharmony_ci}
1360704ebd2Sopenharmony_ci
1370704ebd2Sopenharmony_ciint DistributedInputTest::CheckSinkProxy() const
1380704ebd2Sopenharmony_ci{
1390704ebd2Sopenharmony_ci    OHOS::sptr<OHOS::ISystemAbilityManager> systemAbilityManager =
1400704ebd2Sopenharmony_ci        OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
1410704ebd2Sopenharmony_ci    if (!systemAbilityManager) {
1420704ebd2Sopenharmony_ci        return DH_SUCCESS;
1430704ebd2Sopenharmony_ci    }
1440704ebd2Sopenharmony_ci
1450704ebd2Sopenharmony_ci    OHOS::sptr<OHOS::IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
1460704ebd2Sopenharmony_ci        DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID);
1470704ebd2Sopenharmony_ci    if (!remoteObject) {
1480704ebd2Sopenharmony_ci        return DH_SUCCESS;
1490704ebd2Sopenharmony_ci    }
1500704ebd2Sopenharmony_ci
1510704ebd2Sopenharmony_ci    OHOS::sptr<IDistributedSinkInput> proxyTest;
1520704ebd2Sopenharmony_ci
1530704ebd2Sopenharmony_ci    proxyTest = OHOS::iface_cast<IDistributedSinkInput>(remoteObject);
1540704ebd2Sopenharmony_ci    if ((!proxyTest) || (!proxyTest->AsObject())) {
1550704ebd2Sopenharmony_ci        return DH_SUCCESS;
1560704ebd2Sopenharmony_ci    }
1570704ebd2Sopenharmony_ci
1580704ebd2Sopenharmony_ci    return DH_SUCCESS;
1590704ebd2Sopenharmony_ci}
1600704ebd2Sopenharmony_ci
1610704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0100, testing::ext::TestSize.Level0)
1620704ebd2Sopenharmony_ci{
1630704ebd2Sopenharmony_ci    string deviceId = "PrepareRemoteInput01";
1640704ebd2Sopenharmony_ci    sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
1650704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback);
1660704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
1670704ebd2Sopenharmony_ci}
1680704ebd2Sopenharmony_ci
1690704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0200, testing::ext::TestSize.Level0)
1700704ebd2Sopenharmony_ci{
1710704ebd2Sopenharmony_ci    string deviceId = "";
1720704ebd2Sopenharmony_ci    sptr<TestPrepareDInputCallback> callback = nullptr;
1730704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::PrepareRemoteInput(deviceId, callback);
1740704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
1750704ebd2Sopenharmony_ci}
1760704ebd2Sopenharmony_ci
1770704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0300, testing::ext::TestSize.Level0)
1780704ebd2Sopenharmony_ci{
1790704ebd2Sopenharmony_ci    std::string srcId = "PrepareRemoteInput_test";
1800704ebd2Sopenharmony_ci    std::string sinkId = "PrepareRemoteInput_test";
1810704ebd2Sopenharmony_ci    sptr<IPrepareDInputCallback> callback(new TestPrepareDInputCallback());
1820704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback);
1830704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
1840704ebd2Sopenharmony_ci}
1850704ebd2Sopenharmony_ci
1860704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0400, testing::ext::TestSize.Level0)
1870704ebd2Sopenharmony_ci{
1880704ebd2Sopenharmony_ci    std::string srcId = "";
1890704ebd2Sopenharmony_ci    std::string sinkId = "";
1900704ebd2Sopenharmony_ci    sptr<TestPrepareDInputCallback> callback = nullptr;
1910704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::PrepareRemoteInput(srcId, sinkId, callback);
1920704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
1930704ebd2Sopenharmony_ci}
1940704ebd2Sopenharmony_ci
1950704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0500, testing::ext::TestSize.Level0)
1960704ebd2Sopenharmony_ci{
1970704ebd2Sopenharmony_ci    string deviceId = "UnprepareRemoteInput01";
1980704ebd2Sopenharmony_ci    sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
1990704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback);
2000704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2010704ebd2Sopenharmony_ci}
2020704ebd2Sopenharmony_ci
2030704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0600, testing::ext::TestSize.Level0)
2040704ebd2Sopenharmony_ci{
2050704ebd2Sopenharmony_ci    string deviceId = "";
2060704ebd2Sopenharmony_ci    sptr<TestUnprepareDInputCallback> callback = nullptr;
2070704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnprepareRemoteInput(deviceId, callback);
2080704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2090704ebd2Sopenharmony_ci}
2100704ebd2Sopenharmony_ci
2110704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0700, testing::ext::TestSize.Level0)
2120704ebd2Sopenharmony_ci{
2130704ebd2Sopenharmony_ci    std::string srcId = "PrepareRemoteInput_src";
2140704ebd2Sopenharmony_ci    std::string sinkId = "PrepareRemoteInput_sink";
2150704ebd2Sopenharmony_ci    sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
2160704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback);
2170704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2180704ebd2Sopenharmony_ci}
2190704ebd2Sopenharmony_ci
2200704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0800, testing::ext::TestSize.Level0)
2210704ebd2Sopenharmony_ci{
2220704ebd2Sopenharmony_ci    std::string srcId = "";
2230704ebd2Sopenharmony_ci    std::string sinkId = "";
2240704ebd2Sopenharmony_ci    sptr<TestUnprepareDInputCallback> callback = nullptr;
2250704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnprepareRemoteInput(srcId, sinkId, callback);
2260704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2270704ebd2Sopenharmony_ci}
2280704ebd2Sopenharmony_ci
2290704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_0900, testing::ext::TestSize.Level0)
2300704ebd2Sopenharmony_ci{
2310704ebd2Sopenharmony_ci    string deviceId = "StartRemoteInput01";
2320704ebd2Sopenharmony_ci    sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
2330704ebd2Sopenharmony_ci    int32_t ret =
2340704ebd2Sopenharmony_ci        DistributedInputKit::StartRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
2350704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2360704ebd2Sopenharmony_ci}
2370704ebd2Sopenharmony_ci
2380704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1000, testing::ext::TestSize.Level0)
2390704ebd2Sopenharmony_ci{
2400704ebd2Sopenharmony_ci    string deviceId = "";
2410704ebd2Sopenharmony_ci    sptr<TestStartDInputCallback> callback = nullptr;
2420704ebd2Sopenharmony_ci    int32_t ret =
2430704ebd2Sopenharmony_ci        DistributedInputKit::StartRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
2440704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2450704ebd2Sopenharmony_ci}
2460704ebd2Sopenharmony_ci
2470704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1100, testing::ext::TestSize.Level0)
2480704ebd2Sopenharmony_ci{
2490704ebd2Sopenharmony_ci    std::string sinkId = "StartRemoteInput_sink";
2500704ebd2Sopenharmony_ci    std::vector<std::string> dhIds = {"dhIds_test"};
2510704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback(new TestStartStopDInputCallback());
2520704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback);
2530704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2540704ebd2Sopenharmony_ci}
2550704ebd2Sopenharmony_ci
2560704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1200, testing::ext::TestSize.Level0)
2570704ebd2Sopenharmony_ci{
2580704ebd2Sopenharmony_ci    std::string sinkId = "";
2590704ebd2Sopenharmony_ci    std::vector<std::string> dhIds;
2600704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback = nullptr;
2610704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StartRemoteInput(sinkId, dhIds, callback);
2620704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2630704ebd2Sopenharmony_ci}
2640704ebd2Sopenharmony_ci
2650704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1300, testing::ext::TestSize.Level0)
2660704ebd2Sopenharmony_ci{
2670704ebd2Sopenharmony_ci    string srcId = "StartRemoteInput01-src";
2680704ebd2Sopenharmony_ci    string sinkId = "StartRemoteInput01-sink";
2690704ebd2Sopenharmony_ci    sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
2700704ebd2Sopenharmony_ci    int32_t ret =
2710704ebd2Sopenharmony_ci        DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
2720704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2730704ebd2Sopenharmony_ci}
2740704ebd2Sopenharmony_ci
2750704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1400, testing::ext::TestSize.Level0)
2760704ebd2Sopenharmony_ci{
2770704ebd2Sopenharmony_ci    string srcId = "";
2780704ebd2Sopenharmony_ci    string sinkId = "";
2790704ebd2Sopenharmony_ci    sptr<TestStartDInputCallback> callback = nullptr;
2800704ebd2Sopenharmony_ci    int32_t ret =
2810704ebd2Sopenharmony_ci        DistributedInputKit::StartRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
2820704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2830704ebd2Sopenharmony_ci}
2840704ebd2Sopenharmony_ci
2850704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1500, testing::ext::TestSize.Level0)
2860704ebd2Sopenharmony_ci{
2870704ebd2Sopenharmony_ci    string srcId = "StartRemoteInput01-src";
2880704ebd2Sopenharmony_ci    string sinkId = "StartRemoteInput01-sink";
2890704ebd2Sopenharmony_ci    std::vector<std::string> dhIds = {"dhIds_test"};
2900704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback(new TestStartStopDInputCallback());
2910704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback);
2920704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
2930704ebd2Sopenharmony_ci}
2940704ebd2Sopenharmony_ci
2950704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1600, testing::ext::TestSize.Level0)
2960704ebd2Sopenharmony_ci{
2970704ebd2Sopenharmony_ci    string srcId = "";
2980704ebd2Sopenharmony_ci    string sinkId = "";
2990704ebd2Sopenharmony_ci    std::vector<std::string> dhIds;
3000704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback = nullptr;
3010704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StartRemoteInput(srcId, sinkId, dhIds, callback);
3020704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3030704ebd2Sopenharmony_ci}
3040704ebd2Sopenharmony_ci
3050704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1700, testing::ext::TestSize.Level0)
3060704ebd2Sopenharmony_ci{
3070704ebd2Sopenharmony_ci    string deviceId = "StopRemoteInput01";
3080704ebd2Sopenharmony_ci    sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
3090704ebd2Sopenharmony_ci    int32_t ret =
3100704ebd2Sopenharmony_ci        DistributedInputKit::StopRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
3110704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3120704ebd2Sopenharmony_ci}
3130704ebd2Sopenharmony_ci
3140704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1800, testing::ext::TestSize.Level0)
3150704ebd2Sopenharmony_ci{
3160704ebd2Sopenharmony_ci    string deviceId = "";
3170704ebd2Sopenharmony_ci    sptr<TestStopDInputCallback> callback = nullptr;
3180704ebd2Sopenharmony_ci    int32_t ret =
3190704ebd2Sopenharmony_ci        DistributedInputKit::StopRemoteInput(deviceId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
3200704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3210704ebd2Sopenharmony_ci}
3220704ebd2Sopenharmony_ci
3230704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_1900, testing::ext::TestSize.Level0)
3240704ebd2Sopenharmony_ci{
3250704ebd2Sopenharmony_ci    std::string sinkId = "StartRemoteInput_test";
3260704ebd2Sopenharmony_ci    std::vector<std::string> dhIds = {"dhIds_test"};
3270704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback(new TestStartStopDInputCallback());
3280704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback);
3290704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3300704ebd2Sopenharmony_ci}
3310704ebd2Sopenharmony_ci
3320704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2000, testing::ext::TestSize.Level0)
3330704ebd2Sopenharmony_ci{
3340704ebd2Sopenharmony_ci    std::string sinkId = "";
3350704ebd2Sopenharmony_ci    std::vector<std::string> dhIds;
3360704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback = nullptr;
3370704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StopRemoteInput(sinkId, dhIds, callback);
3380704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3390704ebd2Sopenharmony_ci}
3400704ebd2Sopenharmony_ci
3410704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2100, testing::ext::TestSize.Level0)
3420704ebd2Sopenharmony_ci{
3430704ebd2Sopenharmony_ci    string srcId = "StopRemoteInput03-src";
3440704ebd2Sopenharmony_ci    string sinkId = "StopRemoteInput03-sink";
3450704ebd2Sopenharmony_ci    sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
3460704ebd2Sopenharmony_ci    int32_t ret =
3470704ebd2Sopenharmony_ci        DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
3480704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3490704ebd2Sopenharmony_ci}
3500704ebd2Sopenharmony_ci
3510704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2200, testing::ext::TestSize.Level0)
3520704ebd2Sopenharmony_ci{
3530704ebd2Sopenharmony_ci    string srcId = "";
3540704ebd2Sopenharmony_ci    string sinkId = "";
3550704ebd2Sopenharmony_ci    sptr<TestStopDInputCallback> callback = nullptr;
3560704ebd2Sopenharmony_ci    int32_t ret =
3570704ebd2Sopenharmony_ci        DistributedInputKit::StopRemoteInput(srcId, sinkId, static_cast<uint32_t>(DInputDeviceType::ALL), callback);
3580704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3590704ebd2Sopenharmony_ci}
3600704ebd2Sopenharmony_ci
3610704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2300, testing::ext::TestSize.Level0)
3620704ebd2Sopenharmony_ci{
3630704ebd2Sopenharmony_ci    string srcId = "StartRemoteInput01-src";
3640704ebd2Sopenharmony_ci    string sinkId = "StartRemoteInput01-sink";
3650704ebd2Sopenharmony_ci    std::vector<std::string> dhIds = {"dhIds_test"};
3660704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback(new TestStartStopDInputCallback());
3670704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback);
3680704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3690704ebd2Sopenharmony_ci}
3700704ebd2Sopenharmony_ci
3710704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2400, testing::ext::TestSize.Level0)
3720704ebd2Sopenharmony_ci{
3730704ebd2Sopenharmony_ci    string srcId = "";
3740704ebd2Sopenharmony_ci    string sinkId = "";
3750704ebd2Sopenharmony_ci    std::vector<std::string> dhIds;
3760704ebd2Sopenharmony_ci    sptr<TestStartStopDInputCallback> callback = nullptr;
3770704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::StopRemoteInput(srcId, sinkId, dhIds, callback);
3780704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
3790704ebd2Sopenharmony_ci}
3800704ebd2Sopenharmony_ci
3810704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2500, testing::ext::TestSize.Level0)
3820704ebd2Sopenharmony_ci{
3830704ebd2Sopenharmony_ci    string deviceId = "IsNeedFilterOut01";
3840704ebd2Sopenharmony_ci    BusinessEvent event;
3850704ebd2Sopenharmony_ci    event.pressedKeys.push_back(29);
3860704ebd2Sopenharmony_ci    event.pressedKeys.push_back(56);
3870704ebd2Sopenharmony_ci    event.keyCode = 111;
3880704ebd2Sopenharmony_ci    event.keyAction = 108;
3890704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsNeedFilterOut(deviceId, event);
3900704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
3910704ebd2Sopenharmony_ci}
3920704ebd2Sopenharmony_ci
3930704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2600, testing::ext::TestSize.Level0)
3940704ebd2Sopenharmony_ci{
3950704ebd2Sopenharmony_ci    string deviceId;
3960704ebd2Sopenharmony_ci    BusinessEvent event;
3970704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsNeedFilterOut(deviceId, event);
3980704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
3990704ebd2Sopenharmony_ci}
4000704ebd2Sopenharmony_ci
4010704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2700, testing::ext::TestSize.Level0)
4020704ebd2Sopenharmony_ci{
4030704ebd2Sopenharmony_ci    string deviceId = "IsNeedFilterOut01";
4040704ebd2Sopenharmony_ci    BusinessEvent event;
4050704ebd2Sopenharmony_ci    event.pressedKeys.push_back(29);
4060704ebd2Sopenharmony_ci    event.pressedKeys.push_back(56);
4070704ebd2Sopenharmony_ci    event.keyCode = 111;
4080704ebd2Sopenharmony_ci    event.keyAction = 108;
4090704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsNeedFilterOut(deviceId, event);
4100704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
4110704ebd2Sopenharmony_ci}
4120704ebd2Sopenharmony_ci
4130704ebd2Sopenharmony_ci/**
4140704ebd2Sopenharmony_ci * @tc.name: SUB_DH_DInput_Dcts_2800
4150704ebd2Sopenharmony_ci * @tc.desc: verify the function of filtering events on the touchscreen.
4160704ebd2Sopenharmony_ci * @tc.type: FUNC
4170704ebd2Sopenharmony_ci * @tc.require: SR000GNECO
4180704ebd2Sopenharmony_ci */
4190704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2800, testing::ext::TestSize.Level0)
4200704ebd2Sopenharmony_ci{
4210704ebd2Sopenharmony_ci    std::string sourceWinId = "123";
4220704ebd2Sopenharmony_ci    SinkScreenInfo sinkScreenInfo = DInputContext::GetInstance().GetSinkScreenInfo(sourceWinId);
4230704ebd2Sopenharmony_ci    const TransformInfo trans{10, 10, 100, 100, 1.0, 1.0};
4240704ebd2Sopenharmony_ci    sinkScreenInfo.transformInfo = trans;
4250704ebd2Sopenharmony_ci    DInputContext::GetInstance().UpdateSinkScreenInfo(sourceWinId, sinkScreenInfo);
4260704ebd2Sopenharmony_ci
4270704ebd2Sopenharmony_ci    sourceWinId = "456";
4280704ebd2Sopenharmony_ci    sinkScreenInfo = DInputContext::GetInstance().GetSinkScreenInfo(sourceWinId);
4290704ebd2Sopenharmony_ci    const TransformInfo trans1{120, 130, 50, 50, 1.0, 1.0};
4300704ebd2Sopenharmony_ci    sinkScreenInfo.transformInfo = trans1;
4310704ebd2Sopenharmony_ci    DInputContext::GetInstance().UpdateSinkScreenInfo(sourceWinId, sinkScreenInfo);
4320704ebd2Sopenharmony_ci
4330704ebd2Sopenharmony_ci    TouchScreenEvent event;
4340704ebd2Sopenharmony_ci    event.absX = 100;
4350704ebd2Sopenharmony_ci    event.absY = 100;
4360704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsTouchEventNeedFilterOut(event);
4370704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
4380704ebd2Sopenharmony_ci
4390704ebd2Sopenharmony_ci    event.absX = 140;
4400704ebd2Sopenharmony_ci    event.absY = 150;
4410704ebd2Sopenharmony_ci    ret = DistributedInputKit::IsTouchEventNeedFilterOut(event);
4420704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
4430704ebd2Sopenharmony_ci
4440704ebd2Sopenharmony_ci    event.absX = 150;
4450704ebd2Sopenharmony_ci    event.absY = 20;
4460704ebd2Sopenharmony_ci    ret = DistributedInputKit::IsTouchEventNeedFilterOut(event);
4470704ebd2Sopenharmony_ci    EXPECT_EQ(false, ret);
4480704ebd2Sopenharmony_ci}
4490704ebd2Sopenharmony_ci
4500704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_2900, testing::ext::TestSize.Level0)
4510704ebd2Sopenharmony_ci{
4520704ebd2Sopenharmony_ci    uint32_t flag = 1;
4530704ebd2Sopenharmony_ci    DInputServerType retFlag = DistributedInputKit::IsStartDistributedInput(flag);
4540704ebd2Sopenharmony_ci    EXPECT_EQ(DInputServerType::NULL_SERVER_TYPE, retFlag);
4550704ebd2Sopenharmony_ci}
4560704ebd2Sopenharmony_ci
4570704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3000, testing::ext::TestSize.Level0)
4580704ebd2Sopenharmony_ci{
4590704ebd2Sopenharmony_ci    std::string dhId = "IsStartDistributedInput02";
4600704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsStartDistributedInput(dhId);
4610704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
4620704ebd2Sopenharmony_ci}
4630704ebd2Sopenharmony_ci
4640704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3100, testing::ext::TestSize.Level0)
4650704ebd2Sopenharmony_ci{
4660704ebd2Sopenharmony_ci    std::string dhId = "";
4670704ebd2Sopenharmony_ci    bool ret = DistributedInputKit::IsStartDistributedInput(dhId);
4680704ebd2Sopenharmony_ci    EXPECT_EQ(true, ret);
4690704ebd2Sopenharmony_ci}
4700704ebd2Sopenharmony_ci
4710704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3200, testing::ext::TestSize.Level0)
4720704ebd2Sopenharmony_ci{
4730704ebd2Sopenharmony_ci    sptr<TestSimulationEventListenerStub> listener(new TestSimulationEventListenerStub());
4740704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::RegisterSimulationEventListener(listener);
4750704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
4760704ebd2Sopenharmony_ci}
4770704ebd2Sopenharmony_ci
4780704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3300, testing::ext::TestSize.Level0)
4790704ebd2Sopenharmony_ci{
4800704ebd2Sopenharmony_ci    sptr<TestSimulationEventListenerStub> listener = nullptr;
4810704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::RegisterSimulationEventListener(listener);
4820704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
4830704ebd2Sopenharmony_ci}
4840704ebd2Sopenharmony_ci
4850704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3400, testing::ext::TestSize.Level0)
4860704ebd2Sopenharmony_ci{
4870704ebd2Sopenharmony_ci    sptr<TestSimulationEventListenerStub> listener(new TestSimulationEventListenerStub());
4880704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnregisterSimulationEventListener(listener);
4890704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
4900704ebd2Sopenharmony_ci}
4910704ebd2Sopenharmony_ci
4920704ebd2Sopenharmony_ciHWTEST_F(DistributedInputTest, SUB_DH_DInput_Dcts_3500, testing::ext::TestSize.Level0)
4930704ebd2Sopenharmony_ci{
4940704ebd2Sopenharmony_ci    sptr<TestSimulationEventListenerStub> listener = nullptr;
4950704ebd2Sopenharmony_ci    int32_t ret = DistributedInputKit::UnregisterSimulationEventListener(listener);
4960704ebd2Sopenharmony_ci    EXPECT_EQ(DH_SUCCESS, ret);
4970704ebd2Sopenharmony_ci}