• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
16 #include "auth_hichain_id_service_mock.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 
23 void *g_hichainMockIdInterface;
AuthHichainIdServiceInterfaceMock()24 AuthHichainIdServiceInterfaceMock::AuthHichainIdServiceInterfaceMock()
25 {
26     g_hichainMockIdInterface = reinterpret_cast<void *>(this);
27 }
28 
~AuthHichainIdServiceInterfaceMock()29 AuthHichainIdServiceInterfaceMock::~AuthHichainIdServiceInterfaceMock()
30 {
31     g_hichainMockIdInterface = nullptr;
32 }
33 
GetAuthHichainIdServiceInterfaceMock()34 static AuthHichainIdServiceInterface *GetAuthHichainIdServiceInterfaceMock()
35 {
36     return reinterpret_cast<AuthHichainIdServiceInterfaceMock *>(g_hichainMockIdInterface);
37 }
38 
39 extern "C" {
cJSON_CreateObject()40 cJSON *cJSON_CreateObject()
41 {
42     return GetAuthHichainIdServiceInterfaceMock()->cJSON_CreateObject();
43 }
44 
AddStringToJsonObject(cJSON * json,const char * const string,const char * value)45 bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value)
46 {
47     return GetAuthHichainIdServiceInterfaceMock()->AddStringToJsonObject(json, string, value);
48 }
49 
AddNumberToJsonObject(cJSON * json,const char * const string,int32_t num)50 bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
51 {
52     return GetAuthHichainIdServiceInterfaceMock()->AddNumberToJsonObject(json, string, num);
53 }
54 
cJSON_PrintUnformatted(const cJSON * json)55 char *cJSON_PrintUnformatted(const cJSON *json)
56 {
57     return GetAuthHichainIdServiceInterfaceMock()->cJSON_PrintUnformatted(json);
58 }
59 
InitDeviceAuthService()60 int32_t InitDeviceAuthService()
61 {
62     return GetAuthHichainIdServiceInterfaceMock()->InitDeviceAuthService();
63 }
64 
GetCredMgrInstance()65 const CredManager *GetCredMgrInstance()
66 {
67     return GetAuthHichainIdServiceInterfaceMock()->GetCredMgrInstance();
68 }
69 
GetCredAuthInstance()70 const CredAuthManager *GetCredAuthInstance()
71 {
72     return GetAuthHichainIdServiceInterfaceMock()->GetCredAuthInstance();
73 }
74 
GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode,uint32_t * softbusErrCode)75 void GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode, uint32_t *softbusErrCode)
76 {
77     *softbusErrCode = hichainErrCode;
78     return;
79 }
80 
LnnGetLocalStrInfo(InfoKey key,char * info,uint32_t len)81 int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len)
82 {
83     return GetAuthHichainIdServiceInterfaceMock()->LnnGetLocalStrInfo(key, info, len);
84 }
85 
GetActiveOsAccountIds(void)86 int32_t GetActiveOsAccountIds(void)
87 {
88     return GetAuthHichainIdServiceInterfaceMock()->GetActiveOsAccountIds();
89 }
90 
LnnDeleteSpecificTrustedDevInfo(const char * udid,int32_t localUserId)91 int32_t LnnDeleteSpecificTrustedDevInfo(const char *udid, int32_t localUserId)
92 {
93     return GetAuthHichainIdServiceInterfaceMock()->LnnDeleteSpecificTrustedDevInfo(udid, localUserId);
94 }
95 
LnnHbOnTrustedRelationReduced(void)96 void LnnHbOnTrustedRelationReduced(void)
97 {
98     return GetAuthHichainIdServiceInterfaceMock()->LnnHbOnTrustedRelationReduced();
99 }
100 
LnnGetLocalNumInfo(InfoKey key,int32_t * info)101 int32_t LnnGetLocalNumInfo(InfoKey key, int32_t *info)
102 {
103     return GetAuthHichainIdServiceInterfaceMock()->LnnGetLocalNumInfo(key, info);
104 }
105 
LnnInsertSpecificTrustedDevInfo(const char * udid)106 int32_t LnnInsertSpecificTrustedDevInfo(const char *udid)
107 {
108     return GetAuthHichainIdServiceInterfaceMock()->LnnInsertSpecificTrustedDevInfo(udid);
109 }
110 
LnnHbOnTrustedRelationIncreased(int32_t groupType)111 void LnnHbOnTrustedRelationIncreased(int32_t groupType)
112 {
113     return GetAuthHichainIdServiceInterfaceMock()->LnnHbOnTrustedRelationIncreased(groupType);
114 }
115 
LnnGetLocalByteInfo(InfoKey key,uint8_t * info,uint32_t len)116 int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len)
117 {
118     return GetAuthHichainIdServiceInterfaceMock()->LnnGetLocalByteInfo(key, info, len);
119 }
120 
121 } // extern "C"
122 } // namespace OHOS