• 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 #include "device_manager_adapter.h"
20 #include "commu_types.h"
21 
22 namespace OHOS {
23 namespace DistributedData {
24 using namespace OHOS::AppDistributedKv;
25 using AccessCaller = OHOS::AppDistributedKv::AccessCaller;
26 using AccessCallee = OHOS::AppDistributedKv::AccessCallee;
27 class BDeviceManagerAdapter {
28 public:
29     virtual std::vector<DeviceInfo> GetRemoteDevices() = 0;
30     virtual bool IsOHOSType(const std::string &) = 0;
31     virtual std::vector<std::string> ToUUID(std::vector<DeviceInfo>) = 0;
32     virtual Status StartWatchDeviceChange(const AppDeviceChangeListener *, const PipeInfo &) = 0;
33     virtual Status StopWatchDeviceChange(const AppDeviceChangeListener *, const PipeInfo &) = 0;
34     virtual bool IsSameAccount(const AccessCaller &, const AccessCallee &) = 0;
35     virtual bool CheckAccessControl(const AccessCaller &, const AccessCallee &) = 0;
36     virtual DeviceInfo GetLocalDevice() = 0;
37     static inline std::shared_ptr<BDeviceManagerAdapter> deviceManagerAdapter = nullptr;
38     BDeviceManagerAdapter() = default;
39     virtual ~BDeviceManagerAdapter() = default;
40 };
41 
42 class DeviceManagerAdapterMock : public BDeviceManagerAdapter {
43 public:
44     MOCK_METHOD(std::vector<DeviceInfo>, GetRemoteDevices, ());
45     MOCK_METHOD(bool, IsOHOSType, (const std::string &));
46     MOCK_METHOD((std::vector<std::string>), ToUUID, (std::vector<DeviceInfo>));
47     MOCK_METHOD(Status, StartWatchDeviceChange, (const AppDeviceChangeListener *, const PipeInfo &));
48     MOCK_METHOD(Status, StopWatchDeviceChange, (const AppDeviceChangeListener *, const PipeInfo &));
49     MOCK_METHOD(bool, IsSameAccount, (const AccessCaller &, const AccessCallee &));
50     MOCK_METHOD(bool, CheckAccessControl, (const AccessCaller &, const AccessCallee &));
51     MOCK_METHOD(DeviceInfo, GetLocalDevice, ());
52 };
53 
54 } // namespace DistributedData
55 } // namespace OHOS
56 #endif //OHOS_DISTRIBUTEDDATA_SERVICE_TEST_BDEVICE_MANAGER_ADAPTER_MOCK_H
57