• 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_DISTRIBUTED_DEVICE_PROFILE_CLIENT_MOCK_H
16 #define OHOS_DISTRIBUTED_DEVICE_PROFILE_CLIENT_MOCK_H
17 
18 #include <string>
19 #include <gmock/gmock.h>
20 
21 #include "distributed_device_profile_client.h"
22 
23 namespace OHOS {
24 namespace DistributedDeviceProfile {
25 class DpDistributedDeviceProfileClient {
26 public:
27     virtual ~DpDistributedDeviceProfileClient() = default;
28 public:
29     virtual int32_t GetAccessControlProfile(std::map<std::string, std::string> params,
30         std::vector<AccessControlProfile>& accessControlProfiles) = 0;
31     virtual int32_t PutAccessControlProfile(const AccessControlProfile& accessControlProfile) = 0;
32     virtual int32_t GetAllAccessControlProfile(std::vector<AccessControlProfile>& accessControlProfiles) = 0;
33     virtual int32_t SubscribeDeviceProfileInited(int32_t saId, sptr<IDpInitedCallback> initedCb) = 0;
34     virtual int32_t UnSubscribeDeviceProfileInited(int32_t saId) = 0;
35     virtual int32_t PutAllTrustedDevices(const std::vector<DistributedDeviceProfile::TrustedDeviceInfo> &deviceInfos)
36         = 0;
37     virtual int32_t PutSessionKey(uint32_t userId, const std::vector<uint8_t>& sessionKey, int32_t& sessionKeyId) = 0;
38     virtual int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) = 0;
39     virtual int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType) = 0;
40     virtual int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) = 0;
41     virtual int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName,
42         int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) = 0;
43 public:
44     static inline std::shared_ptr<DpDistributedDeviceProfileClient> dpDistributedDeviceProfileClient = nullptr;
45 };
46 
47 class DistributedDeviceProfileClientMock : public DpDistributedDeviceProfileClient {
48 public:
49     MOCK_METHOD(int32_t, GetAccessControlProfile, ((std::map<std::string, std::string>),
50         std::vector<AccessControlProfile>&));
51     MOCK_METHOD(int32_t, PutAccessControlProfile, (const AccessControlProfile&));
52     MOCK_METHOD(int32_t, GetAllAccessControlProfile, (std::vector<AccessControlProfile>&));
53     MOCK_METHOD(int32_t, SubscribeDeviceProfileInited, (int32_t, sptr<IDpInitedCallback>));
54     MOCK_METHOD(int32_t, UnSubscribeDeviceProfileInited, (int32_t));
55     MOCK_METHOD(int32_t, PutAllTrustedDevices, (const std::vector<DistributedDeviceProfile::TrustedDeviceInfo> &));
56     MOCK_METHOD(int32_t, PutSessionKey, (uint32_t, (const std::vector<uint8_t>&), int32_t&));
57     MOCK_METHOD(int32_t, PutLocalServiceInfo, (const LocalServiceInfo&));
58     MOCK_METHOD(int32_t, DeleteLocalServiceInfo, (const std::string&, int32_t));
59     MOCK_METHOD(int32_t, UpdateLocalServiceInfo, (const LocalServiceInfo&));
60     MOCK_METHOD(int32_t, GetLocalServiceInfoByBundleAndPinType, (const std::string&, int32_t, LocalServiceInfo&));
61 };
62 }
63 }
64 #endif
65