| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "net/base/file_stream.h" | 8 #include "net/base/file_stream.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const char kTestData[] = "0123456789"; | 16 const char kTestData[] = "0123456789"; |
| 17 const int kTestDataSize = arraysize(kTestData) - 1; | 17 const int kTestDataSize = arraysize(kTestData) - 1; |
| 18 | 18 |
| 19 class FileStreamTest : public PlatformTest { | 19 class FileStreamTest : public PlatformTest { |
| 20 public: | 20 public: |
| 21 virtual void SetUp() { | 21 virtual void SetUp() { |
| 22 PlatformTest::SetUp(); | 22 PlatformTest::SetUp(); |
| 23 | 23 |
| 24 file_util::CreateTemporaryFileName(&temp_file_path_); | 24 file_util::CreateTemporaryFile(&temp_file_path_); |
| 25 file_util::WriteFile(temp_file_path_.ToWStringHack(), | 25 file_util::WriteFile(temp_file_path_.ToWStringHack(), |
| 26 kTestData, kTestDataSize); | 26 kTestData, kTestDataSize); |
| 27 } | 27 } |
| 28 virtual void TearDown() { | 28 virtual void TearDown() { |
| 29 file_util::Delete(temp_file_path_, false); | 29 file_util::Delete(temp_file_path_, false); |
| 30 | 30 |
| 31 PlatformTest::TearDown(); | 31 PlatformTest::TearDown(); |
| 32 } | 32 } |
| 33 const FilePath temp_file_path() const { return temp_file_path_; } | 33 const FilePath temp_file_path() const { return temp_file_path_; } |
| 34 private: | 34 private: |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 write_stream.Close(); | 884 write_stream.Close(); |
| 885 | 885 |
| 886 // Read in the contents and make sure we get back what we expected. | 886 // Read in the contents and make sure we get back what we expected. |
| 887 std::string read_contents; | 887 std::string read_contents; |
| 888 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); | 888 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); |
| 889 | 889 |
| 890 EXPECT_EQ("01230123", read_contents); | 890 EXPECT_EQ("01230123", read_contents); |
| 891 } | 891 } |
| 892 | 892 |
| 893 } // namespace | 893 } // namespace |
| OLD | NEW |