1 /* 2 * Copyright (c) 2025 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 "DataShareCommonTest" 16 17 #include <gtest/gtest.h> 18 #include <unistd.h> 19 #include "extension_connect_adaptor.h" 20 #include "data_share_profile_config.h" 21 #include "div_strategy.h" 22 #include "log_print.h" 23 #include "rdb_delegate.h" 24 #include "rdb_subscriber_manager.h" 25 #include "scheduler_manager.h" 26 #include "seq_strategy.h" 27 #include "strategy.h" 28 29 namespace OHOS::Test { 30 using namespace testing::ext; 31 using namespace OHOS::DataShare; 32 class DataShareCommonTest : public testing::Test { 33 public: 34 static constexpr int64_t USER_TEST = 100; SetUpTestCase(void)35 static void SetUpTestCase(void){}; TearDownTestCase(void)36 static void TearDownTestCase(void){}; SetUp()37 void SetUp(){}; TearDown()38 void TearDown(){}; 39 }; 40 41 /** 42 * @tc.name: DivStrategy001 43 * @tc.desc: test DivStrategy function when three parameters are all nullptr 44 * @tc.type: FUNC 45 * @tc.require:SQL 46 */ 47 HWTEST_F(DataShareCommonTest, DivStrategy001, TestSize.Level1) 48 { 49 ZLOGI("DataShareCommonTest DivStrategy001 start"); 50 std::shared_ptr<Strategy> check = nullptr; 51 std::shared_ptr<Strategy> trueAction = nullptr; 52 std::shared_ptr<Strategy> falseAction = nullptr; 53 DivStrategy divStrategy(check, trueAction, falseAction); 54 auto context = std::make_shared<Context>(); 55 bool result = divStrategy.operator()(context); 56 EXPECT_EQ(result, false); 57 ZLOGI("DataShareCommonTest DivStrategy001 end"); 58 } 59 60 /** 61 * @tc.name: DivStrategy002 62 * @tc.desc: test DivStrategy function when trueAction and falseAction are nullptr 63 * @tc.type: FUNC 64 * @tc.require:SQL 65 */ 66 HWTEST_F(DataShareCommonTest, DivStrategy002, TestSize.Level1) 67 { 68 ZLOGI("DataShareCommonTest DivStrategy002 start"); 69 std::shared_ptr<Strategy> check = std::make_shared<Strategy>(); 70 std::shared_ptr<Strategy> trueAction = nullptr; 71 std::shared_ptr<Strategy> falseAction = nullptr; 72 DivStrategy divStrategy(check, trueAction, falseAction); 73 auto context = std::make_shared<Context>(); 74 bool result = divStrategy.operator()(context); 75 EXPECT_EQ(result, false); 76 ZLOGI("DataShareCommonTest DivStrategy002 end"); 77 } 78 79 /** 80 * @tc.name: DivStrategy003 81 * @tc.desc: test DivStrategy function when only falseAction is nullptr 82 * @tc.type: FUNC 83 * @tc.require:SQL 84 */ 85 HWTEST_F(DataShareCommonTest, DivStrategy003, TestSize.Level1) 86 { 87 ZLOGI("DataShareCommonTest DivStrategy003 start"); 88 std::shared_ptr<Strategy> check = std::make_shared<Strategy>(); 89 std::shared_ptr<Strategy> trueAction = std::make_shared<Strategy>(); 90 std::shared_ptr<Strategy> falseAction = nullptr; 91 DivStrategy divStrategy(check, trueAction, falseAction); 92 auto context = std::make_shared<Context>(); 93 bool result = divStrategy.operator()(context); 94 EXPECT_EQ(result, false); 95 ZLOGI("DataShareCommonTest DivStrategy003 end"); 96 } 97 98 /** 99 * @tc.name: SeqStrategyInit001 100 * @tc.desc: test SeqStrategyInit function when item is nullptr 101 * @tc.type: FUNC 102 * @tc.require:issueIBX9E1 103 * @tc.precon: None 104 * @tc.step: 105 1.Creat a seqStrategy object and strategy2 = nullptr 106 2.call Init function 107 * @tc.experct: Init failed and return false 108 */ 109 HWTEST_F(DataShareCommonTest, SeqStrategyInit001, TestSize.Level1) 110 { 111 ZLOGI("SeqStrategyInit001 start"); 112 Strategy* strategy1 = new Strategy(); 113 Strategy* strategy2 = nullptr; 114 SeqStrategy seqStrategy; 115 bool result = seqStrategy.Init({strategy1, strategy2}); 116 EXPECT_FALSE(result); 117 delete strategy1; 118 ZLOGI("SeqStrategyInit001 end"); 119 } 120 121 /** 122 * @tc.name: DoConnect001 123 * @tc.desc: test DoConnect function when callback_ is nullptr 124 * @tc.type: FUNC 125 * @tc.require:issueIBX9E1 126 * @tc.precon: None 127 * @tc.step: 128 1.Creat a ExtensionConnectAdaptor object and callback = nullptr 129 2.call DoConnect function 130 * @tc.experct: DoConnect failed and return false 131 */ 132 HWTEST_F(DataShareCommonTest, DoConnect001, TestSize.Level1) 133 { 134 ZLOGI("DoConnect001 start"); 135 std::string uri = "testUri"; 136 std::string bundleName = "testBundle"; 137 AAFwk::WantParams wantParams; 138 ExtensionConnectAdaptor extensionConnectAdaptor; 139 bool result = extensionConnectAdaptor.DoConnect(uri, bundleName, wantParams); 140 EXPECT_FALSE(result); 141 ZLOGI("DoConnect001 end"); 142 } 143 144 /** 145 * @tc.name: InsertEx001 146 * @tc.desc: test InsertEx function when store_ is nullptr 147 * @tc.type: FUNC 148 * @tc.require:issueIBX9E1 149 * @tc.precon: None 150 * @tc.step: 151 1.Creat a rdbDelegate object and store_ = nullptr 152 2.call InsertEx function 153 * @tc.experct: InsertEx failed and return E_DB_ERROR 154 */ 155 HWTEST_F(DataShareCommonTest, InsertEx001, TestSize.Level1) 156 { 157 ZLOGI("InsertEx001 start"); 158 DistributedData::StoreMetaData metaData; 159 metaData.user = "100"; 160 metaData.bundleName = "test"; 161 metaData.area = 1; 162 int version = 0; 163 bool registerFunction = false; 164 std::string extUri = "uri"; 165 std::string backup = "backup"; 166 RdbDelegate rdbDelegate; 167 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 168 rdbDelegate.store_ = nullptr; 169 std::string tableName = ""; 170 DataShare::DataShareValuesBucket valuesBucket; 171 std::string name0 = ""; 172 valuesBucket.Put("", name0); 173 auto result = rdbDelegate.InsertEx(tableName, valuesBucket); 174 EXPECT_EQ(result.first, E_DB_ERROR); 175 ZLOGI("InsertEx001 end"); 176 } 177 178 /** 179 * @tc.name: UpdateEx001 180 * @tc.desc: test UpdateEx function when store_ is nullptr 181 * @tc.type: FUNC 182 * @tc.require:issueIBX9E1 183 * @tc.precon: None 184 * @tc.step: 185 1.Creat a RdbDelegate object and store_ = nullptr 186 2.call UpdateEx function 187 * @tc.experct: UpdateEx failed and return E_DB_ERROR 188 */ 189 HWTEST_F(DataShareCommonTest, UpdateEx001, TestSize.Level1) 190 { 191 ZLOGI("UpdateEx001 start"); 192 DistributedData::StoreMetaData metaData; 193 metaData.user = "100"; 194 metaData.bundleName = "test"; 195 metaData.area = 1; 196 int version = 0; 197 bool registerFunction = false; 198 std::string extUri = "uri"; 199 std::string backup = "backup"; 200 RdbDelegate rdbDelegate; 201 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 202 rdbDelegate.store_ = nullptr; 203 std::string tableName = ""; 204 DataShare::DataShareValuesBucket valuesBucket; 205 std::string name0 = ""; 206 valuesBucket.Put("", name0); 207 DataSharePredicates predicate; 208 auto result = rdbDelegate.UpdateEx(tableName, predicate, valuesBucket); 209 EXPECT_EQ(result.first, E_DB_ERROR); 210 ZLOGI("UpdateEx001 end"); 211 } 212 213 /** 214 * @tc.name: DeleteEx001 215 * @tc.desc: test DeleteEx function when store_ is nullptr 216 * @tc.type: FUNC 217 * @tc.require:issueIBX9E1 218 * @tc.precon: None 219 * @tc.step: 220 1.Creat a RdbDelegate object and store_ = nullptr 221 2.call DeleteEx function 222 * @tc.experct: DeleteEx failed and return E_DB_ERROR 223 */ 224 HWTEST_F(DataShareCommonTest, DeleteEx001, TestSize.Level1) 225 { 226 ZLOGI("DeleteEx001 start"); 227 DistributedData::StoreMetaData metaData; 228 metaData.user = "100"; 229 metaData.bundleName = "test"; 230 metaData.area = 1; 231 int version = 0; 232 bool registerFunction = false; 233 std::string extUri = "uri"; 234 std::string backup = "backup"; 235 RdbDelegate rdbDelegate; 236 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 237 rdbDelegate.store_ = nullptr; 238 std::string tableName = ""; 239 DataSharePredicates predicate; 240 auto result = rdbDelegate.DeleteEx(tableName, predicate); 241 EXPECT_EQ(result.first, E_DB_ERROR); 242 ZLOGI("DeleteEx001 end"); 243 } 244 245 /** 246 * @tc.name: Query001 247 * @tc.desc: test Query function when store_ is nullptr 248 * @tc.type: FUNC 249 * @tc.require:issueIBX9E1 250 * @tc.precon: None 251 * @tc.step: 252 1.Creat a RdbDelegate object and store_ = nullptr 253 2.call Query function 254 * @tc.experct: Query failed and return errCode 255 */ 256 HWTEST_F(DataShareCommonTest, Query001, TestSize.Level1) 257 { 258 ZLOGI("Query001 start"); 259 DistributedData::StoreMetaData metaData; 260 metaData.user = "100"; 261 metaData.bundleName = "test"; 262 metaData.area = 1; 263 int version = 0; 264 bool registerFunction = false; 265 std::string extUri = "uri"; 266 std::string backup = "backup"; 267 RdbDelegate rdbDelegate; 268 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 269 rdbDelegate.store_ = nullptr; 270 std::string tableName = ""; 271 DataSharePredicates predicate; 272 std::vector<std::string> columns; 273 int32_t callingPid = 1; 274 uint32_t callingTokenId = 1; 275 auto result = rdbDelegate.Query(tableName, predicate, columns, callingPid, callingTokenId); 276 EXPECT_EQ(result.first, rdbDelegate.errCode_); 277 ZLOGI("Query001 end"); 278 } 279 280 /** 281 * @tc.name: Query002 282 * @tc.desc: test Query function when store_ is nullptr 283 * @tc.type: FUNC 284 * @tc.require:issueIBX9E1 285 * @tc.precon: None 286 * @tc.step: 287 1.Creat a RdbDelegate object and store_ = nullptr 288 2.call Query function 289 * @tc.experct: Query failed and return "" 290 */ 291 HWTEST_F(DataShareCommonTest, Query002, TestSize.Level1) 292 { 293 ZLOGI("Query002 start"); 294 DistributedData::StoreMetaData metaData; 295 metaData.user = "100"; 296 metaData.bundleName = "test"; 297 metaData.area = 1; 298 int version = 0; 299 bool registerFunction = false; 300 std::string extUri = "uri"; 301 std::string backup = "backup"; 302 RdbDelegate rdbDelegate; 303 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 304 rdbDelegate.store_ = nullptr; 305 std::string sql = "testsql"; 306 std::vector<std::string> selectionArgs; 307 auto result = rdbDelegate.Query(sql, selectionArgs); 308 EXPECT_EQ(result, ""); 309 ZLOGI("Query002 end"); 310 } 311 312 /** 313 * @tc.name: QuerySql001 314 * @tc.desc: test QuerySql function when store_ is nullptr 315 * @tc.type: FUNC 316 * @tc.require:issueIBX9E1 317 * @tc.precon: None 318 * @tc.step: 319 1.Creat a RdbDelegate object and store_ = nullptr 320 2.call QuerySql function 321 * @tc.experct: QuerySql failed and return nullptr 322 */ 323 HWTEST_F(DataShareCommonTest, QuerySql001, TestSize.Level1) 324 { 325 ZLOGI("QuerySql001 start"); 326 DistributedData::StoreMetaData metaData; 327 metaData.user = "100"; 328 metaData.bundleName = "test"; 329 metaData.area = 1; 330 int version = 0; 331 bool registerFunction = false; 332 std::string extUri = "uri"; 333 std::string backup = "backup"; 334 RdbDelegate rdbDelegate; 335 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 336 rdbDelegate.store_ = nullptr; 337 std::string sql = "testsql"; 338 auto result = rdbDelegate.QuerySql(sql); 339 EXPECT_EQ(result, nullptr); 340 ZLOGI("QuerySql001 end"); 341 } 342 343 /** 344 * @tc.name: UpdateSql001 345 * @tc.desc: test UpdateSql function when store_ is nullptr 346 * @tc.type: FUNC 347 * @tc.require:issueIBX9E1 348 * @tc.precon: None 349 * @tc.step: 350 1.Creat a RdbDelegate object and store_ = nullptr 351 2.call UpdateSql function 352 * @tc.experct: UpdateSql failed and return E_ERROR 353 */ 354 HWTEST_F(DataShareCommonTest, UpdateSql001, TestSize.Level1) 355 { 356 ZLOGI("UpdateSql001 start"); 357 DistributedData::StoreMetaData metaData; 358 metaData.user = "100"; 359 metaData.bundleName = "test"; 360 metaData.area = 1; 361 int version = 0; 362 bool registerFunction = false; 363 std::string extUri = "uri"; 364 std::string backup = "backup"; 365 RdbDelegate rdbDelegate; 366 rdbDelegate.Init(metaData, version, registerFunction, extUri, backup); 367 rdbDelegate.store_ = nullptr; 368 std::string sql = "testsql"; 369 auto result = rdbDelegate.UpdateSql(sql); 370 EXPECT_EQ(result.first, OHOS::DataShare::E_ERROR); 371 ZLOGI("UpdateSql001 end"); 372 } 373 374 /** 375 * @tc.name: EraseTimerTaskId001 376 * @tc.desc: test EraseTimerTaskId function when not find key 377 * @tc.type: FUNC 378 * @tc.require:issueIBX9E1 379 * @tc.precon: None 380 * @tc.step: 381 1.Creat a SchedulerManager object and timerCache_ is null 382 2.call EraseTimerTaskId function 383 * @tc.experct: not find key, EraseTimerTaskId failed and return -1 384 */ 385 HWTEST_F(DataShareCommonTest, EraseTimerTaskId001, TestSize.Level1) 386 { 387 ZLOGI("EraseTimerTaskId001 start"); 388 Key key("uri1", 1, "name1"); 389 auto& manager = SchedulerManager::GetInstance(); 390 int64_t result = manager.EraseTimerTaskId(key); 391 EXPECT_EQ(result, -1); 392 ZLOGI("EraseTimerTaskId001 end"); 393 } 394 395 /** 396 * @tc.name: EraseTimerTaskId002 397 * @tc.desc: test EraseTimerTaskId function when find key 398 * @tc.type: FUNC 399 * @tc.require:issueIBX9E1 400 * @tc.precon: None 401 * @tc.step: 402 1.Creat a SchedulerManager object and timerCache_[key] = timeid 403 2.call EraseTimerTaskId function 404 * @tc.experct: find key, EraseTimerTaskId success and return timeid 405 */ 406 HWTEST_F(DataShareCommonTest, EraseTimerTaskId002, TestSize.Level1) 407 { 408 ZLOGI("EraseTimerTaskId002 start"); 409 Key key("uri1", 1, "name1"); 410 auto& manager = SchedulerManager::GetInstance(); 411 int64_t timeid = 1; 412 manager.timerCache_[key] = timeid; 413 int64_t result = manager.EraseTimerTaskId(key); 414 EXPECT_EQ(result, timeid); 415 ZLOGI("EraseTimerTaskId002 end"); 416 } 417 418 /** 419 * @tc.name: GetSchedulerStatus001 420 * @tc.desc: test GetSchedulerStatus function when not find key 421 * @tc.type: FUNC 422 * @tc.require:issueIBX9E1 423 * @tc.precon: None 424 * @tc.step: 425 1.Creat a SchedulerManager object and schedulerStatusCache_ is null 426 2.call GetSchedulerStatus function 427 * @tc.experct: not find key, GetSchedulerStatus failed and return false 428 */ 429 HWTEST_F(DataShareCommonTest, GetSchedulerStatus001, TestSize.Level1) 430 { 431 ZLOGI("GetSchedulerStatus001 start"); 432 Key key("uri1", 1, "name1"); 433 auto& manager = SchedulerManager::GetInstance(); 434 bool result = manager.GetSchedulerStatus(key); 435 EXPECT_FALSE(result); 436 ZLOGI("GetSchedulerStatus001 end"); 437 } 438 439 /** 440 * @tc.name: GetSchedulerStatus002 441 * @tc.desc: test GetSchedulerStatus function when find key 442 * @tc.type: FUNC 443 * @tc.require:issueIBX9E1 444 * @tc.precon: None 445 * @tc.step: 446 1.Creat a SchedulerManager object and schedulerStatusCache_[key] = true; 447 2.call GetSchedulerStatus function 448 * @tc.experct: find key, GetSchedulerStatus success and return true 449 */ 450 HWTEST_F(DataShareCommonTest, GetSchedulerStatus002, TestSize.Level1) 451 { 452 ZLOGI("GetSchedulerStatus002 start"); 453 Key key("uri1", 1, "name1"); 454 auto& manager = SchedulerManager::GetInstance(); 455 manager.schedulerStatusCache_[key] = true; 456 bool result = manager.GetSchedulerStatus(key); 457 EXPECT_TRUE(result); 458 ZLOGI("GetSchedulerStatus002 end"); 459 } 460 461 /** 462 * @tc.name: RemoveTimer001 463 * @tc.desc: test RemoveTimer function when executor_ is nullptr 464 * @tc.type: FUNC 465 * @tc.require:issueIBX9E1 466 * @tc.precon: None 467 * @tc.step: 468 1.Creat a SchedulerManager object what timerCache_[key] = 1 and executor_ is nullptr 469 2.call RemoveTimer function to remove timer 470 * @tc.experct: RemoveTimer failed and timerCache_ is not null 471 */ 472 HWTEST_F(DataShareCommonTest, RemoveTimer001, TestSize.Level1) 473 { 474 ZLOGI("RemoveTimer001 start"); 475 Key key("uri1", 1, "name1"); 476 auto& manager = SchedulerManager::GetInstance(); 477 manager.executor_ = nullptr; 478 manager.timerCache_[key] = 1; 479 manager.RemoveTimer(key); 480 EXPECT_NE(manager.timerCache_.find(key), manager.timerCache_.end()); 481 ZLOGI("RemoveTimer001 end"); 482 } 483 484 /** 485 * @tc.name: RemoveTimer002 486 * @tc.desc: test RemoveTimer function when executor_ is not nullptr 487 * @tc.type: FUNC 488 * @tc.require:issueIBX9E1 489 * @tc.precon: None 490 * @tc.step: 491 1.Creat a SchedulerManager object and timerCache_[key] = 1 and executor_ is not nullptr 492 2.call RemoveTimer function to remove timer 493 * @tc.experct: RemoveTimer success and timerCache_ is null 494 */ 495 HWTEST_F(DataShareCommonTest, RemoveTimer002, TestSize.Level1) 496 { 497 ZLOGI("RemoveTimer002 start"); 498 Key key("uri1", 1, "name1"); 499 auto& manager = SchedulerManager::GetInstance(); 500 manager.executor_ = std::make_shared<ExecutorPool>(5, 3); 501 manager.timerCache_[key] = 1; 502 manager.RemoveTimer(key); 503 EXPECT_EQ(manager.timerCache_.find(key), manager.timerCache_.end()); 504 ZLOGI("RemoveTimer002 end"); 505 } 506 507 /** 508 * @tc.name: ClearTimer001 509 * @tc.desc: test ClearTimer function when executor_ is nullptr 510 * @tc.type: FUNC 511 * @tc.require:issueIBX9E1 512 * @tc.precon: None 513 * @tc.step: 514 1.Creat a SchedulerManager object what timerCache_[key] = 1 and executor_ is nullptr 515 2.call ClearTimer function to clear timer 516 * @tc.experct: ClearTimer failed and timerCache_ is not empty 517 */ 518 HWTEST_F(DataShareCommonTest, ClearTimer001, TestSize.Level1) 519 { 520 ZLOGI("ClearTimer001 start"); 521 Key key("uri1", 1, "name1"); 522 auto& manager = SchedulerManager::GetInstance(); 523 manager.executor_ = nullptr; 524 manager.timerCache_[key] = 1; 525 manager.ClearTimer(); 526 EXPECT_FALSE(manager.timerCache_.empty()); 527 ZLOGI("ClearTimer001 end"); 528 } 529 530 /** 531 * @tc.name: ClearTimer002 532 * @tc.desc: test ClearTimer function when executor_ is not nullptr and find key 533 * @tc.type: FUNC 534 * @tc.require:issueIBX9E1 535 * @tc.precon: None 536 * @tc.step: 537 1.Creat a SchedulerManager object and timerCache_[key] = 1 and executor_ is not nullptr 538 2.call ClearTimer function to clear timer 539 * @tc.experct: ClearTimer success and timerCache_ is empty 540 */ 541 HWTEST_F(DataShareCommonTest, ClearTimer002, TestSize.Level1) 542 { 543 ZLOGI("ClearTimer002 start"); 544 Key key("uri1", 1, "name1"); 545 auto& manager = SchedulerManager::GetInstance(); 546 manager.executor_ = std::make_shared<ExecutorPool>(5, 3); 547 manager.timerCache_[key] = 1; 548 manager.ClearTimer(); 549 EXPECT_TRUE(manager.timerCache_.empty()); 550 ZLOGI("ClearTimer002 end"); 551 } 552 553 /** 554 * @tc.name: ClearTimer003 555 * @tc.desc: test ClearTimer function when executor_ is not nullptr and not find key 556 * @tc.type: FUNC 557 * @tc.require:issueIBX9E1 558 * @tc.precon: None 559 * @tc.step: 560 1.Creat a SchedulerManager object and timerCache_ is null 561 2.call ClearTimer function 562 * @tc.experct: ClearTimer failed and timerCache_ is empty 563 */ 564 HWTEST_F(DataShareCommonTest, ClearTimer003, TestSize.Level1) 565 { 566 ZLOGI("ClearTimer003 start"); 567 Key key("uri1", 1, "name1"); 568 auto& manager = SchedulerManager::GetInstance(); 569 manager.executor_ = std::make_shared<ExecutorPool>(5, 3); 570 manager.ClearTimer(); 571 EXPECT_TRUE(manager.timerCache_.empty()); 572 ZLOGI("ClearTimer003 end"); 573 } 574 575 /** 576 * @tc.name: DBDelegateTest001 577 * @tc.desc: do nothing when delegate already inited 578 * @tc.type: FUNC 579 */ 580 HWTEST_F(DataShareCommonTest, DBDelegateTest001, TestSize.Level0) { 581 RdbDelegate delegate; 582 DistributedData::StoreMetaData meta; 583 meta.tokenId = 1; 584 585 delegate.isInited_ = true; 586 delegate.Init({}, 0, false, "extUri", "backup"); 587 588 EXPECT_TRUE(delegate.isInited_); 589 EXPECT_EQ(delegate.tokenId_, 0); 590 EXPECT_EQ(delegate.extUri_, ""); 591 EXPECT_EQ(delegate.backup_, ""); 592 } 593 594 /** 595 * @tc.name : DBDelegateTest002 596 * @tc.number: init members in delegate init 597 * @tc.type: FUNC 598 */ 599 HWTEST_F(DataShareCommonTest, DBDelegateTest002, TestSize.Level0) { 600 RdbDelegate delegate; 601 DistributedData::StoreMetaData meta; 602 meta.tokenId = 1; 603 604 delegate.isInited_ = false; 605 delegate.Init(meta, 0, false, "extUri", "backup"); 606 607 EXPECT_FALSE(delegate.isInited_); 608 EXPECT_EQ(delegate.tokenId_, meta.tokenId); 609 EXPECT_EQ(delegate.extUri_, "extUri"); 610 EXPECT_EQ(delegate.backup_, "backup"); 611 } 612 } // namespace OHOS::Test