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 ADD_WHITE_LIST_INFOS_CALLBACK_TEST_H 17 #define ADD_WHITE_LIST_INFOS_CALLBACK_TEST_H 18 19 #include <gtest/gtest.h> 20 21 #include "add_white_list_infos_call_back_proxy.h" 22 #include "add_white_list_infos_call_back_stub.h" 23 #include "get_sink_screen_infos_call_back_proxy.h" 24 #include "get_sink_screen_infos_call_back_stub.h" 25 #include "distributed_input_sink_proxy.h" 26 #include "distributed_input_sink_stub.h" 27 #include "input_node_listener_proxy.h" 28 #include "input_node_listener_stub.h" 29 #include "prepare_d_input_call_back_proxy.h" 30 #include "prepare_d_input_call_back_stub.h" 31 #include "sharing_dhid_listener_proxy.h" 32 #include "sharing_dhid_listener_stub.h" 33 #include "simulation_event_listener_proxy.h" 34 #include "simulation_event_listener_stub.h" 35 #include "start_d_input_call_back_proxy.h" 36 #include "start_d_input_call_back_stub.h" 37 #include "start_stop_d_inputs_call_back_proxy.h" 38 #include "start_stop_d_inputs_call_back_stub.h" 39 #include "start_stop_result_call_back_proxy.h" 40 #include "start_stop_result_call_back_stub.h" 41 #include "stop_d_input_call_back_proxy.h" 42 #include "stop_d_input_call_back_stub.h" 43 #include "register_d_input_call_back_proxy.h" 44 #include "register_d_input_call_back_stub.h" 45 46 namespace OHOS { 47 namespace DistributedHardware { 48 namespace DistributedInput { 49 class AddWhiteListInfosCallbackTest : public testing::Test { 50 public: 51 static void SetUpTestCase(); 52 static void TearDownTestCase(); 53 void SetUp() override; 54 void TearDown() override; 55 56 class TestAddWhiteListInfosCallbackStub : public 57 OHOS::DistributedHardware::DistributedInput::AddWhiteListInfosCallbackStub { 58 public: 59 TestAddWhiteListInfosCallbackStub() = default; 60 virtual ~TestAddWhiteListInfosCallbackStub() = default; 61 void OnResult(const std::string &deviceId, const std::string &strJson); 62 std::string deviceId_; 63 std::string strJson_; 64 }; 65 66 class TestGetSinkScreenInfosCallbackStub : public 67 OHOS::DistributedHardware::DistributedInput::GetSinkScreenInfosCallbackStub { 68 public: 69 TestGetSinkScreenInfosCallbackStub() = default; 70 virtual ~TestGetSinkScreenInfosCallbackStub() = default; 71 void OnResult(const std::string &strJson); 72 std::string strJson_; 73 }; 74 75 class TestInputNodeListenerStub : public 76 OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub { 77 public: 78 TestInputNodeListenerStub() = default; 79 virtual ~TestInputNodeListenerStub() = default; 80 void OnNodeOnLine(const std::string &srcDevId, const std::string &sinkDevId, 81 const std::string &sinkNodeId, const std::string &sinkNodeDesc); 82 83 void OnNodeOffLine(const std::string &srcDevId, const std::string &sinkDevId, 84 const std::string &sinkNodeId); 85 std::string srcDevId_; 86 std::string sinkDevId_; 87 std::string sinkNodeId_; 88 std::string sinkNodeDesc_; 89 }; 90 91 class TestPrepareDInputCallbackStub : public 92 OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub { 93 public: 94 TestPrepareDInputCallbackStub() = default; 95 virtual ~TestPrepareDInputCallbackStub() = default; 96 void OnResult(const std::string &devId, const int32_t &status); 97 std::string devId_; 98 int32_t status_ = 0; 99 }; 100 101 class TestRegisterDInputCallbackStub : public 102 OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub { 103 public: 104 TestRegisterDInputCallbackStub() = default; 105 virtual ~TestRegisterDInputCallbackStub() = default; 106 void OnResult(const std::string &devId, const std::string &dhId, const int32_t &status); 107 std::string devId_; 108 std::string dhId_; 109 int32_t status_ = 0; 110 }; 111 112 class TestSharingDhIdListenerStub : public 113 OHOS::DistributedHardware::DistributedInput::SharingDhIdListenerStub { 114 public: 115 TestSharingDhIdListenerStub() = default; 116 virtual ~TestSharingDhIdListenerStub() = default; 117 int32_t OnSharing(const std::string &dhId); 118 int32_t OnNoSharing(const std::string &dhId); 119 std::string dhId_; 120 }; 121 122 class TestSimulationEventListenerStub : public 123 OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub { 124 public: 125 TestSimulationEventListenerStub() = default; 126 virtual ~TestSimulationEventListenerStub() = default; 127 int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value); 128 uint32_t type_ = 0; 129 uint32_t code_ = 0; 130 int32_t value_ = 0; 131 }; 132 133 class TestStartDInputCallbackStub : public 134 OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub { 135 public: 136 TestStartDInputCallbackStub() = default; 137 virtual ~TestStartDInputCallbackStub() = default; 138 void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); 139 std::string devId_; 140 uint32_t inputTypes_ = 0; 141 int32_t status_ = 0; 142 }; 143 144 class TestStartStopDInputsCallbackStub : public 145 OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub { 146 public: 147 TestStartStopDInputsCallbackStub() = default; 148 virtual ~TestStartStopDInputsCallbackStub() = default; 149 void OnResultDhids(const std::string &devId, const int32_t &status); 150 std::string devId_; 151 int32_t status_ = 0; 152 }; 153 154 class TestStartStopResultCallbackStub : public 155 OHOS::DistributedHardware::DistributedInput::StartStopResultCallbackStub { 156 public: 157 TestStartStopResultCallbackStub() = default; 158 virtual ~TestStartStopResultCallbackStub() = default; 159 void OnStart(const std::string &srcId, const std::string &sinkId, std::vector<std::string> &dhIds); 160 void OnStop(const std::string &srcId, const std::string &sinkId, std::vector<std::string> &dhIds); 161 std::string srcId_; 162 std::string sinkId_; 163 std::vector<std::string> dhIds_; 164 }; 165 166 class TestStopDInputCallbackStub : public 167 OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub { 168 public: 169 TestStopDInputCallbackStub() = default; 170 virtual ~TestStopDInputCallbackStub() = default; 171 void OnResult(const std::string &devId, const uint32_t &inputTypes, const int32_t &status); 172 std::string devId_; 173 uint32_t inputTypes_ = 0; 174 int32_t status_ = 0; 175 }; 176 177 class TestDistributedInputSinkStub : public 178 OHOS::DistributedHardware::DistributedInput::DistributedInputSinkStub { 179 public: 180 TestDistributedInputSinkStub() = default; 181 virtual ~TestDistributedInputSinkStub() = default; 182 int32_t Init(); 183 int32_t Release(); 184 int32_t RegisterGetSinkScreenInfosCallback(sptr<IGetSinkScreenInfosCallback> callback); 185 int32_t NotifyStartDScreen(const SrcScreenInfo &remoteCtrlInfo); 186 int32_t NotifyStopDScreen(const std::string &srcScreenInfoKey); 187 int32_t RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener); 188 }; 189 }; 190 } // namespace DistributedInput 191 } // namespace DistributedHardware 192 } // namespace OHOS 193 #endif // ADD_WHITE_LIST_INFOS_CALLBACK_TEST_H