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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 //----------------------------------------------------------------------------- | 326 //----------------------------------------------------------------------------- |
327 | 327 |
328 // This is the expected list of advertised protocols from the browser's NPN | 328 // This is the expected list of advertised protocols from the browser's NPN |
329 // list. | 329 // list. |
330 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; | 330 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; |
331 | 331 |
332 // This is the expected return from a current server advertising SPDY. | 332 // This is the expected return from a current server advertising SPDY. |
333 static const char kAlternateProtocolHttpHeader[] = | 333 static const char kAlternateProtocolHttpHeader[] = |
334 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; | 334 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; |
335 | 335 |
336 TEST_F(HttpNetworkTransactionTest, LogNumRttVsBytesMetrics_WarmestSocket) { | |
337 MockRead data_reads[1000]; | |
338 data_reads[0] = MockRead("HTTP/1.0 200 OK\r\n\r\n"); | |
339 for (int i = 1; i < 999; i++) { | |
340 data_reads[i] = MockRead("Gagan is a good boy!"); | |
341 } | |
342 data_reads[999] = MockRead(false, OK); | |
343 | |
344 net::SetSocketReusePolicy(0); | |
345 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | |
346 arraysize(data_reads)); | |
347 | |
348 base::Histogram* histogram = NULL; | |
349 base::StatisticsRecorder::FindHistogram( | |
350 "Net.Num_RTT_vs_KB_warmest_socket_15KB", &histogram); | |
351 CHECK(histogram); | |
352 | |
353 base::Histogram::SampleSet sample_set; | |
354 histogram->SnapshotSample(&sample_set); | |
355 EXPECT_EQ(1, sample_set.TotalCount()); | |
356 | |
357 EXPECT_EQ(OK, out.rv); | |
358 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | |
359 } | |
360 | |
361 // TODO(gagansingh): Add test for LogNumRttVsBytesMetrics_LastAccessSocket once | |
362 // it is possible to clear histograms from previous tests. | |
363 | |
364 TEST_F(HttpNetworkTransactionTest, Basic) { | 336 TEST_F(HttpNetworkTransactionTest, Basic) { |
365 SessionDependencies session_deps; | 337 SessionDependencies session_deps; |
366 scoped_ptr<HttpTransaction> trans( | 338 scoped_ptr<HttpTransaction> trans( |
367 new HttpNetworkTransaction(CreateSession(&session_deps))); | 339 new HttpNetworkTransaction(CreateSession(&session_deps))); |
368 } | 340 } |
369 | 341 |
370 TEST_F(HttpNetworkTransactionTest, SimpleGET) { | 342 TEST_F(HttpNetworkTransactionTest, SimpleGET) { |
371 MockRead data_reads[] = { | 343 MockRead data_reads[] = { |
372 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 344 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
373 MockRead("hello world"), | 345 MockRead("hello world"), |
(...skipping 8628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9002 EXPECT_TRUE(response->was_fetched_via_spdy); | 8974 EXPECT_TRUE(response->was_fetched_via_spdy); |
9003 EXPECT_TRUE(response->was_npn_negotiated); | 8975 EXPECT_TRUE(response->was_npn_negotiated); |
9004 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 8976 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
9005 EXPECT_EQ("hello!", response_data); | 8977 EXPECT_EQ("hello!", response_data); |
9006 | 8978 |
9007 HttpStreamFactory::set_next_protos(""); | 8979 HttpStreamFactory::set_next_protos(""); |
9008 HttpStreamFactory::set_use_alternate_protocols(false); | 8980 HttpStreamFactory::set_use_alternate_protocols(false); |
9009 } | 8981 } |
9010 | 8982 |
9011 } // namespace net | 8983 } // namespace net |
OLD | NEW |