• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "base/metrics/histogram_macros.h"
6 #include "base/time/time.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace base {
10 
TEST(ScopedHistogramTimer,TwoTimersOneScope)11 TEST(ScopedHistogramTimer, TwoTimersOneScope) {
12   SCOPED_UMA_HISTOGRAM_TIMER("TestTimer0");
13   SCOPED_UMA_HISTOGRAM_TIMER("TestTimer1");
14   SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer0");
15   SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer1");
16 }
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
TEST(HistogramMacro,IntegralPsuedoEnumeration)23 TEST(HistogramMacro, IntegralPsuedoEnumeration) {
24   UMA_HISTOGRAM_ENUMERATION("Test.FauxEnumeration", 1, 10000);
25 }
26 
TEST(HistogramMacro,UnscopedEnumeration)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 
TEST(HistogramMacro,ScopedEnumeration)38 TEST(HistogramMacro, ScopedEnumeration) {
39   enum class TestEnum {
40     FIRST_VALUE,
41     SECOND_VALUE,
42     THIRD_VALUE,
43     kMaxValue = THIRD_VALUE,
44   };
45   UMA_HISTOGRAM_ENUMERATION("Test.ScopedEnumeration", TestEnum::FIRST_VALUE);
46 
47   enum class TestEnum2 {
48     FIRST_VALUE,
49     SECOND_VALUE,
50     THIRD_VALUE,
51     MAX_ENTRIES,
52   };
53   UMA_HISTOGRAM_ENUMERATION("Test.ScopedEnumeration2", TestEnum2::SECOND_VALUE,
54                             TestEnum2::MAX_ENTRIES);
55 }
56 
57 }  // namespace base
58