Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: components/offline_pages/archive_manager_unittest.cc

Issue 1988973002: [Offline pages] Moving disk size related calls to Archive Manager, reorganizing UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@archive-manager
Patch Set: Addressing feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/offline_pages/archive_manager.cc ('k') | components/offline_pages/offline_page_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/archive_manager_unittest.cc
diff --git a/components/offline_pages/archive_manager_unittest.cc b/components/offline_pages/archive_manager_unittest.cc
index 66e1566a151120763330a01014576dcac3aa5d2e..5b5e59efd67aa1b2a02b34ecf97a193e4fe408fb 100644
--- a/components/offline_pages/archive_manager_unittest.cc
+++ b/components/offline_pages/archive_manager_unittest.cc
@@ -41,6 +41,8 @@ class ArchiveManagerTest : public testing::Test {
void ResetManager(const base::FilePath& file_path);
void Callback(bool result);
void GetAllArchivesCallback(const std::set<base::FilePath>& archive_paths);
+ void GetStorageStatsCallback(
+ const ArchiveManager::StorageStats& storage_sizes);
ArchiveManager* manager() { return manager_.get(); }
const base::FilePath& temp_path() const { return temp_dir_.path(); }
@@ -48,6 +50,9 @@ class ArchiveManagerTest : public testing::Test {
const std::set<base::FilePath>& last_archive_paths() const {
return last_archvie_paths_;
}
+ ArchiveManager::StorageStats last_storage_sizes() const {
+ return last_storage_sizes_;
+ }
private:
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
@@ -57,12 +62,14 @@ class ArchiveManagerTest : public testing::Test {
std::unique_ptr<ArchiveManager> manager_;
CallbackStatus callback_status_;
std::set<base::FilePath> last_archvie_paths_;
+ ArchiveManager::StorageStats last_storage_sizes_;
};
ArchiveManagerTest::ArchiveManagerTest()
: task_runner_(new base::TestSimpleTaskRunner),
task_runner_handle_(task_runner_),
- callback_status_(CallbackStatus::NOT_CALLED) {}
+ callback_status_(CallbackStatus::NOT_CALLED),
+ last_storage_sizes_({0, 0}) {}
void ArchiveManagerTest::SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -93,6 +100,11 @@ void ArchiveManagerTest::GetAllArchivesCallback(
last_archvie_paths_ = archive_paths;
}
+void ArchiveManagerTest::GetStorageStatsCallback(
+ const ArchiveManager::StorageStats& storage_sizes) {
+ last_storage_sizes_ = storage_sizes;
+}
+
TEST_F(ArchiveManagerTest, EnsureArchivesDirCreated) {
base::FilePath archive_dir =
temp_path().Append(FILE_PATH_LITERAL("test_path"));
@@ -245,4 +257,18 @@ TEST_F(ArchiveManagerTest, GetAllArchives) {
EXPECT_EQ(expected_paths[2].BaseName(), actual_paths[2].BaseName());
}
+TEST_F(ArchiveManagerTest, GetStorageStats) {
+ base::FilePath archive_path_1;
+ EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_path(), &archive_path_1));
+ base::FilePath archive_path_2;
+ EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_path(), &archive_path_2));
+
+ manager()->GetStorageStats(base::Bind(
+ &ArchiveManagerTest::GetStorageStatsCallback, base::Unretained(this)));
+ PumpLoop();
+ EXPECT_GT(last_storage_sizes().free_disk_space, 0);
+ EXPECT_EQ(last_storage_sizes().total_archives_size,
+ base::ComputeDirectorySize(temp_path()));
+}
+
} // namespace offline_pages
« no previous file with comments | « components/offline_pages/archive_manager.cc ('k') | components/offline_pages/offline_page_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698