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

Side by Side Diff: webkit/fileapi/test_file_set.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « webkit/fileapi/test_file_set.h ('k') | webkit/fileapi/test_mount_point_provider.h » ('j') | 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 "webkit/fileapi/test_file_set.h" 5 #include "webkit/fileapi/test_file_set.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 {false, FILE_PATH_LITERAL("file 3"), 0}, 32 {false, FILE_PATH_LITERAL("file 3"), 0},
33 {false, FILE_PATH_LITERAL("dir a/file 0"), 39}, 33 {false, FILE_PATH_LITERAL("dir a/file 0"), 39},
34 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 0"), 40}, 34 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 0"), 40},
35 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 1"), 41}, 35 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 1"), 41},
36 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 2"), 42}, 36 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 2"), 42},
37 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 3"), 50}, 37 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 3"), 50},
38 }; 38 };
39 39
40 const size_t kRegularTestCaseSize = arraysize(kRegularTestCases); 40 const size_t kRegularTestCaseSize = arraysize(kRegularTestCases);
41 41
42 void SetUpOneTestCase(const FilePath& root_path, 42 void SetUpOneTestCase(const base::FilePath& root_path,
43 const TestCaseRecord& test_case) { 43 const TestCaseRecord& test_case) {
44 FilePath path = root_path.Append(test_case.path); 44 base::FilePath path = root_path.Append(test_case.path);
45 if (test_case.is_directory) { 45 if (test_case.is_directory) {
46 ASSERT_TRUE(file_util::CreateDirectory(path)); 46 ASSERT_TRUE(file_util::CreateDirectory(path));
47 return; 47 return;
48 } 48 }
49 base::PlatformFileError error_code; 49 base::PlatformFileError error_code;
50 bool created = false; 50 bool created = false;
51 int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS | 51 int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS |
52 base::PLATFORM_FILE_WRITE; 52 base::PLATFORM_FILE_WRITE;
53 base::PlatformFile file_handle = 53 base::PlatformFile file_handle =
54 base::CreatePlatformFile(path, file_flags, &created, &error_code); 54 base::CreatePlatformFile(path, file_flags, &created, &error_code);
55 EXPECT_TRUE(created); 55 EXPECT_TRUE(created);
56 ASSERT_EQ(base::PLATFORM_FILE_OK, error_code); 56 ASSERT_EQ(base::PLATFORM_FILE_OK, error_code);
57 ASSERT_NE(base::kInvalidPlatformFileValue, file_handle); 57 ASSERT_NE(base::kInvalidPlatformFileValue, file_handle);
58 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); 58 EXPECT_TRUE(base::ClosePlatformFile(file_handle));
59 if (test_case.data_file_size > 0U) { 59 if (test_case.data_file_size > 0U) {
60 std::string content = base::RandBytesAsString(test_case.data_file_size); 60 std::string content = base::RandBytesAsString(test_case.data_file_size);
61 ASSERT_EQ(static_cast<int>(content.size()), 61 ASSERT_EQ(static_cast<int>(content.size()),
62 file_util::WriteFile(path, content.data(), content.size())); 62 file_util::WriteFile(path, content.data(), content.size()));
63 } 63 }
64 } 64 }
65 65
66 66
67 void SetUpRegularTestCases(const FilePath& root_path) { 67 void SetUpRegularTestCases(const base::FilePath& root_path) {
68 for (size_t i = 0; i < arraysize(kRegularTestCases); ++i) { 68 for (size_t i = 0; i < arraysize(kRegularTestCases); ++i) {
69 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i); 69 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i);
70 SetUpOneTestCase(root_path, kRegularTestCases[i]); 70 SetUpOneTestCase(root_path, kRegularTestCases[i]);
71 } 71 }
72 } 72 }
73 73
74 } // namespace test 74 } // namespace test
75 75
76 } // namespace fileapi 76 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/test_file_set.h ('k') | webkit/fileapi/test_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698