1 /*
2 * Copyright (c) 2023 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 "sdk_helper.h"
17
18 #include <gtest/gtest.h>
19
20 #include "dfs_error.h"
21
22 namespace OHOS {
23 namespace FileManagement {
24 namespace CloudSync {
25 using namespace std;
26
27 constexpr int TEST_NUM = 100;
28
Init(const int32_t userId,const std::string & bundleName)29 int32_t SdkHelper::Init(const int32_t userId, const std::string &bundleName)
30 {
31 return E_OK;
32 }
33
GetLock(DriveKit::DKLock & lock)34 int32_t SdkHelper::GetLock(DriveKit::DKLock &lock)
35 {
36 GTEST_LOG_(INFO) << "GetLock Start";
37 if (lock.lockInterval == TEST_NUM) {
38 return 1;
39 }
40 return E_OK;
41 }
42
DeleteLock(DriveKit::DKLock & lock)43 void SdkHelper::DeleteLock(DriveKit::DKLock &lock)
44 {
45 return;
46 }
47
FetchRecords(std::shared_ptr<DriveKit::DKContext> context,FetchCondition & cond,DriveKit::DKQueryCursor,FetchRecordsCallback callback)48 int32_t SdkHelper::FetchRecords(std::shared_ptr<DriveKit::DKContext> context,
49 FetchCondition &cond,
50 DriveKit::DKQueryCursor,
51 FetchRecordsCallback callback)
52 {
53 if (context->data_ != nullptr) {
54 return 1;
55 }
56 return E_OK;
57 }
58
FetchRecordWithId(std::shared_ptr<DriveKit::DKContext> context,FetchCondition & cond,DriveKit::DKRecordId recordId,FetchRecordCallback callback)59 int32_t SdkHelper::FetchRecordWithId(std::shared_ptr<DriveKit::DKContext> context,
60 FetchCondition &cond,
61 DriveKit::DKRecordId recordId,
62 FetchRecordCallback callback)
63 {
64 return E_OK;
65 }
66
FetchDatabaseChanges(std::shared_ptr<DriveKit::DKContext> context,FetchCondition & cond,DriveKit::DKQueryCursor cursor,FetchDatabaseChangesCallback callback)67 int32_t SdkHelper::FetchDatabaseChanges(std::shared_ptr<DriveKit::DKContext> context,
68 FetchCondition &cond,
69 DriveKit::DKQueryCursor cursor,
70 FetchDatabaseChangesCallback callback)
71 {
72 if (context->data_ != nullptr) {
73 return 1;
74 }
75 return E_OK;
76 }
77
CreateRecords(shared_ptr<DriveKit::DKContext> context,vector<DriveKit::DKRecord> & records,std::function<void (std::shared_ptr<DriveKit::DKContext>,std::shared_ptr<const DriveKit::DKDatabase>,std::shared_ptr<const std::map<DriveKit::DKRecordId,DriveKit::DKRecordOperResult>>,const DriveKit::DKError &)> callback)78 int32_t SdkHelper::CreateRecords(
79 shared_ptr<DriveKit::DKContext> context,
80 vector<DriveKit::DKRecord> &records,
81 std::function<void(std::shared_ptr<DriveKit::DKContext>,
82 std::shared_ptr<const DriveKit::DKDatabase>,
83 std::shared_ptr<const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult>>,
84 const DriveKit::DKError &)> callback)
85 {
86 return E_OK;
87 }
DeleteRecords(shared_ptr<DriveKit::DKContext> context,vector<DriveKit::DKRecord> & records,std::function<void (std::shared_ptr<DriveKit::DKContext>,std::shared_ptr<const DriveKit::DKDatabase>,std::shared_ptr<const std::map<DriveKit::DKRecordId,DriveKit::DKRecordOperResult>>,const DriveKit::DKError &)> callback)88 int32_t SdkHelper::DeleteRecords(
89 shared_ptr<DriveKit::DKContext> context,
90 vector<DriveKit::DKRecord> &records,
91 std::function<void(std::shared_ptr<DriveKit::DKContext>,
92 std::shared_ptr<const DriveKit::DKDatabase>,
93 std::shared_ptr<const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult>>,
94 const DriveKit::DKError &)> callback)
95 {
96 return E_OK;
97 }
98
ModifyRecords(shared_ptr<DriveKit::DKContext> context,vector<DriveKit::DKRecord> & records,DriveKit::DKDatabase::ModifyRecordsCallback callback)99 int32_t SdkHelper::ModifyRecords(shared_ptr<DriveKit::DKContext> context,
100 vector<DriveKit::DKRecord> &records,
101 DriveKit::DKDatabase::ModifyRecordsCallback callback)
102 {
103 return E_OK;
104 }
105
DownloadAssets(shared_ptr<DriveKit::DKContext> context,std::vector<DriveKit::DKDownloadAsset> & assetsToDownload,DriveKit::DKAssetPath downLoadPath,DriveKit::DKDownloadId & id,std::function<void (std::shared_ptr<DriveKit::DKContext>,std::shared_ptr<const DriveKit::DKDatabase>,const std::map<DriveKit::DKDownloadAsset,DriveKit::DKDownloadResult> &,const DriveKit::DKError &)> resultCallback,std::function<void (std::shared_ptr<DriveKit::DKContext>,DriveKit::DKDownloadAsset,DriveKit::TotalSize,DriveKit::DownloadSize)> progressCallback)106 int32_t SdkHelper::DownloadAssets(
107 shared_ptr<DriveKit::DKContext> context,
108 std::vector<DriveKit::DKDownloadAsset> &assetsToDownload,
109 DriveKit::DKAssetPath downLoadPath,
110 DriveKit::DKDownloadId &id,
111 std::function<void(std::shared_ptr<DriveKit::DKContext>,
112 std::shared_ptr<const DriveKit::DKDatabase>,
113 const std::map<DriveKit::DKDownloadAsset, DriveKit::DKDownloadResult> &,
114 const DriveKit::DKError &)> resultCallback,
115 std::function<void(std::shared_ptr<DriveKit::DKContext>,
116 DriveKit::DKDownloadAsset,
117 DriveKit::TotalSize,
118 DriveKit::DownloadSize)> progressCallback)
119 {
120 return E_OK;
121 }
122
DownloadAssets(DriveKit::DKDownloadAsset & assetsToDownload)123 int32_t SdkHelper::DownloadAssets(DriveKit::DKDownloadAsset &assetsToDownload)
124 {
125 return E_OK;
126 }
127
CancelDownloadAssets(int32_t id)128 int32_t SdkHelper::CancelDownloadAssets(int32_t id)
129 {
130 return E_OK;
131 }
132
GetStartCursor(DriveKit::DKRecordType recordType,DriveKit::DKQueryCursor & cursor)133 int32_t SdkHelper::GetStartCursor(DriveKit::DKRecordType recordType, DriveKit::DKQueryCursor &cursor)
134 {
135 return E_OK;
136 }
137
GetAssetReadSession(DriveKit::DKRecordType recordType,DriveKit::DKRecordId recordId,DriveKit::DKFieldKey assetKey,DriveKit::DKAssetPath assetPath)138 std::shared_ptr<DriveKit::DKAssetReadSession> SdkHelper::GetAssetReadSession(DriveKit::DKRecordType recordType,
139 DriveKit::DKRecordId recordId,
140 DriveKit::DKFieldKey assetKey,
141 DriveKit::DKAssetPath assetPath)
142 {
143 return nullptr;
144 }
145
SaveSubscription(SaveSubscriptionCallback callback)146 int32_t SdkHelper::SaveSubscription(SaveSubscriptionCallback callback)
147 {
148 return E_OK;
149 }
150
DeleteSubscription(DelSubscriptionCallback callback)151 int32_t SdkHelper::DeleteSubscription(DelSubscriptionCallback callback)
152 {
153 return E_OK;
154 }
155
ChangesNotify(ChangesNotifyCallback callback)156 int32_t SdkHelper::ChangesNotify(ChangesNotifyCallback callback)
157 {
158 return E_OK;
159 }
160
Release()161 void SdkHelper::Release()
162 {
163 }
164 } // namespace CloudSync
165 } // namespace FileManagement
166 } // namespace OHOS