代码拉取完成,页面将自动刷新
diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
index 11d630522..425ed00d1 100644
--- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
+++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_rdb_collaboration_test.cpp
@@ -1838,6 +1838,45 @@ HWTEST_F(DistributedDBRDBCollaborationTest, NormalSync018, TestSize.Level0)
EXPECT_EQ(changeData[tableName].field.size(), 1u); // rowid
}
+/**
+ * @tc.name: NormalSync020
+ * @tc.desc: Test set distributed schema after recreating the table.
+ * @tc.type: FUNC
+ * @tc.require:
+ * @tc.author: liaoyonghuang
+ */
+HWTEST_F(DistributedDBRDBCollaborationTest, NormalSync020, TestSize.Level0)
+{
+ /**
+ * @tc.steps: step1. Create device table and cloud table in COLLABORATION
+ * @tc.expected: step1.ok
+ */
+ ASSERT_NO_FATAL_FAILURE(InitDelegate());
+ auto schema = GetSchema();
+ auto distributedSchema = RDBDataGenerator::ParseSchema(schema, true);
+ EXPECT_EQ(delegate_->CreateDistributedTable(DEVICE_SYNC_TABLE, TableSyncType::DEVICE_COOPERATION), OK);
+ deviceB_->SetDistributedSchema(distributedSchema);
+ EXPECT_EQ(delegate_->SetDistributedSchema(distributedSchema), OK);
+ /**
+ * @tc.steps: step2. Sync a piece of data
+ * @tc.expected: step2.ok
+ */
+ auto tableSchema = GetTableSchema();
+ ASSERT_EQ(RDBDataGenerator::InsertVirtualLocalDBData(0, 1, deviceB_, tableSchema), E_OK);
+ ASSERT_EQ(RDBDataGenerator::PrepareVirtualDeviceEnv(tableSchema.name, db_, deviceB_), E_OK);
+ Query query = Query::Select(tableSchema.name);
+ DistributedDBToolsUnitTest::BlockSync(*delegate_, query, SYNC_MODE_PULL_ONLY, OK, {deviceB_->GetDeviceId()});
+ /**
+ * @tc.steps: step3. Recreate table and set distributed schema.
+ * @tc.expected: step3.ok
+ */
+ std::string sql = std::string("drop table ").append(DEVICE_SYNC_TABLE);
+ EXPECT_EQ(SQLiteUtils::ExecuteRawSQL(db_, sql), E_OK);
+ RDBDataGenerator::InitTable(schema.tables.front(), false, *db_);
+ EXPECT_EQ(delegate_->CreateDistributedTable(DEVICE_SYNC_TABLE, TableSyncType::DEVICE_COOPERATION), OK);
+ EXPECT_EQ(delegate_->SetDistributedSchema(distributedSchema), OK);
+}
+
/**
* @tc.name: InvalidSync001
* @tc.desc: Test remote set empty distributed schema and sync.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。