• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd. All rights reserved.
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 <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 #include <memory>
19 
20 #include "cloud_disk_data_syncer.h"
21 #include "data_convertor_mock.h"
22 #include "cloud_file_utils_mock.h"
23 #include "dfs_error.h"
24 #include "dk_database.h"
25 #include "dk_record_mock.h"
26 #include "file_data_convertor.h"
27 #include "file_data_handler.h"
28 #include "rdb_store_mock.h"
29 #include "result_set_mock.h"
30 #include "clouddisk_rdbstore.h"
31 #include "album_data_handler.h"
32 
33 namespace OHOS {
34 namespace FileManagement::CloudSync {
35 namespace Test {
36 using namespace testing::ext;
37 using namespace std;
38 using namespace OHOS::FileManagement::CloudSync;
39 using namespace OHOS::FileManagement::CloudDisk;
40 
41 class CloudDiskDataConvertorMock final : public CloudDiskDataConvertor {
42 public:
CloudDiskDataConvertorMock(int32_t userId,std::string & bundleName,OperationType type,const std::function<void (NativeRdb::ResultSet & resultSet)> & func=nullptr)43     CloudDiskDataConvertorMock(int32_t userId,
44                                std::string &bundleName,
45                                OperationType type,
46                                const std::function<void(NativeRdb::ResultSet &resultSet)> &func = nullptr)
47         : CloudDiskDataConvertor(userId, bundleName, type)
48     {
49     }
50     MOCK_METHOD2(Convert, int32_t(DriveKit::DKRecord &record, NativeRdb::ValuesBucket &valuesBucket));
51 };
52 
53 class CloudDiskDataHandlerMock final : public CloudDiskDataHandler {
54 public:
CloudDiskDataHandlerMock(int32_t userId,const string & bundleName,std::shared_ptr<RdbStore> rdb)55     CloudDiskDataHandlerMock(int32_t userId, const string &bundleName, std::shared_ptr<RdbStore> rdb)
56         : CloudDiskDataHandler(userId, bundleName, rdb, std::make_shared<bool>(false))
57     {
58     }
59 
60     MOCK_METHOD2(Query,
61                  std::shared_ptr<NativeRdb::ResultSet>(const NativeRdb::AbsRdbPredicates &predicates,
62                                                        const std::vector<std::string> &columns));
63     MOCK_METHOD4(Update,
64                  int32_t(int &changedRows,
65                          const NativeRdb::ValuesBucket &values,
66                          const std::string &whereClause,
67                          const std::vector<std::string> &whereArgs));
68     MOCK_METHOD4(Delete,
69                  int32_t(int &deletedRows,
70                          const std::string &tableName,
71                          const string &whereClause,
72                          const vector<string> &whereArgs));
73     MOCK_METHOD3(Delete,
74                  int32_t(int &deletedRows, const std::string &whereClause, const std::vector<std::string> &whereArgs));
75 
76     MOCK_METHOD1(OnRecordFailed, int32_t(const std::pair<DKRecordId, DKRecordOperResult> &entry));
77 
78     MOCK_METHOD3(BatchDetete,
79                  int32_t(const string &whichTable, const string &whichColumn,
80                         const std::vector<NativeRdb::ValueObject> &bindArgs));
81 
SetIsChecking(bool isChecking)82     void SetIsChecking(bool isChecking)
83     {
84         isChecking_ = isChecking;
85     }
86 };
87 class FileDataConvertorMock final : public FileDataConvertor {
88 public:
FileDataConvertorMock(int32_t userId,std::string & bundleName,OperationType type,const std::function<void (NativeRdb::ResultSet & resultSet)> & func=nullptr)89     FileDataConvertorMock(int32_t userId,
90                           std::string &bundleName,
91                           OperationType type,
92                           const std::function<void(NativeRdb::ResultSet &resultSet)> &func = nullptr)
93         : FileDataConvertor(userId, bundleName, type)
94     {
95     }
96     MOCK_METHOD2(ResultSetToRecords,
97                  int32_t(const std::shared_ptr<NativeRdb::ResultSet> resultSet,
98                          std::vector<DriveKit::DKRecord> &records));
99     MOCK_METHOD3(GetString, int32_t(const std::string &key, std::string &val, NativeRdb::ResultSet &resultSet));
100 };
101 
102 class DKRecordOperResultMock final : public DKRecordOperResult {
103 public:
DKRecordOperResultMock()104     DKRecordOperResultMock() {}
105     MOCK_METHOD0(IsSuccess, bool());
106 };
107 
108 class CloudDiskDataHandlerTest : public testing::Test {
109 public:
110     static void SetUpTestCase(void);
111     static void TearDownTestCase(void);
112     void SetUp();
113     void TearDown();
114     shared_ptr<CloudDiskDataHandlerMock> cloudDiskDataHandler_ = nullptr;
115 };
116 
SetUpTestCase(void)117 void CloudDiskDataHandlerTest::SetUpTestCase(void)
118 {
119     std::cout << "SetUpTestCase" << std::endl;
120 }
121 
TearDownTestCase(void)122 void CloudDiskDataHandlerTest::TearDownTestCase(void)
123 {
124     std::cout << "TearDownTestCase" << std::endl;
125 }
126 
SetUp(void)127 void CloudDiskDataHandlerTest::SetUp(void)
128 {
129     std::cout << "SetUp" << std::endl;
130     const int32_t userId = 100;
131     string bundleName = "com.ohos.test";
132     auto rdb = make_shared<RdbStoreMock>();
133     cloudDiskDataHandler_ = make_shared<CloudDiskDataHandlerMock>(userId, bundleName, rdb);
134 }
135 
TearDown(void)136 void CloudDiskDataHandlerTest::TearDown(void)
137 {
138     std::cout << "TearDown" << std::endl;
139     cloudDiskDataHandler_ = nullptr;
140 }
141 
142 /**
143  * @tc.name: CloudDiskDataHandlerTest001
144  * @tc.desc: Verify the CloudDiskDataHandler function.
145  * @tc.type: FUNC
146  * @tc.require: I6H5MH
147  */
148 HWTEST_F(CloudDiskDataHandlerTest, CloudDiskDataHandlerTest001, TestSize.Level1)
149 {
150     GTEST_LOG_(INFO) << "CloudDiskDataHandler Start";
151     int32_t userId = 100;
152     string bundleName = "com.ohos.test";
153     auto rdb = make_shared<RdbStoreMock>();
154     auto stopFlag = make_shared<bool>(false);
155     shared_ptr<CloudDiskDataHandler> dataHandler = make_shared<CloudDiskDataHandler>(userId, bundleName, rdb, stopFlag);
156     EXPECT_NE(dataHandler, nullptr);
157     GTEST_LOG_(INFO) << "CloudDiskDataHandler End";
158 }
159 
160 /**
161  * @tc.name: GetFetchConditionTest001
162  * @tc.desc: Verify the GetFetchCondition function.
163  * @tc.type: FUNC
164  * @tc.require: I6H5MH
165  */
166 HWTEST_F(CloudDiskDataHandlerTest, GetFetchConditionTest001, TestSize.Level1)
167 {
168     GTEST_LOG_(INFO) << "GetFetchCondition Start";
169     cloudDiskDataHandler_->SetIsChecking(true);
170     FetchCondition cond;
171     cloudDiskDataHandler_->GetFetchCondition(cond);
172     EXPECT_EQ(cond.desiredKeys, cloudDiskDataHandler_->desiredKeys_);
173     GTEST_LOG_(INFO) << "GetFetchCondition End";
174 }
175 
176 /**
177  * @tc.name: UTCTimeMilliSecondsTest001
178  * @tc.desc: Verify the UTCTimeMilliSeconds function.
179  * @tc.type: FUNC
180  * @tc.require: I6H5MH
181  */
182 HWTEST_F(CloudDiskDataHandlerTest, UTCTimeMilliSecondsTest001, TestSize.Level1)
183 {
184     GTEST_LOG_(INFO) << "UTCTimeMilliSeconds Start";
185     int64_t ret = cloudDiskDataHandler_->UTCTimeMilliSeconds();
186     EXPECT_GE(ret, 0);
187     GTEST_LOG_(INFO) << "UTCTimeMilliSeconds End";
188 }
189 
190 /**
191  * @tc.name: GetRetryRecordsTest001
192  * @tc.desc: Verify the GetRetryRecords function.
193  * @tc.type: FUNC
194  * @tc.require: I6H5MH
195  */
196 HWTEST_F(CloudDiskDataHandlerTest, GetRetryRecordsTest001, TestSize.Level1)
197 {
198     GTEST_LOG_(INFO) << "GetRetryRecords Start";
199     std::vector<DriveKit::DKRecordId> records;
200     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
201     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
202     EXPECT_CALL(*resultSet, GoToNextRow()).Times(2).WillOnce(Return(0)).WillOnce(Return(2));
203     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
204     EXPECT_CALL(*resultSet, GetString(_, _)).WillOnce(Return(E_OK));
205     int32_t ret = cloudDiskDataHandler_->GetRetryRecords(records);
206     EXPECT_EQ(ret, E_OK);
207     GTEST_LOG_(INFO) << "GetRetryRecords End";
208 }
209 
210 /**
211  * @tc.name: GetRetryRecordsTest002
212  * @tc.desc: Verify the GetRetryRecords function.
213  * @tc.type: FUNC
214  * @tc.require: I6H5MH
215  */
216 HWTEST_F(CloudDiskDataHandlerTest, GetRetryRecordsTest002, TestSize.Level1)
217 {
218     GTEST_LOG_(INFO) << "GetRetryRecords Start";
219     std::vector<DriveKit::DKRecordId> records;
220     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
221     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
222     int32_t ret = cloudDiskDataHandler_->GetRetryRecords(records);
223     EXPECT_EQ(ret, E_RDB);
224     GTEST_LOG_(INFO) << "GetRetryRecords End";
225 }
226 
227 /**
228  * @tc.name: HandleCreateConvertErrTest001
229  * @tc.desc: Verify the HandleCreateConvertErr function.
230  * @tc.type: FUNC
231  * @tc.require: I6H5MH
232  */
233 HWTEST_F(CloudDiskDataHandlerTest, HandleCreateConvertErrTest001, TestSize.Level1)
234 {
235     GTEST_LOG_(INFO) << "HandleCreateConvertErr Start";
236     unsigned int length = cloudDiskDataHandler_->createFailSet_.size();
237     ResultSetMock resultSet;
238     const string cloudId = "sample_id";
239     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
240     EXPECT_CALL(resultSet, GetString(_, _)).WillRepeatedly(DoAll(SetArgReferee<1>(cloudId), Return(E_OK)));
241     int32_t err = E_RDB;
242     cloudDiskDataHandler_->HandleCreateConvertErr(err, resultSet);
243     EXPECT_NE(cloudDiskDataHandler_->createFailSet_.size(), length);
244     GTEST_LOG_(INFO) << "HandleCreateConvertErr End";
245 }
246 
247 /**
248  * @tc.name: HandleCreateConvertErrTest002
249  * @tc.desc: Verify the HandleCreateConvertErr function.
250  * @tc.type: FUNC
251  * @tc.require: I6H5MH
252  */
253 HWTEST_F(CloudDiskDataHandlerTest, HandleCreateConvertErrTest002, TestSize.Level1)
254 {
255     GTEST_LOG_(INFO) << "HandleCreateConvertErr Start";
256     unsigned int length = cloudDiskDataHandler_->createFailSet_.size();
257     ResultSetMock resultSet;
258     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
259     EXPECT_CALL(resultSet, GetString(_, _)).WillOnce(Return(E_RDB));
260     int32_t err = E_RDB;
261     cloudDiskDataHandler_->HandleCreateConvertErr(err, resultSet);
262     EXPECT_EQ(cloudDiskDataHandler_->createFailSet_.size(), length);
263     GTEST_LOG_(INFO) << "HandleCreateConvertErr End";
264 }
265 
266 /**
267  * @tc.name: HandleFdirtyConvertErrTest001
268  * @tc.desc: Verify the HandleFdirtyConvertErr function.
269  * @tc.type: FUNC
270  * @tc.require: I6H5MH
271  */
272 HWTEST_F(CloudDiskDataHandlerTest, HandleFdirtyConvertErrTest001, TestSize.Level1)
273 {
274     GTEST_LOG_(INFO) << "HandleFdirtyConvertErr Start";
275 
276     int length = cloudDiskDataHandler_->modifyFailSet_.size();
277     ResultSetMock resultSet;
278     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
279     EXPECT_CALL(resultSet, GetString(_, _)).WillOnce(Return(E_OK));
280     int32_t err = E_RDB;
281     cloudDiskDataHandler_->HandleFdirtyConvertErr(err, resultSet);
282     EXPECT_NE(cloudDiskDataHandler_->modifyFailSet_.size(), length);
283     GTEST_LOG_(INFO) << "HandleFdirtyConvertErr End";
284 }
285 
286 /**
287  * @tc.name: HandleFdirtyConvertErrTest002
288  * @tc.desc: Verify the HandleFdirtyConvertErr function.
289  * @tc.type: FUNC
290  * @tc.require: I6H5MH
291  */
292 HWTEST_F(CloudDiskDataHandlerTest, HandleFdirtyConvertErrTest002, TestSize.Level1)
293 {
294     GTEST_LOG_(INFO) << "HandleFdirtyConvertErr Start";
295 
296     int length = cloudDiskDataHandler_->modifyFailSet_.size();
297     ResultSetMock resultSet;
298     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
299     EXPECT_CALL(resultSet, GetString(_, _)).WillOnce(Return(E_RDB));
300     int32_t err = E_RDB;
301     cloudDiskDataHandler_->HandleFdirtyConvertErr(err, resultSet);
302     EXPECT_EQ(cloudDiskDataHandler_->modifyFailSet_.size(), length);
303     GTEST_LOG_(INFO) << "HandleFdirtyConvertErr End";
304 }
305 
306 /**
307  * @tc.name: QueryLocalByCloudIdTest001
308  * @tc.desc: Verify the QueryLocalByCloudId function.
309  * @tc.type: FUNC
310  * @tc.require: I6H5MH
311  */
312 HWTEST_F(CloudDiskDataHandlerTest, QueryLocalByCloudIdTest001, TestSize.Level1)
313 {
314     GTEST_LOG_(INFO) << "QueryLocalByCloudId Start";
315     vector<string> recordIds;
316     recordIds.emplace_back("sample_id1");
317     recordIds.emplace_back("sample_id2");
318     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
319     auto [resultSet, recordIdRowIdMap] = cloudDiskDataHandler_->QueryLocalByCloudId(recordIds);
320     EXPECT_EQ(resultSet, nullptr);
321     GTEST_LOG_(INFO) << "QueryLocalByCloudId End";
322 }
323 
324 /**
325  * @tc.name: QueryLocalByCloudIdTest002
326  * @tc.desc: Verify the QueryLocalByCloudId function.
327  * @tc.type: FUNC
328  * @tc.require: I6H5MH
329  */
330 HWTEST_F(CloudDiskDataHandlerTest, QueryLocalByCloudIdTest002, TestSize.Level1)
331 {
332     GTEST_LOG_(INFO) << "QueryLocalByCloudId Start";
333     vector<string> recordIds;
334     auto resultSetMock = make_shared<ResultSetMock>();
335     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSetMock));
336     EXPECT_CALL(*resultSetMock, GetRowCount(_)).WillOnce(Return(-1));
337     auto [resultSet, recordIdRowIdMap] = cloudDiskDataHandler_->QueryLocalByCloudId(recordIds);
338     EXPECT_EQ(resultSet, nullptr);
339     GTEST_LOG_(INFO) << "QueryLocalByCloudId End";
340 }
341 
342 /**
343  * @tc.name: OnFetchRecordsTest001
344  * @tc.desc: Verify the OnFetchRecords function.
345  * @tc.type: FUNC
346  * @tc.require: I6H5MH
347  */
348 HWTEST_F(CloudDiskDataHandlerTest, OnFetchRecordsTest001, TestSize.Level1)
349 {
350     GTEST_LOG_(INFO) << "OnFetchRecords Start";
351     shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
352     DKRecord recordElem1;
353     DKRecord recordElem2;
354     records->emplace_back(recordElem1);
355     records->emplace_back(recordElem2);
356     OnFetchParams params;
357     int32_t ret = cloudDiskDataHandler_->OnFetchRecords(records, params);
358     EXPECT_EQ(ret, E_RDB);
359     GTEST_LOG_(INFO) << "OnFetchRecords End";
360 }
361 
362 /**
363  * @tc.name: OnFetchRecordsTest002
364  * @tc.desc: Verify the OnFetchRecords function.
365  * @tc.type: FUNC
366  * @tc.require: I6H5MH
367  */
368 HWTEST_F(CloudDiskDataHandlerTest, OnFetchRecordsTest002, TestSize.Level1)
369 {
370     GTEST_LOG_(INFO) << "OnFetchRecords Start";
371     shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
372     OnFetchParams params;
373     int32_t ret = cloudDiskDataHandler_->OnFetchRecords(records, params);
374     EXPECT_EQ(ret, E_RDB);
375     GTEST_LOG_(INFO) << "OnFetchRecords End";
376 }
377 
378 /**
379  * @tc.name: OnFetchRecordsTest003
380  * @tc.desc: Verify the OnFetchRecords function.
381  * @tc.type: FUNC
382  * @tc.require: I6H5MH
383  */
384 HWTEST_F(CloudDiskDataHandlerTest, OnFetchRecordsTest003, TestSize.Level1)
385 {
386     GTEST_LOG_(INFO) << "OnFetchRecords Start";
387     try {
388         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
389         shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
390         OnFetchParams params;
391         int32_t ret = cloudDiskDataHandler_->OnFetchRecords(records, params);
392         EXPECT_EQ(ret, E_RDB);
393     } catch(...) {
394         EXPECT_TRUE(false);
395         GTEST_LOG_(INFO) << "OnFetchRecords ERROR";
396     }
397     GTEST_LOG_(INFO) << "OnFetchRecords End";
398 }
399 
400 /**
401  * @tc.name: PullRecordInsertTest001
402  * @tc.desc: Verify the PullRecordInsert function.
403  * @tc.type: FUNC
404  * @tc.require: I6H5MH
405  */
406 HWTEST_F(CloudDiskDataHandlerTest, PullRecordInsertTest001, TestSize.Level1)
407 {
408     GTEST_LOG_(INFO) << "PullRecordInsert Start";
409     DKRecord record;
410     OnFetchParams params;
411     int32_t ret = cloudDiskDataHandler_->PullRecordInsert(record, params);
412     EXPECT_EQ(ret, E_INVALID_ARGS);
413     GTEST_LOG_(INFO) << "PullRecordInsert End";
414 }
415 
416 /**
417  * @tc.name: PullRecordInsertTest002
418  * @tc.desc: Verify the PullRecordInsert function.
419  * @tc.type: FUNC
420  * @tc.require: I6H5MH
421  */
422 HWTEST_F(CloudDiskDataHandlerTest, PullRecordInsertTest002, TestSize.Level1)
423 {
424     GTEST_LOG_(INFO) << "PullRecordInsert Start";
425     DKRecord record;
426     DKRecordData fields;
427     DKRecordField dkRecordFieldString("test.txt");
428     DKRecordField dkDirectlyRecycled(1);
429     DKRecordField dkRecordFieldLong(1);
430     fields.insert({DK_FILE_NAME, dkRecordFieldString});
431     fields.insert({DK_DIRECTLY_RECYCLED, dkDirectlyRecycled});
432     fields.insert({DK_FILE_TIME_RECYCLED, dkRecordFieldLong});
433     record.SetRecordData(fields);
434     record.SetRecordId("sample record Id");
435     OnFetchParams params;
436     int32_t ret = cloudDiskDataHandler_->PullRecordInsert(record, params);
437     EXPECT_EQ(ret, E_INVAL_ARG);
438     GTEST_LOG_(INFO) << "PullRecordInsert End";
439 }
440 
441 /**
442  * @tc.name: PullRecordConflictTest001
443  * @tc.desc: Verify the PullRecordConflict function.
444  * @tc.type: FUNC
445  * @tc.require: I6H5MH
446  */
447 HWTEST_F(CloudDiskDataHandlerTest, PullRecordConflictTest001, TestSize.Level1)
448 {
449     DKRecord record;
450     int32_t ret = cloudDiskDataHandler_->PullRecordConflict(record);
451     EXPECT_EQ(ret, E_INVALID_ARGS);
452     GTEST_LOG_(INFO) << "PullRecordConflict End";
453 }
454 
455 /**
456  * @tc.name: PullRecordConflictTest002
457  * @tc.desc: Verify the PullRecordConflict function.
458  * @tc.type: FUNC
459  * @tc.require: I6H5MH
460  */
461 HWTEST_F(CloudDiskDataHandlerTest, PullRecordConflictTest002, TestSize.Level1)
462 {
463     DKRecord record;
464     DKRecordData fields;
465     DKRecordField dkRecordFieldString("test.txt");
466     DKRecordField dkDirectlyRecycled(1);
467     DKRecordField dkRecordFieldLong(1);
468     fields.insert({DK_FILE_NAME, dkRecordFieldString});
469     fields.insert({DK_DIRECTLY_RECYCLED, dkDirectlyRecycled});
470     fields.insert({DK_FILE_TIME_RECYCLED, dkRecordFieldLong});
471     record.SetRecordData(fields);
472     int32_t ret = cloudDiskDataHandler_->PullRecordConflict(record);
473     EXPECT_EQ(ret, E_OK);
474     GTEST_LOG_(INFO) << "PullRecordConflict End";
475 }
476 
477 /**
478  * @tc.name: PullRecordConflictTest003
479  * @tc.desc: Verify the PullRecordConflict function.
480  * @tc.type: FUNC
481  * @tc.require: I6H5MH
482  */
483 HWTEST_F(CloudDiskDataHandlerTest, PullRecordConflictTest003, TestSize.Level1)
484 {
485     DKRecord record;
486     DKRecordData fields;
487     DKRecordField dkRecordFieldString("test.txt");
488     DKRecordField dkDirectlyRecycled(1);
489     DKRecordField dkRecordFieldLong(0);
490     fields.insert({DK_FILE_NAME, dkRecordFieldString});
491     fields.insert({DK_DIRECTLY_RECYCLED, dkDirectlyRecycled});
492     fields.insert({DK_FILE_TIME_RECYCLED, dkRecordFieldLong});
493     record.SetRecordData(fields);
494     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
495     int32_t ret = cloudDiskDataHandler_->PullRecordConflict(record);
496     EXPECT_EQ(ret, E_RDB);
497     GTEST_LOG_(INFO) << "PullRecordConflict End";
498 }
499 
500 /**
501  * @tc.name: PullRecordConflictTest004
502  * @tc.desc: Verify the PullRecordConflict function.
503  * @tc.type: FUNC
504  * @tc.require: I6H5MH
505  */
506 HWTEST_F(CloudDiskDataHandlerTest, PullRecordConflictTest004, TestSize.Level1)
507 {
508     DKRecord record;
509     DKRecordData fields;
510     DKRecordField dkRecordFieldString("test");
511     DKRecordField dkDirectlyRecycled(1);
512     DKRecordField dkRecordFieldLong(0);
513     fields.insert({DK_FILE_NAME, dkRecordFieldString});
514     fields.insert({DK_DIRECTLY_RECYCLED, dkDirectlyRecycled});
515     fields.insert({DK_FILE_TIME_RECYCLED, dkRecordFieldLong});
516     record.SetRecordData(fields);
517     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
518     int32_t ret = cloudDiskDataHandler_->PullRecordConflict(record);
519     EXPECT_EQ(ret, E_RDB);
520     GTEST_LOG_(INFO) << "PullRecordConflict End";
521 }
522 
523 /**
524  * @tc.name: HandleConflictTest001
525  * @tc.desc: Verify the HandleConflict function.
526  * @tc.type: FUNC
527  * @tc.require: I6H5MH
528  */
529 HWTEST_F(CloudDiskDataHandlerTest, HandleConflictTest001, TestSize.Level1)
530 {
531     string fullName = "fullName";
532     const int lastDot = 0;
533     int32_t ret = cloudDiskDataHandler_->HandleConflict(nullptr, fullName, lastDot);
534     EXPECT_EQ(ret, E_RDB);
535     GTEST_LOG_(INFO) << "HandleConflict End";
536 }
537 
538 /**
539  * @tc.name: HandleConflictTest002
540  * @tc.desc: Verify the HandleConflict function.
541  * @tc.type: FUNC
542  * @tc.require: I6H5MH
543  */
544 HWTEST_F(CloudDiskDataHandlerTest, HandleConflictTest002, TestSize.Level1)
545 {
546     string fullName = "fullName";
547     const int lastDot = 0;
548     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
549     EXPECT_CALL(*resultSet, GetRowCount(_)).WillRepeatedly(DoAll(SetArgReferee<0>(0), Return(E_RDB)));
550     int32_t ret = cloudDiskDataHandler_->HandleConflict(resultSet, fullName, lastDot);
551     EXPECT_EQ(ret, E_RDB);
552     GTEST_LOG_(INFO) << "HandleConflict End";
553 }
554 
555 /**
556  * @tc.name: HandleConflictTest003
557  * @tc.desc: Verify the HandleConflict function.
558  * @tc.type: FUNC
559  * @tc.require: I6H5MH
560  */
561 HWTEST_F(CloudDiskDataHandlerTest, HandleConflictTest003, TestSize.Level1)
562 {
563     string fullName = "fullName";
564     const int lastDot = 0;
565     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
566     EXPECT_CALL(*resultSet, GetRowCount(_)).WillRepeatedly(DoAll(SetArgReferee<0>(0), Return(E_OK)));
567     int32_t ret = cloudDiskDataHandler_->HandleConflict(resultSet, fullName, lastDot);
568     EXPECT_EQ(ret, E_OK);
569     GTEST_LOG_(INFO) << "HandleConflict End";
570 }
571 
572 /**
573  * @tc.name: FindRenameFileTest001
574  * @tc.desc: Verify the FindRenameFile function.
575  * @tc.type: FUNC
576  * @tc.require: I6H5MH
577  */
578 HWTEST_F(CloudDiskDataHandlerTest, FindRenameFileTest001, TestSize.Level1)
579 {
580     string renameFileCloudId = "renameFileCloudId";
581     string fullName = "fullName.txt";
582     size_t lastDot = fullName.rfind('.');
583     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
584     EXPECT_CALL(*resultSet, GoToFirstRow()).Times(2).WillRepeatedly(Return(0));
585     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
586     EXPECT_CALL(*resultSet, GetString(_, _)).Times(3)
587     .WillOnce(DoAll(SetArgReferee<1>(fullName), Return(E_OK)))
588     .WillOnce(DoAll(SetArgReferee<1>(fullName), Return(E_OK)))
589     .WillOnce(DoAll(SetArgReferee<1>("qqq"), Return(E_OK)));
590     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
591     int32_t ret = cloudDiskDataHandler_->FindRenameFile(resultSet, renameFileCloudId, fullName, lastDot);
592     EXPECT_EQ(ret, E_OK);
593     GTEST_LOG_(INFO) << "FindRenameFile End";
594 }
595 
596 /**
597  * @tc.name: FindRenameFileTest002
598  * @tc.desc: Verify the FindRenameFile function.
599  * @tc.type: FUNC
600  * @tc.require: I6H5MH
601  */
602 HWTEST_F(CloudDiskDataHandlerTest, FindRenameFileTest002, TestSize.Level1)
603 {
604     string renameFileCloudId = "renameFileCloudId";
605     string fullName = "fullName.txt";
606     size_t lastDot = fullName.rfind('.');
607     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
608     EXPECT_CALL(*resultSet, GoToFirstRow()).WillOnce(Return(0));
609     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
610     EXPECT_CALL(*resultSet, GetString(_, _)).WillRepeatedly(DoAll(SetArgReferee<1>(""), Return(E_OK)));
611     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
612     int32_t ret = cloudDiskDataHandler_->FindRenameFile(resultSet, renameFileCloudId, fullName, lastDot);
613     EXPECT_EQ(ret, E_OK);
614     GTEST_LOG_(INFO) << "FindRenameFile End";
615 }
616 
617 /**
618  * @tc.name: ConflictReNameTest001
619  * @tc.desc: Verify the ConflictReName function.
620  * @tc.type: FUNC
621  * @tc.require: I6H5MH
622  */
623 HWTEST_F(CloudDiskDataHandlerTest, ConflictReNameTest001, TestSize.Level1)
624 {
625     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
626     EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(E_OK));
627     int32_t ret = cloudDiskDataHandler_->ConflictReName("cloudId", "newFileName");
628     EXPECT_EQ(ret, E_OK);
629     GTEST_LOG_(INFO) << "ConflictReName End";
630 }
631 
632 /**
633  * @tc.name: ConflictReNameTest002
634  * @tc.desc: Verify the ConflictReName function.
635  * @tc.type: FUNC
636  * @tc.require: I6H5MH
637  */
638 HWTEST_F(CloudDiskDataHandlerTest, ConflictReNameTest002, TestSize.Level1)
639 {
640     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
641     EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(-1));
642     int32_t ret = cloudDiskDataHandler_->ConflictReName("cloudId", "newFileName");
643     EXPECT_EQ(ret, E_RDB);
644     GTEST_LOG_(INFO) << "ConflictReName End";
645 }
646 
647 /**
648  * @tc.name: PullRecordUpdateTest001
649  * @tc.desc: Verify the PullRecordUpdate function.
650  * @tc.type: FUNC
651  * @tc.require: I6H5MH
652  */
653 HWTEST_F(CloudDiskDataHandlerTest, PullRecordUpdateTest001, TestSize.Level1)
654 {
655     GTEST_LOG_(INFO) << "PullRecordUpdate Start";
656     DKRecord record;
657     ResultSetMock resultSet;
658     OnFetchParams params;
659     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
660     EXPECT_CALL(resultSet, GetInt(_, _))
661         .WillRepeatedly(DoAll(SetArgReferee<1>(static_cast<int32_t>(DirtyType::TYPE_MDIRTY)), Return(E_OK)));
662     int32_t ret = cloudDiskDataHandler_->PullRecordUpdate(record, resultSet, params);
663     EXPECT_EQ(ret, E_OK);
664     GTEST_LOG_(INFO) << "PullRecordUpdate End";
665 }
666 
667 /**
668  * @tc.name: PullRecordUpdateTest002
669  * @tc.desc: Verify the PullRecordUpdate function.
670  * @tc.type: FUNC
671  * @tc.require: I6H5MH
672  */
673 HWTEST_F(CloudDiskDataHandlerTest, PullRecordUpdateTest002, TestSize.Level1)
674 {
675     GTEST_LOG_(INFO) << "PullRecordUpdate Start";
676     DKRecord record;
677     ResultSetMock resultSet;
678     OnFetchParams params;
679     cloudDiskDataHandler_->localConvertor_.SetRootId("");
680     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_RDB));
681     int32_t ret = cloudDiskDataHandler_->PullRecordUpdate(record, resultSet, params);
682     EXPECT_EQ(ret, E_INVAL_ARG);
683     GTEST_LOG_(INFO) << "PullRecordUpdate End";
684 }
685 
686 /**
687  * @tc.name: PullRecordUpdateTest003
688  * @tc.desc: Verify the PullRecordUpdate function.
689  * @tc.type: FUNC
690  * @tc.require: I6H5MH
691  */
692 HWTEST_F(CloudDiskDataHandlerTest, PullRecordUpdateTest003, TestSize.Level1)
693 {
694     GTEST_LOG_(INFO) << "PullRecordUpdate Start";
695     DKRecord record;
696     ResultSetMock resultSet;
697     OnFetchParams params;
698     cloudDiskDataHandler_->localConvertor_.SetRootId("sample_rootId");
699     EXPECT_CALL(resultSet, GetColumnIndex(_, _)).Times(1).WillRepeatedly(Return(E_RDB));
700     int32_t ret = cloudDiskDataHandler_->PullRecordUpdate(record, resultSet, params);
701     EXPECT_EQ(ret, E_INVAL_ARG);
702     GTEST_LOG_(INFO) << "PullRecordUpdate End";
703 }
704 
705 /**
706  * @tc.name: PullRecordDeleteTest001
707  * @tc.desc: Verify the PullRecordDelete function.
708  * @tc.type: FUNC
709  * @tc.require: I6H5MH
710  */
711 HWTEST_F(CloudDiskDataHandlerTest, PullRecordDeleteTest001, TestSize.Level1)
712 {
713     GTEST_LOG_(INFO) << "PullRecordDelete Start";
714     DKRecord record;
715     record.SetRecordId("sample_id");
716     record.SetRecordType("sample_type");
717     ResultSetMock resultSet;
718     int32_t ret = cloudDiskDataHandler_->PullRecordDelete(record, resultSet);
719     EXPECT_EQ(ret, E_OK);
720     GTEST_LOG_(INFO) << "PullRecordDelete End";
721 }
722 
723 /**
724  * @tc.name: PullRecordDeleteTest002
725  * @tc.desc: Verify the PullRecordDelete function.
726  * @tc.type: FUNC
727  * @tc.require: I6H5MH
728  */
729 HWTEST_F(CloudDiskDataHandlerTest, PullRecordDeleteTest002, TestSize.Level1)
730 {
731     GTEST_LOG_(INFO) << "PullRecordDelete Start";
732     DKRecord record;
733     ResultSetMock resultSet;
734     int32_t ret = cloudDiskDataHandler_->PullRecordDelete(record, resultSet);
735     EXPECT_EQ(ret, E_OK);
736     GTEST_LOG_(INFO) << "PullRecordDelete End";
737 }
738 
739 /**
740  * @tc.name: RecycleFileTest001
741  * @tc.desc: Verify the RecycleFile function.
742  * @tc.type: FUNC
743  * @tc.require: I6H5MH
744  */
745 HWTEST_F(CloudDiskDataHandlerTest, RecycleFileTest001, TestSize.Level1)
746 {
747     GTEST_LOG_(INFO) << "RecycleFile Start";
748     string recordId = "sample_id";
749     auto ret = cloudDiskDataHandler_->RecycleFile(recordId);
750     EXPECT_EQ(ret, E_OK);
751     GTEST_LOG_(INFO) << "RecycleFile End";
752 }
753 
754 /**
755  * @tc.name: RecycleFileTest002
756  * @tc.desc: Verify the RecycleFile function.
757  * @tc.type: FUNC
758  * @tc.require: I6H5MH
759  */
760 HWTEST_F(CloudDiskDataHandlerTest, RecycleFileTest002, TestSize.Level1)
761 {
762     string recordId = "";
763     auto ret = cloudDiskDataHandler_->RecycleFile(recordId);
764     EXPECT_EQ(ret, E_OK);
765     GTEST_LOG_(INFO) << "RecycleFile End";
766 }
767 
768 /**
769  * @tc.name: RecycleFileTest003
770  * @tc.desc: Verify the RecycleFile function.
771  * @tc.type: FUNC
772  * @tc.require: I6H5MH
773  */
774 HWTEST_F(CloudDiskDataHandlerTest, RecycleFileTest003, TestSize.Level1)
775 {
776     GTEST_LOG_(INFO) << "RecycleFile Start";
777     string recordId = "sample_id";
778     EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(E_RDB));
779     auto ret = cloudDiskDataHandler_->RecycleFile(recordId);
780     EXPECT_EQ(ret, E_RDB);
781     GTEST_LOG_(INFO) << "RecycleFile End";
782 }
783 
784 /**
785  * @tc.name: SetRetryTest001
786  * @tc.desc: Verify the SetRetry function.
787  * @tc.type: FUNC
788  * @tc.require: I6H5MH
789  */
790 HWTEST_F(CloudDiskDataHandlerTest, SetRetryTest001, TestSize.Level1)
791 {
792     GTEST_LOG_(INFO) << "SetRetry Start";
793     string recordId = "sample_id";
794     auto ret = cloudDiskDataHandler_->SetRetry(recordId);
795     EXPECT_EQ(ret, E_OK);
796     GTEST_LOG_(INFO) << "SetRetry End";
797 }
798 
799 /**
800  * @tc.name: SetRetryTest002
801  * @tc.desc: Verify the SetRetry function.
802  * @tc.type: FUNC
803  * @tc.require: I6H5MH
804  */
805 HWTEST_F(CloudDiskDataHandlerTest, SetRetryTest002, TestSize.Level1)
806 {
807     GTEST_LOG_(INFO) << "SetRetry Start";
808     string recordId = "";
809     auto ret = cloudDiskDataHandler_->SetRetry(recordId);
810     EXPECT_EQ(ret, E_OK);
811     GTEST_LOG_(INFO) << "SetRetry End";
812 }
813 
814 /**
815  * @tc.name: SetRetryTest003
816  * @tc.desc: Verify the SetRetry function.
817  * @tc.type: FUNC
818  * @tc.require: I6H5MH
819  */
820 HWTEST_F(CloudDiskDataHandlerTest, SetRetryTest003, TestSize.Level1)
821 {
822     GTEST_LOG_(INFO) << "SetRetry Start";
823     string recordId = "sample_id";
824     EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(E_RDB));
825     auto ret = cloudDiskDataHandler_->SetRetry(recordId);
826     EXPECT_EQ(ret, E_RDB);
827     GTEST_LOG_(INFO) << "SetRetry End";
828 }
829 
830 /**
831  * @tc.name: GetCheckRecordsTest001
832  * @tc.desc: Verify the GetCheckRecords function.
833  * @tc.type: FUNC
834  * @tc.require: I6H5MH
835  */
836 HWTEST_F(CloudDiskDataHandlerTest, GetCheckRecordsTest001, TestSize.Level1)
837 {
838     GTEST_LOG_(INFO) << "GetCheckRecords Start";
839     vector<DriveKit::DKRecordId> checkRecords;
840     shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
841     DKRecordMock recordElem1;
842     DKRecordMock recordElem2;
843     records->emplace_back(recordElem1);
844     records->emplace_back(recordElem2);
845     int32_t ret = cloudDiskDataHandler_->GetCheckRecords(checkRecords, records);
846     EXPECT_EQ(ret, E_RDB);
847     GTEST_LOG_(INFO) << "GetCheckRecords End";
848 }
849 
850 /**
851  * @tc.name: GetCheckRecordsTest002
852  * @tc.desc: Verify the GetCheckRecords function.
853  * @tc.type: FUNC
854  * @tc.require: I6H5MH
855  */
856 HWTEST_F(CloudDiskDataHandlerTest, GetCheckRecordsTest002, TestSize.Level1)
857 {
858     GTEST_LOG_(INFO) << "GetCheckRecords Start";
859     vector<DriveKit::DKRecordId> checkRecords;
860     shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
861     int32_t ret = cloudDiskDataHandler_->GetCheckRecords(checkRecords, records);
862     EXPECT_EQ(ret, E_RDB);
863     GTEST_LOG_(INFO) << "GetCheckRecords End";
864 }
865 
866 /**
867  * @tc.name: GetCheckRecordsTest003
868  * @tc.desc: Verify the GetCheckRecords function.
869  * @tc.type: FUNC
870  * @tc.require: I6H5MH
871  */
872 HWTEST_F(CloudDiskDataHandlerTest, GetCheckRecordsTest003, TestSize.Level1)
873 {
874     GTEST_LOG_(INFO) << "GetCheckRecords Start";
875     try {
876         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
877         vector<DriveKit::DKRecordId> checkRecords;
878         shared_ptr<vector<DKRecord>> records = std::make_shared<vector<DKRecord>>();
879         int32_t ret = cloudDiskDataHandler_->GetCheckRecords(checkRecords, records);
880         EXPECT_EQ(ret, E_RDB);
881     } catch(...) {
882         EXPECT_TRUE(false);
883         GTEST_LOG_(INFO) << "GetCheckRecords ERROR";
884     }
885     GTEST_LOG_(INFO) << "GetCheckRecords End";
886 }
887 
888 /**
889  * @tc.name: CleanCloudRecordTest001
890  * @tc.desc: Verify the CleanCloudRecord function.
891  * @tc.type: FUNC
892  * @tc.require: I6H5MH
893  */
894 HWTEST_F(CloudDiskDataHandlerTest, CleanCloudRecordTest001, TestSize.Level1)
895 {
896     GTEST_LOG_(INFO) << "CleanCloudRecord Start";
897     const int action = CleanAction::CLEAR_DATA;
898     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
899     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
900     EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(Return(-1));
901     EXPECT_CALL(*cloudDiskDataHandler_, Delete(_, _, _)).WillOnce(Return(-1));
902     int32_t ret = cloudDiskDataHandler_->CleanCloudRecord(action);
903     EXPECT_EQ(ret, -1);
904     GTEST_LOG_(INFO) << "CleanCloudRecord End";
905 }
906 
907 /**
908  * @tc.name: CleanCloudRecordTest002
909  * @tc.desc: Verify the CleanCloudRecord function.
910  * @tc.type: FUNC
911  * @tc.require: I6H5MH
912  */
913 HWTEST_F(CloudDiskDataHandlerTest, CleanCloudRecordTest002, TestSize.Level1)
914 {
915     GTEST_LOG_(INFO) << "CleanCloudRecord Start";
916     const int action = CleanAction::CLEAR_DATA;
917     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
918     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
919     EXPECT_CALL(*resultSet, GetRowCount(_)).WillRepeatedly(DoAll(SetArgReferee<0>(0), Return(E_OK)));
920     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(0));
921     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_RDB));
922     int32_t ret = cloudDiskDataHandler_->CleanCloudRecord(action);
923     EXPECT_EQ(ret, E_INVAL_ARG);
924     GTEST_LOG_(INFO) << "CleanCloudRecord End";
925 }
926 
927 /**
928  * @tc.name: CleanCloudRecordTest003
929  * @tc.desc: Verify the CleanCloudRecord function.
930  * @tc.type: FUNC
931  * @tc.require: I6H5MH
932  */
933 HWTEST_F(CloudDiskDataHandlerTest, CleanCloudRecordTest003, TestSize.Level1)
934 {
935     GTEST_LOG_(INFO) << "CleanCloudRecord Start";
936     const int action = CleanAction::CLEAR_DATA;
937     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
938     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
939     EXPECT_CALL(*resultSet, GetRowCount(_)).WillRepeatedly(DoAll(SetArgReferee<0>(0), Return(E_OK)));
940     EXPECT_CALL(*resultSet, GoToNextRow())
941         .Times(2)
942         .WillOnce(Return(0))
943         .WillOnce(Return(1));
944     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
945     EXPECT_CALL(*resultSet, GetString(_, _)).WillOnce(Return(E_OK));
946     EXPECT_CALL(*cloudDiskDataHandler_, BatchDetete(_, _, _)).WillOnce(Return(E_OK));
947     EXPECT_CALL(*cloudDiskDataHandler_, Delete(_, _, _)).WillOnce(Return(E_OK));
948     int32_t ret = cloudDiskDataHandler_->CleanCloudRecord(action);
949     EXPECT_EQ(ret, E_OK);
950     GTEST_LOG_(INFO) << "CleanCloudRecord End";
951 }
952 
953 /**
954  * @tc.name: OnDownloadAssetsParaMapTest001
955  * @tc.desc: Verify the OnDownloadAssets function.
956  * @tc.type: FUNC
957  * @tc.require: I6H5MH
958  */
959 HWTEST_F(CloudDiskDataHandlerTest, OnDownloadAssetsParaMapTest001, TestSize.Level1)
960 {
961     GTEST_LOG_(INFO) << "OnDownloadAssets Start";
962     const map<DriveKit::DKDownloadAsset, DriveKit::DKDownloadResult> resultMap;
963     int32_t ret = cloudDiskDataHandler_->OnDownloadAssets(resultMap);
964     EXPECT_EQ(ret, E_OK);
965     GTEST_LOG_(INFO) << "OnDownloadAssets End";
966 }
967 
968 /**
969  * @tc.name: GetCreatedRecordsTest001
970  * @tc.desc: Verify the GetCreatedRecords function.
971  * @tc.type: FUNC
972  * @tc.require: I6H5MH
973  */
974 HWTEST_F(CloudDiskDataHandlerTest, GetCreatedRecordsTest001, TestSize.Level1)
975 {
976     GTEST_LOG_(INFO) << "GetCreatedRecords Start";
977     vector<DKRecord> records;
978     int32_t ret = cloudDiskDataHandler_->GetCreatedRecords(records);
979     EXPECT_EQ(ret, E_RDB);
980     GTEST_LOG_(INFO) << "GetCreatedRecords End";
981 }
982 
983 /**
984  * @tc.name: GetCreatedRecordsTest002
985  * @tc.desc: Verify the GetCreatedRecords function.
986  * @tc.type: FUNC
987  * @tc.require: I6H5MH
988  */
989 HWTEST_F(CloudDiskDataHandlerTest, GetCreatedRecordsTest002, TestSize.Level1)
990 {
991     GTEST_LOG_(INFO) << "GetCreatedRecords Start";
992     vector<DKRecord> records;
993     DKRecord recordElem1;
994     records.emplace_back(recordElem1);
995     int32_t ret = cloudDiskDataHandler_->GetCreatedRecords(records);
996     EXPECT_EQ(ret, E_OK);
997     GTEST_LOG_(INFO) << "GetCreatedRecords End";
998 }
999 
1000 /**
1001  * @tc.name: GetCreatedRecordsTest003
1002  * @tc.desc: Verify the GetCreatedRecords function.
1003  * @tc.type: FUNC
1004  * @tc.require: I6H5MH
1005  */
1006 HWTEST_F(CloudDiskDataHandlerTest, GetCreatedRecordsTest003, TestSize.Level1)
1007 {
1008     GTEST_LOG_(INFO) << "GetCreatedRecords Start";
1009     try {
1010         vector<DKRecord> records;
1011         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1012         int32_t ret = cloudDiskDataHandler_->GetCreatedRecords(records);
1013         EXPECT_EQ(ret, E_RDB);
1014     } catch(...) {
1015         EXPECT_TRUE(false);
1016         GTEST_LOG_(INFO) << "GetCreatedRecords ERROR";
1017     }
1018     GTEST_LOG_(INFO) << "GetCreatedRecords End";
1019 }
1020 
1021 /**
1022  * @tc.name: GetDeletedRecordsTest001
1023  * @tc.desc: Verify the GetDeletedRecords function.
1024  * @tc.type: FUNC
1025  * @tc.require: I6H5MH
1026  */
1027 HWTEST_F(CloudDiskDataHandlerTest, GetDeletedRecordsTest001, TestSize.Level1)
1028 {
1029     GTEST_LOG_(INFO) << "GetDeletedRecords Start";
1030     vector<DKRecord> records;
1031     int32_t ret = cloudDiskDataHandler_->GetDeletedRecords(records);
1032     EXPECT_EQ(ret, E_RDB);
1033     GTEST_LOG_(INFO) << "GetDeletedRecords End";
1034 }
1035 
1036 /**
1037  * @tc.name: GetDeletedRecordsTest002
1038  * @tc.desc: Verify the GetDeletedRecords function.
1039  * @tc.type: FUNC
1040  * @tc.require: I6H5MH
1041  */
1042 HWTEST_F(CloudDiskDataHandlerTest, GetDeletedRecordsTest002, TestSize.Level1)
1043 {
1044     GTEST_LOG_(INFO) << "GetDeletedRecords Start";
1045     try {
1046         vector<DKRecord> records;
1047         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1048         int32_t ret = cloudDiskDataHandler_->GetDeletedRecords(records);
1049         EXPECT_EQ(ret, E_RDB);
1050     } catch(...) {
1051         EXPECT_TRUE(false);
1052         GTEST_LOG_(INFO) << "GetDeletedRecords ERROR";
1053     }
1054     GTEST_LOG_(INFO) << "GetDeletedRecords End";
1055 }
1056 
1057 /**
1058  * @tc.name: GetMetaModifiedRecordsTest001
1059  * @tc.desc: Verify the GetMetaModifiedRecords function.
1060  * @tc.type: FUNC
1061  * @tc.require: I6H5MH
1062  */
1063 HWTEST_F(CloudDiskDataHandlerTest, GetMetaModifiedRecordsTest001, TestSize.Level1)
1064 {
1065     GTEST_LOG_(INFO) << "GetMetaModifiedRecords Start";
1066     vector<DKRecord> records;
1067     int32_t ret = cloudDiskDataHandler_->GetMetaModifiedRecords(records);
1068     EXPECT_EQ(ret, E_RDB);
1069     GTEST_LOG_(INFO) << "GetMetaModifiedRecords End";
1070 }
1071 
1072 /**
1073  * @tc.name: GetMetaModifiedRecordsTest002
1074  * @tc.desc: Verify the GetMetaModifiedRecords function.
1075  * @tc.type: FUNC
1076  * @tc.require: I6H5MH
1077  */
1078 HWTEST_F(CloudDiskDataHandlerTest, GetMetaModifiedRecordsTest002, TestSize.Level1)
1079 {
1080     GTEST_LOG_(INFO) << "GetMetaModifiedRecords Start";
1081     try {
1082         vector<DKRecord> records;
1083         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1084         int32_t ret = cloudDiskDataHandler_->GetMetaModifiedRecords(records);
1085         EXPECT_EQ(ret, E_RDB);
1086     } catch(...) {
1087         EXPECT_TRUE(false);
1088         GTEST_LOG_(INFO) << "GetMetaModifiedRecords ERROR";
1089     }
1090     GTEST_LOG_(INFO) << "GetMetaModifiedRecords End";
1091 }
1092 
1093 /**
1094  * @tc.name: GetFileModifiedRecordsTest001
1095  * @tc.desc: Verify the GetFileModifiedRecords function.
1096  * @tc.type: FUNC
1097  * @tc.require: I6H5MH
1098  */
1099 HWTEST_F(CloudDiskDataHandlerTest, GetFileModifiedRecordsTest001, TestSize.Level1)
1100 {
1101     GTEST_LOG_(INFO) << "GetFileModifiedRecords Start";
1102     vector<DKRecord> records;
1103     int32_t ret = cloudDiskDataHandler_->GetFileModifiedRecords(records);
1104     EXPECT_EQ(ret, E_RDB);
1105     GTEST_LOG_(INFO) << "GetFileModifiedRecords End";
1106 }
1107 
1108 /**
1109  * @tc.name: GetFileModifiedRecordsTest002
1110  * @tc.desc: Verify the GetFileModifiedRecords function.
1111  * @tc.type: FUNC
1112  * @tc.require: I6H5MH
1113  */
1114 HWTEST_F(CloudDiskDataHandlerTest, GetFileModifiedRecordsTest002, TestSize.Level1)
1115 {
1116     GTEST_LOG_(INFO) << "GetFileModifiedRecords Start";
1117     vector<DKRecord> records;
1118     DKRecord recordElem1;
1119     records.emplace_back(recordElem1);
1120     int32_t ret = cloudDiskDataHandler_->GetFileModifiedRecords(records);
1121     EXPECT_EQ(ret, E_OK);
1122     GTEST_LOG_(INFO) << "GetFileModifiedRecords End";
1123 }
1124 
1125 /**
1126  * @tc.name: GetFileModifiedRecordsTest003
1127  * @tc.desc: Verify the GetFileModifiedRecords function.
1128  * @tc.type: FUNC
1129  * @tc.require: I6H5MH
1130  */
1131 HWTEST_F(CloudDiskDataHandlerTest, GetFileModifiedRecordsTest003, TestSize.Level1)
1132 {
1133     GTEST_LOG_(INFO) << "GetFileModifiedRecords Start";
1134     try {
1135         vector<DKRecord> records;
1136         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1137         int32_t ret = cloudDiskDataHandler_->GetFileModifiedRecords(records);
1138         EXPECT_EQ(ret, E_RDB);
1139     } catch(...) {
1140         EXPECT_TRUE(false);
1141         GTEST_LOG_(INFO) << "GetFileModifiedRecords ERROR";
1142     }
1143     GTEST_LOG_(INFO) << "GetFileModifiedRecords End";
1144 }
1145 
1146 /**
1147  * @tc.name: OnCreateRecordsTest001
1148  * @tc.desc: Verify the OnCreateRecords function.
1149  * @tc.type: FUNC
1150  * @tc.require: I6H5MH
1151  */
1152 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordsTest001, TestSize.Level1)
1153 {
1154     GTEST_LOG_(INFO) << "OnCreateRecords Start";
1155     const map<DKRecordId, DKRecordOperResult> testMap;
1156     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1157     int32_t ret = cloudDiskDataHandler_->OnCreateRecords(testMap);
1158     EXPECT_EQ(ret, E_RDB);
1159     GTEST_LOG_(INFO) << "OnCreateRecords End";
1160 }
1161 
1162 /**
1163  * @tc.name: OnCreateRecordsTest002
1164  * @tc.desc: Verify the OnCreateRecords function.
1165  * @tc.type: FUNC
1166  * @tc.require: I6H5MH
1167  */
1168 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordsTest002, TestSize.Level1)
1169 {
1170     GTEST_LOG_(INFO) << "OnCreateRecords Start";
1171     DKRecordId recordId;
1172     DKRecordOperResult result;
1173     map<DKRecordId, DKRecordOperResult> testMap;
1174     testMap.insert({recordId, result});
1175     auto resultSet = make_shared<ResultSetMock>();
1176     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1177     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1178     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1179     int32_t ret = cloudDiskDataHandler_->OnCreateRecords(testMap);
1180     EXPECT_EQ(ret, E_OK);
1181     GTEST_LOG_(INFO) << "OnCreateRecords End";
1182 }
1183 
1184 /**
1185  * @tc.name: OnCreateRecordsTest003
1186  * @tc.desc: Verify the OnCreateRecords function.
1187  * @tc.type: FUNC
1188  * @tc.require: I6H5MH
1189  */
1190 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordsTest003, TestSize.Level1)
1191 {
1192     GTEST_LOG_(INFO) << "OnCreateRecords Start";
1193     DKRecordId recordId;
1194     DKRecordOperResult result;
1195     DKError error;
1196     error.SetLocalError(DriveKit::DKLocalErrorCode::EXISTS);
1197     result.SetDKError(error);
1198     map<DKRecordId, DKRecordOperResult> testMap;
1199     testMap.insert({recordId, result});
1200     auto resultSet = make_shared<ResultSetMock>();
1201     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1202     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1203     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1204     int32_t ret = cloudDiskDataHandler_->OnCreateRecords(testMap);
1205     EXPECT_EQ(ret, E_OK);
1206     GTEST_LOG_(INFO) << "OnCreateRecords End";
1207 }
1208 
1209 /**
1210  * @tc.name: OnDeleteRecordsTest001
1211  * @tc.desc: Verify the OnDeleteRecords function.
1212  * @tc.type: FUNC
1213  * @tc.require: I6H5MH
1214  */
1215 HWTEST_F(CloudDiskDataHandlerTest, OnDeleteRecordsTest001, TestSize.Level1)
1216 {
1217     GTEST_LOG_(INFO) << "OnDeleteRecords Start";
1218     DKRecordId recordId;
1219     DKRecordOperResult result;
1220     map<DKRecordId, DKRecordOperResult> testMap;
1221     testMap.insert({recordId, result});
1222     int32_t ret = cloudDiskDataHandler_->OnDeleteRecords(testMap);
1223     EXPECT_EQ(ret, E_OK);
1224     GTEST_LOG_(INFO) << "OnDeleteRecords End";
1225 }
1226 
1227 /**
1228  * @tc.name: OnDeleteRecordsTest002
1229  * @tc.desc: Verify the OnDeleteRecords function.
1230  * @tc.type: FUNC
1231  * @tc.require: I6H5MH
1232  */
1233 HWTEST_F(CloudDiskDataHandlerTest, OnDeleteRecordsTest002, TestSize.Level1)
1234 {
1235     GTEST_LOG_(INFO) << "OnDeleteRecords Start";
1236     DKRecordId recordId;
1237     DKRecordOperResult result;
1238     DKError error;
1239     error.SetLocalError(DriveKit::DKLocalErrorCode::EXISTS);
1240     result.SetDKError(error);
1241     map<DKRecordId, DKRecordOperResult> testMap;
1242     testMap.insert({recordId, result});
1243     int32_t ret = cloudDiskDataHandler_->OnDeleteRecords(testMap);
1244     EXPECT_EQ(ret, E_OK);
1245     GTEST_LOG_(INFO) << "OnDeleteRecords End";
1246 }
1247 
1248 /**
1249  * @tc.name:OnModifyMdirtyRecordsTest001
1250  * @tc.desc: Verify the OnModifyMdirtyRecords function.
1251  * @tc.type: FUNC
1252  * @tc.require: I6H5MH
1253  */
1254 HWTEST_F(CloudDiskDataHandlerTest, OnModifyMdirtyRecordsTest001, TestSize.Level1)
1255 {
1256     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords Start";
1257     const map<DKRecordId, DKRecordOperResult> testMap;
1258     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1259     int32_t ret = cloudDiskDataHandler_->OnModifyMdirtyRecords(testMap);
1260     EXPECT_EQ(ret, E_RDB);
1261     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords End";
1262 }
1263 
1264 /**
1265  * @tc.name: OnModifyMdirtyRecordsTest002
1266  * @tc.desc: Verify the OnModifyMdirtyRecords function.
1267  * @tc.type: FUNC
1268  * @tc.require: I6H5MH
1269  */
1270 HWTEST_F(CloudDiskDataHandlerTest, OnModifyMdirtyRecordsTest002, TestSize.Level1)
1271 {
1272     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords Start";
1273     DKRecordId recordId;
1274     DKRecordOperResult result;
1275     map<DKRecordId, DKRecordOperResult> testMap;
1276     testMap.insert({recordId, result});
1277     auto resultSet = make_shared<ResultSetMock>();
1278     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1279     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1280     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1281     int32_t ret = cloudDiskDataHandler_->OnModifyMdirtyRecords(testMap);
1282     EXPECT_EQ(ret, E_OK);
1283     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords End";
1284 }
1285 
1286 /**
1287  * @tc.name: OnModifyMdirtyRecordsTest003
1288  * @tc.desc: Verify the OnModifyMdirtyRecords function.
1289  * @tc.type: FUNC
1290  * @tc.require: I6H5MH
1291  */
1292 HWTEST_F(CloudDiskDataHandlerTest, OnModifyMdirtyRecordsTest003, TestSize.Level1)
1293 {
1294     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords Start";
1295     DKRecordId recordId;
1296     DKRecordOperResult result;
1297     DKError error;
1298     error.SetLocalError(DriveKit::DKLocalErrorCode::EXISTS);
1299     result.SetDKError(error);
1300     map<DKRecordId, DKRecordOperResult> testMap;
1301     testMap.insert({recordId, result});
1302     auto resultSet = make_shared<ResultSetMock>();
1303     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1304     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1305     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1306     int32_t ret = cloudDiskDataHandler_->OnModifyMdirtyRecords(testMap);
1307     EXPECT_EQ(ret, E_OK);
1308     GTEST_LOG_(INFO) << "OnModifyMdirtyRecords End";
1309 }
1310 
1311 /**
1312  * @tc.name:OnModifyFdirtyRecordsTest001
1313  * @tc.desc: Verify the OnModifyFdirtyRecords function.
1314  * @tc.type: FUNC
1315  * @tc.require: I6H5MH
1316  */
1317 HWTEST_F(CloudDiskDataHandlerTest, OnModifyFdirtyRecordsTest001, TestSize.Level1)
1318 {
1319     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords Start";
1320     map<DKRecordId, DKRecordOperResult> testMap;
1321     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1322     int32_t ret = cloudDiskDataHandler_->OnModifyFdirtyRecords(testMap);
1323     EXPECT_EQ(ret, E_RDB);
1324     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords End";
1325 }
1326 
1327 /**
1328  * @tc.name: OnModifyFdirtyRecordsTest002
1329  * @tc.desc: Verify the OnModifyFdirtyRecords function.
1330  * @tc.type: FUNC
1331  * @tc.require: I6H5MH
1332  */
1333 HWTEST_F(CloudDiskDataHandlerTest, OnModifyFdirtyRecordsTest002, TestSize.Level1)
1334 {
1335     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords Start";
1336     DKRecordId recordId;
1337     DKRecordOperResult result;
1338     map<DKRecordId, DKRecordOperResult> testMap;
1339     testMap.insert({recordId, result});
1340     auto resultSet = make_shared<ResultSetMock>();
1341     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1342     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1343     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1344     int32_t ret = cloudDiskDataHandler_->OnModifyFdirtyRecords(testMap);
1345     EXPECT_EQ(ret, E_OK);
1346     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords End";
1347 }
1348 
1349 /**
1350  * @tc.name: OnModifyFdirtyRecordsTest003
1351  * @tc.desc: Verify the OnModifyFdirtyRecords function.
1352  * @tc.type: FUNC
1353  * @tc.require: I6H5MH
1354  */
1355 HWTEST_F(CloudDiskDataHandlerTest, OnModifyFdirtyRecordsTest003, TestSize.Level1)
1356 {
1357     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords Start";
1358     DKRecordId recordId;
1359     DKRecordOperResult result;
1360     DKError error;
1361     error.SetLocalError(DriveKit::DKLocalErrorCode::EXISTS);
1362     result.SetDKError(error);
1363     map<DKRecordId, DKRecordOperResult> testMap;
1364     testMap.insert({recordId, result});
1365     auto resultSet = make_shared<ResultSetMock>();
1366     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1367     EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).Times(3).WillRepeatedly(Return(E_OK));
1368     EXPECT_CALL(*resultSet, GoToNextRow()).WillOnce(Return(-1));
1369     int32_t ret = cloudDiskDataHandler_->OnModifyFdirtyRecords(testMap);
1370     EXPECT_EQ(ret, E_OK);
1371     GTEST_LOG_(INFO) << "OnModifyFdirtyRecords End";
1372 }
1373 
1374 /**
1375  * @tc.name: OnDownloadAssetsTest001
1376  * @tc.desc: Verify the OnDownloadAssets function.
1377  * @tc.type: FUNC
1378  * @tc.require: I6H5MH
1379  */
1380 HWTEST_F(CloudDiskDataHandlerTest, OnDownloadAssetsTest001, TestSize.Level1)
1381 {
1382     GTEST_LOG_(INFO) << "OnDownloadAssets Start";
1383     DriveKit::DKDownloadAsset asset;
1384     int32_t ret = cloudDiskDataHandler_->OnDownloadAssets(asset);
1385     EXPECT_EQ(ret, E_OK);
1386     GTEST_LOG_(INFO) << "OnDownloadAssets End";
1387 }
1388 
1389 /**
1390  * @tc.name: OnCreateRecordSuccessTest001
1391  * @tc.desc: Verify the OnCreateRecordSuccess function.
1392  * @tc.type: FUNC
1393  * @tc.require: I6H5MH
1394  */
1395 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordSuccessTest001, TestSize.Level1)
1396 {
1397     GTEST_LOG_(INFO) << "OnCreateRecordSuccess Start";
1398     DKRecordId id = "";
1399     DKRecordOperResult result;
1400     pair<DKRecordId, DKRecordOperResult> entry = {id, result};
1401     string testString = "sample_string";
1402     LocalInfo localInfo = {0, 0};
1403     unordered_map<string, LocalInfo> localMap;
1404     localMap.insert({testString, localInfo});
1405     int32_t ret = cloudDiskDataHandler_->OnCreateRecordSuccess(entry, localMap);
1406     EXPECT_EQ(ret, E_OK);
1407     GTEST_LOG_(INFO) << "OnCreateRecordSuccess End";
1408 }
1409 
1410 /**
1411  * @tc.name: OnCreateRecordSuccessTest002
1412  * @tc.desc: Verify the OnCreateRecordSuccess function.
1413  * @tc.type: FUNC
1414  * @tc.require: I6H5MH
1415  */
1416 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordSuccessTest002, TestSize.Level1)
1417 {
1418     GTEST_LOG_(INFO) << "OnCreateRecordSuccess Start";
1419     DKRecordId id = "sample_id";
1420     DKRecordOperResult result;
1421     pair<DKRecordId, DKRecordOperResult> entry = {id, result};
1422     unordered_map<string, LocalInfo> localMap;
1423     int32_t ret = cloudDiskDataHandler_->OnCreateRecordSuccess(entry, localMap);
1424     EXPECT_EQ(ret, E_OK);
1425     GTEST_LOG_(INFO) << "OnCreateRecordSuccess End";
1426 }
1427 
1428 /**
1429  * @tc.name: OnCreateRecordSuccessTest003
1430  * @tc.desc: Verify the OnCreateRecordSuccess function.
1431  * @tc.type: FUNC
1432  * @tc.require: I6H5MH
1433  */
1434 HWTEST_F(CloudDiskDataHandlerTest, OnCreateRecordSuccessTest003, TestSize.Level1)
1435 {
1436     GTEST_LOG_(INFO) << "OnCreateRecordSuccess Start";
1437     DKRecordId id = "sample_id";
1438     DKRecordOperResult result;
1439     pair<DKRecordId, DKRecordOperResult> entry = {id, result};
1440     string testString = id;
1441     LocalInfo localInfo = {0, 0};
1442     unordered_map<string, LocalInfo> localMap;
1443     localMap.insert({testString, localInfo});
1444     int32_t ret = cloudDiskDataHandler_->OnCreateRecordSuccess(entry, localMap);
1445     EXPECT_EQ(ret, E_OK);
1446     GTEST_LOG_(INFO) << "OnCreateRecordSuccess End";
1447 }
1448 
1449 /**
1450  * @tc.name: OnDeleteRecordSuccessTest001
1451  * @tc.desc: Verify the OnDeleteRecordSuccess function.
1452  * @tc.type: FUNC
1453  * @tc.require: I6H5MH
1454  */
1455 HWTEST_F(CloudDiskDataHandlerTest, OnDeleteRecordSuccessTest001, TestSize.Level1)
1456 {
1457     GTEST_LOG_(INFO) << "OnDeleteRecordSuccess Start";
1458     DKRecordId recordId = "sample_id";
1459     DKRecordOperResult result;
1460     pair<DKRecordId, DKRecordOperResult> entry = {recordId, result};
1461     int32_t ret = cloudDiskDataHandler_->OnDeleteRecordSuccess(entry);
1462     EXPECT_EQ(ret, E_OK);
1463     GTEST_LOG_(INFO) << "OnDeleteRecordSuccess End";
1464 }
1465 
1466 /**
1467  * @tc.name: OnModifyRecordSuccessTest001
1468  * @tc.desc: Verify the OnModifyRecordSuccess function.
1469  * @tc.type: FUNC
1470  * @tc.require: I6H5MH
1471  */
1472 HWTEST_F(CloudDiskDataHandlerTest, OnModifyRecordSuccessTest001, TestSize.Level1)
1473 {
1474     GTEST_LOG_(INFO) << "OnModifyRecordSuccess Start";
1475     DKRecordId recordId = "sample_id";
1476     DKRecordOperResult result;
1477     DKRecord record;
1478     DKRecordData data;
1479     record.SetRecordData(data);
1480     result.SetDKRecord(record);
1481     pair<DKRecordId, DKRecordOperResult> entry = {recordId, result};
1482     unordered_map<string, LocalInfo> localMap;
1483     int32_t ret = cloudDiskDataHandler_->OnModifyRecordSuccess(entry, localMap);
1484     EXPECT_EQ(ret, E_INVAL_ARG);
1485     GTEST_LOG_(INFO) << "OnModifyRecordSuccess End";
1486 }
1487 
1488 /**
1489  * @tc.name: OnModifyRecordSuccessTest002
1490  * @tc.desc: Verify the OnModifyRecordSuccess function.
1491  * @tc.type: FUNC
1492  * @tc.require: I6H5MH
1493  */
1494 HWTEST_F(CloudDiskDataHandlerTest, OnModifyRecordSuccessTest002, TestSize.Level1)
1495 {
1496     GTEST_LOG_(INFO) << "OnModifyRecordSuccess Start";
1497     DKRecordId recordId = "sample_id";
1498     DKRecordOperResult result;
1499     DKRecord record;
1500     DKRecordData data;
1501     DKFieldKey key1 = DK_FILE_ATTRIBUTES;
1502     DKRecordFieldMap fieldMap;
1503     string string1InMap = DK_META_TIME_EDITED;
1504     int64_t meta_date_modified = 10;
1505     DKRecordField field1InMap(meta_date_modified);
1506     fieldMap.insert({string1InMap, field1InMap});
1507     string string2InMap = "sample_map";
1508     DKRecordField field2InMap;
1509     fieldMap.insert({string2InMap, field2InMap});
1510     DKRecordField field1(fieldMap);
1511     data.insert({key1, field1});
1512     DKFieldKey key2 = "sample_key";
1513     DKRecordField field2;
1514     data.insert({key2, field2});
1515     record.SetRecordData(data);
1516     result.SetDKRecord(record);
1517     pair<DKRecordId, DKRecordOperResult> entry = {recordId, result};
1518     string localString1 = recordId;
1519     LocalInfo localInfo1;
1520     unordered_map<string, LocalInfo> localMap;
1521     localMap.insert({localString1, localInfo1});
1522     int32_t ret = cloudDiskDataHandler_->OnModifyRecordSuccess(entry, localMap);
1523     EXPECT_EQ(ret, E_OK);
1524     GTEST_LOG_(INFO) << "OnModifyRecordSuccess End";
1525 }
1526 
1527 /**
1528  * @tc.name: IsTimeChangedTest001
1529  * @tc.desc: Verify the IsTimeChanged function.
1530  * @tc.type: FUNC
1531  * @tc.require: I6H5MH
1532  */
1533 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest001, TestSize.Level1)
1534 {
1535     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1536     DriveKit::DKRecord record;
1537     string type = CloudDisk::FileColumn::FILE_TIME_EDITED;
1538     string cloudId = "rootId";
1539     string testString1 = "testString1";
1540     LocalInfo localInfo1 = {0, 0};
1541     unordered_map<string, LocalInfo> localMap;
1542     localMap.insert({testString1, localInfo1});
1543     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1544     EXPECT_EQ(ret, true);
1545     GTEST_LOG_(INFO) << "IsTimeChanged End";
1546 }
1547 
1548 /**
1549  * @tc.name: IsTimeChangedTest002
1550  * @tc.desc: Verify the IsTimeChanged function.
1551  * @tc.type: FUNC
1552  * @tc.require: I6H5MH
1553  */
1554 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest002, TestSize.Level1)
1555 {
1556     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1557     string type = CloudDisk::FileColumn::FILE_TIME_EDITED;
1558     string cloudId = "rootId";
1559     string testString1 = cloudId;
1560     LocalInfo localInfo1 = {0, 0};
1561     string testString2 = "sample_id";
1562     LocalInfo localInfo2 = {0, 0};
1563     unordered_map<string, LocalInfo> localMap;
1564     localMap.insert({testString1, localInfo1});
1565     localMap.insert({testString2, localInfo2});
1566     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1567     DKRecordField field1;
1568     DKRecordData fields;
1569     fields.insert({key1, field1});
1570     DriveKit::DKRecord record;
1571     record.SetRecordData(fields);
1572     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1573     EXPECT_EQ(ret, false);
1574     GTEST_LOG_(INFO) << "IsTimeChanged End";
1575 }
1576 
1577 /**
1578  * @tc.name: IsTimeChangedTest003
1579  * @tc.desc: Verify the IsTimeChanged function.
1580  * @tc.type: FUNC
1581  * @tc.require: I6H5MH
1582  */
1583 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest003, TestSize.Level1)
1584 {
1585     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1586     string type = CloudDisk::FileColumn::FILE_TIME_EDITED;
1587     string cloudId = "rootId";
1588     string testString1 = cloudId;
1589     int64_t mdirtyTime = 0;
1590     int64_t fdirtyTime = 0;
1591     LocalInfo localInfo1 = {mdirtyTime, fdirtyTime};
1592     string testString2 = "sample_id";
1593     LocalInfo localInfo2 = {0, 0};
1594     unordered_map<string, LocalInfo> localMap;
1595     localMap.insert({testString1, localInfo1});
1596     localMap.insert({testString2, localInfo2});
1597     int64_t localTime = localInfo1.fdirtyTime;
1598     int64_t cloudTime = localTime;
1599     DKRecordFieldMap mapInField1;
1600     string mapString = DK_FILE_TIME_EDITED;
1601     DKRecordField mapField(cloudTime);
1602     mapInField1.insert({mapString, mapField});
1603     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1604     DKRecordField field1(mapInField1);
1605     DKFieldKey key2 = "sample_key";
1606     DKRecordField field2;
1607     DKRecordData fields;
1608     fields.insert({key1, field1});
1609     fields.insert({key2, field2});
1610     DriveKit::DKRecord record;
1611     record.SetRecordData(fields);
1612     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1613     EXPECT_EQ(ret, false);
1614     GTEST_LOG_(INFO) << "IsTimeChanged End";
1615 }
1616 
1617 /**
1618  * @tc.name: IsTimeChangedTest004
1619  * @tc.desc: Verify the IsTimeChanged function.
1620  * @tc.type: FUNC
1621  * @tc.require: I6H5MH
1622  */
1623 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest004, TestSize.Level1)
1624 {
1625     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1626     string type = CloudDisk::FileColumn::FILE_TIME_EDITED;
1627     string cloudId = "rootId";
1628 
1629     string testString1 = cloudId;
1630     int64_t mdirtyTime = 0;
1631     int64_t fdirtyTime = 0;
1632     LocalInfo localInfo1 = {mdirtyTime, fdirtyTime};
1633     string testString2 = "sample_id";
1634     LocalInfo localInfo2 = {0, 0};
1635     unordered_map<string, LocalInfo> localMap;
1636     localMap.insert({testString1, localInfo1});
1637     localMap.insert({testString2, localInfo2});
1638     int64_t cloudTime = 20;
1639     DKRecordFieldMap mapInField1;
1640     string mapString = DK_FILE_TIME_EDITED;
1641     DKRecordField mapField(cloudTime);
1642     mapInField1.insert({mapString, mapField});
1643     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1644     DKRecordField field1(mapInField1);
1645     DKFieldKey key2 = "sample_key";
1646     DKRecordField field2;
1647     DKRecordData fields;
1648     fields.insert({key1, field1});
1649     fields.insert({key2, field2});
1650     DriveKit::DKRecord record;
1651     record.SetRecordData(fields);
1652     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1653     EXPECT_EQ(ret, false);
1654     GTEST_LOG_(INFO) << "IsTimeChanged End";
1655 }
1656 
1657 /**
1658  * @tc.name: IsTimeChangedTest005
1659  * @tc.desc: Verify the IsTimeChanged function.
1660  * @tc.type: FUNC
1661  * @tc.require: I6H5MH
1662  */
1663 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest005, TestSize.Level1)
1664 {
1665     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1666     string type = CloudDisk::FileColumn::FILE_TIME_EDITED;
1667     string cloudId = "rootId";
1668     string testString1 = cloudId;
1669     int64_t mdirtyTime = 0;
1670     int64_t fdirtyTime = 0;
1671     LocalInfo localInfo1 = {mdirtyTime, fdirtyTime};
1672     string testString2 = "sample_id";
1673     LocalInfo localInfo2 = {0, 0};
1674     unordered_map<string, LocalInfo> localMap;
1675     localMap.insert({testString1, localInfo1});
1676     localMap.insert({testString2, localInfo2});
1677     string myString = "sample_string";
1678     DKRecordFieldMap mapInField1;
1679     string mapString = DK_FILE_TIME_EDITED;
1680     DKRecordField mapField(myString);
1681     mapInField1.insert({mapString, mapField});
1682     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1683     DKRecordField field1(mapInField1);
1684     DKFieldKey key2 = "sample_key";
1685     DKRecordField field2;
1686     DKRecordData fields;
1687     fields.insert({key1, field1});
1688     fields.insert({key2, field2});
1689     DriveKit::DKRecord record;
1690     record.SetRecordData(fields);
1691     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1692     EXPECT_EQ(ret, false);
1693     GTEST_LOG_(INFO) << "IsTimeChanged End";
1694 }
1695 
1696 /**
1697  * @tc.name: IsTimeChangedTest006
1698  * @tc.desc: Verify the IsTimeChanged function.
1699  * @tc.type: FUNC
1700  * @tc.require: I6H5MH
1701  */
1702 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest006, TestSize.Level1)
1703 {
1704     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1705     string type = CloudDisk::FileColumn::FILE_TIME_RECYCLED;
1706     string cloudId = "rootId";
1707     string testString1 = cloudId;
1708     int64_t mdirtyTime = 0;
1709     int64_t fdirtyTime = 0;
1710     LocalInfo localInfo1 = {mdirtyTime, fdirtyTime};
1711     string testString2 = "sample_id";
1712     LocalInfo localInfo2 = {0, 0};
1713     unordered_map<string, LocalInfo> localMap;
1714     localMap.insert({testString1, localInfo1});
1715     localMap.insert({testString2, localInfo2});
1716     int64_t localTime = localInfo1.mdirtyTime;
1717     int64_t cloudTime = localTime;
1718     DKRecordFieldMap mapInField1;
1719     string mapString = DK_FILE_TIME_EDITED;
1720     DKRecordField mapField(cloudTime);
1721     mapInField1.insert({mapString, mapField});
1722     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1723     DKRecordField field1(mapInField1);
1724     DKFieldKey key2 = "sample_key";
1725     DKRecordField field2;
1726     DKRecordData fields;
1727     fields.insert({key1, field1});
1728     fields.insert({key2, field2});
1729     DriveKit::DKRecord record;
1730     record.SetRecordData(fields);
1731     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1732     EXPECT_EQ(ret, false);
1733     GTEST_LOG_(INFO) << "IsTimeChanged End";
1734 }
1735 
1736 /**
1737  * @tc.name: IsTimeChangedTest007
1738  * @tc.desc: Verify the IsTimeChanged function.
1739  * @tc.type: FUNC
1740  * @tc.require: I6H5MH
1741  */
1742 HWTEST_F(CloudDiskDataHandlerTest, IsTimeChangedTest007, TestSize.Level1)
1743 {
1744     GTEST_LOG_(INFO) << "IsTimeChanged Start";
1745     string type = CloudDisk::FileColumn::FILE_TIME_RECYCLED;
1746     string cloudId = "rootId";
1747     string testString1 = cloudId;
1748     int64_t mdirtyTime = 0;
1749     int64_t fdirtyTime = 0;
1750     LocalInfo localInfo1 = {mdirtyTime, fdirtyTime};
1751     string testString2 = "sample_id";
1752     LocalInfo localInfo2 = {0, 0};
1753     unordered_map<string, LocalInfo> localMap;
1754     localMap.insert({testString1, localInfo1});
1755     localMap.insert({testString2, localInfo2});
1756     string myString = "sample_string";
1757     DKRecordFieldMap mapInField1;
1758     string mapString = DK_FILE_TIME_EDITED;
1759     DKRecordField mapField(myString);
1760     mapInField1.insert({mapString, mapField});
1761     DKFieldKey key1 = "DK_FILE_ATTRIBUTES";
1762     DKRecordField field1(mapInField1);
1763     DKFieldKey key2 = "sample_key";
1764     DKRecordField field2;
1765     DKRecordData fields;
1766     fields.insert({key1, field1});
1767     fields.insert({key2, field2});
1768     DriveKit::DKRecord record;
1769     record.SetRecordData(fields);
1770     bool ret = cloudDiskDataHandler_->IsTimeChanged(record, localMap, cloudId, type);
1771     EXPECT_EQ(ret, false);
1772     GTEST_LOG_(INFO) << "IsTimeChanged End";
1773 }
1774 
1775 /**
1776  * @tc.name: GetLocalInfoTest001
1777  * @tc.desc: Verify the GetLocalInfo function.
1778  * @tc.type: FUNC
1779  * @tc.require: I6H5MH
1780  */
1781 HWTEST_F(CloudDiskDataHandlerTest, GetLocalInfoTest001, TestSize.Level1)
1782 {
1783     GTEST_LOG_(INFO) << "GetLocalInfo Start";
1784     map<DKRecordId, DKRecordOperResult> map;
1785     DKRecordId id = "sample_id";
1786     DKRecordOperResult result;
1787     map.insert({id, result});
1788     unordered_map<string, LocalInfo> infoMap;
1789     const string type = CloudDisk::FileColumn::CLOUD_ID;
1790     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
1791     EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
1792     EXPECT_CALL(*resultSet, GetColumnIndex(_, _))
1793     .Times(2)
1794     .WillOnce(Return(E_RDB))
1795     .WillOnce(Return(E_RDB));
1796     int32_t ret = cloudDiskDataHandler_->GetLocalInfo(map, infoMap, type);
1797     EXPECT_EQ(ret, E_RDB);
1798     GTEST_LOG_(INFO) << "GetLocalInfo End";
1799 }
1800 
1801 /**
1802  * @tc.name: GetLocalInfoTest002
1803  * @tc.desc: Verify the GetLocalInfo function.
1804  * @tc.type: FUNC
1805  * @tc.require: I6H5MH
1806  */
1807 HWTEST_F(CloudDiskDataHandlerTest, GetLocalInfoTest002, TestSize.Level1)
1808 {
1809     GTEST_LOG_(INFO) << "GetLocalInfo Start";
1810     map<DKRecordId, DKRecordOperResult> map;
1811     unordered_map<string, LocalInfo> infoMap;
1812     const string type = CloudDisk::FileColumn::FILE_NAME;
1813     int32_t ret = cloudDiskDataHandler_->GetLocalInfo(map, infoMap, type);
1814     EXPECT_EQ(ret, E_UNKNOWN);
1815     GTEST_LOG_(INFO) << "GetLocalInfo End";
1816 }
1817 
1818 /**
1819  * @tc.name: GetLocalInfoTest003
1820  * @tc.desc: Verify the GetLocalInfo function.
1821  * @tc.type: FUNC
1822  * @tc.require: I6H5MH
1823  */
1824 HWTEST_F(CloudDiskDataHandlerTest, GetLocalInfoTest003, TestSize.Level1)
1825 {
1826     GTEST_LOG_(INFO) << "GetLocalInfo Start";
1827     try {
1828         map<DKRecordId, DKRecordOperResult> map;
1829         DKRecordId id = "sample_id";
1830         DKRecordOperResult result;
1831         map.insert({id, result});
1832         unordered_map<string, LocalInfo> infoMap;
1833         const string type = CloudDisk::FileColumn::CLOUD_ID;
1834         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
1835         int32_t ret = cloudDiskDataHandler_->GetLocalInfo(map, infoMap, type);
1836         EXPECT_EQ(ret, E_RDB);
1837     } catch(...) {
1838         EXPECT_TRUE(false);
1839         GTEST_LOG_(INFO) << "GetLocalInfo ERROR";
1840     }
1841     GTEST_LOG_(INFO) << "GetLocalInfo End";
1842 }
1843 
1844 /**
1845  * @tc.name: BuildInfoMapTest001
1846  * @tc.desc: Verify the BuildInfoMap function.
1847  * @tc.type: FUNC
1848  * @tc.require: I6H5MH
1849  */
1850 HWTEST_F(CloudDiskDataHandlerTest, BuildInfoMapTest001, TestSize.Level1)
1851 {
1852     GTEST_LOG_(INFO) << "BuildInfoMap Start";
1853     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
1854     unordered_map<string, LocalInfo> infoMap;
1855     const string type = CloudDisk::FileColumn::CLOUD_ID;
1856     EXPECT_CALL(*resultSet, GetColumnIndex(_, _))
1857     .WillOnce(Return(E_RDB))
1858     .WillOnce(Return(E_RDB));
1859     int32_t ret = cloudDiskDataHandler_->BuildInfoMap(resultSet, infoMap, type);
1860     EXPECT_EQ(ret, E_RDB);
1861     GTEST_LOG_(INFO) << "BuildInfoMap End";
1862 }
1863 
1864 /**
1865  * @tc.name: BuildInfoMapTest002
1866  * @tc.desc: Verify the BuildInfoMap function.
1867  * @tc.type: FUNC
1868  * @tc.require: I6H5MH
1869  */
1870 HWTEST_F(CloudDiskDataHandlerTest, BuildInfoMapTest002, TestSize.Level1)
1871 {
1872     GTEST_LOG_(INFO) << "BuildInfoMap Start";
1873     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
1874     unordered_map<string, LocalInfo> infoMap;
1875     const string type = CloudDisk::FileColumn::CLOUD_ID;
1876     EXPECT_CALL(*resultSet, GetColumnIndex(_, _))
1877     .Times(3)
1878     .WillOnce(Return(E_OK))
1879     .WillOnce(Return(E_RDB))
1880     .WillOnce(Return(E_RDB));
1881     int32_t ret = cloudDiskDataHandler_->BuildInfoMap(resultSet, infoMap, type);
1882     EXPECT_EQ(ret, E_RDB);
1883     GTEST_LOG_(INFO) << "BuildInfoMap End";
1884 }
1885 
1886 /**
1887  * @tc.name: BuildInfoMapTest003
1888  * @tc.desc: Verify the BuildInfoMap function.
1889  * @tc.type: FUNC
1890  * @tc.require: I6H5MH
1891  */
1892 HWTEST_F(CloudDiskDataHandlerTest, BuildInfoMapTest003, TestSize.Level1)
1893 {
1894     GTEST_LOG_(INFO) << "BuildInfoMap Start";
1895     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
1896     unordered_map<string, LocalInfo> infoMap;
1897     const string type = CloudDisk::FileColumn::CLOUD_ID;
1898     EXPECT_CALL(*resultSet, GetColumnIndex(_, _))
1899         .Times(4)
1900         .WillOnce(Return(E_OK))
1901         .WillOnce(Return(E_OK))
1902         .WillOnce(Return(E_RDB))
1903         .WillOnce(Return(E_RDB));
1904     int32_t ret = cloudDiskDataHandler_->BuildInfoMap(resultSet, infoMap, type);
1905     EXPECT_EQ(ret, E_RDB);
1906     GTEST_LOG_(INFO) << "BuildInfoMap End";
1907 }
1908 
1909 /**
1910  * @tc.name: BuildInfoMapTest004
1911  * @tc.desc: Verify the BuildInfoMap function.
1912  * @tc.type: FUNC
1913  * @tc.require: I6H5MH
1914  */
1915 HWTEST_F(CloudDiskDataHandlerTest, BuildInfoMapTest004, TestSize.Level1)
1916 {
1917     GTEST_LOG_(INFO) << "BuildInfoMap Start";
1918     std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
1919     unordered_map<string, LocalInfo> infoMap;
1920     const string type = CloudDisk::FileColumn::CLOUD_ID;
1921     EXPECT_CALL(*resultSet, GetColumnIndex(_, _))
1922         .Times(3)
1923         .WillOnce(Return(E_OK))
1924         .WillOnce(Return(E_OK))
1925         .WillOnce(Return(E_OK));
1926     EXPECT_CALL(*resultSet, GoToNextRow())
1927         .Times(3)
1928         .WillOnce(Return(0))
1929         .WillOnce(Return(0))
1930         .WillOnce(Return(-1));
1931     EXPECT_CALL(*resultSet, GetString(_, _))
1932     .Times(2)
1933     .WillOnce(Return(E_OK))
1934     .WillOnce(Return(-1));
1935     EXPECT_CALL(*resultSet, GetLong(_, _))
1936         .Times(2)
1937         .WillOnce(Return(E_OK))
1938         .WillOnce(Return(E_OK));
1939     int32_t ret = cloudDiskDataHandler_->BuildInfoMap(resultSet, infoMap, type);
1940     EXPECT_EQ(ret, E_OK);
1941     GTEST_LOG_(INFO) << "BuildInfoMap End";
1942 }
1943 
1944 /**
1945  * @tc.name: ResetTest001
1946  * @tc.desc: Verify the Reset function.
1947  * @tc.type: FUNC
1948  * @tc.require: I6H5MH
1949  */
1950 HWTEST_F(CloudDiskDataHandlerTest, ResetTest001, TestSize.Level1)
1951 {
1952     GTEST_LOG_(INFO) << "Reset Start";
1953     cloudDiskDataHandler_->Reset();
1954     EXPECT_EQ(cloudDiskDataHandler_->modifyFailSet_.size(), 0);
1955     GTEST_LOG_(INFO) << "Reset End";
1956 }
1957 
1958 /**
1959  * @tc.name: GetDownloadAssetTest000
1960  * @tc.desc: Verify the GetDownloadAsset function.
1961  * @tc.type: FUNC
1962  * @tc.require: I6H5MH
1963  */
1964 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest000, TestSize.Level1)
1965 {
1966     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
1967     try {
1968         std::string fileUri = "";
1969         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
1970         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
1971         EXPECT_EQ(result, E_INVAL_ARG);
1972     } catch(...) {
1973         EXPECT_TRUE(false);
1974         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
1975     }
1976     GTEST_LOG_(INFO) << "GetDownloadAsset End";
1977 }
1978 
1979 /**
1980  * @tc.name: GetDownloadAssetTest001
1981  * @tc.desc: Verify the GetDownloadAsset function.
1982  * @tc.type: FUNC
1983  * @tc.require: I6H5MH
1984  */
1985 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest001, TestSize.Level1)
1986 {
1987     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
1988     try {
1989         std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
1990         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
1991         g_getCloudIdFlag = 3;
1992         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
1993         EXPECT_EQ(result, E_INVAL_ARG);
1994     } catch(...) {
1995         EXPECT_TRUE(false);
1996         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
1997     }
1998     GTEST_LOG_(INFO) << "GetDownloadAsset End";
1999 }
2000 
2001 /**
2002  * @tc.name: GetDownloadAssetTest002
2003  * @tc.desc: Verify the GetDownloadAsset function.
2004  * @tc.type: FUNC
2005  * @tc.require: I6H5MH
2006  */
2007 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest002, TestSize.Level1)
2008 {
2009     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
2010     try {
2011         std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2012         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
2013         g_getCloudIdFlag = 1;
2014         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(nullptr));
2015         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
2016         EXPECT_EQ(result, E_RDB);
2017     } catch(...) {
2018         EXPECT_TRUE(false);
2019         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
2020     }
2021     GTEST_LOG_(INFO) << "GetDownloadAsset End";
2022 }
2023 
2024 /**
2025  * @tc.name: GetDownloadAssetTest003
2026  * @tc.desc: Verify the GetDownloadAsset function.
2027  * @tc.type: FUNC
2028  * @tc.require: I6H5MH
2029  */
2030 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest003, TestSize.Level1)
2031 {
2032     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
2033     try {
2034         std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2035         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
2036         g_getCloudIdFlag = 1;
2037         std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
2038         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
2039         EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(Return(E_RDB));
2040         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
2041         EXPECT_EQ(result, E_RDB);
2042     } catch(...) {
2043         EXPECT_TRUE(false);
2044         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
2045     }
2046     GTEST_LOG_(INFO) << "GetDownloadAsset End";
2047 }
2048 
2049 /**
2050  * @tc.name: GetDownloadAssetTest004
2051  * @tc.desc: Verify the GetDownloadAsset function.
2052  * @tc.type: FUNC
2053  * @tc.require: I6H5MH
2054  */
2055 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest004, TestSize.Level1)
2056 {
2057     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
2058     try {
2059         std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2060         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
2061         g_getCloudIdFlag = 1;
2062         std::string fieldKey = "content";
2063         std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
2064         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
2065         EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(Return(E_OK));
2066         EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
2067         EXPECT_CALL(*resultSet, GetInt(_, _)).WillRepeatedly(DoAll(SetArgReferee<1>(FILE), Return(E_OK)));
2068         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
2069         for (auto &item : outAssetsToDownload)
2070         {
2071             EXPECT_EQ(item.fieldKey, fieldKey);
2072         }
2073         EXPECT_EQ(result, E_OK);
2074     } catch(...) {
2075         EXPECT_TRUE(false);
2076         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
2077     }
2078     GTEST_LOG_(INFO) << "GetDownloadAsset End";
2079 }
2080 
2081 /**
2082  * @tc.name: GetDownloadAssetTest005
2083  * @tc.desc: Verify the GetDownloadAsset function.
2084  * @tc.type: FUNC
2085  * @tc.require: I6H5MH
2086  */
2087 HWTEST_F(CloudDiskDataHandlerTest, GetDownloadAssetTest005, TestSize.Level1)
2088 {
2089     GTEST_LOG_(INFO) << "GetDownloadAsset Start";
2090     try {
2091         std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2092         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
2093         g_getCloudIdFlag = 1;
2094         std::string fieldKey = "content";
2095         std::shared_ptr<ResultSetMock> resultSet = std::make_shared<ResultSetMock>();
2096         EXPECT_CALL(*cloudDiskDataHandler_, Query(_, _)).WillOnce(Return(resultSet));
2097         EXPECT_CALL(*resultSet, GetRowCount(_)).WillOnce(Return(E_OK));
2098         EXPECT_CALL(*resultSet, GetColumnIndex(_, _)).WillOnce(Return(E_OK));
2099         EXPECT_CALL(*resultSet, GetInt(_, _)).WillRepeatedly(DoAll(SetArgReferee<1>(DIRECTORY), Return(E_OK)));
2100         int result = cloudDiskDataHandler_->GetDownloadAsset(fileUri, outAssetsToDownload);
2101         EXPECT_EQ(result, ERR_INVALID_VALUE);
2102     } catch(...) {
2103         EXPECT_TRUE(false);
2104         GTEST_LOG_(INFO) << "GetDownloadAsset ERROR";
2105     }
2106     GTEST_LOG_(INFO) << "GetDownloadAsset End";
2107 }
2108 
2109 /**
2110  * @tc.name: AppendFileToDownload000
2111  * @tc.desc: Verify the AppendFileToDownload function.
2112  * @tc.type: FUNC
2113  * @tc.require: I6H5MH
2114  */
2115 HWTEST_F(CloudDiskDataHandlerTest, AppendFileToDownload000, TestSize.Level1)
2116 {
2117     GTEST_LOG_(INFO) << "AppendFileToDownload Start";
2118     try {
2119         std::string cloudId = "user.cloud.cloudid";
2120         std::string fieldKey = "content";
2121         vector<DriveKit::DKDownloadAsset> outAssetsToDownload;
2122         cloudDiskDataHandler_->AppendFileToDownload(cloudId, fieldKey, outAssetsToDownload);
2123         for (auto &item : outAssetsToDownload)
2124         {
2125             EXPECT_EQ(item.fieldKey, fieldKey);
2126         }
2127     } catch(...) {
2128         EXPECT_TRUE(false);
2129         GTEST_LOG_(INFO) << "AppendFileToDownload ERROR";
2130     }
2131     GTEST_LOG_(INFO) << "AppendFileToDownload End";
2132 }
2133 
2134 /**
2135  * @tc.name: OnDownloadSuccess001
2136  * @tc.desc: Verify the OnDownloadSuccess function.
2137  * @tc.type: FUNC
2138  * @tc.require: I6H5MH
2139  */
2140 HWTEST_F(CloudDiskDataHandlerTest, OnDownloadSuccess001, TestSize.Level1)
2141 {
2142     GTEST_LOG_(INFO) << "OnDownloadSuccess Start";
2143     try {
2144         DriveKit::DKDownloadAsset asset;
2145         asset.asset.assetName = "user.cloud.cloudid.temp.download";
2146         EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(E_OK));
2147         int result = cloudDiskDataHandler_->OnDownloadSuccess(asset);
2148         EXPECT_EQ(result, E_OK);
2149     } catch(...) {
2150         EXPECT_TRUE(false);
2151         GTEST_LOG_(INFO) << "OnDownloadSuccess ERROR";
2152     }
2153     GTEST_LOG_(INFO) << "OnDownloadSuccess End";
2154 }
2155 
2156 /**
2157  * @tc.name: OnDownloadSuccess002
2158  * @tc.desc: Verify the OnDownloadSuccess function.
2159  * @tc.type: FUNC
2160  * @tc.require: I6H5MH
2161  */
2162 HWTEST_F(CloudDiskDataHandlerTest, OnDownloadSuccess002, TestSize.Level1)
2163 {
2164     GTEST_LOG_(INFO) << "OnDownloadSuccess Start";
2165     try {
2166         DriveKit::DKDownloadAsset asset;
2167         asset.asset.assetName = "user.cloud.cloudid.temp.download";
2168         EXPECT_CALL(*cloudDiskDataHandler_, Update(_, _, _, _)).WillOnce(Return(E_RDB));
2169         int result = cloudDiskDataHandler_->OnDownloadSuccess(asset);
2170         EXPECT_EQ(result, E_RDB);
2171     } catch(...) {
2172         EXPECT_TRUE(false);
2173         GTEST_LOG_(INFO) << "OnDownloadSuccess ERROR";
2174     }
2175     GTEST_LOG_(INFO) << "OnDownloadSuccess End";
2176 }
2177 
2178 /**
2179  * @tc.name: CleanCache000
2180  * @tc.desc: Verify the CleanCache function.
2181  * @tc.type: FUNC
2182  * @tc.require: I6H5MH
2183  */
2184 HWTEST_F(CloudDiskDataHandlerTest, CleanCache000, TestSize.Level1)
2185 {
2186     GTEST_LOG_(INFO) << "CleanCache Start";
2187     try {
2188         const std::string fileUri = "";
2189         int result = cloudDiskDataHandler_->CleanCache(fileUri);
2190         EXPECT_EQ(result, E_INVAL_ARG);
2191     } catch(...) {
2192         EXPECT_TRUE(false);
2193         GTEST_LOG_(INFO) << "CleanCache ERROR";
2194     }
2195     GTEST_LOG_(INFO) << "CleanCache End";
2196 }
2197 
2198 /**
2199  * @tc.name: CleanCache001
2200  * @tc.desc: Verify the CleanCache function.
2201  * @tc.type: FUNC
2202  * @tc.require: I6H5MH
2203  */
2204 HWTEST_F(CloudDiskDataHandlerTest, CleanCache001, TestSize.Level1)
2205 {
2206     GTEST_LOG_(INFO) << "CleanCache Start";
2207     try {
2208         const std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2209         g_getCloudIdFlag = 3;
2210         int result = cloudDiskDataHandler_->CleanCache(fileUri);
2211         EXPECT_EQ(result, E_INVAL_ARG);
2212     } catch(...) {
2213         EXPECT_TRUE(false);
2214         GTEST_LOG_(INFO) << "CleanCache ERROR";
2215     }
2216     GTEST_LOG_(INFO) << "CleanCache End";
2217 }
2218 
2219 /**
2220  * @tc.name: CleanCache002
2221  * @tc.desc: Verify the CleanCache function.
2222  * @tc.type: FUNC
2223  * @tc.require: I6H5MH
2224  */
2225 HWTEST_F(CloudDiskDataHandlerTest, CleanCache002, TestSize.Level1)
2226 {
2227     GTEST_LOG_(INFO) << "CleanCache Start";
2228     try {
2229         const std::string fileUri = "file://media/Photo/12/IMG_12345_0011/test.jpg";
2230         g_getCloudIdFlag = 0;
2231         const int32_t userId = 0;
2232         string bundleName = "com.ohos.test";
2233         auto rdb = make_shared<RdbStoreMock>();
2234         CloudDiskDataHandlerMock cloudDiskDataHandlerMock(userId, bundleName, rdb);
2235         int result = cloudDiskDataHandlerMock.CleanCache(fileUri);
2236         EXPECT_EQ(result, E_NO_SUCH_FILE);
2237     } catch(...) {
2238         EXPECT_TRUE(false);
2239         GTEST_LOG_(INFO) << "CleanCache ERROR";
2240     }
2241     GTEST_LOG_(INFO) << "CleanCache End";
2242 }
2243 
2244 } // namespace Test
2245 } // namespace FileManagement::CloudSync
2246 } // namespace OHOS
2247