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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/syncable/model_type.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/internal_api/public/base/model_type.h" 5 #include "sync/internal_api/public/base/model_type.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/values_test_util.h" 10 #include "base/test/values_test_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 int field_number = GetSpecificsFieldNumberFromModelType(iter.Get()); 79 int field_number = GetSpecificsFieldNumberFromModelType(iter.Get());
80 EXPECT_EQ(iter.Get(), 80 EXPECT_EQ(iter.Get(),
81 GetModelTypeFromSpecificsFieldNumber(field_number)); 81 GetModelTypeFromSpecificsFieldNumber(field_number));
82 } 82 }
83 } 83 }
84 84
85 TEST_F(ModelTypeTest, ModelTypeOfInvalidSpecificsFieldNumber) { 85 TEST_F(ModelTypeTest, ModelTypeOfInvalidSpecificsFieldNumber) {
86 EXPECT_EQ(UNSPECIFIED, GetModelTypeFromSpecificsFieldNumber(0)); 86 EXPECT_EQ(UNSPECIFIED, GetModelTypeFromSpecificsFieldNumber(0));
87 } 87 }
88 88
89 TEST_F(ModelTypeTest, ModelTypeHistogramMapping) {
90 std::set<int> histogram_values;
91 ModelTypeSet all_types = ModelTypeSet::All();
92 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
93 SCOPED_TRACE(ModelTypeToString(it.Get()));
94 int histogram_value = ModelTypeToHistogramInt(it.Get());
95
96 EXPECT_TRUE(histogram_values.insert(histogram_value).second)
97 << "Expected histogram values to be unique";
98
99 // This is not necessary for the mapping to be valid, but most instances of
100 // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the
101 // maximum possible value. If you break this assumption, you should update
102 // those histograms.
103 EXPECT_LT(histogram_value, MODEL_TYPE_COUNT);
104 }
105 }
106
89 } // namespace 107 } // namespace
90 } // namespace syncer 108 } // namespace syncer
OLDNEW
« 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