1 /*
2  * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DISRIBUTED_INPUT_INNER_TEST_H
17 #define DISRIBUTED_INPUT_INNER_TEST_H
18 
19 #include <functional>
20 #include <iostream>
21 #include <refbase.h>
22 #include <thread>
23 
24 #include <gtest/gtest.h>
25 #include "ipc_skeleton.h"
26 #include "iservice_registry.h"
27 #include "system_ability_definition.h"
28 
29 #include "constants_dinput.h"
30 #include "distributed_input_kit.h"
31 #include "input_node_listener_stub.h"
32 #include "i_distributed_sink_input.h"
33 #include "i_distributed_source_input.h"
34 #include "start_stop_d_inputs_call_back_stub.h"
35 #include "prepare_d_input_call_back_stub.h"
36 #include "start_d_input_call_back_stub.h"
37 #include "stop_d_input_call_back_stub.h"
38 #include "simulation_event_listener_stub.h"
39 #include "unprepare_d_input_call_back_stub.h"
40 #include "register_session_state_callback_stub.h"
41 
42 namespace OHOS {
43 namespace DistributedHardware {
44 namespace DistributedInput {
45 class DistributedInputInnerTest : public testing::Test {
46 public:
47     static void SetUpTestCase();
48     static void TearDownTestCase();
49     void SetUp() override;
50     void TearDown() override;
51     int CheckSourceProxy() const;
52     int CheckSinkProxy() const;
53 
54     class TestPrepareDInputCallback : public
55         OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub {
56     public:
57         TestPrepareDInputCallback() = default;
58         virtual ~TestPrepareDInputCallback() = default;
59         void OnResult(const std::string &deviceId, const int32_t &status);
60     };
61 
62     class TestUnprepareDInputCallback : public
63         OHOS::DistributedHardware::DistributedInput::UnprepareDInputCallbackStub {
64     public:
65         TestUnprepareDInputCallback() = default;
66         virtual ~TestUnprepareDInputCallback() = default;
67         void OnResult(const std::string &deviceId, const int32_t &status);
68     };
69 
70     class TestStartDInputCallback : public
71         OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub {
72     public:
73         TestStartDInputCallback() = default;
74         virtual ~TestStartDInputCallback() = default;
75         void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status);
76     };
77 
78     class TestStopDInputCallback : public
79         OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub {
80     public:
81         TestStopDInputCallback() = default;
82         virtual ~TestStopDInputCallback() = default;
83         void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status);
84     };
85 
86     class TestStartStopDInputCallback : public
87         OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub {
88     public:
89         TestStartStopDInputCallback() = default;
90         virtual ~TestStartStopDInputCallback() = default;
91         void OnResultDhids(const std::string &devId, const int32_t &status);
92     };
93 
94     class TestInputNodeListener : public
95         OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub {
96     public:
97         TestInputNodeListener() = default;
98         virtual ~TestInputNodeListener() = default;
99         void OnNodeOnLine(const std::string &srcDevId, const std::string &sinkDevId,
100             const std::string &sinkNodeId, const std::string &sinkNodeDesc);
101 
102         void OnNodeOffLine(const std::string &srcDevId, const std::string &sinkDevId,
103             const std::string &sinkNodeId);
104     };
105 
106     class TestSimulationEventListenerStub : public
107         OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub {
108     public:
109         TestSimulationEventListenerStub() = default;
110         virtual ~TestSimulationEventListenerStub() = default;
111         int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value);
112     };
113 
114     class TestRegisterSessionStateCb : public
115         OHOS::DistributedHardware::DistributedInput::RegisterSessionStateCallbackStub {
116     public:
117         TestRegisterSessionStateCb() = default;
118         virtual ~TestRegisterSessionStateCb() = default;
119         void OnResult(const std::string &devId, const uint32_t status);
120     };
121 };
122 } // namespace DistributedInput
123 } // namespace DistributedHardware
124 } // namespace OHOS
125 
126 #endif // DISRIBUTED_INPUT_INNER_TEST_H
127