OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
8 #include "net/http/http_transaction_unittest.h" | 8 #include "net/http/http_transaction_unittest.h" |
9 #include "net/spdy/spdy_http_stream.h" | 9 #include "net/spdy/spdy_http_stream.h" |
10 #include "net/spdy/spdy_network_transaction.h" | 10 #include "net/spdy/spdy_network_transaction.h" |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); | 1970 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); |
1971 EXPECT_EQ("hello!", out.response_data); | 1971 EXPECT_EQ("hello!", out.response_data); |
1972 | 1972 |
1973 // Check that the NetLog was filled reasonably. | 1973 // Check that the NetLog was filled reasonably. |
1974 // This test is intentionally non-specific about the exact ordering of the | 1974 // This test is intentionally non-specific about the exact ordering of the |
1975 // log; instead we just check to make sure that certain events exist, and that | 1975 // log; instead we just check to make sure that certain events exist, and that |
1976 // they are in the right order. | 1976 // they are in the right order. |
1977 EXPECT_LT(0u, log.entries().size()); | 1977 EXPECT_LT(0u, log.entries().size()); |
1978 int pos = 0; | 1978 int pos = 0; |
1979 pos = net::ExpectLogContainsSomewhere(log.entries(), 0, | 1979 pos = net::ExpectLogContainsSomewhere(log.entries(), 0, |
1980 net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, | 1980 net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, |
1981 net::NetLog::PHASE_BEGIN); | 1981 net::NetLog::PHASE_BEGIN); |
1982 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, | 1982 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, |
1983 net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, | 1983 net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, |
1984 net::NetLog::PHASE_END); | 1984 net::NetLog::PHASE_END); |
1985 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, | 1985 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, |
1986 net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, | 1986 net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, |
1987 net::NetLog::PHASE_BEGIN); | 1987 net::NetLog::PHASE_BEGIN); |
1988 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, | 1988 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, |
1989 net::NetLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, | 1989 net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, |
1990 net::NetLog::PHASE_END); | 1990 net::NetLog::PHASE_END); |
1991 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, | 1991 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, |
1992 net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, | 1992 net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, |
1993 net::NetLog::PHASE_BEGIN); | 1993 net::NetLog::PHASE_BEGIN); |
1994 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, | 1994 pos = net::ExpectLogContainsSomewhere(log.entries(), pos + 1, |
1995 net::NetLog::TYPE_SPDY_TRANSACTION_READ_BODY, | 1995 net::NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, |
1996 net::NetLog::PHASE_END); | 1996 net::NetLog::PHASE_END); |
1997 } | 1997 } |
1998 | 1998 |
1999 // Since we buffer the IO from the stream to the renderer, this test verifies | 1999 // Since we buffer the IO from the stream to the renderer, this test verifies |
2000 // that when we read out the maximum amount of data (e.g. we received 50 bytes | 2000 // that when we read out the maximum amount of data (e.g. we received 50 bytes |
2001 // on the network, but issued a Read for only 5 of those bytes) that the data | 2001 // on the network, but issued a Read for only 5 of those bytes) that the data |
2002 // flow still works correctly. | 2002 // flow still works correctly. |
2003 TEST_P(SpdyNetworkTransactionTest, BufferFull) { | 2003 TEST_P(SpdyNetworkTransactionTest, BufferFull) { |
2004 spdy::SpdyFramer framer; | 2004 spdy::SpdyFramer framer; |
2005 | 2005 |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3150 | 3150 |
3151 // Now schedule the ERR_CONNECTION_RESET. | 3151 // Now schedule the ERR_CONNECTION_RESET. |
3152 EXPECT_EQ(3u, data1->read_index()); | 3152 EXPECT_EQ(3u, data1->read_index()); |
3153 data1->CompleteRead(); | 3153 data1->CompleteRead(); |
3154 EXPECT_EQ(4u, data1->read_index()); | 3154 EXPECT_EQ(4u, data1->read_index()); |
3155 } | 3155 } |
3156 rv = callback.WaitForResult(); | 3156 rv = callback.WaitForResult(); |
3157 EXPECT_EQ(OK, rv); | 3157 EXPECT_EQ(OK, rv); |
3158 | 3158 |
3159 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3159 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3160 ASSERT_TRUE(response != NULL); |
3160 EXPECT_TRUE(response->headers != NULL); | 3161 EXPECT_TRUE(response->headers != NULL); |
3161 EXPECT_TRUE(response->was_fetched_via_spdy); | 3162 EXPECT_TRUE(response->was_fetched_via_spdy); |
3162 std::string response_data; | 3163 std::string response_data; |
3163 rv = ReadTransaction(trans.get(), &response_data); | 3164 rv = ReadTransaction(trans.get(), &response_data); |
3164 EXPECT_EQ(OK, rv); | 3165 EXPECT_EQ(OK, rv); |
3165 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3166 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
3166 EXPECT_EQ("hello!", response_data); | 3167 EXPECT_EQ("hello!", response_data); |
3167 } | 3168 } |
3168 | 3169 |
3169 helper.VerifyDataConsumed(); | 3170 helper.VerifyDataConsumed(); |
3170 } | 3171 } |
3171 } | 3172 } |
3172 } // namespace net | 3173 } // namespace net |
OLD | NEW |