• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 
41 namespace OHOS {
42 namespace DistributedHardware {
43 namespace DistributedInput {
44 class DistributedInputTest : public testing::Test {
45 public:
46     static void SetUpTestCase();
47     static void TearDownTestCase();
48     void SetUp() override;
49     void TearDown() override;
50     int CheckSourceProxy() const;
51     int CheckSinkProxy() const;
52 
53     class TestPrepareDInputCallback : public
54         OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub {
55     public:
56         TestPrepareDInputCallback() = default;
57         virtual ~TestPrepareDInputCallback() = default;
58         void OnResult(const std::string& deviceId, const int32_t& status);
59     };
60 
61     class TestUnprepareDInputCallback : public
62         OHOS::DistributedHardware::DistributedInput::UnprepareDInputCallbackStub {
63     public:
64         TestUnprepareDInputCallback() = default;
65         virtual ~TestUnprepareDInputCallback() = default;
66         void OnResult(const std::string& deviceId, const int32_t& status);
67     };
68 
69     class TestStartDInputCallback : public
70         OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub {
71     public:
72         TestStartDInputCallback() = default;
73         virtual ~TestStartDInputCallback() = default;
74         void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
75     };
76 
77     class TestStopDInputCallback : public
78         OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub {
79     public:
80         TestStopDInputCallback() = default;
81         virtual ~TestStopDInputCallback() = default;
82         void OnResult(const std::string& deviceId, const uint32_t& inputTypes, const int32_t& status);
83     };
84 
85     class TestStartStopDInputCallback : public
86         OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub {
87     public:
88         TestStartStopDInputCallback() = default;
89         virtual ~TestStartStopDInputCallback() = default;
90         void OnResultDhids(const std::string &devId, const int32_t &status);
91     };
92 
93     class TestInputNodeListener : public
94         OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub {
95     public:
96         TestInputNodeListener() = default;
97         virtual ~TestInputNodeListener() = default;
98         void OnNodeOnLine(const std::string srcDevId, const std::string sinkDevId,
99             const std::string sinkNodeId, const std::string sinkNodeDesc);
100 
101         void OnNodeOffLine(const std::string srcDevId, const std::string sinkDevId,
102             const std::string sinkNodeId);
103     };
104 
105     class TestSimulationEventListenerStub : public
106         OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub {
107     public:
108         TestSimulationEventListenerStub() = default;
109         virtual ~TestSimulationEventListenerStub() = default;
110         int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value);
111     };
112 };
113 } // namespace DistributedInput
114 } // namespace DistributedHardware
115 } // namespace OHOS
116 
117 #endif // DISRIBUTED_INPUT_INNER_TEST_H
118