• 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 #define LOG_TAG "RdbAssetLoaderTest"
16 
17 #include "rdb_asset_loader.h"
18 
19 #include "log_print.h"
20 #include "object_snapshot.h"
21 #include "rdb_notifier_proxy.h"
22 #include "rdb_watcher.h"
23 #include "store/cursor.h"
24 #include "store/general_value.h"
25 #include "store/general_watcher.h"
26 #include "gtest/gtest.h"
27 
28 using namespace OHOS;
29 using namespace testing;
30 using namespace testing::ext;
31 using namespace OHOS::DistributedRdb;
32 using namespace OHOS::DistributedData;
33 using Type = DistributedDB::Type;
34 using AssetsRecord = DistributedData::AssetRecord;
35 const DistributedDB::Asset g_rdbAsset = { .version = 1,
36     .name = "Phone",
37     .assetId = "0",
38     .subpath = "/local/sync",
39     .uri = "file://rdbtest/local/sync",
40     .modifyTime = "123456",
41     .createTime = "createTime",
42     .size = "256",
43     .hash = "ASE" };
44 namespace OHOS::Test {
45 namespace DistributedRDBTest {
46 class RdbAssetLoaderTest : public testing::Test {
47 public:
SetUpTestCase(void)48     static void SetUpTestCase(void){};
TearDownTestCase(void)49     static void TearDownTestCase(void){};
SetUp()50     void SetUp(){};
TearDown()51     void TearDown(){};
52 };
53 
54 class MockAssetLoader : public DistributedData::AssetLoader {
55 public:
Download(const std::string & tableName,const std::string & gid,const DistributedData::Value & prefix,VBucket & assets)56     int32_t Download(const std::string &tableName, const std::string &gid,
57         const DistributedData::Value &prefix, VBucket &assets) override
58     {
59         return GeneralError::E_OK;
60     }
61 
RemoveLocalAssets(const std::string & tableName,const std::string & gid,const DistributedData::Value & prefix,VBucket & assets)62     int32_t RemoveLocalAssets(const std::string &tableName, const std::string &gid,
63         const DistributedData::Value &prefix, VBucket &assets) override
64     {
65         return GeneralError::E_OK;
66     }
67 
CancelDownload()68     int32_t CancelDownload() override
69     {
70         return GeneralError::E_OK;
71     }
72 };
73 
74 class RdbWatcherTest : public testing::Test {
75 public:
SetUpTestCase(void)76     static void SetUpTestCase(void){};
TearDownTestCase(void)77     static void TearDownTestCase(void){};
SetUp()78     void SetUp(){};
TearDown()79     void TearDown(){};
80 };
81 
82 /**
83 * @tc.name: Download
84 * @tc.desc: RdbAssetLoader download test.
85 * @tc.type: FUNC
86 * @tc.require:
87 * @tc.author: SQL
88 */
89 HWTEST_F(RdbAssetLoaderTest, Download, TestSize.Level0)
90 {
91     BindAssets bindAssets;
92     std::shared_ptr<MockAssetLoader> cloudAssetLoader = std::make_shared<MockAssetLoader>();
93     DistributedRdb::RdbAssetLoader rdbAssetLoader(cloudAssetLoader, bindAssets);
94     std::string tableName = "testTable";
95     std::string groupId = "testGroup";
96     Type prefix;
97     std::map<std::string, DistributedDB::Assets> assets;
98     assets["asset1"].push_back(g_rdbAsset);
99     auto result = rdbAssetLoader.Download(tableName, groupId, prefix, assets);
100     EXPECT_EQ(result, DistributedDB::DBStatus::OK);
101 }
102 
103 /**
104 * @tc.name: BatchDownload
105 * @tc.desc: RdbAssetLoader batch download test.
106 * @tc.type: FUNC
107 * @tc.require:
108 * @tc.author:
109 */
110 HWTEST_F(RdbAssetLoaderTest, BatchDownload, TestSize.Level0)
111 {
112     BindAssets bindAssets;
113     auto cloudAssetLoader = std::make_shared<AssetLoader>();
114     DistributedRdb::RdbAssetLoader rdbAssetLoader(cloudAssetLoader, bindAssets);
115     std::string tableName = "testTable";
116     Type prefix;
117     std::map<std::string, DistributedDB::Assets> assets;
118     assets["asset1"].push_back(g_rdbAsset);
119     std::vector<DistributedDB::IAssetLoader::AssetRecord> assetRecords;
120     DistributedDB::IAssetLoader::AssetRecord assetRecord { .gid = "gid", .prefix = prefix, .assets = assets };
121     assetRecords.emplace_back(assetRecord);
122     rdbAssetLoader.BatchDownload(tableName, assetRecords);
123     ASSERT_TRUE(!assetRecords.empty());
124     EXPECT_EQ(assetRecords[0].status, DistributedDB::DBStatus::OK);
125 }
126 
127 /**
128 * @tc.name: Convert001
129 * @tc.desc: Convert test.
130 * @tc.type: FUNC
131 * @tc.require:
132 * @tc.author:
133 */
134 HWTEST_F(RdbAssetLoaderTest, Convert001, TestSize.Level0)
135 {
136     BindAssets bindAssets;
137     auto cloudAssetLoader = std::make_shared<AssetLoader>();
138     DistributedRdb::RdbAssetLoader rdbAssetLoader(cloudAssetLoader, bindAssets);
139     Type prefix;
140     std::map<std::string, DistributedDB::Assets> assets;
141     assets["asset1"].push_back(g_rdbAsset);
142     std::vector<DistributedDB::IAssetLoader::AssetRecord> assetRecords;
143     DistributedDB::IAssetLoader::AssetRecord assetRecord { .gid = "gid", .prefix = prefix, .assets = assets };
144     assetRecords.emplace_back(assetRecord);
145     assetRecords.emplace_back(assetRecord);
146     auto assetsRecords = rdbAssetLoader.Convert(std::move(assetRecords));
147     EXPECT_TRUE(!assetsRecords.empty());
148 }
149 
150 /**
151 * @tc.name: Convert002
152 * @tc.desc: Convert test.
153 * @tc.type: FUNC
154 * @tc.require:
155 * @tc.author:
156 */
157 HWTEST_F(RdbAssetLoaderTest, Convert002, TestSize.Level0)
158 {
159     BindAssets bindAssets;
160     auto cloudAssetLoader = std::make_shared<AssetLoader>();
161     DistributedRdb::RdbAssetLoader rdbAssetLoader(cloudAssetLoader, bindAssets);
162     Value prefix;
163     VBucket assets;
164     std::vector<AssetsRecord> assetsRecords;
165     AssetRecord assetsRecord { .gid = "gid", .prefix = prefix, .assets = assets };
166     assetsRecords.emplace_back(assetsRecord);
167     auto assetRecords = rdbAssetLoader.Convert(std::move(assetsRecords));
168     EXPECT_TRUE(!assetRecords.empty());
169 }
170 
171 /**
172 * @tc.name: RemoveLocalAssets
173 * @tc.desc: RdbAssetLoader RemoveLocalAssets test.
174 * @tc.type: FUNC
175 * @tc.require:
176 * @tc.author: SQL
177 */
178 HWTEST_F(RdbAssetLoaderTest, RemoveLocalAssets, TestSize.Level0)
179 {
180     BindAssets bindAssets;
181     std::shared_ptr<MockAssetLoader> cloudAssetLoader = std::make_shared<MockAssetLoader>();
182     DistributedRdb::RdbAssetLoader rdbAssetLoader(cloudAssetLoader, bindAssets);
183     std::vector<DistributedDB::Asset> assets;
184     assets.push_back(g_rdbAsset);
185     auto result = rdbAssetLoader.RemoveLocalAssets(assets);
186     EXPECT_EQ(result, DistributedDB::DBStatus::OK);
187 }
188 
189 /**
190 * @tc.name: CancelDownloadTest
191 * @tc.desc: RdbAssetLoader CancelDownload test.
192 * @tc.type: FUNC
193 * @tc.require:
194 * @tc.author: Hollokin
195 */
196 HWTEST_F(RdbAssetLoaderTest, CancelDownloadTest, TestSize.Level0)
197 {
198     BindAssets bindAssets;
199     DistributedRdb::RdbAssetLoader rdbAssetLoader1(nullptr, bindAssets);
200     auto result = rdbAssetLoader1.CancelDownload();
201     EXPECT_EQ(result, DistributedDB::DBStatus::DB_ERROR);
202 
203     std::shared_ptr<MockAssetLoader> cloudAssetLoader = std::make_shared<MockAssetLoader>();
204     DistributedRdb::RdbAssetLoader rdbAssetLoader2(cloudAssetLoader, bindAssets);
205     result = rdbAssetLoader2.CancelDownload();
206     EXPECT_EQ(result, DistributedDB::DBStatus::OK);
207 }
208 
209 /**
210 * @tc.name: PostEvent001
211 * @tc.desc: RdbAssetLoader PostEvent001 test
212 * @tc.type: FUNC
213 * @tc.require:
214 * @tc.author: SQL
215 */
216 HWTEST_F(RdbAssetLoaderTest, PostEvent001, TestSize.Level0)
217 {
218     BindAssets bindAssets = nullptr;
219     std::shared_ptr<AssetLoader> assetLoader = std::make_shared<AssetLoader>();
220     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
221     std::string tableName = "testTable";
222     std::string groupId = "testGroup";
223     Type prefix;
224     std::map<std::string, DistributedDB::Assets> assets;
225     assets["asset1"].push_back(g_rdbAsset);
226     auto result = rdbAssetLoader.Download(tableName, groupId, prefix, assets);
227     EXPECT_EQ(result, DistributedDB::DBStatus::CLOUD_ERROR);
228 }
229 
230 /**
231 * @tc.name: PostEvent002
232 * @tc.desc: RdbAssetLoader PostEvent002 test
233 * @tc.type: FUNC
234 * @tc.require:
235 * @tc.author: SQL
236 */
237 HWTEST_F(RdbAssetLoaderTest, PostEvent002, TestSize.Level0)
238 {
239     DistributedData::Asset asset = {
240         .name = "",
241         .id = "",
242         .path = "",
243         .uri = "",
244         .modifyTime = "",
245         .createTime = "",
246         .size = "",
247         .hash = "",
248         .status = DistributedData::Asset::STATUS_DELETE,
249     };
250     DistributedData::Assets assets;
251     assets.push_back(asset);
252     BindAssets bindAssets = nullptr;
253     std::shared_ptr<AssetLoader> assetLoader = std::make_shared<AssetLoader>();
254     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
255     std::set<std::string> skipAssets;
256     std::set<std::string> deleteAssets;
257     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::DOWNLOAD, assets, skipAssets, deleteAssets);
258     EXPECT_EQ(deleteAssets.size(), 1);
259 }
260 
261 /**
262 @tc.name: PostEvent003
263 @tc.desc: RdbAssetLoader PostEvent003 test
264 @tc.type: FUNC
265 @tc.require:
266 @tc.author: SQL
267 */
268 HWTEST_F(RdbAssetLoaderTest, PostEvent003, TestSize.Level0) {
269     DistributedData::Asset asset = {
270       .name = "",
271       .id = "",
272       .path = "",
273       .uri = "",
274       .modifyTime = "",
275       .createTime = "",
276       .size = "",
277       .hash = "",
278       .status = DistributedData::Asset::STATUS_NORMAL,
279     };
280     DistributedData::Assets assets;
281     assets.push_back(asset);
282     BindAssets bindAssets = nullptr;
283     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
284     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
285     std::set<std::string> skipAssets;
286     std::set<std::string> deleteAssets;
287     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::DOWNLOAD, assets, skipAssets, deleteAssets);
288     EXPECT_EQ(deleteAssets.size(), 0);
289     EXPECT_EQ(skipAssets.size(), 0);
290 }
291 
292 /**
293 @tc.name: PostEvent004
294 @tc.desc: RdbAssetLoader PostEvent004 test,snapshots_ can find data with a value of null
295 @tc.type: FUNC
296 @tc.require:
297 @tc.author: SQL
298 */
299 HWTEST_F(RdbAssetLoaderTest, PostEvent004, TestSize.Level0) {
300     DistributedData::Asset asset = {
301         .name = "",
302         .id = "",
303         .path = "",
304         .uri = "PostEvent004",
305         .modifyTime = "",
306         .createTime = "",
307         .size = "",
308         .hash = "",
309         .status = DistributedData::Asset::STATUS_NORMAL,
310     };
311     DistributedData::Assets assets;
312     assets.push_back(asset);
313     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
314     bindAssets->insert({"PostEvent004", nullptr});
315     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
316     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
317     std::set<std::string> skipAssets;
318     std::set<std::string> deleteAssets;
319     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::DOWNLOAD, assets, skipAssets, deleteAssets);
320     EXPECT_EQ(deleteAssets.size(), 0);
321     EXPECT_EQ(skipAssets.size(), 0);
322 }
323 
324 /**
325 @tc.name: PostEvent005
326 @tc.desc: RdbAssetLoader PostEvent005 test,snapshots_ can find data and the value is not null
327 @tc.type: FUNC
328 @tc.require:
329 @tc.author: SQL
330 */
331 HWTEST_F(RdbAssetLoaderTest, PostEvent005, TestSize.Level0) {
332     class ObjectSnapshotMock : public DistributedObject::ObjectSnapshot {
333     public:
Download(Asset & asset)334         int32_t Download(Asset &asset) override {
335         hasDownload = true;
336         return 0;
337         }
338         bool hasDownload = false;
339     };
340     DistributedData::Asset asset = {
341         .name = "",
342         .id = "",
343         .path = "",
344         .uri = "PostEvent005",
345         .modifyTime = "",
346         .createTime = "",
347         .size = "",
348         .hash = "",
349         .status = DistributedData::Asset::STATUS_NORMAL,
350     };
351     DistributedData::Assets assets;
352     assets.push_back(asset);
353     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
354     auto objectSnapshotMock = std::make_shared<ObjectSnapshotMock>();
355     bindAssets->insert({"PostEvent005", objectSnapshotMock});
356     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
357     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
358     std::set<std::string> skipAssets;
359     std::set<std::string> deleteAssets;
360     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::DOWNLOAD, assets,
361                             skipAssets, deleteAssets);
362     EXPECT_EQ(objectSnapshotMock->hasDownload, true);
363 }
364 
365 /**
366 @tc.name: PostEvent006
367 @tc.desc: RdbAssetLoader PostEvent006 test,snapshots_ not found
368 @tc.type: FUNC
369 @tc.require:
370 @tc.author: SQL
371 */
372 HWTEST_F(RdbAssetLoaderTest, PostEvent006, TestSize.Level0) {
373     DistributedData::Asset asset = {
374         .name = "",
375         .id = "",
376         .path = "",
377         .uri = "",
378         .modifyTime = "",
379         .createTime = "",
380         .size = "",
381         .hash = "",
382         .status = DistributedData::Asset::STATUS_NORMAL,
383     };
384     DistributedData::Assets assets;
385     assets.push_back(asset);
386     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
387     bindAssets->insert({"PostEvent006", std::make_shared<DistributedObject::ObjectSnapshot>()});
388     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
389     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
390     std::set<std::string> skipAssets;
391     std::set<std::string> deleteAssets;
392     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::DOWNLOAD, assets, skipAssets, deleteAssets);
393     EXPECT_EQ(deleteAssets.size(), 0);
394     EXPECT_EQ(skipAssets.size(), 0);
395 }
396 
397 /**
398 @tc.name: PostEvent007
399 @tc.desc: RdbAssetLoader PostEvent007 test, Both deleteAssets and skipAssets can be found.
400 @tc.type: FUNC
401 @tc.require:
402 @tc.author: SQL
403 */
404 HWTEST_F(RdbAssetLoaderTest, PostEvent007, TestSize.Level0) {
405     class ObjectSnapshotMock : public DistributedObject::ObjectSnapshot {
406     public:
Downloaded(Asset & asset)407         int32_t Downloaded(Asset &asset) override {
408         hasDownloaded = true;
409         return 0;
410         }
411         bool hasDownloaded = false;
412     };
413     DistributedData::Asset asset = {
414         .name = "",
415         .id = "",
416         .path = "",
417         .uri = "PostEvent007",
418         .modifyTime = "",
419         .createTime = "",
420         .size = "",
421         .hash = "",
422         .status = DistributedData::Asset::STATUS_NORMAL,
423     };
424     DistributedData::Assets assets;
425     assets.push_back(asset);
426     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
427     auto objectSnapshotMock = std::make_shared<ObjectSnapshotMock>();
428     bindAssets->insert({"PostEvent007", objectSnapshotMock});
429     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
430     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
431     std::set<std::string> skipAssets;
432     skipAssets.insert("PostEvent007");
433     std::set<std::string> deleteAssets;
434     deleteAssets.insert("PostEvent007");
435     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::UPLOAD, assets, skipAssets, deleteAssets);
436     EXPECT_EQ(objectSnapshotMock->hasDownloaded, false);
437 }
438 
439 /**
440 @tc.name: PostEvent008
441 @tc.desc: RdbAssetLoader PostEvent008 test, Neither deleteAssets nor skipAssets can be found.
442 @tc.type: FUNC
443 @tc.require:
444 @tc.author: SQL
445 */
446 HWTEST_F(RdbAssetLoaderTest, PostEvent008, TestSize.Level0) {
447     class ObjectSnapshotMock : public DistributedObject::ObjectSnapshot {
448     public:
Downloaded(Asset & asset)449         int32_t Downloaded(Asset &asset) override {
450         hasDownloaded = true;
451         return 0;
452         }
453         bool hasDownloaded = false;
454     };
455     DistributedData::Asset asset = {
456         .name = "",
457         .id = "",
458         .path = "",
459         .uri = "PostEvent008",
460         .modifyTime = "",
461         .createTime = "",
462         .size = "",
463         .hash = "",
464         .status = DistributedData::Asset::STATUS_NORMAL,
465     };
466     DistributedData::Assets assets;
467     assets.push_back(asset);
468     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
469     auto objectSnapshotMock = std::make_shared<ObjectSnapshotMock>();
470     bindAssets->insert({"PostEvent008", objectSnapshotMock});
471     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
472     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
473     std::set<std::string> skipAssets;
474     std::set<std::string> deleteAssets;
475     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::UPLOAD, assets, skipAssets, deleteAssets);
476     EXPECT_EQ(objectSnapshotMock->hasDownloaded, true);
477 }
478 /**
479 
480 @tc.name: PostEvent009
481 @tc.desc: RdbAssetLoader PostEvent009 test, deleteAssets can be found, skipAssets cannot be found.
482 @tc.type: FUNC
483 @tc.require:
484 @tc.author: SQL
485 */
486 HWTEST_F(RdbAssetLoaderTest, PostEvent009, TestSize.Level0) {
487     class ObjectSnapshotMock : public DistributedObject::ObjectSnapshot {
488     public:
Downloaded(Asset & asset)489         int32_t Downloaded(Asset &asset) override {
490         hasDownloaded = true;
491         return 0;
492         }
493         bool hasDownloaded = false;
494     };
495     DistributedData::Asset asset = {
496         .name = "",
497         .id = "",
498         .path = "",
499         .uri = "PostEvent009",
500         .modifyTime = "",
501         .createTime = "",
502         .size = "",
503         .hash = "",
504         .status = DistributedData::Asset::STATUS_NORMAL,
505     };
506     DistributedData::Assets assets;
507     assets.push_back(asset);
508     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
509     auto objectSnapshotMock = std::make_shared<ObjectSnapshotMock>();
510     bindAssets->insert({"PostEvent009", objectSnapshotMock});
511     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
512     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
513     std::set<std::string> skipAssets;
514     std::set<std::string> deleteAssets;
515     deleteAssets.insert("PostEvent009");
516     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::UPLOAD, assets, skipAssets, deleteAssets);
517     EXPECT_EQ(objectSnapshotMock->hasDownloaded, false);
518 }
519 
520 /**
521 @tc.name: PostEvent0010
522 @tc.desc: RdbAssetLoader PostEvent0010 test, skipAssets can be found, deleteAssets cannot be found.
523 @tc.type: FUNC
524 @tc.require:
525 @tc.author: SQL
526 */
527 HWTEST_F(RdbAssetLoaderTest, PostEvent0010, TestSize.Level0) {
528     class ObjectSnapshotMock : public DistributedObject::ObjectSnapshot {
529     public:
Downloaded(Asset & asset)530         int32_t Downloaded(Asset &asset) override {
531         hasDownloaded = true;
532         return 0;
533         }
534         bool hasDownloaded = false;
535     };
536     DistributedData::Asset asset = {
537         .name = "",
538         .id = "",
539         .path = "",
540         .uri = "PostEvent0010",
541         .modifyTime = "",
542         .createTime = "",
543         .size = "",
544         .hash = "",
545         .status = DistributedData::Asset::STATUS_NORMAL,
546     };
547     DistributedData::Assets assets;
548     assets.push_back(asset);
549     BindAssets bindAssets = std::make_shared<std::map<std::string, std::shared_ptr<Snapshot>>>();
550     auto objectSnapshotMock = std::make_shared<ObjectSnapshotMock>();
551     bindAssets->insert({"PostEvent0010", objectSnapshotMock});
552     std::shared_ptr assetLoader = std::make_shared<AssetLoader>();
553     DistributedRdb::RdbAssetLoader rdbAssetLoader(assetLoader, bindAssets);
554     std::set<std::string> skipAssets;
555     skipAssets.insert("PostEvent0010");
556     std::set<std::string> deleteAssets;
557     rdbAssetLoader.PostEvent(DistributedData::AssetEvent::UPLOAD, assets, skipAssets, deleteAssets);
558     EXPECT_EQ(objectSnapshotMock->hasDownloaded, false);
559 }
560 
561 /**
562 * @tc.name: ConvertStatus
563 * @tc.desc: RdbAssetLoader ConvertStatus abnormal
564 * @tc.type: FUNC
565 * @tc.require:
566 * @tc.author: SQL
567 */
568 HWTEST_F(RdbAssetLoaderTest, ConvertStatus, TestSize.Level0)
569 {
570     auto status = RdbAssetLoader::ConvertStatus(DistributedRdb::RdbAssetLoader::AssetStatus::STATUS_DOWNLOADING);
571     EXPECT_EQ(status, DistributedDB::DBStatus::OK);
572     status = RdbAssetLoader::ConvertStatus(DistributedRdb::RdbAssetLoader::AssetStatus::STATUS_BUTT);
573     EXPECT_EQ(status, DistributedDB::DBStatus::CLOUD_ERROR);
574     status = RdbAssetLoader::ConvertStatus(DistributedRdb::RdbAssetLoader::AssetStatus::STATUS_SKIP_ASSET);
575     EXPECT_EQ(status, DistributedDB::DBStatus::SKIP_ASSET);
576 }
577 
578 /**
579 * @tc.name: RdbWatcher
580 * @tc.desc: RdbWatcher function test.
581 * @tc.type: FUNC
582 * @tc.require:
583 * @tc.author: SQL
584 */
585 HWTEST_F(RdbWatcherTest, RdbWatcher, TestSize.Level0)
586 {
587     GeneralWatcher::Origin origin;
588     GeneralWatcher::PRIFields primaryFields = {{"primaryFields1", "primaryFields2"}};
589     GeneralWatcher::ChangeInfo values;
590     std::shared_ptr<RdbWatcher> watcher = std::make_shared<RdbWatcher>();
591     sptr<RdbNotifierProxy> notifier;
592     watcher->SetNotifier(notifier);
593     EXPECT_EQ(watcher->notifier_, nullptr);
594     auto result = watcher->OnChange(origin, primaryFields, std::move(values));
595     EXPECT_EQ(result, GeneralError::E_NOT_INIT);
596 }
597 } // namespace DistributedRDBTest
598 } // namespace OHOS::Test