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