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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « components/sync/syncable/model_type.cc ('k') | components/sync/syncable/mutable_entry.h » ('j') | 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 <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"
11 #include "sync/internal_api/public/base/model_type.h" 11 #include "components/sync/base/model_type.h"
12 #include "sync/protocol/sync.pb.h" 12 #include "components/sync/protocol/sync.pb.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace syncer { 15 namespace syncer {
16 namespace { 16 namespace {
17 17
18 class ModelTypeTest : public testing::Test {}; 18 class ModelTypeTest : public testing::Test {};
19 19
20 TEST_F(ModelTypeTest, ModelTypeToValue) { 20 TEST_F(ModelTypeTest, ModelTypeToValue) {
21 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) {
22 ModelType model_type = ModelTypeFromInt(i); 22 ModelType model_type = ModelTypeFromInt(i);
23 base::ExpectStringValue(ModelTypeToString(model_type), 23 base::ExpectStringValue(ModelTypeToString(model_type),
24 ModelTypeToValue(model_type)); 24 ModelTypeToValue(model_type));
25 } 25 }
26 base::ExpectStringValue("Top-level folder", 26 base::ExpectStringValue("Top-level folder",
27 ModelTypeToValue(TOP_LEVEL_FOLDER)); 27 ModelTypeToValue(TOP_LEVEL_FOLDER));
28 base::ExpectStringValue("Unspecified", 28 base::ExpectStringValue("Unspecified", ModelTypeToValue(UNSPECIFIED));
29 ModelTypeToValue(UNSPECIFIED));
30 } 29 }
31 30
32 TEST_F(ModelTypeTest, ModelTypeFromValue) { 31 TEST_F(ModelTypeTest, ModelTypeFromValue) {
33 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 32 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
34 ModelType model_type = ModelTypeFromInt(i); 33 ModelType model_type = ModelTypeFromInt(i);
35 std::unique_ptr<base::StringValue> value(ModelTypeToValue(model_type)); 34 std::unique_ptr<base::StringValue> value(ModelTypeToValue(model_type));
36 EXPECT_EQ(model_type, ModelTypeFromValue(*value)); 35 EXPECT_EQ(model_type, ModelTypeFromValue(*value));
37 } 36 }
38 } 37 }
39 38
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 EXPECT_TRUE(IsProxyType(PROXY_TABS)); 77 EXPECT_TRUE(IsProxyType(PROXY_TABS));
79 } 78 }
80 79
81 // Make sure we can convert ModelTypes to and from specifics field 80 // Make sure we can convert ModelTypes to and from specifics field
82 // numbers. 81 // numbers.
83 TEST_F(ModelTypeTest, ModelTypeToFromSpecificsFieldNumber) { 82 TEST_F(ModelTypeTest, ModelTypeToFromSpecificsFieldNumber) {
84 ModelTypeSet protocol_types = ProtocolTypes(); 83 ModelTypeSet protocol_types = ProtocolTypes();
85 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good(); 84 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
86 iter.Inc()) { 85 iter.Inc()) {
87 int field_number = GetSpecificsFieldNumberFromModelType(iter.Get()); 86 int field_number = GetSpecificsFieldNumberFromModelType(iter.Get());
88 EXPECT_EQ(iter.Get(), 87 EXPECT_EQ(iter.Get(), GetModelTypeFromSpecificsFieldNumber(field_number));
89 GetModelTypeFromSpecificsFieldNumber(field_number));
90 } 88 }
91 } 89 }
92 90
93 TEST_F(ModelTypeTest, ModelTypeOfInvalidSpecificsFieldNumber) { 91 TEST_F(ModelTypeTest, ModelTypeOfInvalidSpecificsFieldNumber) {
94 EXPECT_EQ(UNSPECIFIED, GetModelTypeFromSpecificsFieldNumber(0)); 92 EXPECT_EQ(UNSPECIFIED, GetModelTypeFromSpecificsFieldNumber(0));
95 } 93 }
96 94
97 TEST_F(ModelTypeTest, ModelTypeHistogramMapping) { 95 TEST_F(ModelTypeTest, ModelTypeHistogramMapping) {
98 std::set<int> histogram_values; 96 std::set<int> histogram_values;
99 ModelTypeSet all_types = ModelTypeSet::All(); 97 ModelTypeSet all_types = ModelTypeSet::All();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 EXPECT_EQ(notified_model_type, model_type); 182 EXPECT_EQ(notified_model_type, model_type);
185 } else { 183 } else {
186 EXPECT_FALSE(ProtocolTypes().Has(model_type)); 184 EXPECT_FALSE(ProtocolTypes().Has(model_type));
187 EXPECT_TRUE(notification_type.empty()); 185 EXPECT_TRUE(notification_type.empty());
188 } 186 }
189 } 187 }
190 } 188 }
191 189
192 } // namespace 190 } // namespace
193 } // namespace syncer 191 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/model_type.cc ('k') | components/sync/syncable/mutable_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698