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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 379283002: Rework UMAHistogramHelper and StatisticsDeltaReader into [Chrome]HistogramTester. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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 | Annotate | Revision Log
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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/statistics_delta_reader.h" 12 #include "base/test/histogram_tester.h"
13 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
14 #include "net/base/ip_endpoint.h" 14 #include "net/base/ip_endpoint.h"
15 #include "net/base/net_log_unittest.h" 15 #include "net/base/net_log_unittest.h"
16 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
17 #include "net/base/test_data_directory.h" 17 #include "net/base/test_data_directory.h"
18 #include "net/base/test_data_stream.h" 18 #include "net/base/test_data_stream.h"
19 #include "net/socket/client_socket_pool_manager.h" 19 #include "net/socket/client_socket_pool_manager.h"
20 #include "net/socket/next_proto.h" 20 #include "net/socket/next_proto.h"
21 #include "net/socket/socket_test_util.h" 21 #include "net/socket/socket_test_util.h"
22 #include "net/spdy/spdy_http_utils.h" 22 #include "net/spdy/spdy_http_utils.h"
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 session, url, MEDIUM, BoundNetLog()); 1785 session, url, MEDIUM, BoundNetLog());
1786 test::StreamDelegateDoNothing delegate(spdy_stream); 1786 test::StreamDelegateDoNothing delegate(spdy_stream);
1787 spdy_stream->SetDelegate(&delegate); 1787 spdy_stream->SetDelegate(&delegate);
1788 1788
1789 scoped_ptr<SpdyHeaderBlock> headers( 1789 scoped_ptr<SpdyHeaderBlock> headers(
1790 spdy_util_.ConstructGetHeaderBlock(url.spec())); 1790 spdy_util_.ConstructGetHeaderBlock(url.spec()));
1791 spdy_stream->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND); 1791 spdy_stream->SendRequestHeaders(headers.Pass(), NO_MORE_DATA_TO_SEND);
1792 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders()); 1792 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders());
1793 1793
1794 // Write request headers & capture resulting histogram update. 1794 // Write request headers & capture resulting histogram update.
1795 base::StatisticsDeltaReader statistics_delta_reader; 1795 base::HistogramTester histogram_tester;
1796
1796 data.RunFor(1); 1797 data.RunFor(1);
1797 scoped_ptr<base::HistogramSamples> samples(
1798 statistics_delta_reader.GetHistogramSamplesSinceCreation(
1799 "Net.SpdySynStreamCompressionPercentage"));
1800
1801 // Regression test of compression performance under the request fixture. 1798 // Regression test of compression performance under the request fixture.
1802 switch (spdy_util_.spdy_version()) { 1799 switch (spdy_util_.spdy_version()) {
1803 case SPDY2: 1800 case SPDY2:
1804 EXPECT_EQ(samples->GetCount(0), 1); 1801 histogram_tester.ExpectBucketCount(
1802 "Net.SpdySynStreamCompressionPercentage", 0, 1);
1805 break; 1803 break;
1806 case SPDY3: 1804 case SPDY3:
1807 EXPECT_EQ(samples->GetCount(30), 1); 1805 histogram_tester.ExpectBucketCount(
1806 "Net.SpdySynStreamCompressionPercentage", 30, 1);
1808 break; 1807 break;
1809 case SPDY4: 1808 case SPDY4:
1810 EXPECT_EQ(samples->GetCount(82), 1); 1809 histogram_tester.ExpectBucketCount(
1810 "Net.SpdySynStreamCompressionPercentage", 82, 1);
1811 break; 1811 break;
1812 case SPDY5: 1812 case SPDY5:
1813 EXPECT_EQ(samples->GetCount(82), 1); 1813 histogram_tester.ExpectBucketCount(
1814 "Net.SpdySynStreamCompressionPercentage", 82, 1);
1814 break; 1815 break;
1815 default: 1816 default:
1816 NOTREACHED(); 1817 NOTREACHED();
1817 } 1818 }
1818 1819
1819 // Read and process EOF. 1820 // Read and process EOF.
1820 data.RunFor(1); 1821 data.RunFor(1);
1821 base::MessageLoop::current()->RunUntilIdle(); 1822 base::MessageLoop::current()->RunUntilIdle();
1822 EXPECT_TRUE(session == NULL); 1823 EXPECT_TRUE(session == NULL);
1823 } 1824 }
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5099 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5100 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5100 "spdy_pooling.pem"); 5101 "spdy_pooling.pem");
5101 ssl_info.is_issued_by_known_root = true; 5102 ssl_info.is_issued_by_known_root = true;
5102 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5103 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5103 5104
5104 EXPECT_TRUE(SpdySession::CanPool( 5105 EXPECT_TRUE(SpdySession::CanPool(
5105 &tss, ssl_info, "www.example.org", "mail.example.org")); 5106 &tss, ssl_info, "www.example.org", "mail.example.org"));
5106 } 5107 }
5107 5108
5108 } // namespace net 5109 } // namespace net
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.cc ('k') | net/url_request/url_request_throttler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698