• 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 OHOS_DISTRIBUTED_DATA_KVDB_NOTIFIER_CLIENT_MOCK_H
17 #define OHOS_DISTRIBUTED_DATA_KVDB_NOTIFIER_CLIENT_MOCK_H
18 
19 #include "kvdb_notifier_client.h"
20 #include <gmock/gmock.h>
21 
22 namespace OHOS::DistributedKv {
23 class BKVDBNotifierClient {
24 public:
25     virtual bool IsChanged(const std::string &, DataType) = 0;
26     virtual void AddSyncCallback(const std::shared_ptr<KvStoreSyncCallback>, uint64_t) = 0;
27     virtual void DeleteSyncCallback(uint64_t) = 0;
28     virtual void AddCloudSyncCallback(uint64_t, const AsyncDetail &) = 0;
29     virtual void DeleteCloudSyncCallback(uint64_t) = 0;
30     virtual void AddSwitchCallback(const std::string &, std::shared_ptr<KvStoreObserver>) = 0;
31     virtual void DeleteSwitchCallback(const std::string &, std::shared_ptr<KvStoreObserver>) = 0;
32     virtual void SyncCompleted(uint64_t, ProgressDetail &&) = 0;
33     virtual void SyncCompleted(const std::map<std::string, Status> &, uint64_t) = 0;
34     virtual void OnRemoteChange(const std::map<std::string, bool> &, int32_t) = 0;
35     virtual void OnSwitchChange(const SwitchNotification &) = 0;
36     BKVDBNotifierClient() = default;
37     virtual ~BKVDBNotifierClient() = default;
38 
39 public:
40     static inline std::shared_ptr<BKVDBNotifierClient> kVDBNotifierClient = nullptr;
41 };
42 
43 class KVDBNotifierClientMock : public BKVDBNotifierClient {
44 public:
45     MOCK_METHOD(bool, IsChanged, (const std::string &, DataType dataType));
46     MOCK_METHOD(void, AddSyncCallback, (const std::shared_ptr<KvStoreSyncCallback>, uint64_t));
47     MOCK_METHOD(void, DeleteSyncCallback, (uint64_t));
48     MOCK_METHOD(void, AddCloudSyncCallback, (uint64_t, const AsyncDetail &));
49     MOCK_METHOD(void, DeleteCloudSyncCallback, (uint64_t));
50     MOCK_METHOD(void, AddSwitchCallback, (const std::string &, std::shared_ptr<KvStoreObserver>));
51     MOCK_METHOD(void, DeleteSwitchCallback, (const std::string &, std::shared_ptr<KvStoreObserver>));
52     MOCK_METHOD(void, SyncCompleted, (uint64_t, ProgressDetail &&));
53     MOCK_METHOD(void, SyncCompleted, ((const std::map<std::string, Status> &), uint64_t));
54     MOCK_METHOD(void, OnRemoteChange, ((const std::map<std::string, bool> &), int32_t));
55     MOCK_METHOD(void, OnSwitchChange, (const SwitchNotification &));
56 };
57 } // namespace OHOS::DistributedKv
58 #endif // OHOS_DISTRIBUTED_DATA_KVDB_NOTIFIER_CLIENT_MOCK_H