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

Side by Side Diff: base/platform_file_unittest.cc

Issue 314023002: Require FLAG_WRITE when FLAG_CREATE_ALWAYS is specified (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Require FLAG_WRITE on Windows too Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/files/file_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 &created, 94 &created,
95 &error_code); 95 &error_code);
96 EXPECT_EQ(kInvalidPlatformFileValue, file); 96 EXPECT_EQ(kInvalidPlatformFileValue, file);
97 EXPECT_FALSE(created); 97 EXPECT_FALSE(created);
98 EXPECT_EQ(PLATFORM_FILE_ERROR_EXISTS, error_code); 98 EXPECT_EQ(PLATFORM_FILE_ERROR_EXISTS, error_code);
99 99
100 // Create or overwrite a file. 100 // Create or overwrite a file.
101 error_code = PLATFORM_FILE_OK; 101 error_code = PLATFORM_FILE_OK;
102 file = CreatePlatformFile( 102 file = CreatePlatformFile(
103 file_path, 103 file_path,
104 PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_READ, 104 PLATFORM_FILE_CREATE_ALWAYS | PLATFORM_FILE_WRITE,
105 &created, 105 &created,
106 &error_code); 106 &error_code);
107 EXPECT_NE(kInvalidPlatformFileValue, file); 107 EXPECT_NE(kInvalidPlatformFileValue, file);
108 EXPECT_TRUE(created); 108 EXPECT_TRUE(created);
109 EXPECT_EQ(PLATFORM_FILE_OK, error_code); 109 EXPECT_EQ(PLATFORM_FILE_OK, error_code);
110 ClosePlatformFile(file); 110 ClosePlatformFile(file);
111 111
112 // Create a delete-on-close file. 112 // Create a delete-on-close file.
113 created = false; 113 created = false;
114 file_path = temp_dir.path().AppendASCII("create_file_2"); 114 file_path = temp_dir.path().AppendASCII("create_file_2");
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 ReadPlatformFileAtCurrentPos( 445 ReadPlatformFileAtCurrentPos(
446 file, buffer + first_chunk_size, 446 file, buffer + first_chunk_size,
447 kDataSize - first_chunk_size)); 447 kDataSize - first_chunk_size));
448 EXPECT_EQ(std::string(buffer, buffer + kDataSize), 448 EXPECT_EQ(std::string(buffer, buffer + kDataSize),
449 std::string(kData)); 449 std::string(kData));
450 450
451 ClosePlatformFile(file); 451 ClosePlatformFile(file);
452 } 452 }
453 453
454 } // namespace base 454 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698