• 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 
16 #ifndef LNN_KV_ADAPTER_WRAPPER_MOCK_H
17 #define LNN_KV_ADAPTER_WRAPPER_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 #include "lnn_kv_adapter_wrapper.h"
22 
23 namespace OHOS {
24 class LnnKvAdapterInterface {
25 public:
LnnKvAdapterInterface()26     LnnKvAdapterInterface() {};
~LnnKvAdapterInterface()27     virtual ~LnnKvAdapterInterface() {};
28 
29     virtual int32_t LnnCreateKvAdapter(int32_t *dbId, const char *appId, int32_t appIdLen, const char *storeId,
30         int32_t storeIdLen);
31     virtual int32_t LnnDestroyKvAdapter(int32_t dbId);
32     virtual void LnnRegisterDataChangeListener(int32_t dbId, const char *appId, int32_t appIdLen,
33         const char *storeId, int32_t storeIdLen);
34     virtual void LnnUnRegisterDataChangeListener(int32_t dbId);
35     virtual int32_t LnnPutDBData(int32_t dbId, const char *key, int32_t keyLen, const char *value, int32_t valueLen);
36     virtual int32_t LnnDeleteDBDataByPrefix(int32_t dbId, const char *keyPrefix, int32_t keyPrefixLen);
37     virtual int32_t LnnCloudSync(int32_t dbId);
38     virtual int32_t LnnSetCloudAbilityInner(int32_t dbId, const bool isEnableCloud);
39 };
40 
41 class LnnKvAdapterInterfaceMock : public LnnKvAdapterInterface {
42 public:
43     LnnKvAdapterInterfaceMock();
44     ~LnnKvAdapterInterfaceMock() override;
45 
46     MOCK_METHOD5(LnnCreateKvAdapter, int32_t (int32_t *, const char *, int32_t, const char *, int32_t));
47     MOCK_METHOD1(LnnDestroyKvAdapter, int32_t (int32_t));
48     MOCK_METHOD5(LnnRegisterDataChangeListener, void (int32_t, const char *, int32_t, const char *, int32_t));
49     MOCK_METHOD1(LnnUnRegisterDataChangeListener, void (int32_t));
50     MOCK_METHOD5(LnnPutDBData, int32_t (int32_t, const char *, int32_t, const char *, int32_t));
51     MOCK_METHOD3(LnnDeleteDBDataByPrefix, int32_t (int32_t, const char *, int32_t));
52     MOCK_METHOD1(LnnCloudSync, int32_t (int32_t));
53     MOCK_METHOD2(LnnSetCloudAbilityInner, int32_t (int32_t, const bool));
54 };
55 } // namespace OHOS
56 #endif // LNN_AUTH_MOCK_H
57