Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Side by Side Diff: net/base/elements_upload_data_stream_unittest.cc

Issue 789953002: Fix crashes in ElementsUploadDataStreamTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/elements_upload_data_stream.h" 5 #include "net/base/elements_upload_data_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 element_readers_.push_back( 662 element_readers_.push_back(
663 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 663 new UploadFileElementReader(base::MessageLoopProxy::current().get(),
664 temp_file_path, 664 temp_file_path,
665 0, 665 0,
666 kuint64max, 666 kuint64max,
667 base::Time())); 667 base::Time()));
668 scoped_ptr<UploadDataStream> stream( 668 scoped_ptr<UploadDataStream> stream(
669 new ElementsUploadDataStream(element_readers_.Pass(), 0)); 669 new ElementsUploadDataStream(element_readers_.Pass(), 0));
670 670
671 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); 671 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize);
672 expected_data.insert(expected_data.end(), expected_data.begin(), 672 expected_data.insert(expected_data.end(), kTestData,
673 expected_data.begin() + kTestDataSize); 673 kTestData + kTestDataSize);
674 674
675 // Call Init(). 675 // Call Init().
676 TestCompletionCallback init_callback1; 676 TestCompletionCallback init_callback1;
677 ASSERT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback())); 677 ASSERT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback()));
678 EXPECT_EQ(OK, init_callback1.WaitForResult()); 678 EXPECT_EQ(OK, init_callback1.WaitForResult());
679 EXPECT_FALSE(stream->IsEOF()); 679 EXPECT_FALSE(stream->IsEOF());
680 EXPECT_EQ(kTestDataSize*2, stream->size()); 680 EXPECT_EQ(kTestDataSize*2, stream->size());
681 681
682 // Read some. 682 // Read some.
683 TestCompletionCallback read_callback1; 683 TestCompletionCallback read_callback1;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 element_readers_.push_back( 721 element_readers_.push_back(
722 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 722 new UploadFileElementReader(base::MessageLoopProxy::current().get(),
723 temp_file_path, 723 temp_file_path,
724 0, 724 0,
725 kuint64max, 725 kuint64max,
726 base::Time())); 726 base::Time()));
727 scoped_ptr<UploadDataStream> stream( 727 scoped_ptr<UploadDataStream> stream(
728 new ElementsUploadDataStream(element_readers_.Pass(), 0)); 728 new ElementsUploadDataStream(element_readers_.Pass(), 0));
729 729
730 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); 730 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize);
731 expected_data.insert(expected_data.end(), expected_data.begin(), 731 expected_data.insert(expected_data.end(), kTestData,
732 expected_data.begin() + kTestDataSize); 732 kTestData + kTestDataSize);
733 733
734 // Start Init. 734 // Start Init.
735 TestCompletionCallback init_callback1; 735 TestCompletionCallback init_callback1;
736 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback())); 736 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback()));
737 737
738 // Call Init again to cancel the previous init. 738 // Call Init again to cancel the previous init.
739 TestCompletionCallback init_callback2; 739 TestCompletionCallback init_callback2;
740 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback2.callback())); 740 EXPECT_EQ(ERR_IO_PENDING, stream->Init(init_callback2.callback()));
741 EXPECT_EQ(OK, init_callback2.WaitForResult()); 741 EXPECT_EQ(OK, init_callback2.WaitForResult());
742 EXPECT_FALSE(stream->IsEOF()); 742 EXPECT_FALSE(stream->IsEOF());
(...skipping 27 matching lines...) Expand all
770 element_readers_.push_back( 770 element_readers_.push_back(
771 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 771 new UploadFileElementReader(base::MessageLoopProxy::current().get(),
772 temp_file_path, 772 temp_file_path,
773 0, 773 0,
774 kuint64max, 774 kuint64max,
775 base::Time())); 775 base::Time()));
776 scoped_ptr<UploadDataStream> stream( 776 scoped_ptr<UploadDataStream> stream(
777 new ElementsUploadDataStream(element_readers_.Pass(), 0)); 777 new ElementsUploadDataStream(element_readers_.Pass(), 0));
778 778
779 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); 779 std::vector<char> expected_data(kTestData, kTestData + kTestDataSize);
780 expected_data.insert(expected_data.end(), expected_data.begin(), 780 expected_data.insert(expected_data.end(), kTestData,
781 expected_data.begin() + kTestDataSize); 781 kTestData + kTestDataSize);
782 782
783 // Call Init(). 783 // Call Init().
784 TestCompletionCallback init_callback1; 784 TestCompletionCallback init_callback1;
785 ASSERT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback())); 785 ASSERT_EQ(ERR_IO_PENDING, stream->Init(init_callback1.callback()));
786 EXPECT_EQ(OK, init_callback1.WaitForResult()); 786 EXPECT_EQ(OK, init_callback1.WaitForResult());
787 EXPECT_FALSE(stream->IsEOF()); 787 EXPECT_FALSE(stream->IsEOF());
788 EXPECT_EQ(kTestDataSize*2, stream->size()); 788 EXPECT_EQ(kTestDataSize*2, stream->size());
789 789
790 // Start reading. 790 // Start reading.
791 TestCompletionCallback read_callback1; 791 TestCompletionCallback read_callback1;
(...skipping 20 matching lines...) Expand all
812 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); 812 wrapped_buffer2.get(), buf2.size(), read_callback2.callback()));
813 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); 813 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult());
814 EXPECT_EQ(expected_data, buf2); 814 EXPECT_EQ(expected_data, buf2);
815 EXPECT_TRUE(stream->IsEOF()); 815 EXPECT_TRUE(stream->IsEOF());
816 816
817 // Make sure callbacks are not called for cancelled operations. 817 // Make sure callbacks are not called for cancelled operations.
818 EXPECT_FALSE(read_callback1.have_result()); 818 EXPECT_FALSE(read_callback1.have_result());
819 } 819 }
820 820
821 } // namespace net 821 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698