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

Side by Side Diff: sync/syncable/model_type_unittest.cc

Issue 298503002: sync: Enable typed tombstones commits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests for AddDefaultFieldValues Created 6 years, 7 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/protocol/sync.proto ('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"
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
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
OLDNEW
« no previous file with comments | « sync/protocol/sync.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698