| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/test/fileapi_test_file_set.h" | 5 #include "content/test/fileapi_test_file_set.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include <limits> |
| 7 #include <string> | 10 #include <string> |
| 8 | 11 |
| 9 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 11 #include "base/logging.h" | 14 #include "base/logging.h" |
| 12 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 17 |
| 15 namespace content { | 18 namespace content { |
| 16 | 19 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 43 base::FilePath path = root_path.Append(test_case.path); | 46 base::FilePath path = root_path.Append(test_case.path); |
| 44 if (test_case.is_directory) { | 47 if (test_case.is_directory) { |
| 45 ASSERT_TRUE(base::CreateDirectory(path)); | 48 ASSERT_TRUE(base::CreateDirectory(path)); |
| 46 return; | 49 return; |
| 47 } | 50 } |
| 48 base::File file(path, | 51 base::File file(path, |
| 49 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 52 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
| 50 ASSERT_TRUE(file.IsValid()); | 53 ASSERT_TRUE(file.IsValid()); |
| 51 if (test_case.data_file_size) { | 54 if (test_case.data_file_size) { |
| 52 std::string content = base::RandBytesAsString(test_case.data_file_size); | 55 std::string content = base::RandBytesAsString(test_case.data_file_size); |
| 53 EXPECT_LE(test_case.data_file_size, kint32max); | 56 EXPECT_LE(test_case.data_file_size, std::numeric_limits<int32_t>::max()); |
| 54 ASSERT_EQ(static_cast<int>(content.size()), | 57 ASSERT_EQ(static_cast<int>(content.size()), |
| 55 file.Write(0, content.data(), static_cast<int>(content.size()))); | 58 file.Write(0, content.data(), static_cast<int>(content.size()))); |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 | 61 |
| 59 | 62 |
| 60 void SetUpRegularFileSystemTestCases(const base::FilePath& root_path) { | 63 void SetUpRegularFileSystemTestCases(const base::FilePath& root_path) { |
| 61 for (size_t i = 0; i < arraysize(kRegularFileSystemTestCases); ++i) { | 64 for (size_t i = 0; i < arraysize(kRegularFileSystemTestCases); ++i) { |
| 62 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i); | 65 SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i); |
| 63 SetUpOneFileSystemTestCase(root_path, kRegularFileSystemTestCases[i]); | 66 SetUpOneFileSystemTestCase(root_path, kRegularFileSystemTestCases[i]); |
| 64 } | 67 } |
| 65 } | 68 } |
| 66 | 69 |
| 67 } // namespace content | 70 } // namespace content |
| OLD | NEW |