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

Side by Side Diff: content/test/fileapi_test_file_set.cc

Issue 2368913003: Populate storage_unittests target. (Closed)
Patch Set: Removed unnecessary include from storage/browser/blob/blob_storage_context_unittest.cc. Created 4 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 unified diff | Download patch
« no previous file with comments | « content/test/fileapi_test_file_set.h ('k') | storage/browser/BUILD.gn » ('j') | 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 2014 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 "content/test/fileapi_test_file_set.h"
6
7 #include <stdint.h>
8
9 #include <limits>
10 #include <string>
11
12 #include "base/files/file.h"
13 #include "base/files/file_util.h"
14 #include "base/logging.h"
15 #include "base/macros.h"
16 #include "base/rand_util.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 namespace content {
20
21 const FileSystemTestCaseRecord kRegularFileSystemTestCases[] = {
22 {true, FILE_PATH_LITERAL("dir a"), 0},
23 {true, FILE_PATH_LITERAL("dir a/dir A"), 0},
24 {true, FILE_PATH_LITERAL("dir a/dir d"), 0},
25 {true, FILE_PATH_LITERAL("dir a/dir d/dir e"), 0},
26 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir f"), 0},
27 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g"), 0},
28 {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir h"), 0},
29 {true, FILE_PATH_LITERAL("dir b"), 0},
30 {true, FILE_PATH_LITERAL("dir b/dir a"), 0},
31 {true, FILE_PATH_LITERAL("dir c"), 0},
32 {false, FILE_PATH_LITERAL("file 0"), 38},
33 {false, FILE_PATH_LITERAL("file 2"), 60},
34 {false, FILE_PATH_LITERAL("file 3"), 0},
35 {false, FILE_PATH_LITERAL("dir a/file 0"), 39},
36 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 0"), 40},
37 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 1"), 41},
38 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 2"), 42},
39 {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 3"), 50},
40 };
41
42 const size_t kRegularFileSystemTestCaseSize =
43 arraysize(kRegularFileSystemTestCases);
44
45 void SetUpOneFileSystemTestCase(const base::FilePath& root_path,
46 const FileSystemTestCaseRecord& test_case) {
47 base::FilePath path = root_path.Append(test_case.path);
48 if (test_case.is_directory) {
49 ASSERT_TRUE(base::CreateDirectory(path));
50 return;
51 }
52 base::File file(path,
53 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
54 ASSERT_TRUE(file.IsValid());
55 if (test_case.data_file_size) {
56 std::string content = base::RandBytesAsString(test_case.data_file_size);
57 EXPECT_LE(test_case.data_file_size, std::numeric_limits<int32_t>::max());
58 ASSERT_EQ(static_cast<int>(content.size()),
59 file.Write(0, content.data(), static_cast<int>(content.size())));
60 }
61 }
62
63
64 void SetUpRegularFileSystemTestCases(const base::FilePath& root_path) {
65 for (size_t i = 0; i < arraysize(kRegularFileSystemTestCases); ++i) {
66 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i);
67 SetUpOneFileSystemTestCase(root_path, kRegularFileSystemTestCases[i]);
68 }
69 }
70
71 } // namespace content
OLDNEW
« no previous file with comments | « content/test/fileapi_test_file_set.h ('k') | storage/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698