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

Unified Diff: sync/api/sync_data_unittest.cc

Issue 174443002: Add some unit tests for SyncData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply CR feedback. Created 6 years, 10 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 | « no previous file | sync/sync_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/sync_data_unittest.cc
diff --git a/sync/api/sync_data_unittest.cc b/sync/api/sync_data_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19d88d43053732bbe6789ea057b5449bf56ee5ed
--- /dev/null
+++ b/sync/api/sync_data_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/api/sync_data.h"
+
+#include <string>
+
+#include "base/time/time.h"
+#include "sync/protocol/sync.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using std::string;
+
+namespace syncer {
+
+namespace {
+
+const string kSyncTag = "3984729834";
+const ModelType kDatatype = syncer::PREFERENCES;
+const string kNonUniqueTitle = "my preference";
+const int64 kId = 439829;
+const base::Time kLastModifiedTime = base::Time();
+
+typedef testing::Test SyncDataTest;
+
+TEST_F(SyncDataTest, NoArgCtor) {
+ SyncData data;
+ EXPECT_FALSE(data.IsValid());
+}
+
+TEST_F(SyncDataTest, CreateLocalDelete) {
+ SyncData data = SyncData::CreateLocalDelete(kSyncTag, kDatatype);
+ EXPECT_TRUE(data.IsValid());
+ EXPECT_TRUE(data.IsLocal());
+ EXPECT_EQ(kSyncTag, data.GetTag());
+ EXPECT_EQ(kDatatype, data.GetDataType());
+}
+
+TEST_F(SyncDataTest, CreateLocalData) {
+ sync_pb::EntitySpecifics specifics;
+ specifics.mutable_preference();
+ SyncData data =
+ SyncData::CreateLocalData(kSyncTag, kNonUniqueTitle, specifics);
+ EXPECT_TRUE(data.IsValid());
+ EXPECT_TRUE(data.IsLocal());
+ EXPECT_EQ(kSyncTag, data.GetTag());
+ EXPECT_EQ(kDatatype, data.GetDataType());
+ EXPECT_EQ(kNonUniqueTitle, data.GetTitle());
+ EXPECT_TRUE(data.GetSpecifics().has_preference());
+}
+
+TEST_F(SyncDataTest, CreateRemoteData) {
+ sync_pb::EntitySpecifics specifics;
+ specifics.mutable_preference();
+ SyncData data = SyncData::CreateRemoteData(kId, specifics, kLastModifiedTime);
+ EXPECT_TRUE(data.IsValid());
+ EXPECT_FALSE(data.IsLocal());
+ EXPECT_EQ(kId, data.GetRemoteId());
+ EXPECT_EQ(kLastModifiedTime, data.GetRemoteModifiedTime());
+ EXPECT_TRUE(data.GetSpecifics().has_preference());
+}
+
+} // namespace
+
+} // namespace syncer
« no previous file with comments | « no previous file | sync/sync_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698