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

Side by Side Diff: base/metrics/histogram_macros_unittest.cc

Issue 2776853002: Make UMA_HISTOGRAM_ENUMERATION work with scoped enums. (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/metrics/histogram_macros.h" 5 #include "base/metrics/histogram_macros.h"
6 #include "base/time/time.h" 6 #include "base/time/time.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 10
11 TEST(ScopedHistogramTimer, TwoTimersOneScope) { 11 TEST(ScopedHistogramTimer, TwoTimersOneScope) {
12 SCOPED_UMA_HISTOGRAM_TIMER("TestTimer0"); 12 SCOPED_UMA_HISTOGRAM_TIMER("TestTimer0");
13 SCOPED_UMA_HISTOGRAM_TIMER("TestTimer1"); 13 SCOPED_UMA_HISTOGRAM_TIMER("TestTimer1");
14 SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer0"); 14 SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer0");
15 SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer1"); 15 SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer1");
16 } 16 }
17 17
18 // Compile tests for UMA_HISTOGRAM_ENUMERATION with the three different types it
19 // accepts:
20 // - integral types
21 // - unscoped enums
22 // - scoped enums
23 TEST(HistogramMacro, IntegralPsuedoEnumeration) {
24 UMA_HISTOGRAM_ENUMERATION("Test.FauxEnumeration", 1, 10000);
25 }
26
27 TEST(HistogramMacro, UnscopedEnumeration) {
28 enum TestEnum : char {
29 FIRST_VALUE,
30 SECOND_VALUE,
31 THIRD_VALUE,
32 MAX_ENTRIES,
33 };
34 UMA_HISTOGRAM_ENUMERATION("Test.UnscopedEnumeration", SECOND_VALUE,
35 MAX_ENTRIES);
36 }
37
38 TEST(HistogramMacro, ScopedEnumeration) {
39 enum class TestEnum {
40 FIRST_VALUE,
41 SECOND_VALUE,
42 THIRD_VALUE,
43 MAX_ENTRIES,
44 };
45 UMA_HISTOGRAM_ENUMERATION("Test.ScopedEnumeration", TestEnum::SECOND_VALUE,
46 TestEnum::MAX_ENTRIES);
47 }
48
18 } // namespace base 49 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698