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
16 #include "device_manager.h"
17
18 #include "device_manager_mock.h"
19
20 namespace OHOS {
21 namespace DistributedHardware {
DeviceManagerMock()22 DeviceManagerMock::DeviceManagerMock()
23 {
24 ON_CALL(*this, InitDeviceManager).WillByDefault([this](const std::string &, std::shared_ptr<DmInitCallback>) {
25 return 0;
26 });
27
28 ON_CALL(*this, GetUdidByNetworkId)
29 .WillByDefault([](const std::string &, const std::string &netWorkId, std::string &udid) {
30 udid = netWorkId;
31 return 0;
32 });
33
34 ON_CALL(*this, GetTrustedDeviceList)
35 .WillByDefault([](const std::string &, const std::string &, std::vector<DmDeviceInfo> &deviceList) {
36 DmDeviceInfo info1 {.networkId = {'a', 0}, .extraData = "{}"};
37 DmDeviceInfo info2 {.networkId = {'b', 0}, .extraData = "{}"};
38 DmDeviceInfo info3 {.networkId = {'c', 0}};
39 DmDeviceInfo info4 {.networkId = {'d', 0}};
40 deviceList.push_back(info1);
41 deviceList.push_back(info2);
42 deviceList.push_back(info3);
43 deviceList.push_back(info4);
44 return 0;
45 });
46
47 ON_CALL(*this, GetLocalDeviceInfo).WillByDefault([](const std::string &, DmDeviceInfo &deviceInfo) {
48 DmDeviceInfo info1 {.networkId = {'a', 0}};
49 deviceInfo = info1;
50 return 0;
51 });
52 }
53
~DeviceManagerMock()54 DeviceManagerMock::~DeviceManagerMock()
55 {
56 }
57
Instance()58 DeviceManagerMock &DeviceManagerMock::Instance()
59 {
60 static testing::NiceMock<DeviceManagerMock> inst;
61 return inst;
62 }
63 } // namespace DistributedHardware
64 } // namespace OHOS
65