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

Side by Side Diff: sync/engine/entity_tracker_unittest.cc

Issue 1285443002: move V2 classes in chrome/engine to syncer_v2 namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « sync/engine/entity_tracker.cc ('k') | sync/engine/model_type_entity.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #include "sync/engine/entity_tracker.h" 6 #include "sync/engine/entity_tracker.h"
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "sync/internal_api/public/base/model_type.h" 10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/syncable/syncable_util.h" 11 #include "sync/syncable/syncable_util.h"
12 #include "sync/util/time.h" 12 #include "sync/util/time.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace syncer { 15 namespace syncer_v2 {
16 16
17 // Some simple tests for the EntityTracker. 17 // Some simple tests for the EntityTracker.
18 // 18 //
19 // The EntityTracker is an implementation detail of the ModelTypeSyncWorker. 19 // The EntityTracker is an implementation detail of the ModelTypeSyncWorker.
20 // As such, it doesn't make much sense to test it exhaustively, since it 20 // As such, it doesn't make much sense to test it exhaustively, since it
21 // already gets a lot of test coverage from the ModelTypeSyncWorker unit tests. 21 // already gets a lot of test coverage from the ModelTypeSyncWorker unit tests.
22 // 22 //
23 // These tests are intended as a basic sanity check. Anything more complicated 23 // These tests are intended as a basic sanity check. Anything more complicated
24 // would be redundant. 24 // would be redundant.
25 class EntityTrackerTest : public ::testing::Test { 25 class EntityTrackerTest : public ::testing::Test {
26 public: 26 public:
27 EntityTrackerTest() 27 EntityTrackerTest()
28 : kServerId("ServerID"), 28 : kServerId("ServerID"),
29 kClientTag("some.sample.tag"), 29 kClientTag("some.sample.tag"),
30 kClientTagHash(syncable::GenerateSyncableHash(PREFERENCES, kClientTag)), 30 kClientTagHash(
31 syncer::syncable::GenerateSyncableHash(syncer::PREFERENCES,
32 kClientTag)),
31 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)), 33 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)),
32 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)) { 34 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)) {
33 specifics.mutable_preference()->set_name(kClientTag); 35 specifics.mutable_preference()->set_name(kClientTag);
34 specifics.mutable_preference()->set_value("pref.value"); 36 specifics.mutable_preference()->set_value("pref.value");
35 } 37 }
36 38
37 ~EntityTrackerTest() override {} 39 ~EntityTrackerTest() override {}
38 40
39 const std::string kServerId; 41 const std::string kServerId;
40 const std::string kClientTag; 42 const std::string kClientTag;
(...skipping 27 matching lines...) Expand all
68 specifics)); 70 specifics));
69 71
70 ASSERT_TRUE(entity->IsCommitPending()); 72 ASSERT_TRUE(entity->IsCommitPending());
71 sync_pb::SyncEntity pb_entity; 73 sync_pb::SyncEntity pb_entity;
72 int64 sequence_number = 0; 74 int64 sequence_number = 0;
73 entity->PrepareCommitProto(&pb_entity, &sequence_number); 75 entity->PrepareCommitProto(&pb_entity, &sequence_number);
74 EXPECT_EQ(22, sequence_number); 76 EXPECT_EQ(22, sequence_number);
75 EXPECT_EQ(kServerId, pb_entity.id_string()); 77 EXPECT_EQ(kServerId, pb_entity.id_string());
76 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag()); 78 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag());
77 EXPECT_EQ(33, pb_entity.version()); 79 EXPECT_EQ(33, pb_entity.version());
78 EXPECT_EQ(kCtime, ProtoTimeToTime(pb_entity.ctime())); 80 EXPECT_EQ(kCtime, syncer::ProtoTimeToTime(pb_entity.ctime()));
79 EXPECT_EQ(kMtime, ProtoTimeToTime(pb_entity.mtime())); 81 EXPECT_EQ(kMtime, syncer::ProtoTimeToTime(pb_entity.mtime()));
80 EXPECT_FALSE(pb_entity.deleted()); 82 EXPECT_FALSE(pb_entity.deleted());
81 EXPECT_EQ(specifics.preference().name(), 83 EXPECT_EQ(specifics.preference().name(),
82 pb_entity.specifics().preference().name()); 84 pb_entity.specifics().preference().name());
83 EXPECT_EQ(specifics.preference().value(), 85 EXPECT_EQ(specifics.preference().value(),
84 pb_entity.specifics().preference().value()); 86 pb_entity.specifics().preference().value());
85 } 87 }
86 88
87 // Start with a server initiated entity. Commit over top of it. 89 // Start with a server initiated entity. Commit over top of it.
88 TEST_F(EntityTrackerTest, RequestCommit) { 90 TEST_F(EntityTrackerTest, RequestCommit) {
89 scoped_ptr<EntityTracker> entity( 91 scoped_ptr<EntityTracker> entity(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 false, 156 false,
155 specifics)); 157 specifics));
156 158
157 EXPECT_TRUE(entity->IsCommitPending()); 159 EXPECT_TRUE(entity->IsCommitPending());
158 160
159 entity->ReceiveUpdate(33); // Version 33 == 33. 161 entity->ReceiveUpdate(33); // Version 33 == 33.
160 EXPECT_TRUE(entity->IsCommitPending()); 162 EXPECT_TRUE(entity->IsCommitPending());
161 } 163 }
162 164
163 } // namespace syncer 165 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/entity_tracker.cc ('k') | sync/engine/model_type_entity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698