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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 EXPECT_EQ(ERR_IO_PENDING, | 853 EXPECT_EQ(ERR_IO_PENDING, |
854 two_transaction.Start(GetRequestInfo("two.html"), | 854 two_transaction.Start(GetRequestInfo("two.html"), |
855 two_callback.callback(), BoundNetLog())); | 855 two_callback.callback(), BoundNetLog())); |
856 | 856 |
857 data_vector_[0]->RunFor(2); | 857 data_vector_[0]->RunFor(2); |
858 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); | 858 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); |
859 one_transaction.reset(); | 859 one_transaction.reset(); |
860 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); | 860 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); |
861 } | 861 } |
862 | 862 |
863 TEST_F(HttpPipelinedNetworkTransactionTest, ForcedPipelineOrder) { | |
864 Initialize(true); | |
865 | |
866 MockWrite writes[] = { | |
867 MockWrite(ASYNC, 0, "GET /one.html HTTP/1.1\r\n" | |
mmenke
2012/03/02 18:55:55
nit: Think this is a little easier to read if the
| |
868 "Host: localhost\r\n" | |
869 "Connection: keep-alive\r\n\r\n" | |
870 "GET /two.html HTTP/1.1\r\n" | |
871 "Host: localhost\r\n" | |
872 "Connection: keep-alive\r\n\r\n" | |
873 "GET /three.html HTTP/1.1\r\n" | |
874 "Host: localhost\r\n" | |
875 "Connection: keep-alive\r\n\r\n" | |
876 "GET /four.html HTTP/1.1\r\n" | |
877 "Host: localhost\r\n" | |
878 "Connection: keep-alive\r\n\r\n" | |
879 ), | |
880 }; | |
881 MockRead reads[] = { | |
882 MockRead(ASYNC, ERR_FAILED, 1), | |
883 }; | |
884 scoped_refptr<DeterministicSocketData> data(new DeterministicSocketData( | |
885 reads, arraysize(reads), writes, arraysize(writes))); | |
886 data->set_connect_data(MockConnect(ASYNC, OK)); | |
887 factory_.AddSocketDataProvider(data); | |
888 | |
889 scoped_ptr<HttpNetworkTransaction> one_transaction( | |
890 new HttpNetworkTransaction(session_.get())); | |
891 TestCompletionCallback one_callback; | |
892 EXPECT_EQ(ERR_IO_PENDING, | |
893 one_transaction->Start(GetRequestInfo("one.html"), | |
894 one_callback.callback(), BoundNetLog())); | |
895 | |
896 scoped_ptr<HttpNetworkTransaction> two_transaction( | |
897 new HttpNetworkTransaction(session_.get())); | |
898 TestCompletionCallback two_callback; | |
899 EXPECT_EQ(ERR_IO_PENDING, | |
900 two_transaction->Start(GetRequestInfo("two.html"), | |
901 two_callback.callback(), BoundNetLog())); | |
902 | |
903 scoped_ptr<HttpNetworkTransaction> three_transaction( | |
904 new HttpNetworkTransaction(session_.get())); | |
905 TestCompletionCallback three_callback; | |
906 EXPECT_EQ(ERR_IO_PENDING, | |
907 three_transaction->Start(GetRequestInfo("three.html"), | |
908 three_callback.callback(), BoundNetLog())); | |
909 | |
910 scoped_ptr<HttpNetworkTransaction> four_transaction( | |
911 new HttpNetworkTransaction(session_.get())); | |
912 TestCompletionCallback four_callback; | |
913 EXPECT_EQ(ERR_IO_PENDING, | |
914 four_transaction->Start(GetRequestInfo("four.html"), | |
915 four_callback.callback(), BoundNetLog())); | |
916 | |
917 data->RunFor(3); | |
918 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); | |
919 one_transaction.reset(); | |
920 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult()); | |
921 two_transaction.reset(); | |
922 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult()); | |
923 three_transaction.reset(); | |
924 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult()); | |
925 } | |
863 } // anonymous namespace | 926 } // anonymous namespace |
864 | 927 |
865 } // namespace net | 928 } // namespace net |
OLD | NEW |