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

Unified Diff: base/metrics/histogram_macros_unittest.cc

Issue 2776853002: Make UMA_HISTOGRAM_ENUMERATION work with scoped enums. (Closed)
Patch Set: rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/metrics/histogram_macros_unittest.cc
diff --git a/base/metrics/histogram_macros_unittest.cc b/base/metrics/histogram_macros_unittest.cc
index c5991619a0f179fb17b04a0533933c4994268581..33a9c6e5b2e3557033c01c2437eb78e1a76c2687 100644
--- a/base/metrics/histogram_macros_unittest.cc
+++ b/base/metrics/histogram_macros_unittest.cc
@@ -15,4 +15,35 @@ TEST(ScopedHistogramTimer, TwoTimersOneScope) {
SCOPED_UMA_HISTOGRAM_LONG_TIMER("TestLongTimer1");
}
+// Compile tests for UMA_HISTOGRAM_ENUMERATION with the three different types it
+// accepts:
+// - integral types
+// - unscoped enums
+// - scoped enums
+TEST(HistogramMacro, IntegralPsuedoEnumeration) {
+ UMA_HISTOGRAM_ENUMERATION("Test.FauxEnumeration", 1, 10000);
+}
+
+TEST(HistogramMacro, UnscopedEnumeration) {
+ enum TestEnum : char {
+ FIRST_VALUE,
+ SECOND_VALUE,
+ THIRD_VALUE,
+ MAX_ENTRIES,
+ };
+ UMA_HISTOGRAM_ENUMERATION("Test.UnscopedEnumeration", SECOND_VALUE,
+ MAX_ENTRIES);
+}
+
+TEST(HistogramMacro, ScopedEnumeration) {
+ enum class TestEnum {
+ FIRST_VALUE,
+ SECOND_VALUE,
+ THIRD_VALUE,
+ MAX_ENTRIES,
+ };
+ UMA_HISTOGRAM_ENUMERATION("Test.ScopedEnumeration", TestEnum::SECOND_VALUE,
+ TestEnum::MAX_ENTRIES);
+}
+
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698