1 /* 2 * Copyright (c) 2023 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 SECURITY_GUARD_DEVICE_MANAGER_MOCK_H 17 #define SECURITY_GUARD_DEVICE_MANAGER_MOCK_H 18 19 #include "gmock/gmock.h" 20 21 namespace OHOS::DistributedHardware { 22 constexpr int32_t DM_MAX_DEVICE_ID_LEN = 96; 23 24 typedef struct DmDeviceInfo { 25 char deviceId[DM_MAX_DEVICE_ID_LEN]; 26 } DmDeviceInfo; 27 28 class DmInitCallback { 29 public: ~DmInitCallback()30 virtual ~DmInitCallback() {}; 31 virtual void OnRemoteDied() = 0; 32 }; 33 34 class DeviceManagerInterface { 35 public: 36 virtual ~DeviceManagerInterface() = default; 37 virtual int32_t InitDeviceManager(const std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback) = 0; 38 virtual int32_t UnInitDeviceManager(const std::string &pkgName) = 0; 39 virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &deviceInfo) = 0; 40 }; 41 42 class DeviceManager : public DeviceManagerInterface { 43 public: GetInstance()44 static DeviceManager &GetInstance() 45 { 46 static DeviceManager instance; 47 return instance; 48 }; 49 DeviceManager() = default; 50 ~DeviceManager() override = default; 51 MOCK_METHOD2(InitDeviceManager, int32_t(const std::string &pkgName, 52 std::shared_ptr<DmInitCallback> dmInitCallback)); 53 MOCK_METHOD1(UnInitDeviceManager, int32_t(const std::string &pkgName)); 54 MOCK_METHOD2(GetLocalDeviceInfo, int32_t(const std::string &pkgName, DmDeviceInfo &deviceInfo)); 55 }; 56 } // OHOS::DistributedHardware 57 58 #endif // SECURITY_GUARD_DEVICE_MANAGER_MOCK_H