1 /* 2 * Copyright (C) 2024-2025 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 virtual int32_t GetBusinessEvent(BusinessEvent &event) = 0; 44 virtual int32_t PutBusinessEvent(const DistributedDeviceProfile::BusinessEvent &event) = 0; 45 virtual int32_t GetAllAclIncludeLnnAcl(std::vector<AccessControlProfile>& profiles) = 0; 46 public: 47 static inline std::shared_ptr<DpDistributedDeviceProfileClient> dpDistributedDeviceProfileClient = nullptr; 48 }; 49 50 class DistributedDeviceProfileClientMock : public DpDistributedDeviceProfileClient { 51 public: 52 MOCK_METHOD(int32_t, GetAccessControlProfile, ((std::map<std::string, std::string>), 53 std::vector<AccessControlProfile>&)); 54 MOCK_METHOD(int32_t, PutAccessControlProfile, (const AccessControlProfile&)); 55 MOCK_METHOD(int32_t, GetAllAccessControlProfile, (std::vector<AccessControlProfile>&)); 56 MOCK_METHOD(int32_t, SubscribeDeviceProfileInited, (int32_t, sptr<IDpInitedCallback>)); 57 MOCK_METHOD(int32_t, UnSubscribeDeviceProfileInited, (int32_t)); 58 MOCK_METHOD(int32_t, PutAllTrustedDevices, (const std::vector<DistributedDeviceProfile::TrustedDeviceInfo> &)); 59 MOCK_METHOD(int32_t, PutSessionKey, (uint32_t, (const std::vector<uint8_t>&), int32_t&)); 60 MOCK_METHOD(int32_t, PutLocalServiceInfo, (const LocalServiceInfo&)); 61 MOCK_METHOD(int32_t, DeleteLocalServiceInfo, (const std::string&, int32_t)); 62 MOCK_METHOD(int32_t, UpdateLocalServiceInfo, (const LocalServiceInfo&)); 63 MOCK_METHOD(int32_t, GetLocalServiceInfoByBundleAndPinType, (const std::string&, int32_t, LocalServiceInfo&)); 64 MOCK_METHOD(int32_t, GetBusinessEvent, (BusinessEvent &event)); 65 MOCK_METHOD(int32_t, PutBusinessEvent, (const DistributedDeviceProfile::BusinessEvent &event)); 66 MOCK_METHOD(int32_t, GetAllAclIncludeLnnAcl, (std::vector<AccessControlProfile>&)); 67 }; 68 } 69 } 70 #endif 71