1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifdef RELATIONAL_STORE 16 #include <gtest/gtest.h> 17 #include <iostream> 18 #include "cloud/cloud_storage_utils.h" 19 #include "cloud/cloud_db_constant.h" 20 #include "distributeddb_data_generate_unit_test.h" 21 #include "distributeddb_tools_unit_test.h" 22 #include "process_system_api_adapter_impl.h" 23 #include "relational_store_instance.h" 24 #include "relational_store_manager.h" 25 #include "runtime_config.h" 26 #include "sqlite_relational_store.h" 27 #include "sqlite_relational_utils.h" 28 #include "store_observer.h" 29 #include "time_helper.h" 30 #include "virtual_asset_loader.h" 31 #include "virtual_cloud_data_translate.h" 32 #include "virtual_cloud_db.h" 33 #include "virtual_communicator_aggregator.h" 34 #include "mock_asset_loader.h" 35 #include "cloud_db_sync_utils_test.h" 36 37 using namespace testing::ext; 38 using namespace DistributedDB; 39 using namespace DistributedDBUnitTest; 40 using namespace std; 41 42 namespace { 43 string g_storeID = "Relational_Store_SYNC"; 44 const string g_tableName = "worker"; 45 const string DB_SUFFIX = ".db"; 46 const string CLOUD = "cloud"; 47 string g_testDir; 48 string g_storePath; 49 std::shared_ptr<VirtualCloudDb> g_virtualCloudDb; 50 std::shared_ptr<VirtualAssetLoader> g_virtualAssetLoader; 51 RelationalStoreObserverUnitTest *g_observer = nullptr; 52 RelationalStoreDelegate *g_delegate = nullptr; 53 VirtualCommunicatorAggregator *communicatorAggregator_ = nullptr; 54 TrackerSchema g_trackerSchema = { 55 .tableName = g_tableName, .extendColName = "name", .trackerColNames = {"age"} 56 }; 57 TrackerSchema g_trackerSchema2 = { 58 .tableName = g_tableName, .extendColName = "age", .trackerColNames = {"height"} 59 }; 60 TrackerSchema g_trackerSchema3 = { 61 .tableName = g_tableName, .extendColName = "", .trackerColNames = {} 62 }; 63 ChangeProperties g_onChangeProperties = { .isTrackedDataChange = true }; 64 ChangeProperties g_unChangeProperties = { .isTrackedDataChange = false }; 65 const std::vector<std::string> g_tables = {g_tableName}; 66 const std::string CREATE_LOCAL_TABLE_WITHOUT_PRIMARY_KEY_SQL = 67 "CREATE TABLE IF NOT EXISTS " + g_tableName + "(" \ 68 "name TEXT," \ 69 "height REAL ," \ 70 "married BOOLEAN ," \ 71 "photo BLOB NOT NULL," \ 72 "asset BLOB," \ 73 "age INT);"; 74 const std::vector<Field> g_cloudFiledWithoutPrimaryKey = { 75 {"name", TYPE_INDEX<std::string>, false, true}, {"height", TYPE_INDEX<double>}, 76 {"married", TYPE_INDEX<bool>}, {"photo", TYPE_INDEX<Bytes>, false, false}, 77 {"asset", TYPE_INDEX<Asset>}, {"age", TYPE_INDEX<int64_t>} 78 }; 79 InitExpectChangedData(ChangedDataType dataType,int64_t count,ChangeType changeType)80 void InitExpectChangedData(ChangedDataType dataType, int64_t count, ChangeType changeType) 81 { 82 ChangedData changedDataForTable; 83 changedDataForTable.tableName = g_tableName; 84 changedDataForTable.type = dataType; 85 changedDataForTable.field.push_back(std::string("rowid")); 86 for (int64_t i = 1; i <= count; ++i) { 87 changedDataForTable.primaryData[changeType].push_back({i}); 88 } 89 g_observer->SetExpectedResult(changedDataForTable); 90 } 91 InitExpectChangedDataByDetailsType(ChangedDataType dataType,int64_t count,ChangeType changeType,ChangeProperties properties,uint32_t detailsType)92 void InitExpectChangedDataByDetailsType(ChangedDataType dataType, int64_t count, ChangeType changeType, 93 ChangeProperties properties, uint32_t detailsType) 94 { 95 ChangedData changedDataForTable; 96 changedDataForTable.tableName = g_tableName; 97 if (detailsType & static_cast<uint32_t>(CallbackDetailsType::DEFAULT)) { 98 changedDataForTable.type = dataType; 99 changedDataForTable.field.push_back(std::string("rowid")); 100 for (int64_t i = 1; i <= count; ++i) { 101 changedDataForTable.primaryData[changeType].push_back({i}); 102 } 103 } 104 if (detailsType & static_cast<uint32_t>(CallbackDetailsType::BRIEF)) { 105 changedDataForTable.properties = properties; 106 } 107 g_observer->SetExpectedResult(changedDataForTable); 108 } 109 TestChangedDataInTrackerTable(const TrackerSchema & trackerSchema,uint32_t detailsType,std::vector<ChangeProperties> & expectProperties)110 void TestChangedDataInTrackerTable(const TrackerSchema &trackerSchema, uint32_t detailsType, 111 std::vector<ChangeProperties> &expectProperties) 112 { 113 EXPECT_EQ(expectProperties.size(), 3u); // 3 is the num to check change properties 114 /** 115 * @tc.steps:step1. set tracker table 116 * @tc.expected: step1. check the changeddata and return ok 117 */ 118 EXPECT_EQ(g_delegate->SetTrackerTable(trackerSchema), OK); 119 g_observer->SetCallbackDetailsType(detailsType); 120 int64_t cloudCount = 10; // 10 is random cloud count 121 int64_t paddingSize = 10; // 10 is padding size 122 int index = 0; 123 InitExpectChangedDataByDetailsType(ChangedDataType::DATA, cloudCount, ChangeType::OP_INSERT, 124 expectProperties[index++], detailsType); 125 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 126 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 127 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 128 g_observer->ClearChangedData(); 129 130 /** 131 * @tc.steps:step2. update cloud data 132 * @tc.expected: step2. check the changeddata and return ok 133 */ 134 InitExpectChangedDataByDetailsType(ChangedDataType::DATA, cloudCount, ChangeType::OP_UPDATE, 135 expectProperties[index++], detailsType); 136 CloudDBSyncUtilsTest::UpdateCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 137 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 138 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 139 g_observer->ClearChangedData(); 140 141 /** 142 * @tc.steps:step3. delete cloud data 143 * @tc.expected: step3. check the changeddata and return ok 144 */ 145 InitExpectChangedDataByDetailsType(ChangedDataType::DATA, cloudCount, ChangeType::OP_DELETE, 146 expectProperties[index++], detailsType); 147 CloudDBSyncUtilsTest::DeleteCloudTableRecordByGid(0, cloudCount, g_virtualCloudDb); 148 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 149 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 150 g_observer->ClearChangedData(); 151 } 152 153 class DistributedDBCloudTableWithoutPrimaryKeySyncTest : public testing::Test { 154 public: 155 static void SetUpTestCase(void); 156 static void TearDownTestCase(void); 157 void SetUp(); 158 void TearDown(); 159 protected: 160 sqlite3 *db = nullptr; 161 }; 162 SetUpTestCase(void)163 void DistributedDBCloudTableWithoutPrimaryKeySyncTest::SetUpTestCase(void) 164 { 165 DistributedDBToolsUnitTest::TestDirInit(g_testDir); 166 g_storePath = g_testDir + "/" + g_storeID + DB_SUFFIX; 167 LOGI("The test db is:%s", g_testDir.c_str()); 168 RuntimeConfig::SetCloudTranslate(std::make_shared<VirtualCloudDataTranslate>()); 169 } 170 TearDownTestCase(void)171 void DistributedDBCloudTableWithoutPrimaryKeySyncTest::TearDownTestCase(void) 172 {} 173 SetUp(void)174 void DistributedDBCloudTableWithoutPrimaryKeySyncTest::SetUp(void) 175 { 176 if (DistributedDBToolsUnitTest::RemoveTestDbFiles(g_testDir) != 0) { 177 LOGE("rm test db files error."); 178 } 179 DistributedDBToolsUnitTest::PrintTestCaseInfo(); 180 LOGD("Test dir is %s", g_testDir.c_str()); 181 db = RelationalTestUtils::CreateDataBase(g_storePath); 182 ASSERT_NE(db, nullptr); 183 CloudDBSyncUtilsTest::CreateUserDBAndTable(db, CREATE_LOCAL_TABLE_WITHOUT_PRIMARY_KEY_SQL); 184 CloudDBSyncUtilsTest::SetStorePath(g_storePath); 185 CloudDBSyncUtilsTest::InitSyncUtils(g_cloudFiledWithoutPrimaryKey, g_observer, g_virtualCloudDb, 186 g_virtualAssetLoader, g_delegate); 187 communicatorAggregator_ = new (std::nothrow) VirtualCommunicatorAggregator(); 188 ASSERT_TRUE(communicatorAggregator_ != nullptr); 189 RuntimeContext::GetInstance()->SetCommunicatorAggregator(communicatorAggregator_); 190 } 191 TearDown(void)192 void DistributedDBCloudTableWithoutPrimaryKeySyncTest::TearDown(void) 193 { 194 CloudDBSyncUtilsTest::CloseDb(g_observer, g_virtualCloudDb, g_delegate); 195 EXPECT_EQ(sqlite3_close_v2(db), SQLITE_OK); 196 if (DistributedDBToolsUnitTest::RemoveTestDbFiles(g_testDir) != 0) { 197 LOGE("rm test db files error."); 198 } 199 RuntimeContext::GetInstance()->SetCommunicatorAggregator(nullptr); 200 communicatorAggregator_ = nullptr; 201 RuntimeContext::GetInstance()->SetProcessSystemApiAdapter(nullptr); 202 } 203 204 /* 205 * @tc.name: CloudSyncTest001 206 * @tc.desc: test data sync when cloud insert 207 * @tc.type: FUNC 208 * @tc.require: 209 * @tc.author: chenchaohao 210 */ 211 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest001, TestSize.Level0) 212 { 213 /** 214 * @tc.steps:step1. insert cloud data and merge 215 * @tc.expected: step1. check the changeddata and return ok 216 */ 217 int64_t cloudCount = 10; // 10 is random cloud count 218 int64_t paddingSize = 10; // 10 is padding size 219 InitExpectChangedData(ChangedDataType::DATA, cloudCount, ChangeType::OP_INSERT); 220 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 221 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 222 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 223 g_observer->ClearChangedData(); 224 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 225 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 226 } 227 228 /* 229 * @tc.name: CloudSyncTest002 230 * @tc.desc: test data sync when cloud update 231 * @tc.type: FUNC 232 * @tc.require: 233 * @tc.author: chenchaohao 234 */ 235 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest002, TestSize.Level0) 236 { 237 /** 238 * @tc.steps:step1. insert cloud data and merge 239 * @tc.expected: step1. check the changeddata and return ok 240 */ 241 int64_t cloudCount = 10; // 10 is random cloud count 242 int64_t paddingSize = 10; // 10 is padding size 243 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 244 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 245 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 246 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 247 248 /** 249 * @tc.steps:step2. update cloud data and merge 250 * @tc.expected: step2. check the changeddata and return ok 251 */ 252 InitExpectChangedData(ChangedDataType::DATA, cloudCount, ChangeType::OP_UPDATE); 253 CloudDBSyncUtilsTest::UpdateCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 254 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 255 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 256 g_observer->ClearChangedData(); 257 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 258 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 259 } 260 261 /* 262 * @tc.name: CloudSyncTest003 263 * @tc.desc: test data sync when cloud delete 264 * @tc.type: FUNC 265 * @tc.require: 266 * @tc.author: chenchaohao 267 */ 268 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest003, TestSize.Level0) 269 { 270 /** 271 * @tc.steps:step1. insert cloud data and merge 272 * @tc.expected: step1. check the changeddata and return ok 273 */ 274 int64_t cloudCount = 10; // 10 is random cloud count 275 int64_t paddingSize = 10; // 10 is padding size 276 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, true, g_virtualCloudDb); 277 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 278 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 279 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 280 281 /** 282 * @tc.steps:step2. delete cloud data and merge 283 * @tc.expected: step2. check the changeddata and return ok 284 */ 285 InitExpectChangedData(ChangedDataType::DATA, cloudCount, ChangeType::OP_DELETE); 286 CloudDBSyncUtilsTest::DeleteCloudTableRecordByGid(0, cloudCount, g_virtualCloudDb); 287 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 288 CloudDBSyncUtilsTest::CheckCloudTotalCount({0L}, g_virtualCloudDb); 289 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 290 g_observer->ClearChangedData(); 291 CloudDBSyncUtilsTest::CheckLocalRecordNum(db, g_tableName, 0); 292 } 293 294 /* 295 * @tc.name: CloudSyncTest004 296 * @tc.desc: test asset when cloud insert 297 * @tc.type: FUNC 298 * @tc.require: 299 * @tc.author: chenchaohao 300 */ 301 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest004, TestSize.Level0) 302 { 303 /** 304 * @tc.steps:step1. insert cloud asset and merge 305 * @tc.expected: step1. check the changeddata and return ok 306 */ 307 int64_t cloudCount = 10; // 10 is random cloud count 308 int64_t paddingSize = 10; // 10 is padding size 309 InitExpectChangedData(ChangedDataType::ASSET, cloudCount, ChangeType::OP_INSERT); 310 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, false, g_virtualCloudDb); 311 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 312 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 313 g_observer->ClearChangedData(); 314 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 315 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 316 } 317 318 /* 319 * @tc.name: CloudSyncTest005 320 * @tc.desc: test asset sync when cloud insert 321 * @tc.type: FUNC 322 * @tc.require: 323 * @tc.author: chenchaohao 324 */ 325 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest005, TestSize.Level0) 326 { 327 /** 328 * @tc.steps:step1. insert cloud asset and merge 329 * @tc.expected: step1. check the changeddata and return ok 330 */ 331 int64_t cloudCount = 10; // 10 is random cloud count 332 int64_t paddingSize = 10; // 10 is padding size 333 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, false, g_virtualCloudDb); 334 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 335 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 336 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 337 338 /** 339 * @tc.steps:step2. update cloud asset and merge 340 * @tc.expected: step2. check the changeddata and return ok 341 */ 342 InitExpectChangedData(ChangedDataType::ASSET, cloudCount, ChangeType::OP_UPDATE); 343 CloudDBSyncUtilsTest::UpdateCloudTableRecord(0, cloudCount, paddingSize, false, g_virtualCloudDb); 344 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 345 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 346 g_observer->ClearChangedData(); 347 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 348 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 349 } 350 351 /* 352 * @tc.name: CloudSyncTest006 353 * @tc.desc: test asset sync when cloud delete 354 * @tc.type: FUNC 355 * @tc.require: 356 * @tc.author: chenchaohao 357 */ 358 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest006, TestSize.Level0) 359 { 360 /** 361 * @tc.steps:step1. insert cloud asset and merge 362 * @tc.expected: step1. check the changeddata and return ok 363 */ 364 int64_t cloudCount = 10; // 10 is random cloud count 365 int64_t paddingSize = 10; // 10 is padding size 366 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, false, g_virtualCloudDb); 367 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 368 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 369 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 370 371 /** 372 * @tc.steps:step2. insert cloud asset and merge 373 * @tc.expected: step2. check the changeddata and return ok 374 */ 375 InitExpectChangedData(ChangedDataType::ASSET, cloudCount, ChangeType::OP_DELETE); 376 CloudDBSyncUtilsTest::DeleteCloudTableRecordByGid(0, cloudCount, g_virtualCloudDb); 377 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 378 CloudDBSyncUtilsTest::CheckCloudTotalCount({0L}, g_virtualCloudDb); 379 EXPECT_TRUE(g_observer->IsAllChangedDataEq()); 380 g_observer->ClearChangedData(); 381 CloudDBSyncUtilsTest::CheckLocalRecordNum(db, g_tableName, 0); 382 } 383 384 /* 385 * @tc.name: CloudSyncTest007 386 * @tc.desc: test sync when device delete 387 * @tc.type: FUNC 388 * @tc.require: 389 * @tc.author: chenchaohao 390 */ 391 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, CloudSyncTest007, TestSize.Level0) 392 { 393 /** 394 * @tc.steps:step1. insert cloud asset and merge 395 * @tc.expected: step1. check the changeddata and return ok 396 */ 397 int64_t cloudCount = 30; // 30 is random cloud count 398 int64_t paddingSize = 10; // 10 is padding size 399 CloudDBSyncUtilsTest::InsertCloudTableRecord(0, cloudCount, paddingSize, false, g_virtualCloudDb); 400 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 401 CloudDBSyncUtilsTest::CheckDownloadResult(db, {cloudCount}, CLOUD); 402 CloudDBSyncUtilsTest::CheckCloudTotalCount({cloudCount}, g_virtualCloudDb); 403 404 /** 405 * @tc.steps:step2. delete user data and update cloud data 406 * @tc.expected: step2. check sync reseult and return ok 407 */ 408 int64_t deviceBegin = 20; // 20 is device begin 409 int64_t deviceCount = 10; // 10 is device delete 410 CloudDBSyncUtilsTest::DeleteUserTableRecord(db, 0, deviceCount); 411 CloudDBSyncUtilsTest::DeleteUserTableRecord(db, deviceBegin, deviceCount); 412 CloudDBSyncUtilsTest::UpdateCloudTableRecord(0, deviceCount, paddingSize, false, g_virtualCloudDb); 413 CloudDBSyncUtilsTest::callSync(g_tables, SYNC_MODE_CLOUD_MERGE, DBStatus::OK, g_delegate); 414 CloudDBSyncUtilsTest::CheckLocalRecordNum(db, g_tableName, deviceBegin); 415 CloudDBSyncUtilsTest::CheckCloudTotalCount({deviceBegin}, g_virtualCloudDb); 416 } 417 418 /* 419 * @tc.name: ChangeTrackerDataTest001 420 * @tc.desc: test changed data on BRIEF type of sync 421 * @tc.type: FUNC 422 * @tc.require: 423 * @tc.author: bty 424 */ 425 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, ChangeTrackerDataTest001, TestSize.Level0) 426 { 427 std::vector<ChangeProperties> expectProperties = { 428 g_onChangeProperties, g_unChangeProperties, g_onChangeProperties 429 }; 430 TestChangedDataInTrackerTable(g_trackerSchema, static_cast<uint32_t>(CallbackDetailsType::BRIEF), 431 expectProperties); 432 } 433 434 /* 435 * @tc.name: ChangeTrackerDataTest002 436 * @tc.desc: test changed data on DETAILED type of sync 437 * @tc.type: FUNC 438 * @tc.require: 439 * @tc.author: bty 440 */ 441 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, ChangeTrackerDataTest002, TestSize.Level0) 442 { 443 std::vector<ChangeProperties> expectProperties = { 444 g_onChangeProperties, g_unChangeProperties, g_onChangeProperties 445 }; 446 TestChangedDataInTrackerTable(g_trackerSchema, static_cast<uint32_t>(CallbackDetailsType::DETAILED), 447 expectProperties); 448 } 449 450 /* 451 * @tc.name: ChangeTrackerDataTest003 452 * @tc.desc: test changed data on DEFAULT type of sync 453 * @tc.type: FUNC 454 * @tc.require: 455 * @tc.author: bty 456 */ 457 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, ChangeTrackerDataTest003, TestSize.Level0) 458 { 459 std::vector<ChangeProperties> expectProperties = { 460 g_unChangeProperties, g_unChangeProperties, g_unChangeProperties 461 }; 462 TestChangedDataInTrackerTable(g_trackerSchema, static_cast<uint32_t>(CallbackDetailsType::DEFAULT), 463 expectProperties); 464 } 465 466 /* 467 * @tc.name: ChangeTrackerDataTest004 468 * @tc.desc: test changed data on DETAILED type of sync 469 * @tc.type: FUNC 470 * @tc.require: 471 * @tc.author: bty 472 */ 473 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, ChangeTrackerDataTest004, TestSize.Level0) 474 { 475 std::vector<ChangeProperties> expectProperties = { 476 g_onChangeProperties, g_onChangeProperties, g_onChangeProperties 477 }; 478 TestChangedDataInTrackerTable(g_trackerSchema2, static_cast<uint32_t>(CallbackDetailsType::DETAILED), 479 expectProperties); 480 } 481 482 /* 483 * @tc.name: ChangeTrackerDataTest005 484 * @tc.desc: test changed data on unTracker table 485 * @tc.type: FUNC 486 * @tc.require: 487 * @tc.author: bty 488 */ 489 HWTEST_F(DistributedDBCloudTableWithoutPrimaryKeySyncTest, ChangeTrackerDataTest005, TestSize.Level0) 490 { 491 std::vector<ChangeProperties> expectProperties = { 492 g_unChangeProperties, g_unChangeProperties, g_unChangeProperties 493 }; 494 TestChangedDataInTrackerTable(g_trackerSchema3, static_cast<uint32_t>(CallbackDetailsType::DETAILED), 495 expectProperties); 496 } 497 } 498 #endif // RELATIONAL_STORE