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

Side by Side Diff: net/socket_stream/socket_stream_metrics_unittest.cc

Issue 5784005: Properly lock access to static variables.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 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
« no previous file with comments | « chrome/renderer/renderer_main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698