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_NOTIFY_TEST_H 17#define OHOS_DEVICE_MANAGER_NOTIFY_TEST_H 18 19#include <gtest/gtest.h> 20#include <mutex> 21#include <map> 22#include <vector> 23#include <string> 24#include <memory> 25#include <list> 26 27#include "dm_device_info.h" 28#include "dm_subscribe_info.h" 29#include "device_manager_callback.h" 30#include "dm_single_instance.h" 31namespace OHOS { 32namespace DistributedHardware { 33class DeviceManagerNotifyTest : public testing::Test { 34public: 35 static void SetUpTestCase(); 36 static void TearDownTestCase(); 37 void SetUp(); 38 void TearDown(); 39}; 40 41class DmInitCallbackTest : public DmInitCallback { 42public: 43 explicit DmInitCallbackTest(int &count); 44 virtual ~DmInitCallbackTest() {} 45 void OnRemoteDied() override; 46private: 47 int *count_ = nullptr; 48}; 49 50class DeviceStateCallbackTest : public DeviceStateCallback { 51public: 52 explicit DeviceStateCallbackTest(int &count); 53 virtual ~DeviceStateCallbackTest() {} 54 void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override; 55 void OnDeviceReady(const DmDeviceInfo &deviceInfo) override; 56 void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override; 57 void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override; 58private: 59 int *count_ = nullptr; 60}; 61 62class DiscoveryCallbackTest : public DiscoveryCallback { 63public: 64 explicit DiscoveryCallbackTest(int &count); 65 virtual ~DiscoveryCallbackTest() {} 66 void OnDiscoverySuccess(uint16_t subscribeId) override; 67 void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) override; 68 void OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) override; 69private: 70 int *count_ = nullptr; 71}; 72 73class PublishCallbackTest : public PublishCallback { 74public: 75 explicit PublishCallbackTest(int &count); 76 virtual ~PublishCallbackTest() {} 77 void OnPublishResult(int32_t publishId, int32_t failedReason) override; 78private: 79 int *count_ = nullptr; 80}; 81 82class AuthenticateCallbackTest : public AuthenticateCallback { 83public: 84 explicit AuthenticateCallbackTest(int &count); 85 virtual ~AuthenticateCallbackTest() {} 86 void OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status, 87 int32_t reason) override; 88private: 89 int *count_ = nullptr; 90}; 91 92class DeviceManagerFaCallbackTest : public DeviceManagerUiCallback { 93public: 94 explicit DeviceManagerFaCallbackTest(int &count); 95 virtual ~DeviceManagerFaCallbackTest() {} 96 void OnCall(const std::string ¶mJson) override; 97private: 98 int *count_ = nullptr; 99}; 100 101class CredentialCallbackTest : public CredentialCallback { 102public: 103 void OnCredentialResult(int32_t &action, const std::string &credentialResult) override {} 104}; 105 106class DeviceStatusCallbackTest : public DeviceStatusCallback { 107public: 108 void OnDeviceOnline(const DmDeviceBasicInfo &deviceBasicInfo) override {} 109 void OnDeviceOffline(const DmDeviceBasicInfo &deviceBasicInfo) override {} 110 void OnDeviceChanged(const DmDeviceBasicInfo &deviceBasicInfo) override {} 111 void OnDeviceReady(const DmDeviceBasicInfo &deviceBasicInfo) override {} 112}; 113 114class PinHolderCallbackTest : public PinHolderCallback { 115public: 116 void OnPinHolderCreate(const std::string &deviceId, DmPinType pinType, const std::string &payload) {} 117 void OnPinHolderDestroy(DmPinType pinType, const std::string &payload) {} 118 void OnCreateResult(int32_t result) {} 119 void OnDestroyResult(int32_t result) {} 120 void OnPinHolderEvent(DmPinHolderEvent event, int32_t result, const std::string &content) {} 121}; 122} // namespace DistributedHardware 123} // namespace OHOS 124 125#endif // OHOS_DEVICE_MANAGER_NOTIFY_TEST_H 126