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

Unified Diff: chrome/browser/win/jumplist_file_util_unittest.cc

Issue 2859193005: Cache JumpList icons to avoid unnecessary creation and deletion (Closed)
Patch Set: Fix nits. Created 3 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 | « chrome/browser/win/jumplist_file_util.cc ('k') | chrome/browser/win/jumplist_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist_file_util_unittest.cc
diff --git a/chrome/browser/win/jumplist_file_util_unittest.cc b/chrome/browser/win/jumplist_file_util_unittest.cc
index b4cfbfb29bc147e04da4d932231f3ed55bfc1dbe..ec1172bc4fc6da6217bdb0623b821980c271c608 100644
--- a/chrome/browser/win/jumplist_file_util_unittest.cc
+++ b/chrome/browser/win/jumplist_file_util_unittest.cc
@@ -100,3 +100,47 @@ TEST_F(JumpListFileUtilTest, DeleteMaxFilesAllowed) {
EXPECT_TRUE(base::IsDirectoryEmpty(dir_path));
EXPECT_TRUE(DirectoryExists(dir_path));
}
+
+TEST_F(JumpListFileUtilTest, FilesExceedLimitInDir) {
+ base::FilePath dir_path = temp_dir_path();
+
+ // Create 2 files.
+ base::FilePath file_name =
+ dir_path.Append(FILE_PATH_LITERAL("TestFile1.txt"));
+ ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent));
+
+ file_name = dir_path.Append(FILE_PATH_LITERAL("TestFile2.txt"));
+ ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent));
+
+ EXPECT_TRUE(FilesExceedLimitInDir(dir_path, 1));
+ EXPECT_FALSE(FilesExceedLimitInDir(dir_path, 2));
+
+ DeleteDirectory(dir_path, kFileDeleteLimit);
+}
+
+TEST_F(JumpListFileUtilTest, DeleteNonCachedFiles) {
+ base::FilePath dir_path = temp_dir_path();
+
+ base::flat_set<base::FilePath> cached_files;
+
+ // Create 1 file and cache its filename.
+ base::FilePath file_name =
+ dir_path.Append(FILE_PATH_LITERAL("TestFile1.txt"));
+ ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent));
+
+ cached_files.insert(file_name);
+
+ // Create another file but not cache its filename.
+ file_name = dir_path.Append(FILE_PATH_LITERAL("TestFile2.txt"));
+ ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent));
+
+ // The second file created will be deleted as its filename is not in the
+ // cache, while the first file remains.
+ DeleteNonCachedFiles(dir_path, cached_files);
+ EXPECT_FALSE(base::IsDirectoryEmpty(dir_path));
+
+ // Clear the set and delete again, and now the first file should be gone.
+ cached_files.clear();
+ DeleteNonCachedFiles(dir_path, cached_files);
+ EXPECT_TRUE(base::IsDirectoryEmpty(dir_path));
+}
« no previous file with comments | « chrome/browser/win/jumplist_file_util.cc ('k') | chrome/browser/win/jumplist_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698