| 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 28 matching lines...) Expand all Loading... |
| 39 return buf; | 39 return buf; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 class FileStreamTest : public PlatformTest { | 44 class FileStreamTest : public PlatformTest { |
| 45 public: | 45 public: |
| 46 virtual void SetUp() { | 46 virtual void SetUp() { |
| 47 PlatformTest::SetUp(); | 47 PlatformTest::SetUp(); |
| 48 | 48 |
| 49 file_util::CreateTemporaryFile(&temp_file_path_); | 49 base::CreateTemporaryFile(&temp_file_path_); |
| 50 file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize); | 50 file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize); |
| 51 } | 51 } |
| 52 virtual void TearDown() { | 52 virtual void TearDown() { |
| 53 EXPECT_TRUE(base::DeleteFile(temp_file_path_, false)); | 53 EXPECT_TRUE(base::DeleteFile(temp_file_path_, false)); |
| 54 | 54 |
| 55 // FileStreamContexts must be asynchronously closed on the file task runner | 55 // FileStreamContexts must be asynchronously closed on the file task runner |
| 56 // before they can be deleted. Pump the RunLoop to avoid leaks. | 56 // before they can be deleted. Pump the RunLoop to avoid leaks. |
| 57 base::RunLoop().RunUntilIdle(); | 57 base::RunLoop().RunUntilIdle(); |
| 58 PlatformTest::TearDown(); | 58 PlatformTest::TearDown(); |
| 59 } | 59 } |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 total_bytes_read += rv; | 1222 total_bytes_read += rv; |
| 1223 data_read.append(buf->data(), rv); | 1223 data_read.append(buf->data(), rv); |
| 1224 } | 1224 } |
| 1225 EXPECT_EQ(file_size, total_bytes_read); | 1225 EXPECT_EQ(file_size, total_bytes_read); |
| 1226 } | 1226 } |
| 1227 #endif | 1227 #endif |
| 1228 | 1228 |
| 1229 } // namespace | 1229 } // namespace |
| 1230 | 1230 |
| 1231 } // namespace net | 1231 } // namespace net |
| OLD | NEW |