OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 ASSERT_TRUE(CreateDirectory(data_dir)); | 1940 ASSERT_TRUE(CreateDirectory(data_dir)); |
1941 | 1941 |
1942 // Create a fresh, empty copy of this directory. | 1942 // Create a fresh, empty copy of this directory. |
1943 if (PathExists(data_dir)) { | 1943 if (PathExists(data_dir)) { |
1944 ASSERT_TRUE(DeleteFile(data_dir, true)); | 1944 ASSERT_TRUE(DeleteFile(data_dir, true)); |
1945 } | 1945 } |
1946 ASSERT_TRUE(CreateDirectory(data_dir)); | 1946 ASSERT_TRUE(CreateDirectory(data_dir)); |
1947 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); | 1947 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); |
1948 | 1948 |
1949 std::string data("hello"); | 1949 std::string data("hello"); |
1950 EXPECT_EQ(-1, file_util::AppendToFile(foobar, data.c_str(), data.length())); | 1950 EXPECT_EQ(-1, AppendToFile(foobar, data.c_str(), data.length())); |
1951 EXPECT_EQ(static_cast<int>(data.length()), | 1951 EXPECT_EQ(static_cast<int>(data.length()), |
1952 WriteFile(foobar, data.c_str(), data.length())); | 1952 WriteFile(foobar, data.c_str(), data.length())); |
1953 EXPECT_EQ(static_cast<int>(data.length()), | 1953 EXPECT_EQ(static_cast<int>(data.length()), |
1954 file_util::AppendToFile(foobar, data.c_str(), data.length())); | 1954 AppendToFile(foobar, data.c_str(), data.length())); |
1955 | 1955 |
1956 const std::wstring read_content = ReadTextFile(foobar); | 1956 const std::wstring read_content = ReadTextFile(foobar); |
1957 EXPECT_EQ(L"hellohello", read_content); | 1957 EXPECT_EQ(L"hellohello", read_content); |
1958 } | 1958 } |
1959 | 1959 |
1960 TEST_F(FileUtilTest, ReadFileToString) { | 1960 TEST_F(FileUtilTest, ReadFileToString) { |
1961 const char kTestData[] = "0123"; | 1961 const char kTestData[] = "0123"; |
1962 std::string data; | 1962 std::string data; |
1963 | 1963 |
1964 FilePath file_path = | 1964 FilePath file_path = |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 // Trying to close it should crash. This is important for security. | 2503 // Trying to close it should crash. This is important for security. |
2504 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); | 2504 EXPECT_DEATH(CloseWithScopedFD(fds[1]), ""); |
2505 #endif | 2505 #endif |
2506 } | 2506 } |
2507 | 2507 |
2508 #endif // defined(OS_POSIX) | 2508 #endif // defined(OS_POSIX) |
2509 | 2509 |
2510 } // namespace | 2510 } // namespace |
2511 | 2511 |
2512 } // namespace base | 2512 } // namespace base |
OLD | NEW |