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

Side by Side Diff: net/http/http_pipelined_network_transaction_unittest.cc

Issue 9567025: Ensure pipelined requests are sent in the same order they're queued. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clean up unit test Created 8 years, 9 months 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
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 <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
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,
868 "GET /one.html HTTP/1.1\r\n"
869 "Host: localhost\r\n"
870 "Connection: keep-alive\r\n\r\n"
871 "GET /two.html HTTP/1.1\r\n"
872 "Host: localhost\r\n"
873 "Connection: keep-alive\r\n\r\n"
874 "GET /three.html HTTP/1.1\r\n"
875 "Host: localhost\r\n"
876 "Connection: keep-alive\r\n\r\n"
877 "GET /four.html HTTP/1.1\r\n"
878 "Host: localhost\r\n"
879 "Connection: keep-alive\r\n\r\n"
880 ),
881 };
882 MockRead reads[] = {
883 MockRead(ASYNC, ERR_FAILED, 1),
884 };
885 scoped_refptr<DeterministicSocketData> data(new DeterministicSocketData(
886 reads, arraysize(reads), writes, arraysize(writes)));
887 data->set_connect_data(MockConnect(ASYNC, OK));
888 factory_.AddSocketDataProvider(data);
889
890 scoped_ptr<HttpNetworkTransaction> one_transaction(
891 new HttpNetworkTransaction(session_.get()));
892 TestCompletionCallback one_callback;
893 EXPECT_EQ(ERR_IO_PENDING,
894 one_transaction->Start(GetRequestInfo("one.html"),
895 one_callback.callback(), BoundNetLog()));
896
897 scoped_ptr<HttpNetworkTransaction> two_transaction(
898 new HttpNetworkTransaction(session_.get()));
899 TestCompletionCallback two_callback;
900 EXPECT_EQ(ERR_IO_PENDING,
901 two_transaction->Start(GetRequestInfo("two.html"),
902 two_callback.callback(), BoundNetLog()));
903
904 scoped_ptr<HttpNetworkTransaction> three_transaction(
905 new HttpNetworkTransaction(session_.get()));
906 TestCompletionCallback three_callback;
907 EXPECT_EQ(ERR_IO_PENDING,
908 three_transaction->Start(GetRequestInfo("three.html"),
909 three_callback.callback(), BoundNetLog()));
910
911 scoped_ptr<HttpNetworkTransaction> four_transaction(
912 new HttpNetworkTransaction(session_.get()));
913 TestCompletionCallback four_callback;
914 EXPECT_EQ(ERR_IO_PENDING,
915 four_transaction->Start(GetRequestInfo("four.html"),
916 four_callback.callback(), BoundNetLog()));
917
918 data->RunFor(3);
919 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult());
920 one_transaction.reset();
921 EXPECT_EQ(ERR_PIPELINE_EVICTION, two_callback.WaitForResult());
922 two_transaction.reset();
923 EXPECT_EQ(ERR_PIPELINE_EVICTION, three_callback.WaitForResult());
924 three_transaction.reset();
925 EXPECT_EQ(ERR_PIPELINE_EVICTION, four_callback.WaitForResult());
926 }
863 } // anonymous namespace 927 } // anonymous namespace
864 928
865 } // namespace net 929 } // namespace net
OLDNEW
« no previous file with comments | « chrome/browser/net/http_pipelining_compatibility_client.cc ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698