1 /*
2  * Copyright (C) 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 #ifndef OHOS_DFS_SERVICE_DEVICE_MANAGER_MOCK_H
16 #define OHOS_DFS_SERVICE_DEVICE_MANAGER_MOCK_H
17 
18 #include <memory>
19 #include <string>
20 #include <gmock/gmock.h>
21 
22 #include "device_manager.h"
23 #include "softbus_bus_center.h"
24 
25 namespace OHOS::Storage::DistributedFile {
26 using namespace OHOS::DistributedHardware;
27 class DfsDeviceManagerImpl {
28 public:
29     virtual ~DfsDeviceManagerImpl() = default;
30 public:
31     virtual int32_t InitDeviceManager(const std::string &pkgName,
32         std::shared_ptr<DmInitCallback> dmInitCallback) = 0;
33     virtual int32_t UnInitDeviceManager(const std::string &pkgName) = 0;
34     virtual int32_t GetTrustedDeviceList(const std::string &pkgName,
35         const std::string &extra, std::vector<DmDeviceInfo> &deviceList) = 0;
36     virtual int32_t RegisterDevStateCallback(const std::string &pkgName,
37         const std::string &extra, std::shared_ptr<DeviceStateCallback> callback) = 0;
38     virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName) = 0;
39     virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &info) = 0;
40 public:
41     virtual int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info) = 0;
42 public:
43     static inline std::shared_ptr<DfsDeviceManagerImpl> dfsDeviceManagerImpl = nullptr;
44 };
45 
46 class DeviceManagerImplMock : public DfsDeviceManagerImpl {
47 public:
48     MOCK_METHOD2(InitDeviceManager, int32_t(const std::string &pkgName,
49         std::shared_ptr<DmInitCallback> dmInitCallback));
50     MOCK_METHOD1(UnInitDeviceManager, int32_t(const std::string &pkgName));
51     MOCK_METHOD3(GetTrustedDeviceList, int32_t(const std::string &pkgName,
52         const std::string &extra, std::vector<DmDeviceInfo> &deviceList));
53     MOCK_METHOD3(RegisterDevStateCallback, int32_t(const std::string &pkgName,
54         const std::string &extra, std::shared_ptr<DeviceStateCallback> callback));
55     MOCK_METHOD1(UnRegisterDevStateCallback, int32_t(const std::string &pkgName));
56     MOCK_METHOD2(GetLocalNodeDeviceInfo, int32_t(const char *pkgName, NodeBasicInfo *info));
57     MOCK_METHOD2(GetLocalDeviceInfo, int32_t(const std::string &pkgName, DmDeviceInfo &info));
58 };
59 }
60 #endif