1 /* 2 * Copyright (c) 2022-2024 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 DINPUT_SOURCE_CALLBACK_TEST_H 17 #define DINPUT_SOURCE_CALLBACK_TEST_H 18 19 #include <gtest/gtest.h> 20 21 #include "add_white_list_infos_call_back_stub.h" 22 #include "constants_dinput.h" 23 #include "del_white_list_infos_call_back_stub.h" 24 #include "distributed_input_source_proxy.h" 25 #include "distributed_input_source_stub.h" 26 #include "input_node_listener_stub.h" 27 #include "prepare_d_input_call_back_stub.h" 28 #include "register_d_input_call_back_stub.h" 29 #include "start_d_input_call_back_stub.h" 30 #include "stop_d_input_call_back_stub.h" 31 #include "unprepare_d_input_call_back_stub.h" 32 #include "unregister_d_input_call_back_stub.h" 33 #include "start_stop_d_inputs_call_back_stub.h" 34 #include "start_stop_result_call_back_stub.h" 35 #include "simulation_event_listener_stub.h" 36 #include "register_session_state_callback_stub.h" 37 38 namespace OHOS { 39 namespace DistributedHardware { 40 namespace DistributedInput { 41 class DInputSourceCallBackTest : public testing::Test { 42 public: 43 static void SetUpTestCase(); 44 static void TearDownTestCase(); 45 void SetUp() override; 46 void TearDown() override; 47 48 class TestDInputSourceCallBackStub : public 49 OHOS::DistributedHardware::DistributedInput::DistributedInputSourceStub { 50 public: 51 TestDInputSourceCallBackStub() = default; 52 virtual ~TestDInputSourceCallBackStub() = default; 53 int32_t Init(); 54 55 int32_t Release() ; 56 57 int32_t RegisterDistributedHardware( 58 const std::string &devId, const std::string &dhId, const std::string ¶meters, 59 sptr<IRegisterDInputCallback> callback); 60 61 int32_t UnregisterDistributedHardware( 62 const std::string &devId, const std::string &dhId, 63 sptr<IUnregisterDInputCallback> callback); 64 65 int32_t PrepareRemoteInput(const std::string &deviceId, sptr<IPrepareDInputCallback> callback); 66 67 int32_t UnprepareRemoteInput(const std::string &deviceId, sptr<IUnprepareDInputCallback> callback); 68 69 int32_t StartRemoteInput( 70 const std::string &deviceId, const uint32_t &inputTypes, sptr<IStartDInputCallback> callback); 71 72 int32_t StopRemoteInput( 73 const std::string &deviceId, const uint32_t &inputTypes, sptr<IStopDInputCallback> callback); 74 75 int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, 76 sptr<IStartDInputCallback> callback); 77 78 int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, 79 sptr<IStopDInputCallback> callback); 80 81 int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId, 82 sptr<IPrepareDInputCallback> callback); 83 84 int32_t UnprepareRemoteInput(const std::string &srcId, const std::string &sinkId, 85 sptr<IUnprepareDInputCallback> callback); 86 87 int32_t StartRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds, 88 sptr<IStartStopDInputsCallback> callback); 89 90 int32_t StopRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds, 91 sptr<IStartStopDInputsCallback> callback); 92 93 int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, 94 const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback); 95 96 int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, 97 const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback); 98 99 int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback); 100 int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback); 101 102 int32_t RegisterSimulationEventListener(sptr<ISimulationEventListener> listener); 103 int32_t UnregisterSimulationEventListener(sptr<ISimulationEventListener> listener); 104 int32_t RegisterSessionStateCb(sptr<ISessionStateCallback> callback); 105 int32_t UnregisterSessionStateCb(); 106 void OnResult(const std::string &deviceId, const std::string &strJson); 107 std::string deviceId_; 108 std::string strJson_; 109 }; 110 111 class TestDInputRegisterCallBack : public 112 OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub { 113 public: 114 TestDInputRegisterCallBack() = default; 115 virtual ~TestDInputRegisterCallBack() = default; 116 void OnResult(const std::string &devId, const std::string &dhId, const int32_t &status); 117 }; 118 119 class TestDInputUnregisterCallBack : public 120 OHOS::DistributedHardware::DistributedInput::UnregisterDInputCallbackStub { 121 public: 122 TestDInputUnregisterCallBack() = default; 123 virtual ~TestDInputUnregisterCallBack() = default; 124 void OnResult(const std::string &devId, const std::string &dhId, const int32_t &status); 125 }; 126 127 class TestDInputPrepareCallBack : public 128 OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub { 129 public: 130 TestDInputPrepareCallBack() = default; 131 virtual ~TestDInputPrepareCallBack() = default; 132 void OnResult(const std::string &deviceId, const int32_t &status); 133 }; 134 135 class TestDInputUnprepareCallBack : public 136 OHOS::DistributedHardware::DistributedInput::UnprepareDInputCallbackStub { 137 public: 138 TestDInputUnprepareCallBack() = default; 139 virtual ~TestDInputUnprepareCallBack() = default; 140 void OnResult(const std::string &deviceId, const int32_t &status); 141 }; 142 143 class TestDInputStartCallBack : public 144 OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { 145 public: 146 TestDInputStartCallBack() = default; 147 virtual ~TestDInputStartCallBack() = default; 148 void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); 149 }; 150 151 class TestDInputStopCallBack : public 152 OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { 153 public: 154 TestDInputStopCallBack() = default; 155 virtual ~TestDInputStopCallBack() = default; 156 void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status); 157 }; 158 159 class TestVectorStartStopCallBackStub 160 : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { 161 public: 162 TestVectorStartStopCallBackStub() = default; 163 virtual ~TestVectorStartStopCallBackStub() = default; 164 void OnResultDhids(const std::string &devId, const int32_t &status); 165 }; 166 167 class TestAddWhiteListInfosCallBack : public 168 OHOS::DistributedHardware::DistributedInput::AddWhiteListInfosCallbackStub { 169 public: 170 TestAddWhiteListInfosCallBack() = default; 171 virtual ~TestAddWhiteListInfosCallBack() = default; 172 void OnResult(const std::string &deviceId, const std::string &strJson); 173 }; 174 175 class TestDelWhiteListInfosCallBack : public 176 OHOS::DistributedHardware::DistributedInput::DelWhiteListInfosCallbackStub { 177 public: 178 TestDelWhiteListInfosCallBack() = default; 179 virtual ~TestDelWhiteListInfosCallBack() = default; 180 void OnResult(const std::string &deviceId); 181 }; 182 183 class TestDInputNodeListenerCallBack : public 184 OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub { 185 public: 186 TestDInputNodeListenerCallBack() = default; 187 virtual ~TestDInputNodeListenerCallBack() = default; 188 void OnNodeOnLine(const std::string &srcDevId, const std::string &sinkDevId, 189 const std::string &sinkNodeId, const std::string &sinkNodeDesc); 190 191 void OnNodeOffLine(const std::string &srcDevId, const std::string &sinkDevId, 192 const std::string &sinkNodeId); 193 }; 194 195 class TestDInputSimulationEventCallBack : public 196 OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub { 197 public: 198 TestDInputSimulationEventCallBack() = default; 199 virtual ~TestDInputSimulationEventCallBack() = default; 200 int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value); 201 }; 202 }; 203 } // namespace DistributedInput 204 } // namespace DistributedHardware 205 } // namespace OHOS 206 #endif // DINPUT_SOURCE_CALLBACK_TEST_H