• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "cloud_file_utils.h"
17 #include "clouddisk_rdb_utils.h"
18 #include "clouddisk_rdbstore.h"
19 #include "clouddisk_rdbstore_mock.h"
20 #include "clouddisk_resultset_mock.h"
21 #include "dfs_error.h"
22 #include "rdb_helper.h"
23 #include "rdb_open_callback.h"
24 #include "rdb_store_config.h"
25 #include "cloud_status.h"
26 #include <gmock/gmock.h>
27 #include <gtest/gtest.h>
28 #include <memory>
29 
30 namespace OHOS::FileManagement::CloudDisk::Test {
31 using namespace testing;
32 using namespace testing::ext;
33 using namespace std;
34 using namespace NativeRdb;
35 
36 class CloudDiskRdbStoreTest : public testing::Test {
37 public:
38     static void SetUpTestCase(void);
39     static void TearDownTestCase(void);
40     void SetUp();
41     void TearDown();
42 };
43 
SetUpTestCase(void)44 void CloudDiskRdbStoreTest::SetUpTestCase(void)
45 {
46     GTEST_LOG_(INFO) << "SetUpTestCase";
47 }
48 
TearDownTestCase(void)49 void CloudDiskRdbStoreTest::TearDownTestCase(void)
50 {
51     GTEST_LOG_(INFO) << "TearDownTestCase";
52 }
53 
SetUp(void)54 void CloudDiskRdbStoreTest::SetUp(void)
55 {
56     GTEST_LOG_(INFO) << "SetUp";
57 }
58 
TearDown(void)59 void CloudDiskRdbStoreTest::TearDown(void)
60 {
61     GTEST_LOG_(INFO) << "TearDown";
62 }
63 
64 /**
65  * @tc.name: RdbInit
66  * @tc.desc: Verify the CloudDiskRdbStore::RdbInit function
67  * @tc.type: FUNC
68  * @tc.require: SR000HRKKA
69  */
70 HWTEST_F(CloudDiskRdbStoreTest, RdbInitTest1, TestSize.Level1)
71 {
72     const std::string bundleName = "RdbInitTest";
73     const int32_t userId = 123456789;
74     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
75     int32_t ret = CloudDiskRdbStore.RdbInit();
76     EXPECT_EQ(ret, E_OK);
77 }
78 
79 /**
80  * @tc.name: GetRaw
81  * @tc.desc: Verify the CloudDiskRdbStore::GetRaw function
82  * @tc.type: FUNC
83  * @tc.require: SR000HRKKA
84  */
85 HWTEST_F(CloudDiskRdbStoreTest, GetRawTest1, TestSize.Level1)
86 {
87     const std::string bundleName = "InitRootIdTest";
88     const int32_t userId = 123456789;
89     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
90     EXPECT_TRUE(CloudDiskRdbStore.GetRaw());
91 }
92 
93 /**
94  * @tc.name: LookUp
95  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
96  * @tc.type: FUNC
97  * @tc.require: SR000HRKKA
98  */
99 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest1, TestSize.Level1)
100 {
101     const std::string parentCloudId = "LookUpTest";
102     const std::string fileName = "";
103     const std::string bundleName = "InitRootIdTest";
104     const int32_t userId = 123456789;
105     CloudDiskFileInfo info;
106     info.name = "test.txt";
107     info.cloudId = "1223456";
108     info.parentCloudId = "22222";
109     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
110     int32_t ret = CloudDiskRdbStore.LookUp(parentCloudId, fileName, info);
111     EXPECT_EQ(ret, E_INVAL_ARG);
112 }
113 
114 /**
115  * @tc.name: LookUp
116  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
117  * @tc.type: FUNC
118  * @tc.require: SR000HRKKA
119  */
120 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest2, TestSize.Level1)
121 {
122     const std::string parentCloudId = "";
123     const std::string fileName = "LookUpTest";
124     const std::string bundleName = "InitRootIdTest";
125     const int32_t userId = 123456789;
126     CloudDiskFileInfo info;
127     info.name = "test.txt";
128     info.cloudId = "1223456";
129     info.parentCloudId = "22222";
130     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
131     int32_t ret = CloudDiskRdbStore.LookUp(parentCloudId, fileName, info);
132     EXPECT_EQ(ret, E_INVAL_ARG);
133 }
134 
135 /**
136  * @tc.name: LookUp
137  * @tc.desc: Verify the CloudDiskRdbStore::LookUp function
138  * @tc.type: FUNC
139  * @tc.require: SR000HRKKA
140  */
141 HWTEST_F(CloudDiskRdbStoreTest, LookUpTest3, TestSize.Level1)
142 {
143     const std::string parentCloudId = "100";
144     const std::string fileName = "Test";
145     const std::string bundleName = "com.ohos.photos";
146     const int32_t userId = 100;
147     CloudDiskFileInfo info;
148     info.name = "test.txt";
149     info.cloudId = "1223456";
150     info.parentCloudId = "22222";
151     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
152     int32_t ret = CloudDiskRdbStore.LookUp(parentCloudId, fileName, info);
153     EXPECT_EQ(ret, E_OK);
154 }
155 
156 /**
157  * @tc.name: GetAttr
158  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
159  * @tc.type: FUNC
160  * @tc.require: SR000HRKKA
161  */
162 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest1, TestSize.Level1)
163 {
164     const std::string cloudId = "";
165     const std::string parentCloudId = "123456";
166     const std::string fileName = "LookUpTest";
167     const std::string bundleName = "InitRootIdTest";
168     const int32_t userId = 123456789;
169     CloudDiskFileInfo info;
170     info.name = "test.txt";
171     info.cloudId = "";
172     info.parentCloudId = "22222";
173     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
174     int32_t ret = CloudDiskRdbStore.GetAttr(cloudId, info);
175     EXPECT_EQ(ret, E_INVAL_ARG);
176 }
177 
178 /**
179  * @tc.name: GetAttr
180  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
181  * @tc.type: FUNC
182  * @tc.require: SR000HRKKA
183  */
184 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest2, TestSize.Level1)
185 {
186     const std::string cloudId = "rootId";
187     const std::string parentCloudId = "123456";
188     const std::string fileName = "LookUpTest";
189     const std::string bundleName = "InitRootIdTest";
190     const int32_t userId = 123456789;
191     CloudDiskFileInfo info;
192     info.name = "test.txt";
193     info.cloudId = "rootId";
194     info.parentCloudId = "22222";
195     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
196     int32_t ret = CloudDiskRdbStore.GetAttr(cloudId, info);
197     EXPECT_EQ(ret, E_INVAL_ARG);
198 }
199 
200 /**
201  * @tc.name: GetAttr
202  * @tc.desc: Verify the CloudDiskRdbStore::GetAttr function
203  * @tc.type: FUNC
204  * @tc.require: SR000HRKKA
205  */
206 HWTEST_F(CloudDiskRdbStoreTest, GetAttrTest3, TestSize.Level1)
207 {
208     const std::string cloudId = "100";
209     const std::string bundleName = "com.ohos.photos";
210     const int32_t userId = 100;
211     CloudDiskFileInfo info;
212     info.name = "test.txt";
213     info.cloudId = "1223456";
214     info.parentCloudId = "22222";
215     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
216     int32_t ret = CloudDiskRdbStore.GetAttr(cloudId, info);
217     EXPECT_EQ(ret, E_OK);
218 }
219 
220 /**
221  * @tc.name: SetAttr
222  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
223  * @tc.type: FUNC
224  * @tc.require: SR000HRKKA
225  */
226 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest1, TestSize.Level1)
227 {
228     const std::string fileName = "Test";
229     const std::string parentCloudId = "100";
230     const std::string cloudId = "";
231     const unsigned long long size = 0;
232     const std::string bundleName = "com.ohos.photos";
233     const int32_t userId = 100;
234     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
235     int32_t ret = CloudDiskRdbStore.SetAttr(fileName, parentCloudId, cloudId, size);
236     EXPECT_EQ(ret, E_INVAL_ARG);
237 }
238 
239 /**
240  * @tc.name: SetAttr
241  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
242  * @tc.type: FUNC
243  * @tc.require: SR000HRKKA
244  */
245 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest2, TestSize.Level1)
246 {
247     const std::string fileName = "Test";
248     const std::string parentCloudId = "100";
249     const std::string cloudId = "rootId";
250     const unsigned long long size = 0;
251     const std::string bundleName = "com.ohos.photos";
252     const int32_t userId = 100;
253     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
254     int32_t ret = CloudDiskRdbStore.SetAttr(fileName, parentCloudId, cloudId, size);
255     EXPECT_EQ(ret, E_INVAL_ARG);
256 }
257 
258 /**
259  * @tc.name: SetAttr
260  * @tc.desc: Verify the CloudDiskRdbStore::SetAttr function
261  * @tc.type: FUNC
262  * @tc.require: SR000HRKKA
263  */
264 HWTEST_F(CloudDiskRdbStoreTest, SetAttrTest3, TestSize.Level1)
265 {
266     const std::string fileName = "Test";
267     const std::string parentCloudId = "100";
268     const std::string cloudId = "100";
269     const unsigned long long size = 0;
270     const std::string bundleName = "com.ohos.photos";
271     const int32_t userId = 100;
272     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
273     int32_t ret = CloudDiskRdbStore.SetAttr(fileName, parentCloudId, cloudId, size);
274     EXPECT_EQ(ret, E_OK);
275 }
276 
277 /**
278  * @tc.name: ReadDir
279  * @tc.desc: Verify the CloudDiskRdbStore::ReadDir function
280  * @tc.type: FUNC
281  * @tc.require: SR000HRKKA
282  */
283 HWTEST_F(CloudDiskRdbStoreTest, ReadDirTest1, TestSize.Level1)
284 {
285     const std::string cloudId = "rootId";
286     const std::string bundleName = "com.ohos.photos";
287     const int32_t userId = 100;
288     vector<CloudDiskFileInfo> infos;
289     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
290     int32_t ret = CloudDiskRdbStore.ReadDir(cloudId, infos);
291     EXPECT_EQ(ret, E_OK);
292 }
293 
294 /**
295  * @tc.name: Create
296  * @tc.desc: Verify the CloudDiskRdbStore::Create function
297  * @tc.type: FUNC
298  * @tc.require: SR000HRKKA
299  */
300 HWTEST_F(CloudDiskRdbStoreTest, CreateTest1, TestSize.Level1)
301 {
302     const std::string cloudId = "";
303     const std::string parentCloudId = "3246213";
304     const std::string fileName = "test.txt";
305     const std::string filePath = "/data/test";
306     const std::string bundleName = "MkDirTest";
307     const int32_t userId = 123456789;
308     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
309     int32_t ret = CloudDiskRdbStore.Create(cloudId, parentCloudId, fileName);
310     EXPECT_EQ(ret, E_INVAL_ARG);
311 }
312 
313 /**
314  * @tc.name: Create
315  * @tc.desc: Verify the CloudDiskRdbStore::Create function
316  * @tc.type: FUNC
317  * @tc.require: SR000HRKKA
318  */
319 HWTEST_F(CloudDiskRdbStoreTest, CreateTest2, TestSize.Level1)
320 {
321     const std::string cloudId = "123123";
322     const std::string parentCloudId = "";
323     const std::string fileName = "test.txt";
324     const std::string filePath = "/data/test";
325     const std::string bundleName = "MkDirTest";
326     const int32_t userId = 123456789;
327     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
328     int32_t ret = CloudDiskRdbStore.Create(cloudId, parentCloudId, fileName);
329     EXPECT_EQ(ret, E_INVAL_ARG);
330 }
331 
332 /**
333  * @tc.name: Create
334  * @tc.desc: Verify the CloudDiskRdbStore::Create function
335  * @tc.type: FUNC
336  * @tc.require: SR000HRKKA
337  */
338 HWTEST_F(CloudDiskRdbStoreTest, CreateTest3, TestSize.Level1)
339 {
340     const std::string cloudId = "123123";
341     const std::string parentCloudId = "123456";
342     const std::string fileName = "";
343     const std::string filePath = "/data/test";
344     const std::string bundleName = "MkDirTest";
345     const int32_t userId = 123456789;
346     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
347     int32_t ret = CloudDiskRdbStore.Create(cloudId, parentCloudId, fileName);
348     EXPECT_EQ(ret, EINVAL);
349 }
350 
351 /**
352  * @tc.name: Create
353  * @tc.desc: Verify the CloudDiskRdbStore::Create function
354  * @tc.type: FUNC
355  * @tc.require: SR000HRKKA
356  */
357 HWTEST_F(CloudDiskRdbStoreTest, CreateTest4, TestSize.Level1)
358 {
359     const std::string cloudId = "123123";
360     const std::string parentCloudId = "123456";
361     const std::string fileName = "1.txt";
362     const std::string filePath = "/data/test";
363     const std::string bundleName = "MkDirTest";
364     const int32_t userId = 123456789;
365     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
366     int32_t ret = CloudDiskRdbStore.Create(cloudId, parentCloudId, fileName);
367     EXPECT_EQ(ret, E_PATH);
368 }
369 
370 /**
371  * @tc.name: MkDir
372  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
373  * @tc.type: FUNC
374  * @tc.require: SR000HRKKA
375  */
376 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest1, TestSize.Level1)
377 {
378     const std::string cloudId = "100";
379     const std::string parentCloudId = "100";
380     const std::string directoryName = "";
381     const std::string bundleName = "com.ohos.photos";;
382     const int32_t userId = 100;
383     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
384     int32_t ret = CloudDiskRdbStore.MkDir(cloudId, parentCloudId, directoryName);
385     EXPECT_EQ(ret, EINVAL);
386 }
387 
388 /**
389  * @tc.name: MkDir
390  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
391  * @tc.type: FUNC
392  * @tc.require: SR000HRKKA
393  */
394 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest2, TestSize.Level1)
395 {
396     const std::string cloudId = "100";
397     const std::string parentCloudId = "100";
398     const std::string directoryName = " test.txt";
399     const std::string bundleName = "com.ohos.photos";;
400     const int32_t userId = 100;
401     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
402     int32_t ret = CloudDiskRdbStore.MkDir(cloudId, parentCloudId, directoryName);
403     EXPECT_EQ(ret, EINVAL);
404 }
405 
406 /**
407  * @tc.name: MkDir
408  * @tc.desc: Verify the CloudDiskRdbStore::MkDir function
409  * @tc.type: FUNC
410  * @tc.require: SR000HRKKA
411  */
412 HWTEST_F(CloudDiskRdbStoreTest, MkDirTest3, TestSize.Level1)
413 {
414     const std::string cloudId = "";
415     const std::string parentCloudId = "100";
416     const std::string directoryName = "test.txt";
417     const std::string bundleName = "com.ohos.photos";;
418     const int32_t userId = 100;
419     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
420     int32_t ret = CloudDiskRdbStore.MkDir(cloudId, parentCloudId, directoryName);
421     EXPECT_EQ(ret, E_INVAL_ARG);
422 }
423 
424 /**
425  * @tc.name: Write
426  * @tc.desc: Verify the CloudDiskRdbStore::Write function
427  * @tc.type: FUNC
428  * @tc.require: SR000HRKKA
429  */
430 HWTEST_F(CloudDiskRdbStoreTest, WriteTest1, TestSize.Level1)
431 {
432     const std::string cloudId = "nullptr";
433     const std::string bundleName = "WriteTest";
434     const std::string fileName = "file";
435     const std::string parentCloudId = "rootId";
436     const int32_t userId = 123456789;
437     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
438     int32_t ret = CloudDiskRdbStore.Write(fileName, parentCloudId, cloudId);
439     EXPECT_EQ(ret, E_PATH);
440 }
441 
442 /**
443  * @tc.name: Write
444  * @tc.desc: Verify the CloudDiskRdbStore::Write function
445  * @tc.type: FUNC
446  * @tc.require: SR000HRKKA
447  */
448 HWTEST_F(CloudDiskRdbStoreTest, WriteTest2, TestSize.Level1)
449 {
450     const std::string cloudId = "";
451     const std::string bundleName = "WriteTest";
452     const std::string fileName = "file";
453     const std::string parentCloudId = "rootId";
454     const int32_t userId = 123456789;
455     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
456     int32_t ret = CloudDiskRdbStore.Write(fileName, parentCloudId, cloudId);
457     EXPECT_EQ(ret, E_INVAL_ARG);
458 }
459 
460 /**
461  * @tc.name: Write
462  * @tc.desc: Verify the CloudDiskRdbStore::Write function
463  * @tc.type: FUNC
464  * @tc.require: SR000HRKKA
465  */
466 HWTEST_F(CloudDiskRdbStoreTest, WriteTest3, TestSize.Level1)
467 {
468     const std::string cloudId = "rootId";
469     const std::string bundleName = "WriteTest";
470     const int32_t userId = 123456789;
471     const std::string fileName = "file";
472     const std::string parentCloudId = "rootId";
473     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
474     int32_t ret = CloudDiskRdbStore.Write(fileName, parentCloudId, cloudId);
475     EXPECT_EQ(ret, E_INVAL_ARG);
476 }
477 
478 /**
479  * @tc.name: Write
480  * @tc.desc: Verify the CloudDiskRdbStore::Write function
481  * @tc.type: FUNC
482  * @tc.require: SR000HRKKA
483  */
484 HWTEST_F(CloudDiskRdbStoreTest, WriteTest4, TestSize.Level1)
485 {
486     const std::string cloudId = "123123";
487     const std::string filePath = "/data/test";
488     const std::string bundleName = "MkDirTest";
489     const std::string fileName = "test";
490     const std::string parentCloudId = "rootId";
491     const int32_t userId = 123456789;
492     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
493     int32_t ret = CloudDiskRdbStore.Write(fileName, parentCloudId, cloudId);
494     EXPECT_EQ(ret, E_PATH);
495 }
496 
497 /**
498  * @tc.name: LocationSetXattr
499  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
500  * @tc.type: FUNC
501  * @tc.require: SR000HRKKA
502  */
503 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest1, TestSize.Level1)
504 {
505     const std::string name = "test";
506     const std::string parentCloudId = "100";
507     const std::string cloudId = "100";
508     const std::string value = "4";
509     const std::string bundleName = "com.ohos.photos";
510     const int32_t userId = 100;
511     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
512     int32_t ret = CloudDiskRdbStore.LocationSetXattr(name, parentCloudId, cloudId, value);
513     EXPECT_EQ(ret, E_INVAL_ARG);
514 }
515 
516 /**
517  * @tc.name: LocationSetXattr
518  * @tc.desc: Verify the CloudDiskRdbStore::LocationSetXattr function
519  * @tc.type: FUNC
520  * @tc.require: SR000HRKKA
521  */
522 HWTEST_F(CloudDiskRdbStoreTest, LocationSetXattrTest2, TestSize.Level1)
523 {
524     const std::string name = "test";
525     const std::string parentCloudId = "100";
526     const std::string cloudId = "100";
527     const std::string value = "1";
528     const std::string bundleName = "com.ohos.photos";
529     const int32_t userId = 100;
530     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
531     int32_t ret = CloudDiskRdbStore.LocationSetXattr(name, parentCloudId, cloudId, value);
532     EXPECT_EQ(ret, E_OK);
533 }
534 
535 /**
536  * @tc.name: GetRowId
537  * @tc.desc: Verify the CloudDiskRdbStore::GetRowId function
538  * @tc.type: FUNC
539  * @tc.require: SR000HRKKA
540  */
541 HWTEST_F(CloudDiskRdbStoreTest, GetRowIdTest1, TestSize.Level1)
542 {
543     const std::string cloudId = "100";
544     int64_t rowId = 100;
545     const std::string bundleName = "com.ohos.photos";
546     const int32_t userId = 100;
547     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
548     int32_t ret = CloudDiskRdbStore.GetRowId(cloudId, rowId);
549     EXPECT_EQ(ret, E_RDB);
550 }
551 
552 /**
553  * @tc.name: GetParentCloudId
554  * @tc.desc: Verify the CloudDiskRdbStore::GetParentCloudId function
555  * @tc.type: FUNC
556  * @tc.require: SR000HRKKA
557  */
558 HWTEST_F(CloudDiskRdbStoreTest, GetParentCloudIdTest1, TestSize.Level1)
559 {
560     const std::string cloudId = "100";
561     std::string parentCloudId = "100";
562     const std::string bundleName = "com.ohos.photos";
563     const int32_t userId = 100;
564     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
565     int32_t ret = CloudDiskRdbStore.GetParentCloudId(cloudId, parentCloudId);
566     EXPECT_EQ(ret, E_RDB);
567 }
568 
569 /**
570  * @tc.name: RecycleSetXattr
571  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
572  * @tc.type: FUNC
573  * @tc.require: SR000HRKKA
574  */
575 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest1, TestSize.Level1)
576 {
577     const std::string name = "test";
578     const std::string parentCloudId = "100";
579     const std::string cloudId = "100";
580     const std::string value = "notnum";
581     const std::string bundleName = "com.ohos.photos";
582     const int32_t userId = 100;
583     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
584     int32_t ret = CloudDiskRdbStore.RecycleSetXattr(name, parentCloudId, cloudId, value);
585     EXPECT_EQ(ret, EINVAL);
586 }
587 
588 /**
589  * @tc.name: RecycleSetXattr
590  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
591  * @tc.type: FUNC
592  * @tc.require: SR000HRKKA
593  */
594 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest2, TestSize.Level1)
595 {
596     const std::string name = "test";
597     const std::string parentCloudId = "100";
598     const std::string cloudId = "100";
599     const std::string value = "3";
600     const std::string bundleName = "com.ohos.photos";
601     const int32_t userId = 100;
602     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
603     int32_t ret = CloudDiskRdbStore.RecycleSetXattr(name, parentCloudId, cloudId, value);
604     EXPECT_EQ(ret, E_RDB);
605 }
606 
607 /**
608  * @tc.name: RecycleSetXattr
609  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
610  * @tc.type: FUNC
611  * @tc.require: SR000HRKKA
612  */
613 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest3, TestSize.Level1)
614 {
615     const std::string name = "test";
616     const std::string parentCloudId = "100";
617     const std::string cloudId = "100";
618     const std::string value = "0";
619     const std::string bundleName = "com.ohos.photos";
620     const int32_t userId = 100;
621     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
622     int32_t ret = CloudDiskRdbStore.RecycleSetXattr(name, parentCloudId, cloudId, value);
623     EXPECT_EQ(ret, E_RDB);
624 }
625 
626 /**
627  * @tc.name: RecycleSetXattr
628  * @tc.desc: Verify the CloudDiskRdbStore::RecycleSetXattr function
629  * @tc.type: FUNC
630  * @tc.require: SR000HRKKA
631  */
632 HWTEST_F(CloudDiskRdbStoreTest, RecycleSetXattrTest4, TestSize.Level1)
633 {
634     const std::string name = "test";
635     const std::string parentCloudId = "100";
636     const std::string cloudId = "100";
637     const std::string value = "3";
638     const std::string bundleName = "com.ohos.photos";
639     const int32_t userId = 100;
640     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
641     int32_t ret = CloudDiskRdbStore.RecycleSetXattr(name, parentCloudId, cloudId, value);
642     EXPECT_EQ(ret, E_RDB);
643 }
644 
645 /**
646  * @tc.name: GetXAttr
647  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
648  * @tc.type: FUNC
649  * @tc.require: SR000HRKKA
650  */
651 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest1, TestSize.Level1)
652 {
653     const std::string cloudId = "";
654     const std::string key = CLOUD_FILE_LOCATION;
655     std::string value = "";
656     CacheNode node;
657     node.fileName = "test";
658     node.parentCloudId = "100";
659     const std::string bundleName = "com.ohos.photos";
660     const int32_t userId = 100;
661     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
662     int32_t ret = CloudDiskRdbStore.GetXAttr(cloudId, key, value);
663     EXPECT_EQ(ret, E_OK);
664 }
665 
666 /**
667  * @tc.name: GetXAttr
668  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
669  * @tc.type: FUNC
670  * @tc.require: SR000HRKKA
671  */
672 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest2, TestSize.Level1)
673 {
674     const std::string cloudId = "";
675     const std::string key = IS_FAVORITE_XATTR;
676     std::string value = "";
677     const std::string bundleName = "com.ohos.photos";
678     const int32_t userId = 100;
679     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
680     int32_t ret = CloudDiskRdbStore.GetXAttr(cloudId, key, value);
681     EXPECT_EQ(ret, E_INVAL_ARG);
682 }
683 
684 /**
685  * @tc.name: GetXAttr
686  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
687  * @tc.type: FUNC
688  * @tc.require: SR000HRKKA
689  */
690 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest3, TestSize.Level1)
691 {
692     const std::string cloudId = "";
693     const std::string key = IS_FILE_STATUS_XATTR;
694     std::string value = "";
695     const std::string bundleName = "com.ohos.photos";
696     const int32_t userId = 100;
697     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
698     int32_t ret = CloudDiskRdbStore.GetXAttr(cloudId, key, value);
699     EXPECT_EQ(ret, E_INVAL_ARG);
700 }
701 
702 /**
703  * @tc.name: GetXAttr
704  * @tc.desc: Verify the CloudDiskRdbStore::GetXAttr function
705  * @tc.type: FUNC
706  * @tc.require: SR000HRKKA
707  */
708 HWTEST_F(CloudDiskRdbStoreTest, GetXAttrTest4, TestSize.Level1)
709 {
710     const std::string cloudId = "100";
711     const std::string key = CLOUD_CLOUD_RECYCLE_XATTR;
712     std::string value = "";
713     const std::string bundleName = "com.ohos.photos";
714     const int32_t userId = 100;
715     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
716     int32_t ret = CloudDiskRdbStore.GetXAttr(cloudId, key, value);
717     EXPECT_EQ(ret, E_OK);
718 }
719 
720 /**
721  * @tc.name: SetXAttr
722  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
723  * @tc.type: FUNC
724  * @tc.require: SR000HRKKA
725  */
726 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest1, TestSize.Level1)
727 {
728     const std::string cloudId = "100";
729     const std::string key = CLOUD_FILE_LOCATION;
730     const std::string value = "notnum";
731     const std::string name = "test";
732     const std::string parentCloudId = "100";
733     const std::string bundleName = "com.ohos.photos";
734     const int32_t userId = 100;
735     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
736     int32_t ret = CloudDiskRdbStore.SetXAttr(cloudId, key, value, name, parentCloudId);
737     EXPECT_EQ(ret, E_INVAL_ARG);
738 }
739 
740 /**
741  * @tc.name: SetXAttr
742  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
743  * @tc.type: FUNC
744  * @tc.require: SR000HRKKA
745  */
746 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest2, TestSize.Level1)
747 {
748     const std::string cloudId = "100";
749     const std::string key = CLOUD_CLOUD_RECYCLE_XATTR;
750     const std::string value = "notnum";
751     const std::string name = "test";
752     const std::string parentCloudId = "100";
753     const std::string bundleName = "com.ohos.photos";
754     const int32_t userId = 100;
755     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
756     int32_t ret = CloudDiskRdbStore.SetXAttr(cloudId, key, value, name, parentCloudId);
757     EXPECT_EQ(ret, EINVAL);
758 }
759 
760 /**
761  * @tc.name: SetXAttr
762  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
763  * @tc.type: FUNC
764  * @tc.require: SR000HRKKA
765  */
766 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest3, TestSize.Level1)
767 {
768     const std::string cloudId = "100";
769     const std::string key = IS_FAVORITE_XATTR;
770     const std::string value = "notnum";
771     const std::string name = "test";
772     const std::string parentCloudId = "100";
773     const std::string bundleName = "com.ohos.photos";
774     const int32_t userId = 100;
775     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
776     int32_t ret = CloudDiskRdbStore.SetXAttr(cloudId, key, value, name, parentCloudId);
777     EXPECT_EQ(ret, EINVAL);
778 }
779 
780 /**
781  * @tc.name: SetXAttr
782  * @tc.desc: Verify the CloudDiskRdbStore::SetXAttr function
783  * @tc.type: FUNC
784  * @tc.require: SR000HRKKA
785  */
786 HWTEST_F(CloudDiskRdbStoreTest, SetXAttrTest4, TestSize.Level1)
787 {
788     const std::string cloudId = "100";
789     const std::string key = IS_FILE_STATUS_XATTR;
790     const std::string value = "notnum";
791     const std::string name = "test";
792     const std::string parentCloudId = "100";
793     const std::string bundleName = "com.ohos.photos";
794     const int32_t userId = 100;
795     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
796     int32_t ret = CloudDiskRdbStore.SetXAttr(cloudId, key, value, name, parentCloudId);
797     EXPECT_EQ(ret, E_OK);
798 }
799 
800 /**
801  * @tc.name: Rename
802  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
803  * @tc.type: FUNC
804  * @tc.require: SR000HRKKA
805  */
806 HWTEST_F(CloudDiskRdbStoreTest, RenameTest1, TestSize.Level1)
807 {
808     const std::string oldParentCloudId = "100";
809     const std::string oldFileName = "test";
810     const std::string newParentCloudId = "100";
811     const std::string newFileName = "";
812     const std::string bundleName = "com.ohos.photos";
813     const int32_t userId = 100;
814     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
815     int32_t ret = CloudDiskRdbStore.Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
816     EXPECT_EQ(ret, EINVAL);
817 }
818 
819 /**
820  * @tc.name: Rename
821  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
822  * @tc.type: FUNC
823  * @tc.require: SR000HRKKA
824  */
825 HWTEST_F(CloudDiskRdbStoreTest, RenameTest2, TestSize.Level1)
826 {
827     const std::string oldParentCloudId = "100";
828     const std::string oldFileName = "";
829     const std::string newParentCloudId = "";
830     const std::string newFileName = "test";
831     const std::string bundleName = "com.ohos.photos";
832     const int32_t userId = 100;
833     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
834     int32_t ret = CloudDiskRdbStore.Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
835     EXPECT_EQ(ret, E_INVAL_ARG);
836 }
837 
838 /**
839  * @tc.name: Rename
840  * @tc.desc: Verify the CloudDiskRdbStore::Rename function
841  * @tc.type: FUNC
842  * @tc.require: SR000HRKKA
843  */
844 HWTEST_F(CloudDiskRdbStoreTest, RenameTest3, TestSize.Level1)
845 {
846     const std::string oldParentCloudId = "100";
847     const std::string oldFileName = "test";
848     const std::string newParentCloudId = "100";
849     const std::string newFileName = " test";
850     const std::string bundleName = "com.ohos.photos";
851     const int32_t userId = 100;
852     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
853     int32_t ret = CloudDiskRdbStore.Rename(oldParentCloudId, oldFileName, newParentCloudId, newFileName);
854     EXPECT_EQ(ret, EINVAL);
855 }
856 
857 /**
858  * @tc.name: GetHasChild
859  * @tc.desc: Verify the CloudDiskRdbStore::GetHasChild function
860  * @tc.type: FUNC
861  * @tc.require: SR000HRKKA
862  */
863 HWTEST_F(CloudDiskRdbStoreTest, GetHasChildTest1, TestSize.Level1)
864 {
865     const std::string cloudId = "100";
866     bool hasChild = true;
867     const int32_t userId = 100;
868     const std::string bundleName = "com.ohos.photos";
869     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
870     int32_t ret = CloudDiskRdbStore.GetHasChild(cloudId, hasChild);
871     EXPECT_EQ(ret, E_OK);
872 }
873 
874 /**
875  * @tc.name: UnlinkSynced
876  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkSynced function
877  * @tc.type: FUNC
878  * @tc.require: SR000HRKKA
879  */
880 HWTEST_F(CloudDiskRdbStoreTest, UnlinkSyncedTest1, TestSize.Level1)
881 {
882     const std::string cloudId = "100";
883     const int32_t userId = 100;
884     const std::string bundleName = "com.ohos.photos";
885     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
886     int32_t ret = CloudDiskRdbStore.UnlinkSynced(cloudId);
887     EXPECT_EQ(ret, E_OK);
888 }
889 
890 /**
891  * @tc.name: UnlinkLocal
892  * @tc.desc: Verify the CloudDiskRdbStore::UnlinkLocal function
893  * @tc.type: FUNC
894  * @tc.require: SR000HRKKA
895  */
896 HWTEST_F(CloudDiskRdbStoreTest, UnlinkLocalTest1, TestSize.Level1)
897 {
898     const std::string cloudId = "100";
899     const int32_t userId = 100;
900     const std::string bundleName = "com.ohos.photos";
901     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
902     int32_t ret = CloudDiskRdbStore.UnlinkLocal(cloudId);
903     EXPECT_EQ(ret, E_OK);
904 }
905 
906 /**
907  * @tc.name: Unlink
908  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
909  * @tc.type: FUNC
910  * @tc.require: SR000HRKKA
911  */
912 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest1, TestSize.Level1)
913 {
914     std::string cloudId = "";
915     const int32_t position = LOCAL;
916     const int32_t userId = 100;
917     const std::string bundleName = "com.ohos.photos";
918     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
919     int32_t ret = CloudDiskRdbStore.Unlink(cloudId, position);
920     EXPECT_EQ(ret, E_INVAL_ARG);
921 }
922 
923 /**
924  * @tc.name: Unlink
925  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
926  * @tc.type: FUNC
927  * @tc.require: SR000HRKKA
928  */
929 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest2, TestSize.Level1)
930 {
931     const int32_t position = LOCAL;
932     std::string cloudId = "100";
933     const int32_t userId = 100;
934     const std::string bundleName = "com.ohos.photos";
935     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
936     int32_t ret = CloudDiskRdbStore.Unlink(cloudId, position);
937     EXPECT_EQ(ret, E_OK);
938 }
939 
940 /**
941  * @tc.name: Unlink
942  * @tc.desc: Verify the CloudDiskRdbStore::Unlink function
943  * @tc.type: FUNC
944  * @tc.require: SR000HRKKA
945  */
946 HWTEST_F(CloudDiskRdbStoreTest, UnlinkTest3, TestSize.Level1)
947 {
948     const int32_t position = CLOUD;
949     std::string cloudId = "100";
950     const int32_t userId = 100;
951     const std::string bundleName = "com.ohos.photos";
952     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
953     int32_t ret = CloudDiskRdbStore.Unlink(cloudId, position);
954     EXPECT_EQ(ret, E_OK);
955 }
956 
957 /**
958  * @tc.name: GetDirtyType
959  * @tc.desc: Verify the CloudDiskRdbStore::GetDirtyType function
960  * @tc.type: FUNC
961  * @tc.require: SR000HRKKA
962  */
963 HWTEST_F(CloudDiskRdbStoreTest, GetDirtyTypeTest1, TestSize.Level1)
964 {
965     int32_t dirtyType = 0;
966     std::string cloudId = "100";
967     const int32_t userId = 100;
968     const std::string bundleName = "com.ohos.photos";
969     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
970     int32_t ret = CloudDiskRdbStore.GetDirtyType(cloudId, dirtyType);
971     EXPECT_EQ(ret, E_RDB);
972 }
973 
974 /**
975  * @tc.name: GetCurNode
976  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
977  * @tc.type: FUNC
978  * @tc.require: SR000HRKKA
979  */
980 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest1, TestSize.Level1)
981 {
982     CacheNode curNode;
983     std::string cloudId = "";
984     const int32_t userId = 100;
985     const std::string bundleName = "com.ohos.photos";
986     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
987     int32_t ret = CloudDiskRdbStore.GetCurNode(cloudId, curNode);
988     EXPECT_EQ(ret, E_INVAL_ARG);
989 }
990 
991 /**
992  * @tc.name: GetCurNode
993  * @tc.desc: Verify the CloudDiskRdbStore::GetCurNode function
994  * @tc.type: FUNC
995  * @tc.require: SR000HRKKA
996  */
997 HWTEST_F(CloudDiskRdbStoreTest, GetCurNodeTest2, TestSize.Level1)
998 {
999     CacheNode curNode;
1000     std::string cloudId = "100";
1001     const int32_t userId = 100;
1002     const std::string bundleName = "com.ohos.photos";
1003     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1004     int32_t ret = CloudDiskRdbStore.GetCurNode(cloudId, curNode);
1005     EXPECT_EQ(ret, E_RDB);
1006 }
1007 
1008 /**
1009  * @tc.name: GetParentNode
1010  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
1011  * @tc.type: FUNC
1012  * @tc.require: SR000HRKKA
1013  */
1014 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest1, TestSize.Level1)
1015 {
1016     const std::string parentCloudId = "";
1017     std::string nextCloudId = "100";
1018     std::string fileName = "test";
1019     const int32_t userId = 100;
1020     const std::string bundleName = "com.ohos.photos";
1021     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1022     int32_t ret = CloudDiskRdbStore.GetParentNode(parentCloudId, nextCloudId, fileName);
1023     EXPECT_EQ(ret, E_INVAL_ARG);
1024 }
1025 
1026 /**
1027  * @tc.name: GetParentNode
1028  * @tc.desc: Verify the CloudDiskRdbStore::GetParentNode function
1029  * @tc.type: FUNC
1030  * @tc.require: SR000HRKKA
1031  */
1032 HWTEST_F(CloudDiskRdbStoreTest, GetParentNodeTest2, TestSize.Level1)
1033 {
1034     const std::string parentCloudId = "100";
1035     std::string nextCloudId = "100";
1036     std::string fileName = "test";
1037     const int32_t userId = 100;
1038     const std::string bundleName = "com.ohos.photos";
1039     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1040     int32_t ret = CloudDiskRdbStore.GetParentNode(parentCloudId, nextCloudId, fileName);
1041     EXPECT_EQ(ret, E_RDB);
1042 }
1043 
1044 /**
1045  * @tc.name: GetUriFromDB
1046  * @tc.desc: Verify the CloudDiskRdbStore::GetUriFromDB function
1047  * @tc.type: FUNC
1048  * @tc.require: SR000HRKKA
1049  */
1050 HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest1, TestSize.Level1)
1051 {
1052     const std::string parentCloudId = "";
1053     std::string uri = "100";
1054     const int32_t userId = 100;
1055     const std::string bundleName = "com.ohos.photos";
1056     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1057     int32_t ret = CloudDiskRdbStore.GetUriFromDB(parentCloudId, uri);
1058     EXPECT_EQ(ret, E_OK);
1059 }
1060 
1061 /**
1062  * @tc.name: GetUriFromDB
1063  * @tc.desc: Verify the CloudDiskRdbStore::GetUriFromDB function
1064  * @tc.type: FUNC
1065  * @tc.require: SR000HRKKA
1066  */
1067 HWTEST_F(CloudDiskRdbStoreTest, GetUriFromDBTest2, TestSize.Level1)
1068 {
1069     const std::string parentCloudId = "100";
1070     std::string uri = "100";
1071     const int32_t userId = 100;
1072     const std::string bundleName = "com.ohos.photos";
1073     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1074     int32_t ret = CloudDiskRdbStore.GetUriFromDB(parentCloudId, uri);
1075     EXPECT_EQ(ret, E_RDB);
1076 }
1077 
1078 /**
1079  * @tc.name: GetNotifyUri
1080  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyUri function
1081  * @tc.type: FUNC
1082  * @tc.require: SR000HRKKA
1083  */
1084 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyUriTest1, TestSize.Level1)
1085 {
1086     CacheNode cacheNode;
1087     std::string uri = "100";
1088     const int32_t userId = 100;
1089     const std::string bundleName = "com.ohos.photos";
1090     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1091     int32_t ret = CloudDiskRdbStore.GetNotifyUri(cacheNode, uri);
1092     EXPECT_EQ(ret, E_INVAL_ARG);
1093 }
1094 
1095 /**
1096  * @tc.name: GetNotifyData
1097  * @tc.desc: Verify the CloudDiskRdbStore::GetNotifyData function
1098  * @tc.type: FUNC
1099  * @tc.require: SR000HRKKA
1100  */
1101 HWTEST_F(CloudDiskRdbStoreTest, GetNotifyDataTest1, TestSize.Level1)
1102 {
1103     CacheNode cacheNode;
1104     NotifyData notifyData;
1105     const int32_t userId = 100;
1106     const std::string bundleName = "com.ohos.photos";
1107     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1108     int32_t ret = CloudDiskRdbStore.GetNotifyData(cacheNode, notifyData);
1109     EXPECT_EQ(ret, E_INVAL_ARG);
1110 }
1111 
1112 /**
1113  * @tc.name: FavoriteSetXattr
1114  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1115  * @tc.type: FUNC
1116  * @tc.require: SR000HRKKA
1117  */
1118 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest1, TestSize.Level1)
1119 {
1120     const std::string cloudId = "root";
1121     const std::string value = "notnum";
1122     const std::string bundleName = "com.ohos.photos";
1123     const int32_t userId = 100;
1124     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1125     int32_t ret = CloudDiskRdbStore.FavoriteSetXattr(cloudId, value);
1126     EXPECT_EQ(ret, EINVAL);
1127 }
1128 
1129 /**
1130  * @tc.name: FavoriteSetXattr
1131  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1132  * @tc.type: FUNC
1133  * @tc.require: SR000HRKKA
1134  */
1135 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest2, TestSize.Level1)
1136 {
1137     const std::string cloudId = "root";
1138     const std::string value = "0";
1139     const std::string bundleName = "com.ohos.photos";
1140     const int32_t userId = 100;
1141     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1142     int32_t ret = CloudDiskRdbStore.FavoriteSetXattr(cloudId, value);
1143     EXPECT_EQ(ret, E_OK);
1144 }
1145 
1146 /**
1147  * @tc.name: FavoriteSetXattr
1148  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1149  * @tc.type: FUNC
1150  * @tc.require: SR000HRKKA
1151  */
1152 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest3, TestSize.Level1)
1153 {
1154     const std::string cloudId = "root";
1155     const std::string value = "1";
1156     const std::string bundleName = "com.ohos.photos";
1157     const int32_t userId = 100;
1158     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1159     int32_t ret = CloudDiskRdbStore.FavoriteSetXattr(cloudId, value);
1160     EXPECT_EQ(ret, E_OK);
1161 }
1162 
1163 /**
1164  * @tc.name: FavoriteSetXattr
1165  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteSetXattr function
1166  * @tc.type: FUNC
1167  * @tc.require: SR000HRKKA
1168  */
1169 HWTEST_F(CloudDiskRdbStoreTest, FavoriteSetXattrTest4, TestSize.Level1)
1170 {
1171     const std::string cloudId = "root";
1172     const std::string value = "2";
1173     const std::string bundleName = "com.ohos.photos";
1174     const int32_t userId = 100;
1175     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1176     int32_t ret = CloudDiskRdbStore.FavoriteSetXattr(cloudId, value);
1177     EXPECT_EQ(ret, E_RDB);
1178 }
1179 
1180 /**
1181  * @tc.name: LocationGetXattr
1182  * @tc.desc: Verify the CloudDiskRdbStore::LocationGetXattr function
1183  * @tc.type: FUNC
1184  * @tc.require: SR000HRKKA
1185  */
1186 HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest1, TestSize.Level1)
1187 {
1188     const std::string cloudId = "";
1189     const std::string key = IS_FAVORITE_XATTR;
1190     std::string value = "";
1191     const std::string bundleName = "com.ohos.photos";
1192     const std::string name = "test";
1193     const std::string parentCloudId = "rootId";
1194     const int32_t userId = 100;
1195     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1196     int32_t ret = CloudDiskRdbStore.LocationGetXattr(name, key, value, parentCloudId);
1197     EXPECT_EQ(ret, E_INVAL_ARG);
1198 }
1199 
1200 /**
1201  * @tc.name: LocationGetXattr
1202  * @tc.desc: Verify the CloudDiskRdbStore::LocationGetXattr function
1203  * @tc.type: FUNC
1204  * @tc.require: SR000HRKKA
1205  */
1206 HWTEST_F(CloudDiskRdbStoreTest, LocationGetXattrTest2, TestSize.Level1)
1207 {
1208     const std::string cloudId = "";
1209     const std::string key = CLOUD_FILE_LOCATION;
1210     std::string value = "";
1211     const std::string bundleName = "com.ohos.photos";
1212     const std::string name = "test";
1213     const std::string parentCloudId = "rootId";
1214     const int32_t userId = 100;
1215     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1216     int32_t ret = CloudDiskRdbStore.LocationGetXattr(name, key, value, parentCloudId);
1217     EXPECT_EQ(ret, E_OK);
1218 }
1219 
1220 /**
1221  * @tc.name: FavoriteGetXattr
1222  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1223  * @tc.type: FUNC
1224  * @tc.require: SR000HRKKA
1225  */
1226 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest1, TestSize.Level1)
1227 {
1228     const std::string cloudId = "";
1229     const std::string key = CLOUD_FILE_LOCATION;
1230     std::string value = "";
1231     const std::string bundleName = "com.ohos.photos";
1232     const int32_t userId = 100;
1233     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1234     int32_t ret = CloudDiskRdbStore.FavoriteGetXattr(cloudId, key, value);
1235     EXPECT_EQ(ret, E_INVAL_ARG);
1236 }
1237 
1238 /**
1239  * @tc.name: FavoriteGetXattr
1240  * @tc.desc: Verify the CloudDiskRdbStore::FavoriteGetXattr function
1241  * @tc.type: FUNC
1242  * @tc.require: SR000HRKKA
1243  */
1244 HWTEST_F(CloudDiskRdbStoreTest, FavoriteGetXattrTest2, TestSize.Level1)
1245 {
1246     const std::string cloudId = "cloudId";
1247     const std::string key = IS_FAVORITE_XATTR;
1248     std::string value = "";
1249     const std::string bundleName = "com.ohos.photos";
1250     const int32_t userId = 100;
1251     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1252     int32_t ret = CloudDiskRdbStore.FavoriteGetXattr(cloudId, key, value);
1253     EXPECT_EQ(ret, E_RDB);
1254 }
1255 
1256 /**
1257  * @tc.name: FileStatusGetXattr
1258  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1259  * @tc.type: FUNC
1260  * @tc.require: SR000HRKKA
1261  */
1262 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest1, TestSize.Level1)
1263 {
1264     const std::string cloudId = "";
1265     const std::string key = IS_FAVORITE_XATTR;
1266     std::string value = "";
1267     const std::string bundleName = "com.ohos.photos";
1268     const int32_t userId = 100;
1269     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1270     int32_t ret = CloudDiskRdbStore.FileStatusGetXattr(cloudId, key, value);
1271     EXPECT_EQ(ret, E_INVAL_ARG);
1272 }
1273 
1274 /**
1275  * @tc.name: FileStatusGetXattr
1276  * @tc.desc: Verify the CloudDiskRdbStore::FileStatusGetXattr function
1277  * @tc.type: FUNC
1278  * @tc.require: SR000HRKKA
1279  */
1280 HWTEST_F(CloudDiskRdbStoreTest, FileStatusGetXattrTest2, TestSize.Level1)
1281 {
1282     const std::string cloudId = "cloudId";
1283     const std::string key = IS_FILE_STATUS_XATTR;
1284     std::string value = "";
1285     const std::string bundleName = "com.ohos.photos";
1286     const int32_t userId = 100;
1287     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1288     int32_t ret = CloudDiskRdbStore.FileStatusGetXattr(cloudId, key, value);
1289     EXPECT_EQ(ret, E_RDB);
1290 }
1291 
1292 /**
1293  * @tc.name: OnUpgrade
1294  * @tc.desc: Verify the CloudDiskRdbStore::OnUpgrade function
1295  * @tc.type: FUNC
1296  * @tc.require: SR000HRKKA
1297  */
1298 HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest1, TestSize.Level1)
1299 {
1300     RdbStoreMock store;
1301     int32_t oldVersion = 8;
1302     int32_t newVersion = 9;
1303     const std::string bundleName = "com.ohos.photos";
1304     const int32_t userId = 100;
1305     CloudDiskDataCallBack CloudDiskDataCallBack;
1306     int32_t ret = CloudDiskDataCallBack.OnUpgrade(store, oldVersion, newVersion);
1307     EXPECT_EQ(ret, E_OK);
1308 }
1309 
1310 /**
1311  * @tc.name: OnUpgrade
1312  * @tc.desc: Verify the CloudDiskRdbStore::OnUpgrade function
1313  * @tc.type: FUNC
1314  */
1315 HWTEST_F(CloudDiskRdbStoreTest, OnUpgradeTest2, TestSize.Level1)
1316 {
1317     RdbStoreMock store;
1318     int32_t oldVersion = 11;
1319     int32_t newVersion = 12;
1320     const std::string bundleName = "com.ohos.photos";
1321     const int32_t userId = 100;
1322     CloudDiskDataCallBack CloudDiskDataCallBack;
1323     int32_t ret = CloudDiskDataCallBack.OnUpgrade(store, oldVersion, newVersion);
1324     EXPECT_EQ(ret, E_OK);
1325 }
1326 
1327 /**
1328  * @tc.name: ExtAttributeSetXattr
1329  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1330  * @tc.type: FUNC
1331  */
1332 HWTEST_F(CloudDiskRdbStoreTest, ExtAttributeSetXattrTest1, TestSize.Level1)
1333 {
1334     const std::string cloudId = "root";
1335     const std::string key = "user.cloud.test1";
1336     const std::string value = "1";
1337     const std::string bundleName = "com.ohos.photos";
1338     const int32_t userId = 100;
1339     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1340     int32_t ret = CloudDiskRdbStore.ExtAttributeSetXattr(cloudId, value, key);
1341     EXPECT_EQ(ret, E_OK);
1342 }
1343 
1344 /**
1345  * @tc.name: GetExtAttrValue
1346  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1347  * @tc.type: FUNC
1348  */
1349 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrValueTest1, TestSize.Level1)
1350 {
1351     const std::string cloudId = "root";
1352     const std::string key = "user.cloud.test2";
1353     std::string value = "";
1354     const std::string bundleName = "com.ohos.photos";
1355     const int32_t userId = 100;
1356     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1357     int32_t ret = CloudDiskRdbStore.GetExtAttrValue(cloudId, key, value);
1358     EXPECT_EQ(ret, E_RDB);
1359 }
1360 
1361 /**
1362  * @tc.name: GetExtAttr
1363  * @tc.desc: Verify the CloudDiskRdbStore::ExtAttributeSetXattr function
1364  * @tc.type: FUNC
1365  */
1366 HWTEST_F(CloudDiskRdbStoreTest, GetExtAttrTest1, TestSize.Level1)
1367 {
1368     const std::string cloudId = "root";
1369     std::string value = "";
1370     const std::string bundleName = "com.ohos.photos";
1371     const int32_t userId = 100;
1372     int32_t pos = 0;
1373     CloudDiskRdbStore CloudDiskRdbStore(bundleName, userId);
1374     int32_t ret = CloudDiskRdbStore.GetExtAttr(cloudId, value, pos);
1375     EXPECT_EQ(ret, E_RDB);
1376 }
1377 } // namespace OHOS::FileManagement::CloudDisk::Test