diff --git a/services/distributeddataservice/framework/test/checker_manager_test.cpp b/services/distributeddataservice/framework/test/checker_manager_test.cpp index 8dfc80b40..d95a7df7d 100644 --- a/services/distributeddataservice/framework/test/checker_manager_test.cpp +++ b/services/distributeddataservice/framework/test/checker_manager_test.cpp @@ -170,4 +170,36 @@ HWTEST_F(CheckerManagerTest, BundleChecker, TestSize.Level0) AccessTokenKit::GetHapTokenInfo(storeInfo.tokenId, tokenInfo); ASSERT_EQ(Crypto::Sha256(tokenInfo.appID), CheckerManager::GetInstance().GetAppId(storeInfo)); ASSERT_TRUE(CheckerManager::GetInstance().IsValid(storeInfo)); +} + +/** +* @tc.name: IsDynamic +* @tc.desc: checker data type. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CheckerManagerTest, IsDynamic, TestSize.Level0) +{ + CheckerManager::StoreInfo storeInfo; + storeInfo.uid = 2000000; + storeInfo.tokenId = AccessTokenKit::GetHapTokenID(100, "ohos.test.demo", 0); + storeInfo.bundleName = "ohos.test.demo"; + ASSERT_FALSE(CheckerManager::GetInstance().IsDynamic(storeInfo)); +} + +/** +* @tc.name: IsStatic +* @tc.desc: checker data type. +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CheckerManagerTest, IsStatic, TestSize.Level0) +{ + CheckerManager::StoreInfo storeInfo; + storeInfo.uid = 2000000; + storeInfo.tokenId = AccessTokenKit::GetHapTokenID(100, "ohos.test.demo", 0); + storeInfo.bundleName = "ohos.test.demo"; + ASSERT_FALSE(CheckerManager::GetInstance().IsStatic(storeInfo)); } \ No newline at end of file diff --git a/services/distributeddataservice/framework/test/cloud_test.cpp b/services/distributeddataservice/framework/test/cloud_test.cpp index 45fdaf538..90232b184 100644 --- a/services/distributeddataservice/framework/test/cloud_test.cpp +++ b/services/distributeddataservice/framework/test/cloud_test.cpp @@ -18,11 +18,13 @@ #include "serializable/serializable.h" #include "cloud/cloud_db.h" +#include "cloud/cloud_event.h" #include "cloud/cloud_info.h" #include "cloud/cloud_server.h" #include "cloud/schema_meta.h" #include "nlohmann/json.hpp" #include "utils/crypto.h" +#include "screen/screen_manager.h" #include "store/general_store.h" #include "store/general_value.h" #include "store/general_watcher.h" @@ -54,6 +56,22 @@ public: void TearDown(){}; }; +class CloudEventTest : public testing::Test { +public: + static void SetUpTestCase(void){}; + static void TearDownTestCase(void){}; + void SetUp(){}; + void TearDown(){}; +}; + +class ScreenManagerTest : public testing::Test { +public: + static void SetUpTestCase(void){}; + static void TearDownTestCase(void){}; + void SetUp(){}; + void TearDown(){}; +}; + class MockGeneralWatcher : public DistributedData::GeneralWatcher { public: int32_t OnChange(const Origin &origin, const PRIFields &primaryFields, @@ -533,4 +551,32 @@ HWTEST_F(CloudInfoTest, SchemaMeta, TestSize.Level0) auto result2 = schemaMeta.GetHighVersion(); EXPECT_EQ(result2, metaVersion); } + +/** +* @tc.name: GetEventId +* @tc.desc: test GetEventId function +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(CloudEventTest, GetEventId, TestSize.Level0) +{ + int32_t evtId = 1; + StoreInfo info; + CloudEvent event(evtId, info); + auto ret = event.GetEventId(); + EXPECT_EQ(ret, evtId); +} + +/** +* @tc.name: IsLocked +* @tc.desc: test IsLocked function +* @tc.type: FUNC +* @tc.require: +* @tc.author: +*/ +HWTEST_F(ScreenManagerTest, IsLocked, TestSize.Level0) +{ + ASSERT_FALSE(ScreenManager::GetInstance()->IsLocked()); +} } // namespace OHOS::Test diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 346fa669a..c4632e74f 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -257,6 +257,7 @@ void CloudDataTest::SetUpTestCase(void) InitCloudInfo(); InitMetaData(); InitSchemaMeta(); + DeviceManagerAdapter::GetInstance().SetNet(DeviceManagerAdapter::WIFI); } void CloudDataTest::TearDownTestCase() @@ -298,11 +299,7 @@ HWTEST_F(CloudDataTest, GetSchema, TestSize.Level0) auto event = std::make_unique(CloudEvent::GET_SCHEMA, storeInfo); EventCenter::GetInstance().PostEvent(std::move(event)); auto ret = MetaDataManager::GetInstance().LoadMeta(cloudInfo.GetSchemaKey(TEST_CLOUD_BUNDLE), schemaMeta, true); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - ASSERT_TRUE(ret); - } else { - ASSERT_FALSE(ret); - } + ASSERT_TRUE(ret); } /** @@ -482,12 +479,8 @@ HWTEST_F(CloudDataTest, QueryLastSyncInfo004, TestSize.Level0) auto [status, result] = cloudServiceImpl_->QueryLastSyncInfo(TEST_CLOUD_ID, TEST_CLOUD_BUNDLE, TEST_CLOUD_DATABASE_ALIAS_1); EXPECT_EQ(status, CloudData::CloudService::SUCCESS); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - EXPECT_TRUE(!result.empty()); - EXPECT_TRUE(result[TEST_CLOUD_DATABASE_ALIAS_1].code = E_CLOUD_DISABLED); - } else { - EXPECT_TRUE(result.empty()); - } + EXPECT_TRUE(!result.empty()); + EXPECT_TRUE(result[TEST_CLOUD_DATABASE_ALIAS_1].code = E_CLOUD_DISABLED); } /** @@ -511,12 +504,8 @@ HWTEST_F(CloudDataTest, QueryLastSyncInfo005, TestSize.Level0) auto [status, result] = cloudServiceImpl_->QueryLastSyncInfo(TEST_CLOUD_ID, TEST_CLOUD_BUNDLE, TEST_CLOUD_DATABASE_ALIAS_1); EXPECT_EQ(status, CloudData::CloudService::SUCCESS); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - EXPECT_TRUE(!result.empty()); - EXPECT_TRUE(result[TEST_CLOUD_DATABASE_ALIAS_1].code = E_CLOUD_DISABLED); - } else { - EXPECT_TRUE(result.empty()); - } + EXPECT_TRUE(!result.empty()); + EXPECT_TRUE(result[TEST_CLOUD_DATABASE_ALIAS_1].code = E_CLOUD_DISABLED); } /** @@ -1473,11 +1462,7 @@ HWTEST_F(CloudDataTest, GetPostEventTask, TestSize.Level0) CloudData::SyncManager sync; auto task = sync.GetPostEventTask(schemas, cloudInfo_, info, true); auto ret = task(); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - EXPECT_TRUE(ret); - } else { - EXPECT_FALSE(ret); - } + EXPECT_TRUE(ret); } /** @@ -1610,11 +1595,7 @@ HWTEST_F(CloudDataTest, RetryCallback, TestSize.Level0) HWTEST_F(CloudDataTest, UpdateCloudInfoFromServer, TestSize.Level0) { auto ret = cloudServiceImpl_->UpdateCloudInfoFromServer(cloudInfo_.user); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - EXPECT_EQ(ret, E_OK); - } else { - EXPECT_EQ(ret, E_ERROR); - } + EXPECT_EQ(ret, E_OK); } /** @@ -1627,11 +1608,7 @@ HWTEST_F(CloudDataTest, GetCloudInfo, TestSize.Level0) { MetaDataManager::GetInstance().DelMeta(cloudInfo_.GetKey(), true); auto ret = cloudServiceImpl_->GetCloudInfo(cloudInfo_.user); - if (DeviceManagerAdapter::GetInstance().IsNetworkAvailable()) { - EXPECT_EQ(ret.first, CloudData::SUCCESS); - } else { - EXPECT_EQ(ret.first, Status::NETWORK_ERROR); - } + EXPECT_EQ(ret.first, CloudData::SUCCESS); } /**