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

Unified Diff: sync/syncable/model_type_unittest.cc

Issue 1413233003: Organizing model type, notification type, root tag and model type string in map. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/syncable/model_type.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/model_type_unittest.cc
diff --git a/sync/syncable/model_type_unittest.cc b/sync/syncable/model_type_unittest.cc
index 05692c009974acd178cd6adaa7b90870e179da41..a60b7cf566e108596103f68fbca50bcc70882e75 100644
--- a/sync/syncable/model_type_unittest.cc
+++ b/sync/syncable/model_type_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_util.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "sync/protocol/sync.pb.h"
@@ -144,5 +145,52 @@ TEST_F(ModelTypeTest, DefaultFieldValues) {
}
}
+TEST_F(ModelTypeTest, ModelTypeToRootTagValues) {
+ ModelTypeSet all_types = ModelTypeSet::All();
+ for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
+ ModelType model_type = it.Get();
+ std::string root_tag = ModelTypeToRootTag(model_type);
+ if (IsProxyType(model_type)) {
+ EXPECT_EQ(root_tag, std::string());
+ } else if (IsRealDataType(model_type)) {
+ EXPECT_TRUE(base::StartsWith(root_tag, "google_chrome_",
+ base::CompareCase::INSENSITIVE_ASCII));
+ } else {
+ EXPECT_EQ(root_tag, "INVALID");
+ }
+ }
+}
+
+TEST_F(ModelTypeTest, ModelTypeStringMapping) {
+ ModelTypeSet all_types = ModelTypeSet::All();
+ for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
+ ModelType model_type = it.Get();
+ const char* model_type_string = ModelTypeToString(model_type);
+ ModelType converted_model_type = ModelTypeFromString(model_type_string);
+ if (IsRealDataType(model_type))
+ EXPECT_EQ(converted_model_type, model_type);
+ else
+ EXPECT_EQ(converted_model_type, UNSPECIFIED);
+ }
+}
+
+TEST_F(ModelTypeTest, ModelTypeNotificationTypeMapping) {
+ ModelTypeSet all_types = ModelTypeSet::All();
+ for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
+ ModelType model_type = it.Get();
+ std::string notification_type;
+ bool ret = RealModelTypeToNotificationType(model_type, &notification_type);
+ if (ret) {
+ ModelType notified_model_type;
+ EXPECT_TRUE(NotificationTypeToRealModelType(notification_type,
+ &notified_model_type));
+ EXPECT_EQ(notified_model_type, model_type);
+ } else {
+ EXPECT_FALSE(ProtocolTypes().Has(model_type));
+ EXPECT_TRUE(notification_type.empty());
+ }
+ }
+}
+
} // namespace
} // namespace syncer
« no previous file with comments | « sync/syncable/model_type.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698