| 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/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 IOBufferWithSize* CreateTestDataBuffer() { | 39 IOBufferWithSize* CreateTestDataBuffer() { |
| 40 IOBufferWithSize* buf = new IOBufferWithSize(kTestDataSize); | 40 IOBufferWithSize* buf = new IOBufferWithSize(kTestDataSize); |
| 41 memcpy(buf->data(), kTestData, kTestDataSize); | 41 memcpy(buf->data(), kTestData, kTestDataSize); |
| 42 return buf; | 42 return buf; |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 class FileStreamTest : public PlatformTest { | 47 class FileStreamTest : public PlatformTest { |
| 48 public: | 48 public: |
| 49 virtual void SetUp() { | 49 void SetUp() override { |
| 50 PlatformTest::SetUp(); | 50 PlatformTest::SetUp(); |
| 51 | 51 |
| 52 base::CreateTemporaryFile(&temp_file_path_); | 52 base::CreateTemporaryFile(&temp_file_path_); |
| 53 base::WriteFile(temp_file_path_, kTestData, kTestDataSize); | 53 base::WriteFile(temp_file_path_, kTestData, kTestDataSize); |
| 54 } | 54 } |
| 55 virtual void TearDown() { | 55 void TearDown() override { |
| 56 // FileStreamContexts must be asynchronously closed on the file task runner | 56 // FileStreamContexts must be asynchronously closed on the file task runner |
| 57 // before they can be deleted. Pump the RunLoop to avoid leaks. | 57 // before they can be deleted. Pump the RunLoop to avoid leaks. |
| 58 base::RunLoop().RunUntilIdle(); | 58 base::RunLoop().RunUntilIdle(); |
| 59 EXPECT_TRUE(base::DeleteFile(temp_file_path_, false)); | 59 EXPECT_TRUE(base::DeleteFile(temp_file_path_, false)); |
| 60 | 60 |
| 61 PlatformTest::TearDown(); | 61 PlatformTest::TearDown(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 const base::FilePath temp_file_path() const { return temp_file_path_; } | 64 const base::FilePath temp_file_path() const { return temp_file_path_; } |
| 65 | 65 |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 total_bytes_read += rv; | 874 total_bytes_read += rv; |
| 875 data_read.append(buf->data(), rv); | 875 data_read.append(buf->data(), rv); |
| 876 } | 876 } |
| 877 EXPECT_EQ(file_size, total_bytes_read); | 877 EXPECT_EQ(file_size, total_bytes_read); |
| 878 } | 878 } |
| 879 #endif | 879 #endif |
| 880 | 880 |
| 881 } // namespace | 881 } // namespace |
| 882 | 882 |
| 883 } // namespace net | 883 } // namespace net |
| OLD | NEW |