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

Unified Diff: sync/syncable/model_type_unittest.cc

Issue 12820010: sync: Define histogram ints for model types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove comment Created 7 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
« no previous file with comments | « sync/syncable/model_type.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/model_type_unittest.cc
diff --git a/sync/syncable/model_type_unittest.cc b/sync/syncable/model_type_unittest.cc
index 9b9f8dda0e7a373b618b0a21979109c05c60eae6..5af6dbcd846326d88e3ea17d57a6c7b138dd1833 100644
--- a/sync/syncable/model_type_unittest.cc
+++ b/sync/syncable/model_type_unittest.cc
@@ -86,5 +86,23 @@ TEST_F(ModelTypeTest, ModelTypeOfInvalidSpecificsFieldNumber) {
EXPECT_EQ(UNSPECIFIED, GetModelTypeFromSpecificsFieldNumber(0));
}
+TEST_F(ModelTypeTest, ModelTypeHistogramMapping) {
+ std::set<int> histogram_values;
+ ModelTypeSet all_types = ModelTypeSet::All();
+ for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
+ SCOPED_TRACE(ModelTypeToString(it.Get()));
+ int histogram_value = ModelTypeToHistogramInt(it.Get());
+
+ EXPECT_TRUE(histogram_values.insert(histogram_value).second)
+ << "Expected histogram values to be unique";
+
+ // This is not necessary for the mapping to be valid, but most instances of
+ // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the
+ // maximum possible value. If you break this assumption, you should update
+ // those histograms.
+ EXPECT_LT(histogram_value, MODEL_TYPE_COUNT);
+ }
+}
+
} // namespace
} // namespace syncer
« no previous file with comments | « sync/syncable/model_type.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698