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

Side by Side Diff: webrtc/system_wrappers/source/metrics_unittest.cc

Issue 2268323002: Use swap instead of copy in RtcHistogram::GetAndReset. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove Reset change Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 EXPECT_EQ(1, metrics::NumEvents(kName, kSample)); 51 EXPECT_EQ(1, metrics::NumEvents(kName, kSample));
52 } 52 }
53 53
54 TEST_F(MetricsTest, RtcHistogramEnumeration_AddSample) { 54 TEST_F(MetricsTest, RtcHistogramEnumeration_AddSample) {
55 const std::string kName = "Enumeration"; 55 const std::string kName = "Enumeration";
56 RTC_HISTOGRAM_ENUMERATION(kName, kSample, kSample + 1); 56 RTC_HISTOGRAM_ENUMERATION(kName, kSample, kSample + 1);
57 EXPECT_EQ(1, metrics::NumSamples(kName)); 57 EXPECT_EQ(1, metrics::NumSamples(kName));
58 EXPECT_EQ(1, metrics::NumEvents(kName, kSample)); 58 EXPECT_EQ(1, metrics::NumEvents(kName, kSample));
59 } 59 }
60 60
61 TEST_F(MetricsTest, RtcHistogramBoolean_AddSample) {
62 const std::string kName = "Boolean";
63 const int kSample = 0;
64 RTC_HISTOGRAM_BOOLEAN(kName, kSample);
65 EXPECT_EQ(1, metrics::NumSamples(kName));
66 EXPECT_EQ(1, metrics::NumEvents(kName, kSample));
67 }
68
61 TEST_F(MetricsTest, RtcHistogramCountsSparse_AddSample) { 69 TEST_F(MetricsTest, RtcHistogramCountsSparse_AddSample) {
62 const std::string kName = "CountsSparse100"; 70 const std::string kName = "CountsSparse100";
63 RTC_HISTOGRAM_COUNTS_SPARSE_100(kName, kSample); 71 RTC_HISTOGRAM_COUNTS_SPARSE_100(kName, kSample);
64 EXPECT_EQ(1, metrics::NumSamples(kName)); 72 EXPECT_EQ(1, metrics::NumSamples(kName));
65 EXPECT_EQ(1, metrics::NumEvents(kName, kSample)); 73 EXPECT_EQ(1, metrics::NumEvents(kName, kSample));
66 } 74 }
67 75
68 TEST_F(MetricsTest, RtcHistogramCounts_AddSample) { 76 TEST_F(MetricsTest, RtcHistogramCounts_AddSample) {
69 const std::string kName = "Counts100"; 77 const std::string kName = "Counts100";
70 RTC_HISTOGRAM_COUNTS_100(kName, kSample); 78 RTC_HISTOGRAM_COUNTS_100(kName, kSample);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 118 }
111 119
112 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 120 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
113 TEST_F(MetricsTest, RtcHistogram_FailsForNonConstantName) { 121 TEST_F(MetricsTest, RtcHistogram_FailsForNonConstantName) {
114 AddSample("ConstantName1", kSample); 122 AddSample("ConstantName1", kSample);
115 EXPECT_DEATH(AddSample("NotConstantName1", kSample), ""); 123 EXPECT_DEATH(AddSample("NotConstantName1", kSample), "");
116 } 124 }
117 #endif 125 #endif
118 126
119 } // namespace webrtc 127 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698