| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/win/jumplist_file_util.h" | 5 #include "chrome/browser/win/jumplist_file_util.h" |
| 6 | 6 |
| 7 #include <Shlwapi.h> | |
| 8 #include <string> | 7 #include <string> |
| 9 | 8 |
| 10 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 12 |
| 14 namespace { | 13 namespace { |
| 15 | 14 |
| 16 // Random text to write into a file. | 15 // Random text to write into a file. |
| 17 constexpr char kFileContent[] = "I'm random context."; | 16 constexpr char kFileContent[] = "I'm random context."; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 dir_path.Append(FILE_PATH_LITERAL("TestDeleteFile1.txt")); | 86 dir_path.Append(FILE_PATH_LITERAL("TestDeleteFile1.txt")); |
| 88 ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent)); | 87 ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent)); |
| 89 | 88 |
| 90 file_name = dir_path.Append(FILE_PATH_LITERAL("TestDeleteFile2.txt")); | 89 file_name = dir_path.Append(FILE_PATH_LITERAL("TestDeleteFile2.txt")); |
| 91 ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent)); | 90 ASSERT_NO_FATAL_FAILURE(CreateTextFile(file_name, kFileContent)); |
| 92 | 91 |
| 93 // Delete the directory content using DeleteDirectoryContent(). | 92 // Delete the directory content using DeleteDirectoryContent(). |
| 94 // Sine the maximum files allowed to delete is 1, only 1 out of the 2 | 93 // Sine the maximum files allowed to delete is 1, only 1 out of the 2 |
| 95 // files is deleted. Therefore, the directory is not empty yet. | 94 // files is deleted. Therefore, the directory is not empty yet. |
| 96 ASSERT_EQ(DeleteDirectoryContent(dir_path, kFileDeleteLimitForTest), SUCCEED); | 95 ASSERT_EQ(DeleteDirectoryContent(dir_path, kFileDeleteLimitForTest), SUCCEED); |
| 97 EXPECT_FALSE(::PathIsDirectoryEmpty(dir_path.value().c_str())); | 96 EXPECT_FALSE(base::IsDirectoryEmpty(dir_path)); |
| 98 | 97 |
| 99 // Delete another file, and now the directory is empty. | 98 // Delete another file, and now the directory is empty. |
| 100 ASSERT_EQ(DeleteDirectoryContent(dir_path, kFileDeleteLimitForTest), SUCCEED); | 99 ASSERT_EQ(DeleteDirectoryContent(dir_path, kFileDeleteLimitForTest), SUCCEED); |
| 101 EXPECT_TRUE(::PathIsDirectoryEmpty(dir_path.value().c_str())); | 100 EXPECT_TRUE(base::IsDirectoryEmpty(dir_path)); |
| 102 EXPECT_TRUE(DirectoryExists(dir_path)); | 101 EXPECT_TRUE(DirectoryExists(dir_path)); |
| 103 } | 102 } |
| OLD | NEW |