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

Side by Side Diff: components/sync/protocol/proto_enum_conversions_unittest.cc

Issue 2374223003: Sync MDP: reimplement value conversions ontop of visitors
Patch Set: Created 4 years, 2 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
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 // Keep this file in sync with the .proto files in this directory. 5 // Keep this file in sync with the .proto files in this directory.
6 6
7 #include "components/sync/protocol/proto_enum_conversions.h" 7 #include "components/sync/protocol/proto_enum_conversions.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace syncer { 13 namespace syncer {
14 namespace { 14 namespace {
15 15
16 class ProtoEnumConversionsTest : public testing::Test {}; 16 class ProtoEnumConversionsTest : public testing::Test {};
17 17
18 template <class T> 18 template <class T>
19 void TestEnumStringFunction(const char* (*enum_string_fn)(T), 19 void TestEnumStringFunction(T enum_min, T enum_max) {
20 int enum_min,
21 int enum_max) {
22 for (int i = enum_min; i <= enum_max; ++i) { 20 for (int i = enum_min; i <= enum_max; ++i) {
23 const std::string& str = enum_string_fn(static_cast<T>(i)); 21 const std::string& str = ProtoEnumToString(static_cast<T>(i));
24 EXPECT_FALSE(str.empty()); 22 EXPECT_FALSE(str.empty());
25 } 23 }
26 } 24 }
27 25
28 TEST_F(ProtoEnumConversionsTest, GetAppListItemTypeString) { 26 TEST_F(ProtoEnumConversionsTest, GetAppListItemTypeString) {
29 TestEnumStringFunction(GetAppListItemTypeString, 27 TestEnumStringFunction(sync_pb::AppListSpecifics::AppListItemType_MIN,
30 sync_pb::AppListSpecifics::AppListItemType_MIN,
31 sync_pb::AppListSpecifics::AppListItemType_MAX); 28 sync_pb::AppListSpecifics::AppListItemType_MAX);
32 } 29 }
33 30
34 TEST_F(ProtoEnumConversionsTest, GetBrowserTypeString) { 31 TEST_F(ProtoEnumConversionsTest, GetBrowserTypeString) {
35 TestEnumStringFunction(GetBrowserTypeString, 32 TestEnumStringFunction(sync_pb::SessionWindow::BrowserType_MIN,
36 sync_pb::SessionWindow::BrowserType_MIN,
37 sync_pb::SessionWindow::BrowserType_MAX); 33 sync_pb::SessionWindow::BrowserType_MAX);
38 } 34 }
39 35
40 TEST_F(ProtoEnumConversionsTest, GetPageTransitionString) { 36 TEST_F(ProtoEnumConversionsTest, GetPageTransitionString) {
41 TestEnumStringFunction(GetPageTransitionString, 37 TestEnumStringFunction(sync_pb::SyncEnums::PageTransition_MIN,
42 sync_pb::SyncEnums::PageTransition_MIN,
43 sync_pb::SyncEnums::PageTransition_MAX); 38 sync_pb::SyncEnums::PageTransition_MAX);
44 } 39 }
45 40
46 TEST_F(ProtoEnumConversionsTest, GetPageTransitionQualifierString) { 41 TEST_F(ProtoEnumConversionsTest, GetPageTransitionQualifierString) {
47 TestEnumStringFunction(GetPageTransitionRedirectTypeString, 42 TestEnumStringFunction(sync_pb::SyncEnums::PageTransitionRedirectType_MIN,
48 sync_pb::SyncEnums::PageTransitionRedirectType_MIN,
49 sync_pb::SyncEnums::PageTransitionRedirectType_MAX); 43 sync_pb::SyncEnums::PageTransitionRedirectType_MAX);
50 } 44 }
51 45
52 TEST_F(ProtoEnumConversionsTest, GetWifiCredentialSecurityClassString) { 46 TEST_F(ProtoEnumConversionsTest, GetWifiCredentialSecurityClassString) {
53 TestEnumStringFunction(GetWifiCredentialSecurityClassString, 47 TestEnumStringFunction(sync_pb::WifiCredentialSpecifics::SecurityClass_MIN,
54 sync_pb::WifiCredentialSpecifics::SecurityClass_MIN,
55 sync_pb::WifiCredentialSpecifics::SecurityClass_MAX); 48 sync_pb::WifiCredentialSpecifics::SecurityClass_MAX);
56 } 49 }
57 50
58 TEST_F(ProtoEnumConversionsTest, GetUpdatesSourceString) { 51 TEST_F(ProtoEnumConversionsTest, GetUpdatesSourceString) {
59 TestEnumStringFunction(GetUpdatesSourceString, 52 TestEnumStringFunction(sync_pb::GetUpdatesCallerInfo::GetUpdatesSource_MIN,
60 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource_MIN,
61 sync_pb::GetUpdatesCallerInfo::PERIODIC); 53 sync_pb::GetUpdatesCallerInfo::PERIODIC);
62 TestEnumStringFunction(GetUpdatesSourceString, 54 TestEnumStringFunction(sync_pb::GetUpdatesCallerInfo::RETRY,
63 sync_pb::GetUpdatesCallerInfo::RETRY,
64 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource_MAX); 55 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource_MAX);
65 } 56 }
66 57
67 TEST_F(ProtoEnumConversionsTest, GetResponseTypeString) { 58 TEST_F(ProtoEnumConversionsTest, GetResponseTypeString) {
68 TestEnumStringFunction(GetResponseTypeString, 59 TestEnumStringFunction(sync_pb::CommitResponse::ResponseType_MIN,
69 sync_pb::CommitResponse::ResponseType_MIN,
70 sync_pb::CommitResponse::ResponseType_MAX); 60 sync_pb::CommitResponse::ResponseType_MAX);
71 } 61 }
72 62
73 TEST_F(ProtoEnumConversionsTest, GetErrorTypeString) { 63 TEST_F(ProtoEnumConversionsTest, GetErrorTypeString) {
74 // We have a gap, so we need to do two ranges. 64 // We have a gap, so we need to do two ranges.
75 TestEnumStringFunction(GetErrorTypeString, sync_pb::SyncEnums::ErrorType_MIN, 65 TestEnumStringFunction(
76 sync_pb::SyncEnums::MIGRATION_DONE); 66 sync_pb::SyncEnums::ErrorType_MIN,
77 TestEnumStringFunction(GetErrorTypeString, sync_pb::SyncEnums::UNKNOWN, 67 sync_pb::SyncEnums::MIGRATION_DONE);
78 sync_pb::SyncEnums::ErrorType_MAX); 68 TestEnumStringFunction(
69 sync_pb::SyncEnums::UNKNOWN,
70 sync_pb::SyncEnums::ErrorType_MAX);
79 } 71 }
80 72
81 TEST_F(ProtoEnumConversionsTest, GetActionString) { 73 TEST_F(ProtoEnumConversionsTest, GetActionString) {
82 TestEnumStringFunction(GetActionString, sync_pb::SyncEnums::Action_MIN, 74 TestEnumStringFunction(sync_pb::SyncEnums::Action_MIN,
83 sync_pb::SyncEnums::Action_MAX); 75 sync_pb::SyncEnums::Action_MAX);
84 } 76 }
85 77
86 } // namespace 78 } // namespace
87 } // namespace syncer 79 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/protocol/proto_enum_conversions.cc ('k') | components/sync/protocol/proto_old_value_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698