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 "distributed_database.h" 17 18 #include "ans_log_wrapper.h" 19 20 namespace { 21 bool g_mockOnDeviceConnectedRet = true; 22 bool g_mockGetEntriesFromDistributedDBRet = true; 23 bool g_mockGetDeviceInfoListRet = true; 24 bool g_mockGetLocalDeviceIdRet = true; 25 } 26 MockOnDeviceConnected(bool mockRet)27void MockOnDeviceConnected(bool mockRet) 28 { 29 g_mockOnDeviceConnectedRet = mockRet; 30 } 31 MockGetEntriesFromDistributedDB(bool mockRet)32void MockGetEntriesFromDistributedDB(bool mockRet) 33 { 34 g_mockGetEntriesFromDistributedDBRet = mockRet; 35 } 36 MockGetDeviceInfoList(bool mockRet)37void MockGetDeviceInfoList(bool mockRet) 38 { 39 g_mockGetDeviceInfoListRet = mockRet; 40 } 41 MockGetLocalDeviceId(bool mockRet)42void MockGetLocalDeviceId(bool mockRet) 43 { 44 g_mockGetLocalDeviceIdRet = mockRet; 45 } 46 47 namespace OHOS { 48 namespace Notification { OnDeviceConnected()49bool DistributedDatabase::OnDeviceConnected() 50 { 51 return g_mockOnDeviceConnectedRet; 52 } 53 GetEntriesFromDistributedDB(const std::string & prefixKey,std::vector<Entry> & entries)54bool DistributedDatabase::GetEntriesFromDistributedDB(const std::string &prefixKey, std::vector<Entry> &entries) 55 { 56 Entry entry; 57 entry.key = "GetEntriesFromDistributedDB"; 58 entries.emplace_back(entry); 59 return g_mockGetEntriesFromDistributedDBRet; 60 } 61 GetDeviceInfoList(std::vector<DeviceInfo> & deviceList)62bool DistributedDatabase::GetDeviceInfoList(std::vector<DeviceInfo> &deviceList) 63 { 64 return g_mockGetDeviceInfoListRet; 65 } 66 GetLocalDeviceId(std::string & deviceId)67bool DistributedDatabase::GetLocalDeviceId(std::string &deviceId) 68 { 69 return g_mockGetLocalDeviceIdRet; 70 } 71 PutToDistributedDB(const std::string & key,const std::string & value)72bool DistributedDatabase::PutToDistributedDB(const std::string &key, const std::string &value) 73 { 74 return false; 75 } 76 GetLocalDeviceInfo(DeviceInfo & localInfo)77bool DistributedDatabase::GetLocalDeviceInfo(DeviceInfo &localInfo) 78 { 79 return false; 80 } 81 RecreateDistributedDB()82bool DistributedDatabase::RecreateDistributedDB() 83 { 84 return false; 85 } 86 } // namespace Notification 87 } // namespace OHOS