From e934f04ba947a8938331a19e0b39356568cdd254 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Sat, 30 Aug 2025 20:36:47 +0800 Subject: [PATCH 01/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/cloud/cloud_info.cpp | 38 ++++ .../framework/cloud/cloud_mark.cpp | 12 + .../framework/cloud/schema_meta.cpp | 45 ++++ .../framework/include/cloud/cloud_info.h | 5 + .../framework/include/cloud/cloud_mark.h | 2 + .../framework/include/cloud/schema_meta.h | 8 + .../framework/test/cloud_test.cpp | 208 +++++++++++++++++- .../service/cloud/cloud_service_impl.cpp | 97 +++++--- .../service/cloud/sync_manager.cpp | 6 +- .../sync_strategies/network_sync_strategy.cpp | 5 + .../sync_strategies/network_sync_strategy.h | 1 + .../service/test/cloud_data_test.cpp | 37 +++- 12 files changed, 422 insertions(+), 42 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index 0d80c15d9..ca2409703 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -48,6 +48,33 @@ bool CloudInfo::Unmarshal(const Serializable::json &node) return true; } +bool CloudInfo::IsMapEqual(const std::map &appInfos) const +{ + if (apps.size() != appInfos.size()) { + return false; + } + + for (const auto &pair : apps) { + auto it = appInfos.find(pair.first); + if (it == appInfos.end() || it->second == pair.second) { + return false; + } + } + return true; +} + +bool CloudInfo::operator==(const CloudInfo &info) const +{ + return (user == info.user) && (id == info.id) && (totalSpace == info.totalSpace) && + (remainSpace == info.remainSpace) && (enableCloud == info.enableCloud) && IsMapEqual(info.apps) && + (maxNumber == info.maxNumber) && (maxSize == info.maxSize); +} + +bool CloudInfo::operator!=(const CloudInfo &info) const +{ + return !operator==(info); +} + bool CloudInfo::AppInfo::Marshal(Serializable::json &node) const { SetValue(node[GET_NAME(bundleName)], bundleName); @@ -68,6 +95,17 @@ bool CloudInfo::AppInfo::Unmarshal(const Serializable::json &node) return true; } +bool CloudInfo::AppInfo::operator==(const AppInfo &info) const +{ + return (bundleName == info.bundleName) && (appId == info.appId) && (version == info.version) && + (instanceId == info.instanceId) && (cloudSwitch == info.cloudSwitch); +} + +bool CloudInfo::AppInfo::operator!=(const AppInfo &info) const +{ + return !operator==(info); +} + std::string CloudInfo::GetKey() const { return GetKey(INFO_PREFIX, { std::to_string(user) }); diff --git a/services/distributeddataservice/framework/cloud/cloud_mark.cpp b/services/distributeddataservice/framework/cloud/cloud_mark.cpp index 37e69ad2e..1cfc8ad5a 100644 --- a/services/distributeddataservice/framework/cloud/cloud_mark.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_mark.cpp @@ -31,6 +31,18 @@ bool CloudMark::Unmarshal(const Serializable::json &node) return true; } +bool CloudMark::operator==(const CloudMark &cloudMark) const +{ + return bundleName == cloudMark.bundleName && deviceId == cloudMark.deviceId && index == cloudMark.index && + isClearWaterMark == cloudMark.isClearWaterMark && storeId == cloudMark.storeId && + userId == cloudMark.userId; +} + +bool CloudMark::operator!=(const CloudMark &cloudMark) const +{ + return !operator==(cloudMark); +} + std::string CloudMark::GetKey() { return GetKey({ deviceId, std::to_string(userId), "default", bundleName, storeId, std::to_string(index) }); diff --git a/services/distributeddataservice/framework/cloud/schema_meta.cpp b/services/distributeddataservice/framework/cloud/schema_meta.cpp index 273fc6b48..e15043b19 100644 --- a/services/distributeddataservice/framework/cloud/schema_meta.cpp +++ b/services/distributeddataservice/framework/cloud/schema_meta.cpp @@ -40,6 +40,17 @@ bool SchemaMeta::Unmarshal(const Serializable::json &node) return true; } +bool SchemaMeta::operator==(const SchemaMeta &meta) const +{ + return (metaVersion == meta.metaVersion) && (version == meta.version) && (bundleName == meta.bundleName) && + (databases == meta.databases) && (e2eeEnable == meta.e2eeEnable); +} + +bool SchemaMeta::operator!=(const SchemaMeta &meta) const +{ + return !operator==(meta); +} + std::vector Database::GetTableNames() const { std::vector tableNames; @@ -99,6 +110,18 @@ bool Database::Unmarshal(const Serializable::json &node) return true; } +bool Database::operator==(const Database &database) const +{ + return (name == database.name) && (alias == database.alias) && (tables == database.tables) && + (version == database.version) && (bundleName == database.bundleName) && (user == database.user) && + (deviceId == database.deviceId) && (autoSyncType == database.autoSyncType); +} + +bool Database::operator!=(const Database &database) const +{ + return !operator==(database); +} + bool Table::Marshal(Serializable::json &node) const { SetValue(node[GET_NAME(name)], name); @@ -122,6 +145,18 @@ bool Table::Unmarshal(const Serializable::json &node) return true; } +bool Table::operator==(const Table &table) const +{ + return (name == table.name) && (alias == table.alias) && (fields == table.fields) && + (deviceSyncFields == table.deviceSyncFields) && (cloudSyncFields == table.cloudSyncFields) && + (sharedTableName == table.sharedTableName); +} + +bool Table::operator!=(const Table &table) const +{ + return !operator==(table); +} + bool Field::Marshal(Serializable::json &node) const { SetValue(node[GET_NAME(colName)], colName); @@ -144,6 +179,16 @@ bool Field::Unmarshal(const Serializable::json &node) GetValue(node, GET_NAME(notNull), nullable); return true; } +bool Field::operator==(const Field &field) const +{ + return (colName == field.colName) && (alias == field.alias) && (type == field.type) && + (primary == field.primary) && (nullable == field.nullable); +} + +bool Field::operator!=(const Field &field) const +{ + return !operator==(field); +} Database SchemaMeta::GetDataBase(const std::string &storeId) { diff --git a/services/distributeddataservice/framework/include/cloud/cloud_info.h b/services/distributeddataservice/framework/include/cloud/cloud_info.h index c565fcd2f..6ddf22628 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_info.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_info.h @@ -32,6 +32,8 @@ public: bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const AppInfo &info) const; + bool operator!=(const AppInfo &info) const; }; int32_t user = 0; std::string id = ""; @@ -57,6 +59,9 @@ public: bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool IsMapEqual(const std::map &appInfos) const; + bool operator==(const CloudInfo &info) const; + bool operator!=(const CloudInfo &info) const; private: static constexpr const char *INFO_PREFIX = "CLOUD_INFO"; diff --git a/services/distributeddataservice/framework/include/cloud/cloud_mark.h b/services/distributeddataservice/framework/include/cloud/cloud_mark.h index 47c5783d9..e4e101fab 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_mark.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_mark.h @@ -34,6 +34,8 @@ public: } bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const CloudMark &cloudMark) const; + bool operator!=(const CloudMark &cloudMark) const; std::string GetKey(); std::string GetKey(const std::initializer_list &fields); }; diff --git a/services/distributeddataservice/framework/include/cloud/schema_meta.h b/services/distributeddataservice/framework/include/cloud/schema_meta.h index 889392199..4d8c6ad83 100644 --- a/services/distributeddataservice/framework/include/cloud/schema_meta.h +++ b/services/distributeddataservice/framework/include/cloud/schema_meta.h @@ -25,6 +25,8 @@ struct API_EXPORT Field final : public Serializable { bool nullable = true; bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const Field &field) const; + bool operator!=(const Field &field) const; }; struct API_EXPORT Table final : public Serializable { @@ -36,6 +38,8 @@ struct API_EXPORT Table final : public Serializable { std::vector cloudSyncFields = {}; bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const Table &table) const; + bool operator!=(const Table &table) const; }; struct API_EXPORT Database final : public Serializable { @@ -53,6 +57,8 @@ struct API_EXPORT Database final : public Serializable { API_EXPORT static std::string GetPrefix(const std::initializer_list &fields); bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const Database &database) const; + bool operator!=(const Database &database) const; }; class API_EXPORT SchemaMeta final : public Serializable { @@ -95,6 +101,8 @@ public: bool IsValid() const; Database GetDataBase(const std::string &storeId); std::vector GetStores(); + bool operator==(const SchemaMeta &meta) const; + bool operator!=(const SchemaMeta &meta) const; }; // Table mode of device data sync time diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 57e4ab7ec..8f9a15db8 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -20,6 +20,7 @@ #include "cloud/cloud_db.h" #include "cloud/cloud_event.h" #include "cloud/cloud_info.h" +#include "cloud/cloud_mark.h" #include "cloud/cloud_server.h" #include "cloud/schema_meta.h" #include "utils/crypto.h" @@ -256,13 +257,44 @@ HWTEST_F(CloudInfoTest, CloudInfoTest001, TestSize.Level0) } /** -* @tc.name: AppInfoTest +* @tc.name: CloudInfoTest002 +* @tc.desc: CloudInfo Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) +{ + CloudInfo cloudInfo1; + cloudInfo1.user = 111; + cloudInfo1.id = "test1_id"; + cloudInfo1.totalSpace = 0; + cloudInfo1.remainSpace = 0; + cloudInfo1.enableCloud = false; + cloudInfo1.maxNumber = CloudInfo::DEFAULT_BATCH_NUMBER; + cloudInfo1.maxSize = CloudInfo::DEFAULT_BATCH_SIZE; + + CloudInfo cloudInfo2 = cloudInfo1; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, true); + ret = cloudInfo2 != cloudInfo1; + EXPECT_EQ(ret, false); + + cloudInfo2.user = 222; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + ret = cloudInfo2 != cloudInfo1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: AppInfoTest001 * @tc.desc: Marshal and Unmarshal of AppInfo. * @tc.type: FUNC * @tc.require: * @tc.author: Anvette */ -HWTEST_F(CloudInfoTest, AppInfoTest, TestSize.Level0) +HWTEST_F(CloudInfoTest, AppInfoTest001, TestSize.Level0) { CloudInfo::AppInfo cloudInfoAppInfo1; cloudInfoAppInfo1.bundleName = "ohos.test.demo"; @@ -281,13 +313,42 @@ HWTEST_F(CloudInfoTest, AppInfoTest, TestSize.Level0) } /** -* @tc.name: TableTest +* @tc.name: AppInfoTest002 +* @tc.desc: AppInfoTest Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) +{ + CloudInfo::AppInfo cloudInfoAppInfo1; + cloudInfoAppInfo1.bundleName = "ohos.test.demo"; + cloudInfoAppInfo1.appId = "test1_id"; + cloudInfoAppInfo1.version = 0; + cloudInfoAppInfo1.instanceId = 0; + cloudInfoAppInfo1.cloudSwitch = false; + + CloudInfo::AppInfo cloudInfoAppInfo2 = cloudInfoAppInfo1; + auto ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, true); + ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; + EXPECT_EQ(ret, false); + + cloudInfoAppInfo2.version = 1; + ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, false); + ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: TableTest001 * @tc.desc: Marshal and Unmarshal of Table. * @tc.type: FUNC * @tc.require: * @tc.author: Anvette */ -HWTEST_F(CloudInfoTest, TableTest, TestSize.Level0) +HWTEST_F(CloudInfoTest, TableTest001, TestSize.Level0) { Field field1; field1.colName = "test1_colName"; @@ -310,6 +371,71 @@ HWTEST_F(CloudInfoTest, TableTest, TestSize.Level0) EXPECT_EQ(Serializable::Marshall(table1), Serializable::Marshall(table2)); } +/** +* @tc.name: TableTest002 +* @tc.desc: Table Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) +{ + Field field1; + field1.colName = "test1_colName"; + field1.alias = "test1_alias"; + field1.type = 1; + field1.primary = true; + field1.nullable = false; + + Table table1; + table1.name = "test1_name"; + table1.sharedTableName = "test1_sharedTableName"; + table1.alias = "test1_alias"; + table1.fields.push_back(field1); + + Table table2 = table1; + auto ret = table2 == table1; + EXPECT_EQ(ret, true); + ret = table2 != table1; + EXPECT_EQ(ret, false); + + table1.name = "test2_name"; + ret = table2 == table1; + EXPECT_EQ(ret, false); + ret = table2 != table1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: FieldTest +* @tc.desc: Field Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) +{ + Field field1; + field1.colName = "test1_colName"; + field1.alias = "test1_alias"; + field1.type = 1; + field1.primary = true; + field1.nullable = false; + + + Field field2 = field1; + auto ret = field2 == field1; + EXPECT_EQ(ret, true); + ret = field2 != field1; + EXPECT_EQ(ret, false); + + field2.type = 2; + ret = field2 == field1; + EXPECT_EQ(ret, false); + ret = field2 != field1; + EXPECT_EQ(ret, true); +} + /** * @tc.name: IsAllSwitchOffTest * @tc.desc: Determine if all apps have their cloud synchronization disabled. @@ -514,13 +640,13 @@ HWTEST_F(ServicesCloudDBTest, CloudDB, TestSize.Level0) } /** -* @tc.name: SchemaMeta +* @tc.name: SchemaMeta001 * @tc.desc: test SchemaMeta GetLowVersion and GetHighVersion function. * @tc.type: FUNC * @tc.require: * @tc.author: SQL */ -HWTEST_F(CloudInfoTest, SchemaMeta, TestSize.Level0) +HWTEST_F(CloudInfoTest, SchemaMeta001, TestSize.Level0) { SchemaMeta schemaMeta; auto metaVersion = SchemaMeta::CURRENT_VERSION & 0xFFFF; @@ -531,6 +657,48 @@ HWTEST_F(CloudInfoTest, SchemaMeta, TestSize.Level0) EXPECT_EQ(result2, metaVersion); } +/** +* @tc.name: SchemaMeta002 +* @tc.desc: SchemaMeta Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) +{ + SchemaMeta::Field field1; + field1.colName = "test_cloud_field_name1"; + field1.alias = "test_cloud_field_alias1"; + + SchemaMeta::Table table; + table.name = "test_cloud_table_name"; + table.alias = "test_cloud_table_alias"; + table.fields.emplace_back(field1); + + SchemaMeta::Database database; + database.name = "test_cloud_store"; + database.alias = "test_cloud_database_alias_1"; + database.tables.emplace_back(table); + + SchemaMeta schemaMeta1; + schemaMeta1.version = 1; + schemaMeta1.bundleName = "test_cloud_bundleName"; + schemaMeta1.databases.emplace_back(database); + schemaMeta1.e2eeEnable = false; + + SchemaMeta schemaMeta2 = schemaMeta1; + auto ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, true); + ret = schemaMeta2 != schemaMeta1; + EXPECT_EQ(ret, false); + + schemaMeta2.version = 2; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + ret = schemaMeta2 != schemaMeta1; + EXPECT_EQ(ret, true); +} + /** * @tc.name: GetEventId * @tc.desc: test GetEventId function @@ -546,4 +714,32 @@ HWTEST_F(CloudEventTest, GetEventId, TestSize.Level0) auto ret = event.GetEventId(); EXPECT_EQ(ret, evtId); } + +/** +* @tc.name: CloudMarkTest +* @tc.desc: CloudMark Overload function test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: SQL +*/ +HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) +{ + CloudMark cloudmark1; + cloudmark1.bundleName = "test_cloud_bundleName"; + cloudmark1.deviceId = "1111"; + cloudmark1.storeId = "test_db"; + + + CloudMark cloudmark2 = cloudmark1; + auto ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, true); + ret = cloudmark2 != cloudmark1; + EXPECT_EQ(ret, false); + + cloudmark2.deviceId = "222"; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); + ret = cloudmark2 != cloudmark1; + EXPECT_EQ(ret, true); +} } // namespace OHOS::Test diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index a1f141257..a737895cb 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -134,18 +134,24 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map CloudServiceImpl::GetSchemaMeta(int32_t userId, c } UpgradeSchemaMeta(userId, schemaMeta); HapInfo hapInfo{ .user = userId, .instIndex = instanceId, .bundleName = bundleName }; - std::tie(status, schemaMeta) = GetSchemaFromHap(hapInfo); + SchemaMeta newMeta; + std::tie(status, newMeta) = GetSchemaFromHap(hapInfo); if (status == SUCCESS) { - MetaDataManager::GetInstance().SaveMeta(schemaKey, schemaMeta, true); - return { status, schemaMeta }; + if (newMeta != schemaMeta) { + MetaDataManager::GetInstance().SaveMeta(schemaKey, newMeta, true); + } + return { status, newMeta }; } if (!Account::GetInstance()->IsVerified(userId)) { ZLOGE("user:%{public}d is locked!", userId); return { ERROR, schemaMeta }; } - std::tie(status, schemaMeta) = GetAppSchemaFromServer(userId, bundleName); + std::tie(status, newMeta) = GetAppSchemaFromServer(userId, bundleName); if (status == NOT_SUPPORT) { ZLOGW("app not support, del cloudInfo! userId:%{public}d, bundleName:%{public}s", userId, bundleName.c_str()); MetaDataManager::GetInstance().DelMeta(cloudInfo.GetKey(), true); @@ -1098,8 +1117,10 @@ std::pair CloudServiceImpl::GetSchemaMeta(int32_t userId, c if (status != SUCCESS) { return { status, schemaMeta }; } - MetaDataManager::GetInstance().SaveMeta(schemaKey, schemaMeta, true); - return { SUCCESS, schemaMeta }; + if (newMeta != schemaMeta) { + MetaDataManager::GetInstance().SaveMeta(schemaKey, newMeta, true); + } + return { SUCCESS, newMeta }; } std::pair CloudServiceImpl::GetCloudInfo(int32_t userId) @@ -1112,26 +1133,31 @@ std::pair CloudServiceImpl::GetCloudInfo(int32_t userId) ZLOGW("user:%{public}d is locked!", userId); return { ERROR, cloudInfo }; } - std::tie(status, cloudInfo) = GetCloudInfoFromServer(userId); + CloudInfo newInfo; + std::tie(status, newInfo) = GetCloudInfoFromServer(userId); if (status != SUCCESS) { ZLOGE("userId:%{public}d, status:%{public}d", userId, status); return { status, cloudInfo }; } - MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true); - return { SUCCESS, cloudInfo }; + if (newInfo != cloudInfo) { + MetaDataManager::GetInstance().SaveMeta(newInfo.GetKey(), newInfo, true); + } + return { SUCCESS, newInfo }; } int32_t CloudServiceImpl::CloudStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) { Subscription sub; - if (MetaDataManager::GetInstance().LoadMeta(Subscription::GetKey(user), sub, true)) { + if (MetaDataManager::GetInstance().LoadMeta(Subscription::GetKey(user), sub, true) && + sub.expiresTime.find(bundleName) != sub.expiresTime.end()) { sub.expiresTime.erase(bundleName); MetaDataManager::GetInstance().SaveMeta(Subscription::GetKey(user), sub, true); } CloudInfo cloudInfo; cloudInfo.user = user; - if (MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetKey(), cloudInfo, true)) { + if (MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetKey(), cloudInfo, true) && + cloudInfo.apps.find(bundleName) != cloudInfo.apps.end()) { cloudInfo.apps.erase(bundleName); MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true); } @@ -1206,7 +1232,9 @@ int32_t CloudServiceImpl::UpdateSchemaFromHap(const HapInfo &hapInfo) if (MetaDataManager::GetInstance().LoadMeta(schemaKey, schemaMeta, true)) { UpdateClearWaterMark(hapInfo, newSchemaMeta, schemaMeta); } - MetaDataManager::GetInstance().SaveMeta(schemaKey, newSchemaMeta, true); + if (newSchemaMeta != schemaMeta) { + MetaDataManager::GetInstance().SaveMeta(schemaKey, newSchemaMeta, true); + } return SUCCESS; } @@ -1232,7 +1260,11 @@ void CloudServiceImpl::UpdateClearWaterMark( if (dbMap.find(database.name) != dbMap.end() && database.version != dbMap[database.name]) { metaData.storeId = database.name; metaData.isClearWaterMark = true; - MetaDataManager::GetInstance().SaveMeta(metaData.GetKey(), metaData, true); + CloudMark newMark; + MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), newMark, true); + if (newMark != metaData) { + MetaDataManager::GetInstance().SaveMeta(newMark.GetKey(), newMark, true); + } ZLOGI("clear watermark, storeId:%{public}s, newVersion:%{public}d, oldVersion:%{public}d", Anonymous::Change(metaData.storeId).c_str(), database.version, dbMap[database.name]); } @@ -1900,6 +1932,9 @@ int32_t CloudServiceImpl::SaveNetworkStrategy(const std::vector> SyncManager::GetCloudSyncInfo(const ZLOGE("cloud is empty, user: %{public}d", cloud.user); return cloudSyncInfos; } - if (!MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true)) { - ZLOGW("save cloud info fail, user: %{public}d", cloud.user); + CloudInfo oldInfo; + MetaDataManager::GetInstance().LoadMeta(cloud.GetKey(), oldInfo, true); + if (oldInfo != cloud) { + MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true); } } auto schemaKey = CloudInfo::GetSchemaKey(cloud.user, info.bundleName_); diff --git a/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.cpp b/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.cpp index ae1cb2a47..8f939d028 100644 --- a/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.cpp +++ b/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.cpp @@ -89,6 +89,11 @@ bool NetworkSyncStrategy::StrategyInfo::Unmarshal(const Serializable::json &node return false; } +bool NetworkSyncStrategy::StrategyInfo::operator==(const StrategyInfo &info) const +{ + return user == info.user && bundleName == info.bundleName && strategy == info.strategy; +} + std::string NetworkSyncStrategy::StrategyInfo::GetKey() { return Constant::Join(StrategyInfo::PREFIX, Constant::KEY_SEPARATOR, { std::to_string(user), bundleName }); diff --git a/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.h b/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.h index 2c32abc0b..53a713345 100644 --- a/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.h +++ b/services/distributeddataservice/service/cloud/sync_strategies/network_sync_strategy.h @@ -34,6 +34,7 @@ public: uint32_t strategy = DEFAULT_STRATEGY; bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; + bool operator==(const StrategyInfo &info) const; std::string GetKey(); static constexpr int32_t INVALID_USER = -1; static constexpr const char *PREFIX = "NETWORK_SYNC_STRATEGY"; diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 7e2995508..375f74f17 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1396,12 +1396,12 @@ HWTEST_F(CloudDataTest, ChangeAppSwitch, TestSize.Level0) } /** -* @tc.name: EnableCloud -* @tc.desc: +* @tc.name: EnableCloud01 +* @tc.desc: Test the EnableCloud function to ensure that the id in cloudinfo matches the passed id. * @tc.type: FUNC * @tc.require: */ -HWTEST_F(CloudDataTest, EnableCloud, TestSize.Level0) +HWTEST_F(CloudDataTest, EnableCloud01, TestSize.Level0) { std::string bundleName = "testName"; std::map switches; @@ -1411,6 +1411,37 @@ HWTEST_F(CloudDataTest, EnableCloud, TestSize.Level0) EXPECT_EQ(ret, CloudData::CloudService::SUCCESS); } +/** +* @tc.name: EnableCloud02 +* @tc.desc: Test the EnableCloud function to ensure that the id in cloudinfo does not equal the passed id. +* @tc.type: FUNC +* @tc.require: + */ +HWTEST_F(CloudDataTest, EnableCloud02, TestSize.Level0) +{ + std::string bundleName = "testName"; + std::map switches; + switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_ON); + switches.insert_or_assign(bundleName, CloudData::CloudService::SWITCH_ON); + auto ret = cloudServiceImpl_->EnableCloud("123456", switches); + EXPECT_NE(ret, CloudData::CloudService::INVALID_ARGUMENT); +} + +/** +* @tc.name: EnableCloud03 +* @tc.desc: Test the EnableCloud function to SWITCH_OFF. +* @tc.type: FUNC +* @tc.require: + */ +HWTEST_F(CloudDataTest, EnableCloud03, TestSize.Level0) +{ + std::map switches; + switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_OFF); + auto ret = cloudServiceImpl_->EnableCloud(TEST_CLOUD_ID, switches); + EXPECT_NE(ret, CloudData::CloudService::SUCCESS); +} + + /** * @tc.name: OnEnableCloud * @tc.desc: -- Gitee From 4b2b4755c9b3d06109a1526e52fba6a3280c8cd9 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Mon, 1 Sep 2025 20:37:59 +0800 Subject: [PATCH 02/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/framework/cloud/cloud_info.cpp | 2 +- .../distributeddataservice/framework/cloud/cloud_mark.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index ca2409703..fde7ad7f4 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -55,7 +55,7 @@ bool CloudInfo::IsMapEqual(const std::map &appInfos) const } for (const auto &pair : apps) { - auto it = appInfos.find(pair.first); + auto it = appInfos.find(pair.first); if (it == appInfos.end() || it->second == pair.second) { return false; } diff --git a/services/distributeddataservice/framework/cloud/cloud_mark.cpp b/services/distributeddataservice/framework/cloud/cloud_mark.cpp index 1cfc8ad5a..f12039a1b 100644 --- a/services/distributeddataservice/framework/cloud/cloud_mark.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_mark.cpp @@ -33,9 +33,9 @@ bool CloudMark::Unmarshal(const Serializable::json &node) bool CloudMark::operator==(const CloudMark &cloudMark) const { - return bundleName == cloudMark.bundleName && deviceId == cloudMark.deviceId && index == cloudMark.index && - isClearWaterMark == cloudMark.isClearWaterMark && storeId == cloudMark.storeId && - userId == cloudMark.userId; + return (bundleName == cloudMark.bundleName) && (deviceId == cloudMark.deviceId) && (index == cloudMark.index) && + (isClearWaterMark == cloudMark.isClearWaterMark) && (storeId == cloudMark.storeId) && + (userId == cloudMark.userId); } bool CloudMark::operator!=(const CloudMark &cloudMark) const -- Gitee From f947ed926db029b7aabdff7cbddbd7c127a876fc Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Mon, 1 Sep 2025 20:37:59 +0800 Subject: [PATCH 03/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/test/cloud_data_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 375f74f17..f5b772aba 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1424,7 +1424,7 @@ HWTEST_F(CloudDataTest, EnableCloud02, TestSize.Level0) switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_ON); switches.insert_or_assign(bundleName, CloudData::CloudService::SWITCH_ON); auto ret = cloudServiceImpl_->EnableCloud("123456", switches); - EXPECT_NE(ret, CloudData::CloudService::INVALID_ARGUMENT); + EXPECT_NE(ret, CloudData::CloudService::SUCCESS); } /** -- Gitee From 7731b1d163515cbbe1d1d44fc9ff4e62dc456ba1 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Mon, 1 Sep 2025 20:37:59 +0800 Subject: [PATCH 04/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index a737895cb..43848c5b0 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -1260,10 +1260,10 @@ void CloudServiceImpl::UpdateClearWaterMark( if (dbMap.find(database.name) != dbMap.end() && database.version != dbMap[database.name]) { metaData.storeId = database.name; metaData.isClearWaterMark = true; - CloudMark newMark; - MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), newMark, true); - if (newMark != metaData) { - MetaDataManager::GetInstance().SaveMeta(newMark.GetKey(), newMark, true); + CloudMark oldMark; + MetaDataManager::GetInstance().LoadMeta(metaData.GetKey(), oldMark, true); + if (oldMark != metaData) { + MetaDataManager::GetInstance().SaveMeta(metaData.GetKey(), metaData, true); } ZLOGI("clear watermark, storeId:%{public}s, newVersion:%{public}d, oldVersion:%{public}d", Anonymous::Change(metaData.storeId).c_str(), database.version, dbMap[database.name]); -- Gitee From 15d90a15cc8d2c9a227291eb1bcce1c2dc2aac6b Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Mon, 1 Sep 2025 22:17:24 +0800 Subject: [PATCH 05/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 43848c5b0..01032cd95 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -149,7 +149,9 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map Date: Mon, 1 Sep 2025 22:27:48 +0800 Subject: [PATCH 06/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 01032cd95..c3c2e9ad9 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -204,11 +204,9 @@ int32_t CloudServiceImpl::ChangeAppSwitch(const std::string &id, const std::stri XCollie xcollie(__FUNCTION__, XCollie::XCOLLIE_LOG | XCollie::XCOLLIE_RECOVERY); auto tokenId = IPCSkeleton::GetCallingTokenID(); auto user = Account::GetInstance()->GetUserByToken(tokenId); - CloudSyncScene scene; + CloudSyncScene scene = CloudSyncScene::SWITCH_OFF; if (appSwitch == SWITCH_ON) { scene = CloudSyncScene::SWITCH_ON; - } else { - scene = CloudSyncScene::SWITCH_OFF; } std::lock_guard lock(rwMetaMutex_); auto [status, cloudInfo] = GetCloudInfo(user); -- Gitee From 814c61f7d50712af8368cf8461ebc64748951980 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 10:57:06 +0800 Subject: [PATCH 07/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/cloud/sync_manager.cpp | 4 ++-- .../distributeddataservice/service/test/cloud_data_test.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/cloud/sync_manager.cpp b/services/distributeddataservice/service/cloud/sync_manager.cpp index 0064ff625..ff916398c 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -741,8 +741,8 @@ std::vector> SyncManager::GetCloudSyncInfo(const } CloudInfo oldInfo; MetaDataManager::GetInstance().LoadMeta(cloud.GetKey(), oldInfo, true); - if (oldInfo != cloud) { - MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true); + if (oldInfo != cloud && !MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true)) { + ZLOGW("save cloud info fail, user: %{public}d", cloud.user); } } auto schemaKey = CloudInfo::GetSchemaKey(cloud.user, info.bundleName_); diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index f5b772aba..0e55deb93 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1438,7 +1438,7 @@ HWTEST_F(CloudDataTest, EnableCloud03, TestSize.Level0) std::map switches; switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_OFF); auto ret = cloudServiceImpl_->EnableCloud(TEST_CLOUD_ID, switches); - EXPECT_NE(ret, CloudData::CloudService::SUCCESS); + EXPECT_EQ(ret, CloudData::CloudService::SUCCESS); } -- Gitee From 0bfb5f0569f620e591866b19808989e321dd3930 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 11:28:35 +0800 Subject: [PATCH 08/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/framework/cloud/cloud_info.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index fde7ad7f4..51cf985ec 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -53,10 +53,8 @@ bool CloudInfo::IsMapEqual(const std::map &appInfos) const if (apps.size() != appInfos.size()) { return false; } - for (const auto &pair : apps) { - auto it = appInfos.find(pair.first); - if (it == appInfos.end() || it->second == pair.second) { + if (pair.second != appInfos.at(pair.first)) { return false; } } -- Gitee From 028ed6185b1c2ea295a7eaaf7991cd761e5c11af Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 11:56:22 +0800 Subject: [PATCH 09/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/framework/cloud/cloud_info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index 51cf985ec..b1835ce6d 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -53,8 +53,8 @@ bool CloudInfo::IsMapEqual(const std::map &appInfos) const if (apps.size() != appInfos.size()) { return false; } - for (const auto &pair : apps) { - if (pair.second != appInfos.at(pair.first)) { + for (auto it = apps.begin(), newIt = appInfos.begin(); it != apps.end(); ++it, ++newIt) { + if (it.second != newIt.second) { return false; } } -- Gitee From 995ea029029ec8a6c67eccae132055bb48a86948 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 11:58:58 +0800 Subject: [PATCH 10/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- services/distributeddataservice/framework/cloud/cloud_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index b1835ce6d..29d643efb 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -54,7 +54,7 @@ bool CloudInfo::IsMapEqual(const std::map &appInfos) const return false; } for (auto it = apps.begin(), newIt = appInfos.begin(); it != apps.end(); ++it, ++newIt) { - if (it.second != newIt.second) { + if (it->second != newIt->second) { return false; } } -- Gitee From 4db808b849659f25f06d2035de5cd71614e3bbd1 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 16:29:57 +0800 Subject: [PATCH 11/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/cloud/cloud_info.cpp | 8 ++++---- .../framework/include/cloud/cloud_info.h | 2 +- .../framework/test/cloud_test.cpp | 12 ++++++------ .../service/cloud/cloud_service_impl.cpp | 6 +----- .../service/test/cloud_data_test.cpp | 18 +----------------- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index 29d643efb..93ec22596 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -48,13 +48,13 @@ bool CloudInfo::Unmarshal(const Serializable::json &node) return true; } -bool CloudInfo::IsMapEqual(const std::map &appInfos) const +bool CloudInfo::IsAppsEqual(const std::map &appInfos) const { if (apps.size() != appInfos.size()) { return false; } - for (auto it = apps.begin(), newIt = appInfos.begin(); it != apps.end(); ++it, ++newIt) { - if (it->second != newIt->second) { + for (auto it = apps.begin(), rIt = appInfos.begin(); it != apps.end(); ++it, ++rIt) { + if (it->second != rIt->second) { return false; } } @@ -64,7 +64,7 @@ bool CloudInfo::IsMapEqual(const std::map &appInfos) const bool CloudInfo::operator==(const CloudInfo &info) const { return (user == info.user) && (id == info.id) && (totalSpace == info.totalSpace) && - (remainSpace == info.remainSpace) && (enableCloud == info.enableCloud) && IsMapEqual(info.apps) && + (remainSpace == info.remainSpace) && (enableCloud == info.enableCloud) && IsAppsEqual(info.apps) && (maxNumber == info.maxNumber) && (maxSize == info.maxSize); } diff --git a/services/distributeddataservice/framework/include/cloud/cloud_info.h b/services/distributeddataservice/framework/include/cloud/cloud_info.h index 6ddf22628..f9f3c2af5 100644 --- a/services/distributeddataservice/framework/include/cloud/cloud_info.h +++ b/services/distributeddataservice/framework/include/cloud/cloud_info.h @@ -59,7 +59,6 @@ public: bool Marshal(json &node) const override; bool Unmarshal(const json &node) override; - bool IsMapEqual(const std::map &appInfos) const; bool operator==(const CloudInfo &info) const; bool operator!=(const CloudInfo &info) const; @@ -68,6 +67,7 @@ private: static constexpr const char *SCHEMA_PREFIX = "CLOUD_SCHEMA"; static std::string GetKey(const std::string &prefix, const std::initializer_list &fields); + bool IsAppsEqual(const std::map &appInfos) const; }; } // namespace OHOS::DistributedData #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_INFO_H diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 8f9a15db8..7c4fb2eea 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -261,7 +261,7 @@ HWTEST_F(CloudInfoTest, CloudInfoTest001, TestSize.Level0) * @tc.desc: CloudInfo Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) { @@ -317,7 +317,7 @@ HWTEST_F(CloudInfoTest, AppInfoTest001, TestSize.Level0) * @tc.desc: AppInfoTest Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) { @@ -376,7 +376,7 @@ HWTEST_F(CloudInfoTest, TableTest001, TestSize.Level0) * @tc.desc: Table Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) { @@ -411,7 +411,7 @@ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) * @tc.desc: Field Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) { @@ -662,7 +662,7 @@ HWTEST_F(CloudInfoTest, SchemaMeta001, TestSize.Level0) * @tc.desc: SchemaMeta Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) { @@ -720,7 +720,7 @@ HWTEST_F(CloudEventTest, GetEventId, TestSize.Level0) * @tc.desc: CloudMark Overload function test. * @tc.type: FUNC * @tc.require: -* @tc.author: SQL +* @tc.author: */ HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) { diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index c3c2e9ad9..c26d54e53 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -134,11 +134,7 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map switches; - switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_ON); - switches.insert_or_assign(bundleName, CloudData::CloudService::SWITCH_ON); - auto ret = cloudServiceImpl_->EnableCloud("123456", switches); - EXPECT_NE(ret, CloudData::CloudService::SUCCESS); -} - -/** -* @tc.name: EnableCloud03 * @tc.desc: Test the EnableCloud function to SWITCH_OFF. * @tc.type: FUNC * @tc.require: */ -HWTEST_F(CloudDataTest, EnableCloud03, TestSize.Level0) +HWTEST_F(CloudDataTest, EnableCloud02, TestSize.Level0) { std::map switches; switches.insert_or_assign(TEST_CLOUD_BUNDLE, CloudData::CloudService::SWITCH_OFF); -- Gitee From 8e5593021e3283612de8d07f079e87ff0d8e73a9 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 16:35:55 +0800 Subject: [PATCH 12/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index c26d54e53..7ddade35f 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -134,18 +134,18 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map Date: Tue, 2 Sep 2025 16:53:54 +0800 Subject: [PATCH 13/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/cloud/cloud_info.cpp | 6 +++--- .../framework/cloud/cloud_mark.cpp | 6 +++--- .../framework/cloud/schema_meta.cpp | 20 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index 93ec22596..f9d99ff92 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -63,9 +63,9 @@ bool CloudInfo::IsAppsEqual(const std::map &appInfos) cons bool CloudInfo::operator==(const CloudInfo &info) const { - return (user == info.user) && (id == info.id) && (totalSpace == info.totalSpace) && - (remainSpace == info.remainSpace) && (enableCloud == info.enableCloud) && IsAppsEqual(info.apps) && - (maxNumber == info.maxNumber) && (maxSize == info.maxSize); + return std::tie(user, id, totalSpace, remainSpace, enableCloud, maxNumber, maxSize) == + std::tie(info.user, info.id, info.totalSpace, info.remainSpace, info.enableCloud, info.maxNumber, + info.maxSize) && IsAppsEqual(info.apps); } bool CloudInfo::operator!=(const CloudInfo &info) const diff --git a/services/distributeddataservice/framework/cloud/cloud_mark.cpp b/services/distributeddataservice/framework/cloud/cloud_mark.cpp index f12039a1b..56661597d 100644 --- a/services/distributeddataservice/framework/cloud/cloud_mark.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_mark.cpp @@ -33,9 +33,9 @@ bool CloudMark::Unmarshal(const Serializable::json &node) bool CloudMark::operator==(const CloudMark &cloudMark) const { - return (bundleName == cloudMark.bundleName) && (deviceId == cloudMark.deviceId) && (index == cloudMark.index) && - (isClearWaterMark == cloudMark.isClearWaterMark) && (storeId == cloudMark.storeId) && - (userId == cloudMark.userId); + return std::tie(bundleName, deviceId, index, isClearWaterMark, storeId, userId) == + std::tie(cloudMark.bundleName, cloudMark.deviceId, cloudMark.index, cloudMark.isClearWaterMark, + cloudMark.storeId, cloudMark.userId); } bool CloudMark::operator!=(const CloudMark &cloudMark) const diff --git a/services/distributeddataservice/framework/cloud/schema_meta.cpp b/services/distributeddataservice/framework/cloud/schema_meta.cpp index e15043b19..a34b86873 100644 --- a/services/distributeddataservice/framework/cloud/schema_meta.cpp +++ b/services/distributeddataservice/framework/cloud/schema_meta.cpp @@ -42,8 +42,8 @@ bool SchemaMeta::Unmarshal(const Serializable::json &node) bool SchemaMeta::operator==(const SchemaMeta &meta) const { - return (metaVersion == meta.metaVersion) && (version == meta.version) && (bundleName == meta.bundleName) && - (databases == meta.databases) && (e2eeEnable == meta.e2eeEnable); + return std::tie(metaVersion, version, bundleName, databases, e2eeEnable) == + std::tie(meta.metaVersion, meta.version, meta.bundleName, meta.databases, meta.e2eeEnable); } bool SchemaMeta::operator!=(const SchemaMeta &meta) const @@ -112,9 +112,9 @@ bool Database::Unmarshal(const Serializable::json &node) bool Database::operator==(const Database &database) const { - return (name == database.name) && (alias == database.alias) && (tables == database.tables) && - (version == database.version) && (bundleName == database.bundleName) && (user == database.user) && - (deviceId == database.deviceId) && (autoSyncType == database.autoSyncType); + return std::tie(name, alias, tables, version, bundleName, user, deviceId, autoSyncType) == + std::tie(database.name, database.alias, database.tables, database.version, database.bundleName, database.user, + database.deviceId, database.autoSyncType); } bool Database::operator!=(const Database &database) const @@ -147,9 +147,9 @@ bool Table::Unmarshal(const Serializable::json &node) bool Table::operator==(const Table &table) const { - return (name == table.name) && (alias == table.alias) && (fields == table.fields) && - (deviceSyncFields == table.deviceSyncFields) && (cloudSyncFields == table.cloudSyncFields) && - (sharedTableName == table.sharedTableName); + return std::tie(name, alias, fields, deviceSyncFields, cloudSyncFields, sharedTableName) == + std::tie(table.name, table.alias, table.fields, table.deviceSyncFields, table.cloudSyncFields, + table.sharedTableName); } bool Table::operator!=(const Table &table) const @@ -181,8 +181,8 @@ bool Field::Unmarshal(const Serializable::json &node) } bool Field::operator==(const Field &field) const { - return (colName == field.colName) && (alias == field.alias) && (type == field.type) && - (primary == field.primary) && (nullable == field.nullable); + return std::tie(colName, alias, type, primary, nullable) == + std::tie(field.colName, field.alias, field.type, field.primary, field.nullable); } bool Field::operator!=(const Field &field) const -- Gitee From 178f848d7c9bbdfebdd3dbaf2301fbc273fa07d5 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 17:05:47 +0800 Subject: [PATCH 14/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/cloud/cloud_service_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 7ddade35f..ec1fd1836 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -149,7 +149,7 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map Date: Tue, 2 Sep 2025 17:07:55 +0800 Subject: [PATCH 15/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/framework/cloud/cloud_info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_info.cpp b/services/distributeddataservice/framework/cloud/cloud_info.cpp index f9d99ff92..0c70f3e94 100644 --- a/services/distributeddataservice/framework/cloud/cloud_info.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_info.cpp @@ -95,8 +95,8 @@ bool CloudInfo::AppInfo::Unmarshal(const Serializable::json &node) bool CloudInfo::AppInfo::operator==(const AppInfo &info) const { - return (bundleName == info.bundleName) && (appId == info.appId) && (version == info.version) && - (instanceId == info.instanceId) && (cloudSwitch == info.cloudSwitch); + return std::tie(bundleName, appId, version, instanceId, cloudSwitch) == std::tie(info.bundleName, info.appId, + info.version, info.instanceId, info.cloudSwitch); } bool CloudInfo::AppInfo::operator!=(const AppInfo &info) const -- Gitee From 8f8f5dfd07d456bda913d2dd15abb1d8f6926ddc Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 17:10:27 +0800 Subject: [PATCH 16/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/cloud/cloud_mark.cpp | 2 +- .../service/cloud/cloud_service_impl.cpp | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/services/distributeddataservice/framework/cloud/cloud_mark.cpp b/services/distributeddataservice/framework/cloud/cloud_mark.cpp index 56661597d..f6003a209 100644 --- a/services/distributeddataservice/framework/cloud/cloud_mark.cpp +++ b/services/distributeddataservice/framework/cloud/cloud_mark.cpp @@ -35,7 +35,7 @@ bool CloudMark::operator==(const CloudMark &cloudMark) const { return std::tie(bundleName, deviceId, index, isClearWaterMark, storeId, userId) == std::tie(cloudMark.bundleName, cloudMark.deviceId, cloudMark.index, cloudMark.isClearWaterMark, - cloudMark.storeId, cloudMark.userId); + cloudMark.storeId, cloudMark.userId); } bool CloudMark::operator!=(const CloudMark &cloudMark) const diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index ec1fd1836..3d8b1929a 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -183,14 +183,15 @@ int32_t CloudServiceImpl::DisableCloud(const std::string &id) Anonymous::Change(cloudInfo.id).c_str()); return INVALID_ARGUMENT; } - auto newCloudInfo = cloudInfo; - newCloudInfo.enableCloud = false; - if (newCloudInfo != cloudInfo) { - if (!MetaDataManager::GetInstance().SaveMeta(newCloudInfo.GetKey(), newCloudInfo, true)) { + cloudInfo.enableCloud = false; + CloudInfo oldCloudInfo; + MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetKey(), oldCloudInfo, true); + if (oldCloudInfo != cloudInfo) { + if (!MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true)) { return ERROR; } } - Execute(GenTask(0, newCloudInfo.user, CloudSyncScene::DISABLE_CLOUD, { WORK_STOP_CLOUD_SYNC, WORK_SUB })); + Execute(GenTask(0, cloudInfo.user, CloudSyncScene::DISABLE_CLOUD, { WORK_STOP_CLOUD_SYNC, WORK_SUB })); ZLOGI("DisableCloud success, id:%{public}s", Anonymous::Change(id).c_str()); return SUCCESS; } @@ -228,18 +229,18 @@ int32_t CloudServiceImpl::ChangeAppSwitch(const std::string &id, const std::stri "ChangeAppSwitch ret=" + std::to_string(status)); return INVALID_ARGUMENT; } - ZLOGI("add app switch, bundleName:%{public}s", bundleName.c_str()); } - auto newCloudInfo = cloudInfo; - newCloudInfo.apps[bundleName].cloudSwitch = (appSwitch == SWITCH_ON); - if (newCloudInfo != cloudInfo) { - if (!MetaDataManager::GetInstance().SaveMeta(newCloudInfo.GetKey(), newCloudInfo, true)) { + cloudInfo.apps[bundleName].cloudSwitch = (appSwitch == SWITCH_ON); + CloudInfo oldCloudInfo; + MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetKey(), oldCloudInfo, true); + if (oldCloudInfo != cloudInfo) { + if (!MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true)) { return ERROR; } } - Execute(GenTask(0, newCloudInfo.user, scene, { WORK_CLOUD_INFO_UPDATE, WORK_SCHEMA_UPDATE, WORK_SUB })); - if (newCloudInfo.enableCloud && appSwitch == SWITCH_ON) { - SyncManager::SyncInfo info(newCloudInfo.user, bundleName); + Execute(GenTask(0, cloudInfo.user, scene, { WORK_CLOUD_INFO_UPDATE, WORK_SCHEMA_UPDATE, WORK_SUB })); + if (cloudInfo.enableCloud && appSwitch == SWITCH_ON) { + SyncManager::SyncInfo info(cloudInfo.user, bundleName); syncManager_.DoCloudSync(info); } ZLOGI("ChangeAppSwitch success, id:%{public}s app:%{public}s, switch:%{public}d", Anonymous::Change(id).c_str(), -- Gitee From 4aba63783a11819f7e5adafa2f2766254dacf57f Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 17:34:49 +0800 Subject: [PATCH 17/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 3d8b1929a..bcd2148a2 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -1097,19 +1097,16 @@ std::pair CloudServiceImpl::GetSchemaMeta(int32_t userId, c } UpgradeSchemaMeta(userId, schemaMeta); HapInfo hapInfo{ .user = userId, .instIndex = instanceId, .bundleName = bundleName }; - SchemaMeta newMeta; - std::tie(status, newMeta) = GetSchemaFromHap(hapInfo); + std::tie(status, schemaMeta) = GetSchemaFromHap(hapInfo); if (status == SUCCESS) { - if (newMeta != schemaMeta) { - MetaDataManager::GetInstance().SaveMeta(schemaKey, newMeta, true); - } - return { status, newMeta }; + MetaDataManager::GetInstance().SaveMeta(schemaKey, schemaMeta, true); + return { status, schemaMeta }; } if (!Account::GetInstance()->IsVerified(userId)) { ZLOGE("user:%{public}d is locked!", userId); return { ERROR, schemaMeta }; } - std::tie(status, newMeta) = GetAppSchemaFromServer(userId, bundleName); + std::tie(status, schemaMeta) = GetAppSchemaFromServer(userId, bundleName); if (status == NOT_SUPPORT) { ZLOGW("app not support, del cloudInfo! userId:%{public}d, bundleName:%{public}s", userId, bundleName.c_str()); MetaDataManager::GetInstance().DelMeta(cloudInfo.GetKey(), true); @@ -1118,10 +1115,8 @@ std::pair CloudServiceImpl::GetSchemaMeta(int32_t userId, c if (status != SUCCESS) { return { status, schemaMeta }; } - if (newMeta != schemaMeta) { - MetaDataManager::GetInstance().SaveMeta(schemaKey, newMeta, true); - } - return { SUCCESS, newMeta }; + MetaDataManager::GetInstance().SaveMeta(schemaKey, schemaMeta, true); + return { SUCCESS, schemaMeta }; } std::pair CloudServiceImpl::GetCloudInfo(int32_t userId) -- Gitee From 1f5951cbab781c217e6c7fa0b53aafc7f83db9a2 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 17:47:55 +0800 Subject: [PATCH 18/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../service/cloud/cloud_service_impl.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index bcd2148a2..ae94de6b0 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -1129,16 +1129,13 @@ std::pair CloudServiceImpl::GetCloudInfo(int32_t userId) ZLOGW("user:%{public}d is locked!", userId); return { ERROR, cloudInfo }; } - CloudInfo newInfo; - std::tie(status, newInfo) = GetCloudInfoFromServer(userId); + std::tie(status, cloudInfo) = GetCloudInfoFromServer(userId); if (status != SUCCESS) { ZLOGE("userId:%{public}d, status:%{public}d", userId, status); return { status, cloudInfo }; } - if (newInfo != cloudInfo) { - MetaDataManager::GetInstance().SaveMeta(newInfo.GetKey(), newInfo, true); - } - return { SUCCESS, newInfo }; + MetaDataManager::GetInstance().SaveMeta(cloudInfo.GetKey(), cloudInfo, true); + return { SUCCESS, cloudInfo }; } int32_t CloudServiceImpl::CloudStatic::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index) -- Gitee From 37d9372d69da464b8b4113fed469484c333b6b1a Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 18:45:30 +0800 Subject: [PATCH 19/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/cloud/cloud_service_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index ae94de6b0..803889071 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -139,7 +139,7 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map Date: Tue, 2 Sep 2025 22:46:51 +0800 Subject: [PATCH 20/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/test/cloud_test.cpp | 344 +++++++++++++++++- .../service/test/cloud_data_test.cpp | 34 +- 2 files changed, 376 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 7c4fb2eea..0a252ddc4 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -274,15 +274,90 @@ HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) cloudInfo1.maxNumber = CloudInfo::DEFAULT_BATCH_NUMBER; cloudInfo1.maxSize = CloudInfo::DEFAULT_BATCH_SIZE; + CloudInfo::AppInfo cloudInfoAppInfo1; + cloudInfoAppInfo1.bundleName = "ohos.test.demo"; + cloudInfoAppInfo1.appId = "test1_id"; + cloudInfoAppInfo1.version = 0; + cloudInfoAppInfo1.instanceId = 0; + cloudInfoAppInfo1.cloudSwitch = false; + cloudInfo1.apps["ohos.test.demo"] = cloudInfoAppInfo1; + CloudInfo cloudInfo2 = cloudInfo1; auto ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, true); ret = cloudInfo2 != cloudInfo1; EXPECT_EQ(ret, false); + cloudInfo2.maxSize = 1; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.maxNumber = 1; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.enableCloud = true; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.remainSpace = 1; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.totalSpace = 1; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.id = "test2_id"; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); cloudInfo2.user = 222; ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); + cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; + ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + ret = cloudInfo2 != cloudInfo1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: CloudInfoTest003 +* @tc.desc: CloudInfo Overload function apps test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudInfoTest, CloudInfoTest003, TestSize.Level0) +{ + CloudInfo cloudInfo1; + cloudInfo1.user = 111; + cloudInfo1.id = "test1_id"; + cloudInfo1.totalSpace = 0; + cloudInfo1.remainSpace = 0; + cloudInfo1.enableCloud = false; + cloudInfo1.maxNumber = CloudInfo::DEFAULT_BATCH_NUMBER; + cloudInfo1.maxSize = CloudInfo::DEFAULT_BATCH_SIZE; + + CloudInfo::AppInfo cloudInfoAppInfo1; + cloudInfoAppInfo1.bundleName = "ohos.test.demo"; + cloudInfoAppInfo1.appId = "test1_id"; + cloudInfoAppInfo1.version = 0; + cloudInfoAppInfo1.instanceId = 0; + cloudInfoAppInfo1.cloudSwitch = false; + cloudInfo1.apps["ohos.test.demo"] = cloudInfoAppInfo1; + + CloudInfo cloudInfo2 = cloudInfo1; + cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.apps["ohos.test.demo"].instanceId = 1; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.apps["ohos.test.demo"].version = 1; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.apps["ohos.test.demo"].appId = "test2_id"; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); + cloudInfo2.apps["ohos.test.demo"].bundleName = "ohos.test.demo2"; + auto ret = cloudInfo2 == cloudInfo1; + EXPECT_EQ(ret, false); ret = cloudInfo2 != cloudInfo1; EXPECT_EQ(ret, true); } @@ -334,9 +409,21 @@ HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; EXPECT_EQ(ret, false); + cloudInfoAppInfo2.cloudSwitch = true; + ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, false); + cloudInfoAppInfo2.instanceId = 1; + ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, false); cloudInfoAppInfo2.version = 1; ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; EXPECT_EQ(ret, false); + cloudInfoAppInfo2.appId = "test2_id"; + ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, false); + cloudInfoAppInfo2.bundleName = "ohos.test.demo2"; + ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; + EXPECT_EQ(ret, false); ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; EXPECT_EQ(ret, true); } @@ -399,7 +486,64 @@ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) ret = table2 != table1; EXPECT_EQ(ret, false); - table1.name = "test2_name"; + table2.sharedTableName = "share"; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.cloudSyncFields.push_back("cloud"); + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.deviceSyncFields.push_back("device"); + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.fields[0].primary = true; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.alias = "test2_alias"; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.name = "test2_name"; + ret = table2 == table1; + EXPECT_EQ(ret, false); + ret = table2 != table1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: TableTest003 +* @tc.desc: Table Overload function Field test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudInfoTest, TableTest003, TestSize.Level0) +{ + Field field1; + field1.colName = "test1_colName"; + field1.alias = "test1_alias"; + field1.type = 1; + field1.primary = true; + field1.nullable = false; + + Table table1; + table1.name = "test1_name"; + table1.sharedTableName = "test1_sharedTableName"; + table1.alias = "test1_alias"; + table1.fields.push_back(field1); + + Table table2 = table1; + table2.fields[0].nullable = true; + auto ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.fields[0].primary = false; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.fields[0].type = 2; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.fields[0].alias = "test2_alias"; + ret = table2 == table1; + EXPECT_EQ(ret, false); + table2.fields[0].colName = "test1_colName"; ret = table2 == table1; EXPECT_EQ(ret, false); ret = table2 != table1; @@ -429,9 +573,21 @@ HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) ret = field2 != field1; EXPECT_EQ(ret, false); + field2.nullable = true; + ret = field2 == field1; + EXPECT_EQ(ret, false); + field2.primary = false; + ret = field2 == field1; + EXPECT_EQ(ret, false); field2.type = 2; ret = field2 == field1; EXPECT_EQ(ret, false); + field2.alias = "test2_alias"; + ret = field2 == field1; + EXPECT_EQ(ret, false); + field2.colName = "test2_colName"; + ret = field2 == field1; + EXPECT_EQ(ret, false); ret = field2 != field1; EXPECT_EQ(ret, true); } @@ -692,9 +848,180 @@ HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) ret = schemaMeta2 != schemaMeta1; EXPECT_EQ(ret, false); + schemaMeta2.e2eeEnable = true; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].alias = "test_cloud_database_alias_2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.bundleName = "test_cloud_bundleName2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); schemaMeta2.version = 2; ret = schemaMeta2 == schemaMeta1; EXPECT_EQ(ret, false); + schemaMeta2.metaVersion = 2; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + ret = schemaMeta2 != schemaMeta1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: SchemaMeta003 +* @tc.desc: SchemaMeta Overload function database test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudInfoTest, SchemaMeta003, TestSize.Level0) +{ + SchemaMeta::Field field1; + field1.colName = "test_cloud_field_name1"; + field1.alias = "test_cloud_field_alias1"; + + SchemaMeta::Table table; + table.name = "test_cloud_table_name"; + table.alias = "test_cloud_table_alias"; + table.fields.emplace_back(field1); + + SchemaMeta::Database database; + database.name = "test_cloud_store"; + database.alias = "test_cloud_database_alias_1"; + database.tables.emplace_back(table); + + SchemaMeta schemaMeta1; + schemaMeta1.version = 1; + schemaMeta1.bundleName = "test_cloud_bundleName"; + schemaMeta1.databases.emplace_back(database); + schemaMeta1.e2eeEnable = false; + + SchemaMeta schemaMeta2 = schemaMeta1; + schemaMeta2.databases[0].autoSyncType = 1; + auto ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].deviceId = "111"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].user = "111"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].bundleName = "test_cloud_bundleName2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].version = 2; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].alias = "test_cloud_database_alias_2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].name = "test_cloud_store2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + ret = schemaMeta2 != schemaMeta1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: SchemaMeta004 +* @tc.desc: SchemaMeta Overload function Table test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudInfoTest, SchemaMeta004, TestSize.Level0) +{ + SchemaMeta::Field field1; + field1.colName = "test_cloud_field_name1"; + field1.alias = "test_cloud_field_alias1"; + + SchemaMeta::Table table; + table.name = "test_cloud_table_name"; + table.alias = "test_cloud_table_alias"; + table.fields.emplace_back(field1); + + SchemaMeta::Database database; + database.name = "test_cloud_store"; + database.alias = "test_cloud_database_alias_1"; + database.tables.emplace_back(table); + + SchemaMeta schemaMeta1; + schemaMeta1.version = 1; + schemaMeta1.bundleName = "test_cloud_bundleName"; + schemaMeta1.databases.emplace_back(database); + schemaMeta1.e2eeEnable = false; + + SchemaMeta schemaMeta2 = schemaMeta1; + schemaMeta2.databases[0].tables[0].sharedTableName = "share"; + auto ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].cloudSyncFields.push_back("cloud"); + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].deviceSyncFields.push_back("device"); + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].fields[0].alias = "test_cloud_field_alias2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].alias = "test_cloud_table_alias2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + ret = schemaMeta2 != schemaMeta1; + EXPECT_EQ(ret, true); +} + +/** +* @tc.name: SchemaMeta005 +* @tc.desc: SchemaMeta Overload function Field test. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudInfoTest, SchemaMeta005, TestSize.Level0) +{ + SchemaMeta::Field field1; + field1.colName = "test_cloud_field_name1"; + field1.alias = "test_cloud_field_alias1"; + + SchemaMeta::Table table; + table.name = "test_cloud_table_name"; + table.alias = "test_cloud_table_alias"; + table.fields.emplace_back(field1); + + SchemaMeta::Database database; + database.name = "test_cloud_store"; + database.alias = "test_cloud_database_alias_1"; + database.tables.emplace_back(table); + + SchemaMeta schemaMeta1; + schemaMeta1.version = 1; + schemaMeta1.bundleName = "test_cloud_bundleName"; + schemaMeta1.databases.emplace_back(database); + schemaMeta1.e2eeEnable = false; + + SchemaMeta schemaMeta2 = schemaMeta1; + schemaMeta2.databases[0].tables[0].fields[0].nullable = false; + auto ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].fields[0].primary = true; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].fields[0].type = 1; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].fields[0].alias = "test_cloud_field_alias1"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); + schemaMeta2.databases[0].tables[0].fields[0].colName = "test_cloud_field_name2"; + ret = schemaMeta2 == schemaMeta1; + EXPECT_EQ(ret, false); ret = schemaMeta2 != schemaMeta1; EXPECT_EQ(ret, true); } @@ -736,9 +1063,24 @@ HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) ret = cloudmark2 != cloudmark1; EXPECT_EQ(ret, false); + cloudmark2.userId = 1; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); + cloudmark2.storeId = "test_db2"; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); + cloudmark2.isClearWaterMark = true; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); + cloudmark2.index = 1; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); cloudmark2.deviceId = "222"; ret = cloudmark2 == cloudmark1; EXPECT_EQ(ret, false); + cloudmark2.bundleName = "test_cloud_bundleName2"; + ret = cloudmark2 == cloudmark1; + EXPECT_EQ(ret, false); ret = cloudmark2 != cloudmark1; EXPECT_EQ(ret, true); } diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 766bc2041..ac30e7735 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -55,6 +55,7 @@ #include "store/general_value.h" #include "store/store_info.h" #include "sync_manager.h" +#include "sync_strategies/network_sync_strategy.h" #include "token_setproc.h" using namespace testing::ext; @@ -1425,7 +1426,6 @@ HWTEST_F(CloudDataTest, EnableCloud02, TestSize.Level0) EXPECT_EQ(ret, CloudData::CloudService::SUCCESS); } - /** * @tc.name: OnEnableCloud * @tc.desc: @@ -3182,5 +3182,37 @@ HWTEST_F(CloudDataTest, GetValidGeneralCode, TestSize.Level0) ret = CloudData::SyncManager::ConvertValidGeneralCode(E_SYNC_TASK_MERGED); EXPECT_TRUE(ret == E_ERROR); } + +/** +* @tc.name: StrategyInfo +* @tc.desc: StrategyInfo Overload function test. +* @tc.type: FUNC +* @tc.require: + */ +HWTEST_F(CloudDataTest, StrategyInfo, TestSize.Level0) +{ + CloudData::NetworkSyncStrategy::StrategyInfo info1; + info1.bundleName = "test_cloud_bundleName"; + + CloudData::NetworkSyncStrategy::StrategyInfo info2 = info1; + auto ret = info2 == info1; + EXPECT_TRUE(ret); + + info2.strategy = CloudData::NetworkSyncStrategy::Strategy::WIFI; + ret = info2 == info1; + EXPECT_FALSE(ret); + info2.strategy = CloudData::NetworkSyncStrategy::Strategy::CELLULAR; + ret = info2 == info1; + EXPECT_FALSE(ret); + info2.strategy = CloudData::NetworkSyncStrategy::Strategy::BUTT; + ret = info2 == info1; + EXPECT_TRUE(ret); + info2.strategy = "test_cloud_bundleName2"; + ret = info2 == info1; + EXPECT_FALSE(ret); + info2.user = 1; + ret = info2 == info1; + EXPECT_FALSE(ret); +} } // namespace DistributedDataTest } // namespace OHOS::Test \ No newline at end of file -- Gitee From 6da79fd7527306f3dc96eed403953e505f5ea650 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 22:48:22 +0800 Subject: [PATCH 21/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/test/cloud_test.cpp | 10 +++++----- .../service/test/cloud_data_test.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 0a252ddc4..c1b1d782a 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -344,19 +344,19 @@ HWTEST_F(CloudInfoTest, CloudInfoTest003, TestSize.Level0) CloudInfo cloudInfo2 = cloudInfo1; cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; - auto ret = cloudInfo2 == cloudInfo1; + autoauto ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); cloudInfo2.apps["ohos.test.demo"].instanceId = 1; - auto ret = cloudInfo2 == cloudInfo1; + ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); cloudInfo2.apps["ohos.test.demo"].version = 1; - auto ret = cloudInfo2 == cloudInfo1; + ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); cloudInfo2.apps["ohos.test.demo"].appId = "test2_id"; - auto ret = cloudInfo2 == cloudInfo1; + ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); cloudInfo2.apps["ohos.test.demo"].bundleName = "ohos.test.demo2"; - auto ret = cloudInfo2 == cloudInfo1; + ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); ret = cloudInfo2 != cloudInfo1; EXPECT_EQ(ret, true); diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index ac30e7735..1228553dd 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -3207,7 +3207,7 @@ HWTEST_F(CloudDataTest, StrategyInfo, TestSize.Level0) info2.strategy = CloudData::NetworkSyncStrategy::Strategy::BUTT; ret = info2 == info1; EXPECT_TRUE(ret); - info2.strategy = "test_cloud_bundleName2"; + info2.buddleName = "test_cloud_bundleName2"; ret = info2 == info1; EXPECT_FALSE(ret); info2.user = 1; -- Gitee From 9989be58260ac17313a3a9ea48b234c47ff6b6ce Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 22:52:41 +0800 Subject: [PATCH 22/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/test/cloud_data_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 1228553dd..81325cea4 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -3207,7 +3207,7 @@ HWTEST_F(CloudDataTest, StrategyInfo, TestSize.Level0) info2.strategy = CloudData::NetworkSyncStrategy::Strategy::BUTT; ret = info2 == info1; EXPECT_TRUE(ret); - info2.buddleName = "test_cloud_bundleName2"; + info2.bundleName = "test_cloud_bundleName2"; ret = info2 == info1; EXPECT_FALSE(ret); info2.user = 1; -- Gitee From c460017a5c0dbcc50da61d223341be18f3b8b1d4 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Tue, 2 Sep 2025 22:52:41 +0800 Subject: [PATCH 23/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- services/distributeddataservice/framework/test/cloud_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index c1b1d782a..8678f1ba5 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -344,7 +344,7 @@ HWTEST_F(CloudInfoTest, CloudInfoTest003, TestSize.Level0) CloudInfo cloudInfo2 = cloudInfo1; cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; - autoauto ret = cloudInfo2 == cloudInfo1; + auto ret = cloudInfo2 == cloudInfo1; EXPECT_EQ(ret, false); cloudInfo2.apps["ohos.test.demo"].instanceId = 1; ret = cloudInfo2 == cloudInfo1; -- Gitee From 1874aaecc2f76dfa193885cbe318f0ecb8d46458 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Wed, 3 Sep 2025 22:05:01 +0800 Subject: [PATCH 24/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/test/cloud_test.cpp | 263 ++++++------------ .../service/cloud/cloud_service_impl.cpp | 26 +- 2 files changed, 99 insertions(+), 190 deletions(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 8678f1ba5..57e65eeb7 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -283,37 +283,26 @@ HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) cloudInfo1.apps["ohos.test.demo"] = cloudInfoAppInfo1; CloudInfo cloudInfo2 = cloudInfo1; - auto ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, true); - ret = cloudInfo2 != cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_EQ(cloudInfo2, cloudInfo1); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.maxSize = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.maxNumber = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.enableCloud = true; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.remainSpace = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.totalSpace = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.id = "test2_id"; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.user = 222; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); - ret = cloudInfo2 != cloudInfo1; - EXPECT_EQ(ret, true); + EXPECT_NE(cloudInfo2, cloudInfo1); + EXPECT_EQ(cloudInfo2, cloudInfo1); } /** @@ -344,22 +333,15 @@ HWTEST_F(CloudInfoTest, CloudInfoTest003, TestSize.Level0) CloudInfo cloudInfo2 = cloudInfo1; cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; - auto ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].instanceId = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); - cloudInfo2.apps["ohos.test.demo"].version = 1; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); + cloudInfo2.apps["ohos.test.demo"].version = 1;EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].appId = "test2_id"; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].bundleName = "ohos.test.demo2"; - ret = cloudInfo2 == cloudInfo1; - EXPECT_EQ(ret, false); - ret = cloudInfo2 != cloudInfo1; - EXPECT_EQ(ret, true); + EXPECT_NE(cloudInfo2, cloudInfo1); + EXPECT_EQ(cloudInfo2, cloudInfo1); } /** @@ -404,28 +386,20 @@ HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) cloudInfoAppInfo1.cloudSwitch = false; CloudInfo::AppInfo cloudInfoAppInfo2 = cloudInfoAppInfo1; - auto ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, true); - ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; - EXPECT_EQ(ret, false); + EXPECT_EQ(cloudInfoAppInfo2, cloudInfoAppInfo1); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.cloudSwitch = true; - ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.instanceId = 1; - ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.version = 1; - ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.appId = "test2_id"; - ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.bundleName = "ohos.test.demo2"; - ret = cloudInfoAppInfo2 == cloudInfoAppInfo1; - EXPECT_EQ(ret, false); - ret = cloudInfoAppInfo2 != cloudInfoAppInfo1; - EXPECT_EQ(ret, true); + EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); + EXPECT_EQ(cloudInfoAppInfo2, cloudInfoAppInfo1); } /** @@ -481,31 +455,22 @@ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) table1.fields.push_back(field1); Table table2 = table1; - auto ret = table2 == table1; - EXPECT_EQ(ret, true); - ret = table2 != table1; - EXPECT_EQ(ret, false); + EXPECT_EQ(table2, table1); + EXPECT_NE(table2, table1); table2.sharedTableName = "share"; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.cloudSyncFields.push_back("cloud"); - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.deviceSyncFields.push_back("device"); - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.fields[0].primary = true; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.alias = "test2_alias"; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.name = "test2_name"; - ret = table2 == table1; - EXPECT_EQ(ret, false); - ret = table2 != table1; - EXPECT_EQ(ret, true); + EXPECT_NE(table2, table1); + EXPECT_EQ(table2, table1); } /** @@ -532,22 +497,16 @@ HWTEST_F(CloudInfoTest, TableTest003, TestSize.Level0) Table table2 = table1; table2.fields[0].nullable = true; - auto ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.fields[0].primary = false; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.fields[0].type = 2; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.fields[0].alias = "test2_alias"; - ret = table2 == table1; - EXPECT_EQ(ret, false); + EXPECT_NE(table2, table1); table2.fields[0].colName = "test1_colName"; - ret = table2 == table1; - EXPECT_EQ(ret, false); - ret = table2 != table1; - EXPECT_EQ(ret, true); + EXPECT_NE(table2, table1); + EXPECT_EQ(table2, table1); } /** @@ -568,28 +527,20 @@ HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) Field field2 = field1; - auto ret = field2 == field1; - EXPECT_EQ(ret, true); - ret = field2 != field1; - EXPECT_EQ(ret, false); + EXPECT_EQ(field2, field1); + EXPECT_NE(field2, field1); field2.nullable = true; - ret = field2 == field1; - EXPECT_EQ(ret, false); + EXPECT_NE(field2, field1); field2.primary = false; - ret = field2 == field1; - EXPECT_EQ(ret, false); + EXPECT_NE(field2, field1); field2.type = 2; - ret = field2 == field1; - EXPECT_EQ(ret, false); + EXPECT_NE(field2, field1); field2.alias = "test2_alias"; - ret = field2 == field1; - EXPECT_EQ(ret, false); + EXPECT_NE(field2, field1); field2.colName = "test2_colName"; - ret = field2 == field1; - EXPECT_EQ(ret, false); - ret = field2 != field1; - EXPECT_EQ(ret, true); + EXPECT_NE(field2, field1); + EXPECT_EQ(field2, field1); } /** @@ -843,28 +794,20 @@ HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) schemaMeta1.e2eeEnable = false; SchemaMeta schemaMeta2 = schemaMeta1; - auto ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, true); - ret = schemaMeta2 != schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_EQ(schemaMeta2, schemaMeta1); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.e2eeEnable = true; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].alias = "test_cloud_database_alias_2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.bundleName = "test_cloud_bundleName2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.version = 2; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.metaVersion = 2; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); - ret = schemaMeta2 != schemaMeta1; - EXPECT_EQ(ret, true); + EXPECT_NE(schemaMeta2, schemaMeta1); + EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -898,31 +841,22 @@ HWTEST_F(CloudInfoTest, SchemaMeta003, TestSize.Level0) SchemaMeta schemaMeta2 = schemaMeta1; schemaMeta2.databases[0].autoSyncType = 1; - auto ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].deviceId = "111"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].user = "111"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].bundleName = "test_cloud_bundleName2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].version = 2; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_EQ(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].alias = "test_cloud_database_alias_2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].name = "test_cloud_store2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); - ret = schemaMeta2 != schemaMeta1; - EXPECT_EQ(ret, true); + EXPECT_NE(schemaMeta2, schemaMeta1); + EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -956,25 +890,18 @@ HWTEST_F(CloudInfoTest, SchemaMeta004, TestSize.Level0) SchemaMeta schemaMeta2 = schemaMeta1; schemaMeta2.databases[0].tables[0].sharedTableName = "share"; - auto ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].cloudSyncFields.push_back("cloud"); - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].deviceSyncFields.push_back("device"); - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].alias = "test_cloud_field_alias2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].alias = "test_cloud_table_alias2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); - ret = schemaMeta2 != schemaMeta1; - EXPECT_EQ(ret, true); + EXPECT_NE(schemaMeta2, schemaMeta1); + EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -1008,22 +935,16 @@ HWTEST_F(CloudInfoTest, SchemaMeta005, TestSize.Level0) SchemaMeta schemaMeta2 = schemaMeta1; schemaMeta2.databases[0].tables[0].fields[0].nullable = false; - auto ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].primary = true; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].type = 1; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].alias = "test_cloud_field_alias1"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].colName = "test_cloud_field_name2"; - ret = schemaMeta2 == schemaMeta1; - EXPECT_EQ(ret, false); - ret = schemaMeta2 != schemaMeta1; - EXPECT_EQ(ret, true); + EXPECT_NE(schemaMeta2, schemaMeta1); + EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -1056,32 +977,22 @@ HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) cloudmark1.deviceId = "1111"; cloudmark1.storeId = "test_db"; - CloudMark cloudmark2 = cloudmark1; - auto ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, true); - ret = cloudmark2 != cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_EQ(cloudmark2, cloudmark1); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.userId = 1; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.storeId = "test_db2"; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.isClearWaterMark = true; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.index = 1; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.deviceId = "222"; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); + EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.bundleName = "test_cloud_bundleName2"; - ret = cloudmark2 == cloudmark1; - EXPECT_EQ(ret, false); - ret = cloudmark2 != cloudmark1; - EXPECT_EQ(ret, true); + EXPECT_NE(cloudmark2, cloudmark1); + EXPECT_EQ(cloudmark2, cloudmark1); } } // namespace OHOS::Test diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 803889071..664e72ff0 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -143,8 +143,8 @@ int32_t CloudServiceImpl::EnableCloud(const std::string &id, const std::map Date: Wed, 3 Sep 2025 22:07:41 +0800 Subject: [PATCH 25/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../distributeddataservice/service/cloud/sync_manager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/cloud/sync_manager.cpp b/services/distributeddataservice/service/cloud/sync_manager.cpp index ff916398c..70c3aa46c 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -740,9 +740,8 @@ std::vector> SyncManager::GetCloudSyncInfo(const return cloudSyncInfos; } CloudInfo oldInfo; - MetaDataManager::GetInstance().LoadMeta(cloud.GetKey(), oldInfo, true); - if (oldInfo != cloud && !MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true)) { - ZLOGW("save cloud info fail, user: %{public}d", cloud.user); + if (!MetaDataManager::GetInstance().LoadMeta(cloud.GetKey(), oldInfo, true) || oldInfo != cloud) { + MetaDataManager::GetInstance().SaveMeta(cloud.GetKey(), cloud, true); } } auto schemaKey = CloudInfo::GetSchemaKey(cloud.user, info.bundleName_); -- Gitee From 29c47fab57462f1a750a4d5ab6f9e08b4143606c Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Thu, 4 Sep 2025 10:16:08 +0800 Subject: [PATCH 26/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- .../framework/test/cloud_test.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 57e65eeb7..0fc8c8788 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -284,7 +284,6 @@ HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) CloudInfo cloudInfo2 = cloudInfo1; EXPECT_EQ(cloudInfo2, cloudInfo1); - EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.maxSize = 1; EXPECT_NE(cloudInfo2, cloudInfo1); @@ -302,7 +301,6 @@ HWTEST_F(CloudInfoTest, CloudInfoTest002, TestSize.Level0) EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].cloudSwitch = true; EXPECT_NE(cloudInfo2, cloudInfo1); - EXPECT_EQ(cloudInfo2, cloudInfo1); } /** @@ -341,7 +339,6 @@ HWTEST_F(CloudInfoTest, CloudInfoTest003, TestSize.Level0) EXPECT_NE(cloudInfo2, cloudInfo1); cloudInfo2.apps["ohos.test.demo"].bundleName = "ohos.test.demo2"; EXPECT_NE(cloudInfo2, cloudInfo1); - EXPECT_EQ(cloudInfo2, cloudInfo1); } /** @@ -387,7 +384,6 @@ HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) CloudInfo::AppInfo cloudInfoAppInfo2 = cloudInfoAppInfo1; EXPECT_EQ(cloudInfoAppInfo2, cloudInfoAppInfo1); - EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.cloudSwitch = true; EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); @@ -399,7 +395,6 @@ HWTEST_F(CloudInfoTest, AppInfoTest002, TestSize.Level0) EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); cloudInfoAppInfo2.bundleName = "ohos.test.demo2"; EXPECT_NE(cloudInfoAppInfo2, cloudInfoAppInfo1); - EXPECT_EQ(cloudInfoAppInfo2, cloudInfoAppInfo1); } /** @@ -456,7 +451,6 @@ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) Table table2 = table1; EXPECT_EQ(table2, table1); - EXPECT_NE(table2, table1); table2.sharedTableName = "share"; EXPECT_NE(table2, table1); @@ -470,7 +464,6 @@ HWTEST_F(CloudInfoTest, TableTest002, TestSize.Level0) EXPECT_NE(table2, table1); table2.name = "test2_name"; EXPECT_NE(table2, table1); - EXPECT_EQ(table2, table1); } /** @@ -506,7 +499,6 @@ HWTEST_F(CloudInfoTest, TableTest003, TestSize.Level0) EXPECT_NE(table2, table1); table2.fields[0].colName = "test1_colName"; EXPECT_NE(table2, table1); - EXPECT_EQ(table2, table1); } /** @@ -528,7 +520,6 @@ HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) Field field2 = field1; EXPECT_EQ(field2, field1); - EXPECT_NE(field2, field1); field2.nullable = true; EXPECT_NE(field2, field1); @@ -540,7 +531,6 @@ HWTEST_F(CloudInfoTest, FieldTest, TestSize.Level0) EXPECT_NE(field2, field1); field2.colName = "test2_colName"; EXPECT_NE(field2, field1); - EXPECT_EQ(field2, field1); } /** @@ -795,7 +785,6 @@ HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) SchemaMeta schemaMeta2 = schemaMeta1; EXPECT_EQ(schemaMeta2, schemaMeta1); - EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.e2eeEnable = true; EXPECT_NE(schemaMeta2, schemaMeta1); @@ -807,7 +796,6 @@ HWTEST_F(CloudInfoTest, SchemaMeta002, TestSize.Level0) EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.metaVersion = 2; EXPECT_NE(schemaMeta2, schemaMeta1); - EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -856,7 +844,6 @@ HWTEST_F(CloudInfoTest, SchemaMeta003, TestSize.Level0) EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].name = "test_cloud_store2"; EXPECT_NE(schemaMeta2, schemaMeta1); - EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -901,7 +888,6 @@ HWTEST_F(CloudInfoTest, SchemaMeta004, TestSize.Level0) EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; EXPECT_NE(schemaMeta2, schemaMeta1); - EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -944,7 +930,6 @@ HWTEST_F(CloudInfoTest, SchemaMeta005, TestSize.Level0) EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].fields[0].colName = "test_cloud_field_name2"; EXPECT_NE(schemaMeta2, schemaMeta1); - EXPECT_EQ(schemaMeta2, schemaMeta1); } /** @@ -979,7 +964,6 @@ HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) CloudMark cloudmark2 = cloudmark1; EXPECT_EQ(cloudmark2, cloudmark1); - EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.userId = 1; EXPECT_NE(cloudmark2, cloudmark1); @@ -993,6 +977,5 @@ HWTEST_F(CloudInfoTest, CloudMarkTest, TestSize.Level0) EXPECT_NE(cloudmark2, cloudmark1); cloudmark2.bundleName = "test_cloud_bundleName2"; EXPECT_NE(cloudmark2, cloudmark1); - EXPECT_EQ(cloudmark2, cloudmark1); } } // namespace OHOS::Test -- Gitee From a6d091a5e90e47212d0a3fed4262b013d81f86a8 Mon Sep 17 00:00:00 2001 From: Jeam_wang Date: Thu, 4 Sep 2025 14:06:12 +0800 Subject: [PATCH 27/27] =?UTF-8?q?savemeta=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeam_wang --- services/distributeddataservice/framework/test/cloud_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 0fc8c8788..e39d12fe6 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -839,7 +839,7 @@ HWTEST_F(CloudInfoTest, SchemaMeta003, TestSize.Level0) schemaMeta2.databases[0].version = 2; EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].tables[0].name = "test_cloud_table_name2"; - EXPECT_EQ(schemaMeta2, schemaMeta1); + EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].alias = "test_cloud_database_alias_2"; EXPECT_NE(schemaMeta2, schemaMeta1); schemaMeta2.databases[0].name = "test_cloud_store2"; -- Gitee