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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "sync/protocol/sync.pb.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace syncer { | 15 namespace syncer { |
15 namespace { | 16 namespace { |
16 | 17 |
17 class ModelTypeTest : public testing::Test {}; | 18 class ModelTypeTest : public testing::Test {}; |
18 | 19 |
19 TEST_F(ModelTypeTest, ModelTypeToValue) { | 20 TEST_F(ModelTypeTest, ModelTypeToValue) { |
20 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 21 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
21 ModelType model_type = ModelTypeFromInt(i); | 22 ModelType model_type = ModelTypeFromInt(i); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 syncer::ModelTypeSet two(BOOKMARKS, TYPED_URLS); | 111 syncer::ModelTypeSet two(BOOKMARKS, TYPED_URLS); |
111 | 112 |
112 EXPECT_TRUE( | 113 EXPECT_TRUE( |
113 empty.Equals(ModelTypeSetFromString(ModelTypeSetToString(empty)))); | 114 empty.Equals(ModelTypeSetFromString(ModelTypeSetToString(empty)))); |
114 EXPECT_TRUE( | 115 EXPECT_TRUE( |
115 one.Equals(ModelTypeSetFromString(ModelTypeSetToString(one)))); | 116 one.Equals(ModelTypeSetFromString(ModelTypeSetToString(one)))); |
116 EXPECT_TRUE( | 117 EXPECT_TRUE( |
117 two.Equals(ModelTypeSetFromString(ModelTypeSetToString(two)))); | 118 two.Equals(ModelTypeSetFromString(ModelTypeSetToString(two)))); |
118 } | 119 } |
119 | 120 |
| 121 TEST_F(ModelTypeTest, DefaultFieldValues) { |
| 122 syncer::ModelTypeSet types = syncer::ProtocolTypes(); |
| 123 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { |
| 124 SCOPED_TRACE(ModelTypeToString(it.Get())); |
| 125 |
| 126 sync_pb::EntitySpecifics specifics; |
| 127 syncer::AddDefaultFieldValue(it.Get(), &specifics); |
| 128 EXPECT_TRUE(specifics.IsInitialized()); |
| 129 |
| 130 std::string tmp; |
| 131 EXPECT_TRUE(specifics.SerializeToString(&tmp)); |
| 132 |
| 133 sync_pb::EntitySpecifics from_string; |
| 134 EXPECT_TRUE(from_string.ParseFromString(tmp)); |
| 135 EXPECT_TRUE(from_string.IsInitialized()); |
| 136 |
| 137 EXPECT_EQ(it.Get(), syncer::GetModelTypeFromSpecifics(from_string)); |
| 138 } |
| 139 } |
| 140 |
120 } // namespace | 141 } // namespace |
121 } // namespace syncer | 142 } // namespace syncer |
OLD | NEW |