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

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

Issue 183343002: Move test_file_set to content/test/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, rename files Created 6 years, 9 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/browser/fileapi/test_file_set.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/browser/fileapi/test_file_set.h"
6
7 #include <string>
8
9 #include "base/file_util.h"
10 #include "base/files/file.h"
11 #include "base/logging.h"
12 #include "base/rand_util.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace fileapi {
16
17 namespace test {
18
19 const TestCaseRecord kRegularTestCases[] = {
20 {true, FILE_PATH_LITERAL("dir a"), 0},
21 {true, FILE_PATH_LITERAL("dir a/dir A"), 0},
22 {true, FILE_PATH_LITERAL("dir a/dir d"), 0},
23 {true, FILE_PATH_LITERAL("dir a/dir d/dir e"), 0},
24 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir f"), 0},
25 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g"), 0},
26 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir h"), 0},
27 {true, FILE_PATH_LITERAL("dir b"), 0},
28 {true, FILE_PATH_LITERAL("dir b/dir a"), 0},
29 {true, FILE_PATH_LITERAL("dir c"), 0},
30 {false, FILE_PATH_LITERAL("file 0"), 38},
31 {false, FILE_PATH_LITERAL("file 2"), 60},
32 {false, FILE_PATH_LITERAL("file 3"), 0},
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},
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},
37 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 3"), 50},
38 };
39
40 const size_t kRegularTestCaseSize = arraysize(kRegularTestCases);
41
42 void SetUpOneTestCase(const base::FilePath& root_path,
43 const TestCaseRecord& test_case) {
44 base::FilePath path = root_path.Append(test_case.path);
45 if (test_case.is_directory) {
46 ASSERT_TRUE(base::CreateDirectory(path));
47 return;
48 }
49 base::File file(path,
50 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
51 ASSERT_TRUE(file.IsValid());
52 if (test_case.data_file_size) {
53 std::string content = base::RandBytesAsString(test_case.data_file_size);
54 EXPECT_LE(test_case.data_file_size, kint32max);
55 ASSERT_EQ(static_cast<int>(content.size()),
56 file.Write(0, content.data(), static_cast<int>(content.size())));
57 }
58 }
59
60
61 void SetUpRegularTestCases(const base::FilePath& root_path) {
62 for (size_t i = 0; i < arraysize(kRegularTestCases); ++i) {
63 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i);
64 SetUpOneTestCase(root_path, kRegularTestCases[i]);
65 }
66 }
67
68 } // namespace test
69
70 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/test_file_set.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698