• 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_DEVICE_MANAGER_SERVICE_IMPL_MOCK_H
16 #define OHOS_DEVICE_MANAGER_SERVICE_IMPL_MOCK_H
17 
18 #include <string>
19 #include <gmock/gmock.h>
20 
21 #include "device_manager_service_impl.h"
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 class DmDeviceManagerServiceImpl {
26 public:
27     virtual ~DmDeviceManagerServiceImpl() = default;
28 public:
29     virtual int32_t StopAuthenticateDevice(const std::string &pkgName) = 0;
30     virtual int32_t GetBindLevel(const std::string &pkgName, const std::string &localUdid,
31         const std::string &udid, uint64_t &tokenId) = 0;
32     virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) = 0;
33     virtual std::multimap<std::string, int32_t> GetDeviceIdAndUserId(int32_t userId, const std::string &accountId) = 0;
34     virtual std::map<std::string, int32_t> GetDeviceIdAndBindLevel(int32_t userId) = 0;
35     virtual std::multimap<std::string, int32_t> GetDeviceIdAndUserId(int32_t localUserId) = 0;
36     virtual std::unordered_map<std::string, DmAuthForm> GetAppTrustDeviceIdList(std::string pkgname) = 0;
37     virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &udid, int32_t bindLevel) = 0;
38     virtual int32_t UnBindDevice(const std::string &pkgName, const std::string &udid,
39         int32_t bindLevel, const std::string &extra) = 0;
40 public:
41     static inline std::shared_ptr<DmDeviceManagerServiceImpl> dmDeviceManagerServiceImpl = nullptr;
42 };
43 
44 class DeviceManagerServiceImplMock : public DmDeviceManagerServiceImpl {
45 public:
46     MOCK_METHOD(int32_t, StopAuthenticateDevice, (const std::string &));
47     MOCK_METHOD(int32_t, GetBindLevel, (const std::string &, const std::string &, const std::string &, uint64_t &));
48     MOCK_METHOD(int32_t, UnBindDevice, (const std::string &, const std::string &, int32_t));
49     MOCK_METHOD((std::multimap<std::string, int32_t>), GetDeviceIdAndUserId, (int32_t, const std::string &));
50     MOCK_METHOD((std::multimap<std::string, int32_t>), GetDeviceIdAndUserId, (int32_t));
51     MOCK_METHOD((std::map<std::string, int32_t>), GetDeviceIdAndBindLevel, (int32_t));
52     MOCK_METHOD((std::unordered_map<std::string, DmAuthForm>), GetAppTrustDeviceIdList, (std::string));
53     MOCK_METHOD(int32_t, UnAuthenticateDevice, (const std::string &, const std::string &, int32_t));
54     MOCK_METHOD(int32_t, UnBindDevice, (const std::string &, const std::string &, int32_t, const std::string &));
55 };
56 }
57 }
58 #endif
59