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 OHOS_DEVICE_MANAGER_IMPL_TEST_H
17 #define OHOS_DEVICE_MANAGER_IMPL_TEST_H
18 
19 #include <gtest/gtest.h>
20 #include <refbase.h>
21 
22 #include <memory>
23 #include <cstdint>
24 #include "mock/mock_ipc_client_proxy.h"
25 #include "device_manager.h"
26 #include "dm_single_instance.h"
27 #include "device_manager_impl.h"
28 #include "softbus_error_code.h"
29 
30 namespace OHOS {
31 namespace DistributedHardware {
32 class DeviceManagerImplTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
40 class DeviceDiscoveryCallbackTest : public DiscoveryCallback {
41 public:
DeviceDiscoveryCallbackTest()42     DeviceDiscoveryCallbackTest() : DiscoveryCallback() {}
~DeviceDiscoveryCallbackTest()43     ~DeviceDiscoveryCallbackTest() {}
44     void OnDiscoverySuccess(uint16_t subscribeId) override {}
45     void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) override {}
46     void OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) override {}
47     void OnDeviceFound(uint16_t subscribeId, const DmDeviceBasicInfo &deviceBasicInfo) override{}
48 };
49 
50 class DevicePublishCallbackTest : public PublishCallback {
51 public:
DevicePublishCallbackTest()52     DevicePublishCallbackTest() : PublishCallback() {}
~DevicePublishCallbackTest()53     virtual ~DevicePublishCallbackTest() {}
54     void OnPublishResult(int32_t publishId, int32_t failedReason) override {}
55 };
56 
57 class DmInitCallbackTest : public DmInitCallback {
58 public:
DmInitCallbackTest()59     DmInitCallbackTest() : DmInitCallback() {}
~DmInitCallbackTest()60     virtual ~DmInitCallbackTest() {}
61     void OnRemoteDied() override {}
62 };
63 
64 class DeviceStateCallbackTest : public DeviceStateCallback {
65 public:
DeviceStateCallbackTest()66     DeviceStateCallbackTest() : DeviceStateCallback() {}
~DeviceStateCallbackTest()67     virtual ~DeviceStateCallbackTest() {}
68     void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override {}
69     void OnDeviceReady(const DmDeviceInfo &deviceInfo) override {}
70     void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override {}
71     void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override {}
72 };
73 
74 class DeviceManagerFaCallbackTest : public DeviceManagerUiCallback {
75 public:
DeviceManagerFaCallbackTest()76     DeviceManagerFaCallbackTest() : DeviceManagerUiCallback() {}
~DeviceManagerFaCallbackTest()77     virtual ~DeviceManagerFaCallbackTest() {}
78     void OnCall(const std::string &paramJson) override {}
79 };
80 
81 class CredentialCallbackTest : public CredentialCallback {
82 public:
~CredentialCallbackTest()83     virtual ~CredentialCallbackTest() {}
84     void OnCredentialResult(int32_t &action, const std::string &credentialResult) override {}
85 };
86 
87 class DeviceStatusCallbackTest : public DeviceStatusCallback {
88 public:
~DeviceStatusCallbackTest()89     ~DeviceStatusCallbackTest() {}
90     void OnDeviceOnline(const DmDeviceBasicInfo &deviceBasicInfo) override {}
91     void OnDeviceOffline(const DmDeviceBasicInfo &deviceBasicInfo) override {}
92     void OnDeviceChanged(const DmDeviceBasicInfo &deviceBasicInfo)  override {}
93     void OnDeviceReady(const DmDeviceBasicInfo &deviceBasicInfo) override {}
94 };
95 
96 class AuthenticateCallbackTest : public AuthenticateCallback {
97 public:
~AuthenticateCallbackTest()98     ~AuthenticateCallbackTest()
99     {
100     }
101     void OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status,
102                       int32_t reason) override {}
103 };
104 
105 class DeviceScreenStatusCallbackTest : public DeviceScreenStatusCallback {
106 public:
~DeviceScreenStatusCallbackTest()107     ~DeviceScreenStatusCallbackTest()
108     {
109     }
110     void OnDeviceScreenStatus(const DmDeviceInfo &deviceInfo) override {}
111 };
112 
113 class DevTrustChangeCallbackTest : public DevTrustChangeCallback {
114 public:
~DevTrustChangeCallbackTest()115     virtual ~DevTrustChangeCallbackTest()
116     {
117     }
118     void OnDeviceTrustChange(const std::string &udid, const std::string &uuid, DmAuthForm authForm) override {}
119 };
120 
121 class CandidateRestrictStatusCallbackTest : public CredentialAuthStatusCallback {
122 public:
~CandidateRestrictStatusCallbackTest()123     virtual ~CandidateRestrictStatusCallbackTest()
124     {
125     }
126     void OnCredentialAuthStatus(const std::string &deviceList, uint16_t deviceTypeId, int32_t errcode) override {}
127 };
128 } // namespace DistributedHardware
129 } // namespace OHOS
130 
131 #endif // OHOS_DEVICE_MANAGER_IMPL_TEST_H
132