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

Side by Side 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: ModelType::BOOKMARKS -> syncer::BOOKMARKS 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 unified diff | Download patch
« no previous file with comments | « no previous file | sync/sync_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "sync/api/sync_data.h"
6
7 #include <string>
8
9 #include "base/time/time.h"
10 #include "sync/internal_api/public/base_node.h"
Nicolas Zea 2014/02/21 19:12:00 is this needed?
maniscalco 2014/02/21 19:23:06 Nope, left over from a previous revision where I n
11 #include "sync/protocol/sync.pb.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 using std::string;
15 using syncer::ModelType;
16
17 namespace syncer {
18
19 namespace {
20
21 const string kSyncTag = "3984729834";
22 const ModelType kDatatype = syncer::BOOKMARKS;
Nicolas Zea 2014/02/21 19:12:00 nit: given that bookmarks is the only type that fu
maniscalco 2014/02/21 19:23:06 Heh, good point. Switched to PREFERENCES.
23 const string kNonUniqueTitle = "my bookmark";
24 const int64 kId = 439829;
25 const base::Time kLastModifiedTime = base::Time();
26
27 typedef testing::Test SyncDataTest;
28
29 TEST_F(SyncDataTest, NoArgCtor) {
30 SyncData data;
31 EXPECT_FALSE(data.IsValid());
32 }
33
34 TEST_F(SyncDataTest, CreateLocalDelete) {
35 SyncData data = SyncData::CreateLocalDelete(kSyncTag, kDatatype);
36 EXPECT_TRUE(data.IsValid());
37 EXPECT_TRUE(data.IsLocal());
38 EXPECT_EQ(kSyncTag, data.GetTag());
39 EXPECT_EQ(kDatatype, data.GetDataType());
40 }
41
42 TEST_F(SyncDataTest, CreateLocalData) {
43 sync_pb::EntitySpecifics specifics;
44 specifics.mutable_bookmark();
45 SyncData data =
46 SyncData::CreateLocalData(kSyncTag, kNonUniqueTitle, specifics);
47 EXPECT_TRUE(data.IsValid());
48 EXPECT_TRUE(data.IsLocal());
49 EXPECT_EQ(kSyncTag, data.GetTag());
50 EXPECT_EQ(kDatatype, data.GetDataType());
51 EXPECT_EQ(kNonUniqueTitle, data.GetTitle());
52 EXPECT_TRUE(data.GetSpecifics().has_bookmark());
53 }
54
55 TEST_F(SyncDataTest, CreateRemoteData) {
56 sync_pb::EntitySpecifics specifics;
57 specifics.mutable_bookmark();
58 SyncData data = SyncData::CreateRemoteData(kId, specifics, kLastModifiedTime);
59 EXPECT_TRUE(data.IsValid());
60 EXPECT_FALSE(data.IsLocal());
61 EXPECT_EQ(kId, data.GetRemoteId());
62 EXPECT_EQ(kLastModifiedTime, data.GetRemoteModifiedTime());
63 EXPECT_TRUE(data.GetSpecifics().has_bookmark());
64 }
65
66 } // namespace
67
68 } // namespace syncer
OLDNEW
« 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