OLD | NEW |
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 Loading... |
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 |
OLD | NEW |