1 /*
2 * Copyright (c) 2022 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_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22 void *g_hichainInterface;
AuthHichainInterfaceMock()23 AuthHichainInterfaceMock::AuthHichainInterfaceMock()
24 {
25 g_hichainInterface = reinterpret_cast<void *>(this);
26 }
27
~AuthHichainInterfaceMock()28 AuthHichainInterfaceMock::~AuthHichainInterfaceMock()
29 {
30 g_hichainInterface = nullptr;
31 }
32
InvokeAuthDevice(int32_t osAccountId,int64_t authReqId,const char * authParams,const DeviceAuthCallback * gaCallback)33 int32_t AuthHichainInterfaceMock::InvokeAuthDevice(int32_t osAccountId, int64_t authReqId, const char *authParams,
34 const DeviceAuthCallback *gaCallback)
35 {
36 return 0;
37 }
38
InvokeDataChangeListener(const char * appId,const DataChangeListener * listener)39 int32_t AuthHichainInterfaceMock::InvokeDataChangeListener(const char *appId, const DataChangeListener *listener)
40 {
41 return 0;
42 }
43
GetHichainInterface()44 static AuthHichainInterface *GetHichainInterface()
45 {
46 return reinterpret_cast<AuthHichainInterfaceMock *>(g_hichainInterface);
47 }
48
49 extern "C" {
InitDeviceAuthService(void)50 int32_t InitDeviceAuthService(void)
51 {
52 return GetHichainInterface()->InitDeviceAuthService();
53 }
54
DestroyDeviceAuthService(void)55 void DestroyDeviceAuthService(void)
56 {
57 return GetHichainInterface()->DestroyDeviceAuthService();
58 }
59
GetGaInstance(void)60 const GroupAuthManager *GetGaInstance(void)
61 {
62 return GetHichainInterface()->GetGaInstance();
63 }
64
GetGmInstance(void)65 const DeviceGroupManager *GetGmInstance(void)
66 {
67 return GetHichainInterface()->GetGmInstance();
68 }
69 }
70 }