OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "net/socket_stream/socket_stream_metrics.h" | 8 #include "net/socket_stream/socket_stream_metrics.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
11 | 11 |
12 using base::Histogram; | 12 using base::Histogram; |
13 using base::StatisticsRecorder; | 13 using base::StatisticsRecorder; |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 TEST(SocketStreamMetricsTest, Initialize) { | 17 TEST(SocketStreamMetricsTest, Initialize) { |
18 if (!StatisticsRecorder::WasStarted()) { | 18 if (!StatisticsRecorder::IsActive()) { |
19 // Create the recorder if not yet started, as SocketStreamMetrics | 19 // Create the recorder if not yet started, as SocketStreamMetrics |
20 // relys on the StatisticsRecorder to be present. This is useful when | 20 // relys on the StatisticsRecorder to be present. This is useful when |
21 // tests are run with --gtest_filter='SocketStreamMetricsTest*'. | 21 // tests are run with --gtest_filter='SocketStreamMetricsTest*'. |
22 static StatisticsRecorder *recorder = NULL; | 22 static StatisticsRecorder *recorder = NULL; |
23 recorder = new StatisticsRecorder; | 23 recorder = new StatisticsRecorder; |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 TEST(SocketStreamMetricsTest, ProtocolType) { | 27 TEST(SocketStreamMetricsTest, ProtocolType) { |
28 scoped_refptr<Histogram> histogram; | 28 scoped_refptr<Histogram> histogram; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 // SentCounts. | 176 // SentCounts. |
177 ASSERT_TRUE(StatisticsRecorder::FindHistogram( | 177 ASSERT_TRUE(StatisticsRecorder::FindHistogram( |
178 "Net.SocketStream.SentCounts", &histogram)); | 178 "Net.SocketStream.SentCounts", &histogram)); |
179 EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags()); | 179 EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags()); |
180 histogram->SnapshotSample(&sample); | 180 histogram->SnapshotSample(&sample); |
181 EXPECT_EQ(3, sample.sum() - original_sent_counts); // 3 write requests. | 181 EXPECT_EQ(3, sample.sum() - original_sent_counts); // 3 write requests. |
182 } | 182 } |
183 | 183 |
184 } // namespace net | 184 } // namespace net |
OLD | NEW |