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

Unified Diff: util/file/file_io_test.cc

Issue 1395543002: Add non-logging OpenFileForWrite() and OpenFileForReadAndWrite() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 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 | « util/file/file_io_posix.cc ('k') | util/file/file_io_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/file_io_test.cc
diff --git a/util/file/file_io_test.cc b/util/file/file_io_test.cc
index 29cf320444e9c6b1bc1a7e57857744310a246202..77529ea5d2133bc3a98e5ea791d7cb152be720ca 100644
--- a/util/file/file_io_test.cc
+++ b/util/file/file_io_test.cc
@@ -28,29 +28,30 @@ namespace crashpad {
namespace test {
namespace {
-TEST(FileIO, OpenFileForWrite) {
+void TestOpenFileForWrite(FileHandle (*opener)(const base::FilePath&,
+ FileWriteMode,
+ FilePermissions)) {
ScopedTempDir temp_dir;
base::FilePath file_path_1 =
temp_dir.path().Append(FILE_PATH_LITERAL("file_1"));
ASSERT_FALSE(FileExists(file_path_1));
- ScopedFileHandle
- file_handle(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kReuseOrFail,
- FilePermissions::kWorldReadable));
+ ScopedFileHandle file_handle(opener(file_path_1,
+ FileWriteMode::kReuseOrFail,
+ FilePermissions::kWorldReadable));
EXPECT_EQ(kInvalidFileHandle, file_handle);
EXPECT_FALSE(FileExists(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kCreateOrFail,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kCreateOrFail,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(0, FileSize(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kReuseOrCreate,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kReuseOrCreate,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(0, FileSize(file_path_1));
@@ -62,30 +63,30 @@ TEST(FileIO, OpenFileForWrite) {
file_handle.reset();
EXPECT_EQ(implicit_cast<FileOffset>(sizeof(data)), FileSize(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kReuseOrCreate,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kReuseOrCreate,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(implicit_cast<FileOffset>(sizeof(data)), FileSize(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kCreateOrFail,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kCreateOrFail,
+ FilePermissions::kWorldReadable));
EXPECT_EQ(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(implicit_cast<FileOffset>(sizeof(data)), FileSize(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kReuseOrFail,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kReuseOrFail,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(implicit_cast<FileOffset>(sizeof(data)), FileSize(file_path_1));
- file_handle.reset(LoggingOpenFileForWrite(file_path_1,
- FileWriteMode::kTruncateOrCreate,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_1,
+ FileWriteMode::kTruncateOrCreate,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_1));
EXPECT_EQ(0, FileSize(file_path_1));
@@ -94,9 +95,9 @@ TEST(FileIO, OpenFileForWrite) {
temp_dir.path().Append(FILE_PATH_LITERAL("file_2"));
ASSERT_FALSE(FileExists(file_path_2));
- file_handle.reset(LoggingOpenFileForWrite(file_path_2,
- FileWriteMode::kTruncateOrCreate,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_2,
+ FileWriteMode::kTruncateOrCreate,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_2));
EXPECT_EQ(0, FileSize(file_path_2));
@@ -105,14 +106,30 @@ TEST(FileIO, OpenFileForWrite) {
temp_dir.path().Append(FILE_PATH_LITERAL("file_3"));
ASSERT_FALSE(FileExists(file_path_3));
- file_handle.reset(LoggingOpenFileForWrite(file_path_3,
- FileWriteMode::kReuseOrCreate,
- FilePermissions::kWorldReadable));
+ file_handle.reset(opener(file_path_3,
+ FileWriteMode::kReuseOrCreate,
+ FilePermissions::kWorldReadable));
EXPECT_NE(kInvalidFileHandle, file_handle);
EXPECT_TRUE(FileExists(file_path_3));
EXPECT_EQ(0, FileSize(file_path_3));
}
+TEST(FileIO, OpenFileForWrite) {
+ TestOpenFileForWrite(OpenFileForWrite);
+}
+
+TEST(FileIO, OpenFileForReadAndWrite) {
+ TestOpenFileForWrite(OpenFileForReadAndWrite);
+}
+
+TEST(FileIO, LoggingOpenFileForWrite) {
+ TestOpenFileForWrite(LoggingOpenFileForWrite);
+}
+
+TEST(FileIO, LoggingOpenFileForReadAndWrite) {
+ TestOpenFileForWrite(LoggingOpenFileForReadAndWrite);
+}
+
enum class ReadOrWrite : bool {
kRead,
kWrite,
« no previous file with comments | « util/file/file_io_posix.cc ('k') | util/file/file_io_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698