| 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 "net/base/file_stream.h" | 5 #include "net/base/file_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 ASSERT_EQ(4, write_stream->Truncate(4)); | 1010 ASSERT_EQ(4, write_stream->Truncate(4)); |
| 1011 | 1011 |
| 1012 // Write again. | 1012 // Write again. |
| 1013 write_stream->WriteSync(test_data, 4); | 1013 write_stream->WriteSync(test_data, 4); |
| 1014 | 1014 |
| 1015 // Close the stream. | 1015 // Close the stream. |
| 1016 write_stream.reset(); | 1016 write_stream.reset(); |
| 1017 | 1017 |
| 1018 // Read in the contents and make sure we get back what we expected. | 1018 // Read in the contents and make sure we get back what we expected. |
| 1019 std::string read_contents; | 1019 std::string read_contents; |
| 1020 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); | 1020 EXPECT_TRUE(base::ReadFileToString(temp_file_path(), &read_contents)); |
| 1021 | 1021 |
| 1022 EXPECT_EQ("01230123", read_contents); | 1022 EXPECT_EQ("01230123", read_contents); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 TEST_F(FileStreamTest, AsyncOpenAndDelete) { | 1025 TEST_F(FileStreamTest, AsyncOpenAndDelete) { |
| 1026 scoped_ptr<FileStream> stream(new FileStream(NULL)); | 1026 scoped_ptr<FileStream> stream(new FileStream(NULL)); |
| 1027 int flags = base::PLATFORM_FILE_OPEN | | 1027 int flags = base::PLATFORM_FILE_OPEN | |
| 1028 base::PLATFORM_FILE_WRITE | | 1028 base::PLATFORM_FILE_WRITE | |
| 1029 base::PLATFORM_FILE_ASYNC; | 1029 base::PLATFORM_FILE_ASYNC; |
| 1030 TestCompletionCallback open_callback; | 1030 TestCompletionCallback open_callback; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 scoped_refptr<IOBuffer> buf = new WrappedIOBuffer(NULL); | 1073 scoped_refptr<IOBuffer> buf = new WrappedIOBuffer(NULL); |
| 1074 rv = stream->Read(buf.get(), 1, callback.callback()); | 1074 rv = stream->Read(buf.get(), 1, callback.callback()); |
| 1075 if (rv == ERR_IO_PENDING) | 1075 if (rv == ERR_IO_PENDING) |
| 1076 rv = callback.WaitForResult(); | 1076 rv = callback.WaitForResult(); |
| 1077 EXPECT_LT(rv, 0); | 1077 EXPECT_LT(rv, 0); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 } // namespace | 1080 } // namespace |
| 1081 | 1081 |
| 1082 } // namespace net | 1082 } // namespace net |
| OLD | NEW |