• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DISTRIBUTEDDATA_SERVICE_TEST_BDEVICE_MANAGER_ADAPTER_MOCK_H
16 #define OHOS_DISTRIBUTEDDATA_SERVICE_TEST_BDEVICE_MANAGER_ADAPTER_MOCK_H
17 
18 #include <gmock/gmock.h>
19 
20 #include "commu_types.h"
21 #include "device_manager_adapter.h"
22 
23 namespace OHOS {
24 namespace DistributedData {
25 using namespace OHOS::AppDistributedKv;
26 using AccessCaller = OHOS::AppDistributedKv::AccessCaller;
27 using AccessCallee = OHOS::AppDistributedKv::AccessCallee;
28 using DeviceInfo = OHOS::AppDistributedKv::DeviceInfo;
29 class BDeviceManagerAdapter {
30 public:
31     virtual std::vector<DeviceInfo> GetRemoteDevices() = 0;
32     virtual bool IsOHOSType(const std::string &) = 0;
33     virtual std::vector<std::string> ToUUID(std::vector<DeviceInfo>) = 0;
34     virtual std::vector<std::string> ToUUID(const std::vector<std::string> &) = 0;
35     virtual std::string ToUUID(const std::string &) = 0;
36     virtual Status StartWatchDeviceChange(const AppDeviceChangeListener *, const PipeInfo &) = 0;
37     virtual Status StopWatchDeviceChange(const AppDeviceChangeListener *, const PipeInfo &) = 0;
38     virtual bool IsSameAccount(const AccessCaller &, const AccessCallee &) = 0;
39     virtual bool IsSameAccount(const std::string &) = 0;
40     virtual std::string GetUuidByNetworkId(const std::string &);
41     virtual DeviceInfo GetDeviceInfo(const std::string &);
42     virtual std::string ToNetworkID(const std::string &);
43     virtual bool CheckAccessControl(const AccessCaller &, const AccessCallee &) = 0;
44     virtual DeviceInfo GetLocalDevice() = 0;
45     virtual std::string CalcClientUuid(const std::string &appId, const std::string &uuid) = 0;
46     static inline std::shared_ptr<BDeviceManagerAdapter> deviceManagerAdapter = nullptr;
47     BDeviceManagerAdapter() = default;
48     virtual ~BDeviceManagerAdapter() = default;
49 };
50 
51 class DeviceManagerAdapterMock : public BDeviceManagerAdapter {
52 public:
53     MOCK_METHOD(std::vector<DeviceInfo>, GetRemoteDevices, ());
54     MOCK_METHOD(bool, IsOHOSType, (const std::string &));
55     MOCK_METHOD((std::vector<std::string>), ToUUID, (std::vector<DeviceInfo>));
56     MOCK_METHOD((std::vector<std::string>), ToUUID, (const std::vector<std::string> &));
57     MOCK_METHOD(std::string, ToUUID, (const std::string &));
58     MOCK_METHOD(Status, StartWatchDeviceChange, (const AppDeviceChangeListener *, const PipeInfo &));
59     MOCK_METHOD(Status, StopWatchDeviceChange, (const AppDeviceChangeListener *, const PipeInfo &));
60     MOCK_METHOD(bool, IsSameAccount, (const AccessCaller &, const AccessCallee &));
61     MOCK_METHOD(bool, IsSameAccount, (const std::string &));
62     MOCK_METHOD(std::string, GetUuidByNetworkId, (const std::string &));
63     MOCK_METHOD(DeviceInfo, GetDeviceInfo, (const std::string &));
64     MOCK_METHOD(std::string, ToNetworkID, (const std::string &));
65     MOCK_METHOD(bool, CheckAccessControl, (const AccessCaller &, const AccessCallee &));
66     MOCK_METHOD(DeviceInfo, GetLocalDevice, ());
67     MOCK_METHOD(std::string, CalcClientUuid, (const std::string &, const std::string &));
68 };
69 
70 } // namespace DistributedData
71 } // namespace OHOS
72 #endif //OHOS_DISTRIBUTEDDATA_SERVICE_TEST_BDEVICE_MANAGER_ADAPTER_MOCK_H
73