diff --git a/frameworks/native/cloud_file_kit_inner/src/big_data_statistics/gallery_download_file_stat.cpp b/frameworks/native/cloud_file_kit_inner/src/big_data_statistics/gallery_download_file_stat.cpp index f8368e2a7d5ba109fdca6e2d377d6f734943f39d..c0bbd4118f7b4714c84e220279952a17cc5a86a8 100644 --- a/frameworks/native/cloud_file_kit_inner/src/big_data_statistics/gallery_download_file_stat.cpp +++ b/frameworks/native/cloud_file_kit_inner/src/big_data_statistics/gallery_download_file_stat.cpp @@ -204,7 +204,7 @@ static inline DownloadFileStatInfo SumTwoDownloadFileStat(DownloadFileStatInfo d return dataOne; } -void GalleryDownloadFileStat::IsSameBundleName(DownloadFileStatInfo info) +void GalleryDownloadFileStat::HandleBundleName(const DownloadFileStatInfo &info) { if (!info.bundleName.empty() && info.bundleName != stat_.bundleName && !stat_.bundleName.empty()) { @@ -220,7 +220,7 @@ void GalleryDownloadFileStat::IsSameBundleName(DownloadFileStatInfo info) void GalleryDownloadFileStat::OutputToFile() { DownloadFileStatInfo tmpInfo = ReadVecFromLocal(); - IsSameBundleName(tmpInfo); + HandleBundleName(tmpInfo); std::vector lines; /* Keep code order below */ @@ -292,7 +292,7 @@ void GalleryDownloadFileStat::ClearDownloadFileStat() std::fill(stat_.videoDownloadSpeed.begin(), stat_.videoDownloadSpeed.end(), 0); } -int32_t GalleryDownloadFileStat::ReportDownloadFileStat(DownloadFileStatInfo info) +int32_t GalleryDownloadFileStat::ReportDownloadFileStat(const DownloadFileStatInfo &info) { int32_t ret = CLOUD_SYNC_SYS_EVENT("CLOUD_SYNC_DOWNLOAD_FILE_STAT", HiviewDFX::HiSysEvent::EventType::STATISTIC, diff --git a/interfaces/inner_api/native/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat.h b/interfaces/inner_api/native/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat.h index c0421807d4c6210acf73e3531186ea093f670605..967d0992622cccb9c57852d1a94d1ebf9913156f 100644 --- a/interfaces/inner_api/native/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat.h +++ b/interfaces/inner_api/native/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat.h @@ -64,8 +64,8 @@ private: void UpdateDownloadSpeedStat(uint32_t mediaType, uint64_t size, uint64_t duration); void UpdateDownloadSizeStat(uint32_t mediaType, uint64_t size, uint64_t duration); DownloadFileStatInfo ReadVecFromLocal(); - int32_t ReportDownloadFileStat(DownloadFileStatInfo info); - void IsSameBundleName(DownloadFileStatInfo info); + int32_t ReportDownloadFileStat(const DownloadFileStatInfo &info); + void HandleBundleName(const DownloadFileStatInfo &info); DownloadFileStatInfo stat_; }; diff --git a/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h b/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h index 4ca56fdeb6c1e2b820981c78cbc2ea411826b980..edf7b168dbf0d9c57a9b6ef28864fd2193468a01 100644 --- a/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h +++ b/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h @@ -78,7 +78,7 @@ public: void UpdateReadTimeStat(uint64_t size, uint64_t time); void UpdateStatData(); void UpdateReadInfo(uint32_t index); - void UpdateBundleName(std::string bundleName); + void UpdateBundleName(const std::string &bundleName); mutex mutex_; private: CloudDaemonStatistic() = default; @@ -87,9 +87,9 @@ private: void ClearStat(); void OutputToFile(); int32_t CheckFileStat(); - void SumTwoReadStat(CloudDaemonStatisticInfo info); - int32_t ReportReadStat(CloudDaemonStatisticInfo info); - void IsSameBundleName(CloudDaemonStatisticInfo info); + void SumTwoReadStat(const CloudDaemonStatisticInfo &info); + int32_t ReportReadStat(const CloudDaemonStatisticInfo &info); + void HandleBundleName(const CloudDaemonStatisticInfo &info); vector openSizeStat_ = vector(OPEN_SIZE_MAX, 0); vector> openTimeStat_ = @@ -98,7 +98,7 @@ private: vector> readTimeStat_ = vector>(READ_SIZE_MAX, vector(READ_TIME_MAX, 0)); vector videoReadInfo_ = vector(VIDEO_READ_INFO, 0); - std::string bundleName_{"com.ohos.photos"}; + std::string bundleName_{""}; }; } // namespace CloudFile } // namespace FileManagement diff --git a/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp b/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp index ad8cbf9bb41655b4490f606498fbe21d99c48b92..5bf4a9629cb664ab24b59ff906b3447ce012dcbb 100644 --- a/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp +++ b/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp @@ -132,7 +132,7 @@ void CloudDaemonStatistic::UpdateReadInfo(uint32_t index) CheckOverflow(videoReadInfo_[index], 1); } -void CloudDaemonStatistic::UpdateBundleName(std::string bundleName) +void CloudDaemonStatistic::UpdateBundleName(const std::string &bundleName) { bundleName_ = bundleName; } @@ -266,7 +266,7 @@ void CloudDaemonStatistic::ClearStat() } } -void CloudDaemonStatistic::SumTwoReadStat(CloudDaemonStatisticInfo info) +void CloudDaemonStatistic::SumTwoReadStat(const CloudDaemonStatisticInfo &info) { for (uint32_t i = 0; i < OPEN_SIZE_MAX; i++) { CheckOverflow(openSizeStat_[i], info.openSizeStat[i]); @@ -289,7 +289,7 @@ void CloudDaemonStatistic::SumTwoReadStat(CloudDaemonStatisticInfo info) } } -int32_t CloudDaemonStatistic::ReportReadStat(CloudDaemonStatisticInfo info) +int32_t CloudDaemonStatistic::ReportReadStat(const CloudDaemonStatisticInfo &info) { int32_t ret = CLOUD_SYNC_SYS_EVENT("CLOUD_SYNC_READ_FILE_STAT", HiviewDFX::HiSysEvent::EventType::STATISTIC, @@ -310,7 +310,7 @@ int32_t CloudDaemonStatistic::ReportReadStat(CloudDaemonStatisticInfo info) return ret; } -void CloudDaemonStatistic::IsSameBundleName(CloudDaemonStatisticInfo info) +void CloudDaemonStatistic::HandleBundleName(const CloudDaemonStatisticInfo &info) { if (!info.bundleName.empty() && info.bundleName != bundleName_) { auto ret = ReportReadStat(info); @@ -327,7 +327,7 @@ void CloudDaemonStatistic::UpdateStatData() lock_guard lock(mutex_); CloudDaemonStatisticInfo info; AddFileData(info); - IsSameBundleName(info); + HandleBundleName(info); OutputToFile(); ClearStat(); } diff --git a/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp b/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp index cb3bc373f254c803cd81a76fde486f8f54c93a84..ecbdf1a3e5b2e20642564b09a1f8c8912df00672 100644 --- a/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp +++ b/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp @@ -955,12 +955,15 @@ static void HandleReopen(fuse_req_t req, struct FuseData *data, shared_ptr cInode, uint64_t startTime) +static void UpdateReadStat(shared_ptr cInode, + uint64_t startTime, + std::string bundleName) { uint64_t endTime = UTCTimeMilliSeconds(); CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); readStat.UpdateOpenSizeStat(cInode->mBase->size); readStat.UpdateOpenTimeStat(cInode->mBase->fileType, (endTime > startTime) ? (endTime - startTime) : 0); + readStat.UpdateBundleName(bundleName); } static string GetPrepareTraceId(int32_t userId) @@ -1020,7 +1023,7 @@ static void CloudOpenHelper(fuse_req_t req, fuse_ino_t ino, struct fuse_file_inf fuse_reply_err(req, -ret); cInode->readSession = nullptr; } - UpdateReadStat(cInode, startTime); + UpdateReadStat(cInode, startTime, data->activeBundle); wSesLock.unlock(); return; } @@ -1350,7 +1353,10 @@ static void SaveCacheToFile(shared_ptr readArgs, } } -static void UpdateReadStatInfo(size_t size, std::string name, uint64_t readTime) +static void UpdateReadStatInfo(size_t size, + std::string name, + uint64_t readTime, + std::string bundleName) { CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); readStat.UpdateReadSizeStat(size); @@ -1358,6 +1364,7 @@ static void UpdateReadStatInfo(size_t size, std::string name, uint64_t readTime) if (IsVideoType(name)) { readStat.UpdateReadInfo(READ_SUM); } + readStat.UpdateBundleName(bundleName); } static void CloudReadOnCloudFile(pid_t pid, @@ -1391,7 +1398,7 @@ static void CloudReadOnCloudFile(pid_t pid, readSession->PRead(readArgs->offset, readArgs->size, readArgs->buf.get(), *readArgs->ckError, readArgs->appId); uint64_t endTime = UTCTimeMilliSeconds(); uint64_t readTime = (endTime > startTime) ? (endTime - startTime) : 0; - UpdateReadStatInfo(readArgs->size, cInode->mBase->name, readTime); + UpdateReadStatInfo(readArgs->size, cInode->mBase->name, readTime, data->activeBundle); { unique_lock lck(cInode->readLock); *readArgs->readStatus = READ_FINISHED; @@ -1447,7 +1454,7 @@ static void CloudReadOnCacheFile(shared_ptr readArgs, uint64_t endTime = UTCTimeMilliSeconds(); uint64_t readTime = (endTime > startTime) ? (endTime - startTime) : 0; - UpdateReadStatInfo(readArgs->size, cInode->mBase->name, startTime); + UpdateReadStatInfo(readArgs->size, cInode->mBase->name, readTime, data->activeBundle); cInode->SetReadCacheFlag(cacheIndex, PG_UPTODATE); wSesLock.lock(); diff --git a/test/unittests/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat_test.cpp b/test/unittests/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat_test.cpp index 0c93f9d3205811051a4d0ed8694528e0ccf4e033..0b20a13f9f38dd2d0698595965dcf0a88640b996 100644 --- a/test/unittests/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat_test.cpp +++ b/test/unittests/cloud_file_kit_inner/big_data_statistics/gallery_download_file_stat_test.cpp @@ -353,117 +353,117 @@ HWTEST_F(GalleryDownloadFileStatTest, UpdateDownloadBundleNameTest_001, TestSize } /** - * @tc.name: IsSameBundleNameTest_001 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_001 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(GalleryDownloadFileStatTest, IsSameBundleNameTest_001, TestSize.Level1) +HWTEST_F(GalleryDownloadFileStatTest, HandleBundleNameTest_001, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 Start"; GalleryDownloadFileStat downloadStat; downloadStat.stat_.bundleName = "test.bundle.name"; DownloadFileStatInfo info; info.bundleName = "test.bundle.name"; try { - downloadStat.IsSameBundleName(info); + downloadStat.HandleBundleName(info); EXPECT_EQ(downloadStat.stat_.bundleName, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 End"; } /** - * @tc.name: IsSameBundleNameTest_002 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_002 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(GalleryDownloadFileStatTest, IsSameBundleNameTest_002, TestSize.Level1) +HWTEST_F(GalleryDownloadFileStatTest, HandleBundleNameTest_002, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 Start"; GalleryDownloadFileStat downloadStat; downloadStat.stat_.bundleName = "test.bundle.name"; DownloadFileStatInfo info; info.bundleName = "different.bundle.name"; try { - downloadStat.IsSameBundleName(info); + downloadStat.HandleBundleName(info); EXPECT_EQ(downloadStat.stat_.bundleName, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 End"; } /** - * @tc.name: IsSameBundleNameTest_003 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_003 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(GalleryDownloadFileStatTest, IsSameBundleNameTest_003, TestSize.Level1) +HWTEST_F(GalleryDownloadFileStatTest, HandleBundleNameTest_003, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 Start"; GalleryDownloadFileStat downloadStat; downloadStat.stat_.bundleName = ""; DownloadFileStatInfo info; info.bundleName = "test.bundle.name"; try { - downloadStat.IsSameBundleName(info); + downloadStat.HandleBundleName(info); EXPECT_EQ(downloadStat.stat_.bundleName, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 End"; } /** - * @tc.name: IsSameBundleNameTest_004 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_004 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(GalleryDownloadFileStatTest, IsSameBundleNameTest_004, TestSize.Level1) +HWTEST_F(GalleryDownloadFileStatTest, HandleBundleNameTest_004, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 Start"; GalleryDownloadFileStat downloadStat; downloadStat.stat_.bundleName = ""; DownloadFileStatInfo info; info.bundleName = ""; try { - downloadStat.IsSameBundleName(info); + downloadStat.HandleBundleName(info); EXPECT_EQ(downloadStat.stat_.bundleName, ""); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 End"; } /** - * @tc.name: IsSameBundleNameTest_005 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_005 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(GalleryDownloadFileStatTest, IsSameBundleNameTest_005, TestSize.Level1) +HWTEST_F(GalleryDownloadFileStatTest, HandleBundleNameTest_005, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_005 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_005 Start"; GalleryDownloadFileStat downloadStat; downloadStat.stat_.bundleName = "test.bundle.name"; DownloadFileStatInfo info; info.bundleName = ""; try { - downloadStat.IsSameBundleName(info); + downloadStat.HandleBundleName(info); EXPECT_EQ(downloadStat.stat_.bundleName, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_005 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_005 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_005 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_005 End"; } } \ No newline at end of file diff --git a/test/unittests/services_daemon/cloud_daemon_statistic_test.cpp b/test/unittests/services_daemon/cloud_daemon_statistic_test.cpp index 1f71aa8d9c83d585ab19c67d0b86f930fb6da9fd..fa5abe68e505b8a7eab9032094b05e08e04943e8 100644 --- a/test/unittests/services_daemon/cloud_daemon_statistic_test.cpp +++ b/test/unittests/services_daemon/cloud_daemon_statistic_test.cpp @@ -245,94 +245,94 @@ HWTEST_F(CloudDaemonStatisticTest, ReportReadStatTest_001, TestSize.Level1) } /** - * @tc.name: IsSameBundleNameTest_001 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_001 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(CloudDaemonStatisticTest, IsSameBundleNameTest_001, TestSize.Level1) +HWTEST_F(CloudDaemonStatisticTest, HandleBundleNameTest_001, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 Start"; CloudDaemonStatistic cds; cds.bundleName_ = "test.bundle.name"; CloudDaemonStatisticInfo info; info.bundleName = "test.bundle.name"; try { - cds.IsSameBundleName(info); + cds.HandleBundleName(info); EXPECT_EQ(cds.bundleName_, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_001 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_001 End"; } /** - * @tc.name: IsSameBundleNameTest_002 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_002 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(CloudDaemonStatisticTest, IsSameBundleNameTest_002, TestSize.Level1) +HWTEST_F(CloudDaemonStatisticTest, HandleBundleNameTest_002, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 Start"; CloudDaemonStatistic cds; cds.bundleName_ = "test.bundle.name"; CloudDaemonStatisticInfo info; info.bundleName = "different.bundle.name"; try { - cds.IsSameBundleName(info); + cds.HandleBundleName(info); EXPECT_EQ(cds.bundleName_, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_002 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_002 End"; } /** - * @tc.name: IsSameBundleNameTest_003 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_003 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(CloudDaemonStatisticTest, IsSameBundleNameTest_003, TestSize.Level1) +HWTEST_F(CloudDaemonStatisticTest, HandleBundleNameTest_003, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 Start"; CloudDaemonStatistic cds; cds.bundleName_ = "test.bundle.name"; CloudDaemonStatisticInfo info; info.bundleName = ""; try { - cds.IsSameBundleName(info); + cds.HandleBundleName(info); EXPECT_EQ(cds.bundleName_, "test.bundle.name"); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_003 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_003 End"; } /** - * @tc.name: IsSameBundleNameTest_004 - * @tc.desc: Verify the IsSameBundleName function + * @tc.name: HandleBundleNameTest_004 + * @tc.desc: Verify the HandleBundleName function * @tc.type: FUNC * @tc.require: ICQTGD */ -HWTEST_F(CloudDaemonStatisticTest, IsSameBundleNameTest_004, TestSize.Level1) +HWTEST_F(CloudDaemonStatisticTest, HandleBundleNameTest_004, TestSize.Level1) { - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 Start"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 Start"; CloudDaemonStatistic cds; cds.bundleName_ = ""; CloudDaemonStatisticInfo info; info.bundleName = ""; try { - cds.IsSameBundleName(info); + cds.HandleBundleName(info); EXPECT_EQ(cds.bundleName_, ""); } catch(...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 ERROR"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 ERROR"; } - GTEST_LOG_(INFO) << "IsSameBundleNameTest_004 End"; + GTEST_LOG_(INFO) << "HandleBundleNameTest_004 End"; } } \ No newline at end of file diff --git a/test/unittests/services_daemon/fuse_manager_static_test.cpp b/test/unittests/services_daemon/fuse_manager_static_test.cpp index a7c718843e57b918e4bd34f54e6211f8fc0250a3..d9cd95d45b4c03003372362d1f60542e3c647ffd 100644 --- a/test/unittests/services_daemon/fuse_manager_static_test.cpp +++ b/test/unittests/services_daemon/fuse_manager_static_test.cpp @@ -414,4 +414,106 @@ HWTEST_F(FuseManagerStaticTest, IsHdc002, TestSize.Level1) } GTEST_LOG_(INFO) << "IsHdc002 End"; } + +/** + * @tc.name: UpdateReadStatInfoTest001 + * @tc.desc: Verify the UpdateReadStatInfo function + * @tc.type: FUNC + * @tc.require:ICTLI4 + */ +HWTEST_F(FuseManagerStaticTest, UpdateReadStatInfoTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest001 Begin"; + try { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + readStat.bundleName_ = ""; + size_t size = 1; + string name = "name"; + uint64_t readTime = 1; + string bundleName = "test.bundle.name"; + UpdateReadStatInfo(size, name, 1, bundleName); + EXPECT_EQ(readStat.bundleName_, "test.bundle.name"); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest001 Error"; + } + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest001 End"; +} + +/** + * @tc.name: UpdateReadStatInfoTest002 + * @tc.desc: Verify the UpdateReadStatInfo function + * @tc.type: FUNC + * @tc.require:ICTLI4 + */ +HWTEST_F(FuseManagerStaticTest, UpdateReadStatInfoTest002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest002 Begin"; + try { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + readStat.bundleName_ = "test.bundle.name"; + size_t size = 1; + string name = "name"; + uint64_t readTime = 1; + string bundleName = "new.bundle.name"; + UpdateReadStatInfo(size, name, 1, bundleName); + EXPECT_EQ(readStat.bundleName_, "new.bundle.name"); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest002 Error"; + } + GTEST_LOG_(INFO) << "UpdateReadStatInfoTest002 End"; +} + +/** + * @tc.name: UpdateReadStatTest001 + * @tc.desc: Verify the UpdateReadStat function + * @tc.type: FUNC + * @tc.require:ICTLI4 + */ +HWTEST_F(FuseManagerStaticTest, UpdateReadStatTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdateReadStatTest001 Begin"; + try { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + readStat.bundleName_ = ""; + auto cInode = make_shared(); + cInode->mBase = make_shared("test"); + cInode->mBase->fileType = FILE_TYPE_THUMBNAIL; + uint64_t startTime = 1; + string bundleName = "test.bundle.name"; + UpdateReadStat(cInode, startTime, bundleName); + EXPECT_EQ(readStat.bundleName_, "test.bundle.name"); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "UpdateReadStatTest001 Error"; + } + GTEST_LOG_(INFO) << "UpdateReadStatTest001 End"; +} + +/** + * @tc.name: UpdateReadStatTest002 + * @tc.desc: Verify the UpdateReadStat function + * @tc.type: FUNC + * @tc.require:ICTLI4 + */ +HWTEST_F(FuseManagerStaticTest, UpdateReadStatTest002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdateReadStatTest002 Begin"; + try { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + readStat.bundleName_ = "test.bundle.name"; + auto cInode = make_shared(); + cInode->mBase = make_shared("test"); + cInode->mBase->fileType = FILE_TYPE_THUMBNAIL; + uint64_t startTime = 1; + string bundleName = "new.bundle.name"; + UpdateReadStat(cInode, startTime, bundleName); + EXPECT_EQ(readStat.bundleName_, "new.bundle.name"); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "UpdateReadStatTest002 Error"; + } + GTEST_LOG_(INFO) << "UpdateReadStatTest002 End"; +} } // namespace OHOS::FileManagement::CloudSync::Test \ No newline at end of file