| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/test/values_test_util.h" | 9 #include "base/test/values_test_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 // This is not necessary for the mapping to be valid, but most instances of | 107 // This is not necessary for the mapping to be valid, but most instances of |
| 108 // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the | 108 // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the |
| 109 // maximum possible value. If you break this assumption, you should update | 109 // maximum possible value. If you break this assumption, you should update |
| 110 // those histograms. | 110 // those histograms. |
| 111 EXPECT_LT(histogram_value, MODEL_TYPE_COUNT); | 111 EXPECT_LT(histogram_value, MODEL_TYPE_COUNT); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST_F(ModelTypeTest, ModelTypeSetFromString) { | 115 TEST_F(ModelTypeTest, ModelTypeSetFromString) { |
| 116 syncer::ModelTypeSet empty; | 116 ModelTypeSet empty; |
| 117 syncer::ModelTypeSet one(BOOKMARKS); | 117 ModelTypeSet one(BOOKMARKS); |
| 118 syncer::ModelTypeSet two(BOOKMARKS, TYPED_URLS); | 118 ModelTypeSet two(BOOKMARKS, TYPED_URLS); |
| 119 | 119 |
| 120 EXPECT_EQ(empty, ModelTypeSetFromString(ModelTypeSetToString(empty))); | 120 EXPECT_EQ(empty, ModelTypeSetFromString(ModelTypeSetToString(empty))); |
| 121 EXPECT_EQ(one, ModelTypeSetFromString(ModelTypeSetToString(one))); | 121 EXPECT_EQ(one, ModelTypeSetFromString(ModelTypeSetToString(one))); |
| 122 EXPECT_EQ(two, ModelTypeSetFromString(ModelTypeSetToString(two))); | 122 EXPECT_EQ(two, ModelTypeSetFromString(ModelTypeSetToString(two))); |
| 123 } | 123 } |
| 124 | 124 |
| 125 TEST_F(ModelTypeTest, DefaultFieldValues) { | 125 TEST_F(ModelTypeTest, DefaultFieldValues) { |
| 126 syncer::ModelTypeSet types = syncer::ProtocolTypes(); | 126 ModelTypeSet types = ProtocolTypes(); |
| 127 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { | 127 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { |
| 128 SCOPED_TRACE(ModelTypeToString(it.Get())); | 128 SCOPED_TRACE(ModelTypeToString(it.Get())); |
| 129 | 129 |
| 130 sync_pb::EntitySpecifics specifics; | 130 sync_pb::EntitySpecifics specifics; |
| 131 syncer::AddDefaultFieldValue(it.Get(), &specifics); | 131 AddDefaultFieldValue(it.Get(), &specifics); |
| 132 EXPECT_TRUE(specifics.IsInitialized()); | 132 EXPECT_TRUE(specifics.IsInitialized()); |
| 133 | 133 |
| 134 std::string tmp; | 134 std::string tmp; |
| 135 EXPECT_TRUE(specifics.SerializeToString(&tmp)); | 135 EXPECT_TRUE(specifics.SerializeToString(&tmp)); |
| 136 | 136 |
| 137 sync_pb::EntitySpecifics from_string; | 137 sync_pb::EntitySpecifics from_string; |
| 138 EXPECT_TRUE(from_string.ParseFromString(tmp)); | 138 EXPECT_TRUE(from_string.ParseFromString(tmp)); |
| 139 EXPECT_TRUE(from_string.IsInitialized()); | 139 EXPECT_TRUE(from_string.IsInitialized()); |
| 140 | 140 |
| 141 EXPECT_EQ(it.Get(), syncer::GetModelTypeFromSpecifics(from_string)); | 141 EXPECT_EQ(it.Get(), GetModelTypeFromSpecifics(from_string)); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(ModelTypeTest, ModelTypeToRootTagValues) { | 145 TEST_F(ModelTypeTest, ModelTypeToRootTagValues) { |
| 146 ModelTypeSet all_types = ModelTypeSet::All(); | 146 ModelTypeSet all_types = ModelTypeSet::All(); |
| 147 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) { | 147 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) { |
| 148 ModelType model_type = it.Get(); | 148 ModelType model_type = it.Get(); |
| 149 std::string root_tag = ModelTypeToRootTag(model_type); | 149 std::string root_tag = ModelTypeToRootTag(model_type); |
| 150 if (IsProxyType(model_type)) { | 150 if (IsProxyType(model_type)) { |
| 151 EXPECT_EQ(root_tag, std::string()); | 151 EXPECT_EQ(root_tag, std::string()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_EQ(notified_model_type, model_type); | 184 EXPECT_EQ(notified_model_type, model_type); |
| 185 } else { | 185 } else { |
| 186 EXPECT_FALSE(ProtocolTypes().Has(model_type)); | 186 EXPECT_FALSE(ProtocolTypes().Has(model_type)); |
| 187 EXPECT_TRUE(notification_type.empty()); | 187 EXPECT_TRUE(notification_type.empty()); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace | 192 } // namespace |
| 193 } // namespace syncer | 193 } // namespace syncer |
| OLD | NEW |