OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 EXPECT_EQ(kTestDataSize * 2, file_size); | 639 EXPECT_EQ(kTestDataSize * 2, file_size); |
640 | 640 |
641 EXPECT_EQ(kTestDataSize * 2, total_bytes_read); | 641 EXPECT_EQ(kTestDataSize * 2, total_bytes_read); |
642 const std::string kExpectedFileData = | 642 const std::string kExpectedFileData = |
643 std::string(kTestData) + std::string(kTestData); | 643 std::string(kTestData) + std::string(kTestData); |
644 EXPECT_EQ(kExpectedFileData, data_read); | 644 EXPECT_EQ(kExpectedFileData, data_read); |
645 } | 645 } |
646 | 646 |
647 class TestWriteReadCompletionCallback : public Callback1<int>::Type { | 647 class TestWriteReadCompletionCallback : public Callback1<int>::Type { |
648 public: | 648 public: |
649 explicit TestWriteReadCompletionCallback( | 649 TestWriteReadCompletionCallback( |
650 FileStream* stream, | 650 FileStream* stream, |
651 int* total_bytes_written, | 651 int* total_bytes_written, |
652 int* total_bytes_read, | 652 int* total_bytes_read, |
653 std::string* data_read) | 653 std::string* data_read) |
654 : result_(0), | 654 : result_(0), |
655 have_result_(false), | 655 have_result_(false), |
656 waiting_for_result_(false), | 656 waiting_for_result_(false), |
657 stream_(stream), | 657 stream_(stream), |
658 total_bytes_written_(total_bytes_written), | 658 total_bytes_written_(total_bytes_written), |
659 total_bytes_read_(total_bytes_read), | 659 total_bytes_read_(total_bytes_read), |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 EXPECT_EQ(kTestDataSize * 2, file_size); | 769 EXPECT_EQ(kTestDataSize * 2, file_size); |
770 | 770 |
771 EXPECT_EQ(kTestDataSize * 2, total_bytes_read); | 771 EXPECT_EQ(kTestDataSize * 2, total_bytes_read); |
772 const std::string kExpectedFileData = | 772 const std::string kExpectedFileData = |
773 std::string(kTestData) + std::string(kTestData); | 773 std::string(kTestData) + std::string(kTestData); |
774 EXPECT_EQ(kExpectedFileData, data_read); | 774 EXPECT_EQ(kExpectedFileData, data_read); |
775 } | 775 } |
776 | 776 |
777 class TestWriteCloseCompletionCallback : public Callback1<int>::Type { | 777 class TestWriteCloseCompletionCallback : public Callback1<int>::Type { |
778 public: | 778 public: |
779 explicit TestWriteCloseCompletionCallback(FileStream* stream, | 779 TestWriteCloseCompletionCallback(FileStream* stream, int* total_bytes_written) |
780 int* total_bytes_written) | |
781 : result_(0), | 780 : result_(0), |
782 have_result_(false), | 781 have_result_(false), |
783 waiting_for_result_(false), | 782 waiting_for_result_(false), |
784 stream_(stream), | 783 stream_(stream), |
785 total_bytes_written_(total_bytes_written) {} | 784 total_bytes_written_(total_bytes_written) {} |
786 | 785 |
787 int WaitForResult() { | 786 int WaitForResult() { |
788 DCHECK(!waiting_for_result_); | 787 DCHECK(!waiting_for_result_); |
789 while (!have_result_) { | 788 while (!have_result_) { |
790 waiting_for_result_ = true; | 789 waiting_for_result_ = true; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 885 |
887 // 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. |
888 std::string read_contents; | 887 std::string read_contents; |
889 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); | 888 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); |
890 | 889 |
891 EXPECT_EQ("01230123", read_contents); | 890 EXPECT_EQ("01230123", read_contents); |
892 } | 891 } |
893 | 892 |
894 } // namespace | 893 } // namespace |
895 } // namespace net | 894 } // namespace net |
OLD | NEW |