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

Side by Side Diff: components/sync/engine_impl/worker_entity_tracker_unittest.cc

Issue 2388163002: [Sync] Move //components/sync to the syncer namespace, take 2. (Closed)
Patch Set: Rebase. Created 4 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 unified diff | Download patch
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 "components/sync/engine_impl/worker_entity_tracker.h" 6 #include "components/sync/engine_impl/worker_entity_tracker.h"
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/sync/base/model_type.h" 13 #include "components/sync/base/model_type.h"
14 #include "components/sync/base/time.h" 14 #include "components/sync/base/time.h"
15 #include "components/sync/core/non_blocking_sync_common.h" 15 #include "components/sync/core/non_blocking_sync_common.h"
16 #include "components/sync/syncable/syncable_util.h" 16 #include "components/sync/syncable/syncable_util.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace syncer_v2 { 19 namespace syncer {
20 20
21 // Some simple tests for the WorkerEntityTracker. 21 // Some simple tests for the WorkerEntityTracker.
22 // 22 //
23 // The WorkerEntityTracker is an implementation detail of the ModelTypeWorker. 23 // The WorkerEntityTracker is an implementation detail of the ModelTypeWorker.
24 // As such, it doesn't make much sense to test it exhaustively, since it 24 // As such, it doesn't make much sense to test it exhaustively, since it
25 // already gets a lot of test coverage from the ModelTypeWorker unit tests. 25 // already gets a lot of test coverage from the ModelTypeWorker unit tests.
26 // 26 //
27 // These tests are intended as a basic sanity check. Anything more complicated 27 // These tests are intended as a basic sanity check. Anything more complicated
28 // would be redundant. 28 // would be redundant.
29 class WorkerEntityTrackerTest : public ::testing::Test { 29 class WorkerEntityTrackerTest : public ::testing::Test {
30 public: 30 public:
31 WorkerEntityTrackerTest() 31 WorkerEntityTrackerTest()
32 : kServerId("ServerID"), 32 : kServerId("ServerID"),
33 kClientTag("some.sample.tag"), 33 kClientTag("some.sample.tag"),
34 kClientTagHash( 34 kClientTagHash(syncable::GenerateSyncableHash(PREFERENCES, kClientTag)),
35 syncer::syncable::GenerateSyncableHash(syncer::PREFERENCES,
36 kClientTag)),
37 kSpecificsHash("somehash"), 35 kSpecificsHash("somehash"),
38 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)), 36 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)),
39 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)), 37 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)),
40 entity_(new WorkerEntityTracker(kClientTagHash)) { 38 entity_(new WorkerEntityTracker(kClientTagHash)) {
41 specifics.mutable_preference()->set_name(kClientTag); 39 specifics.mutable_preference()->set_name(kClientTag);
42 specifics.mutable_preference()->set_value("pref.value"); 40 specifics.mutable_preference()->set_value("pref.value");
43 } 41 }
44 42
45 ~WorkerEntityTrackerTest() override {} 43 ~WorkerEntityTrackerTest() override {}
46 44
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 CommitRequestData data = MakeCommitRequestData(kSequenceNumber, kBaseVersion); 96 CommitRequestData data = MakeCommitRequestData(kSequenceNumber, kBaseVersion);
99 entity_->RequestCommit(data); 97 entity_->RequestCommit(data);
100 EXPECT_EQ("", entity_->id()); 98 EXPECT_EQ("", entity_->id());
101 99
102 ASSERT_TRUE(entity_->HasPendingCommit()); 100 ASSERT_TRUE(entity_->HasPendingCommit());
103 sync_pb::SyncEntity pb_entity; 101 sync_pb::SyncEntity pb_entity;
104 entity_->PopulateCommitProto(&pb_entity); 102 entity_->PopulateCommitProto(&pb_entity);
105 EXPECT_EQ("", pb_entity.id_string()); 103 EXPECT_EQ("", pb_entity.id_string());
106 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag()); 104 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag());
107 EXPECT_EQ(kBaseVersion, pb_entity.version()); 105 EXPECT_EQ(kBaseVersion, pb_entity.version());
108 EXPECT_EQ(kCtime, syncer::ProtoTimeToTime(pb_entity.ctime())); 106 EXPECT_EQ(kCtime, ProtoTimeToTime(pb_entity.ctime()));
109 EXPECT_EQ(kMtime, syncer::ProtoTimeToTime(pb_entity.mtime())); 107 EXPECT_EQ(kMtime, ProtoTimeToTime(pb_entity.mtime()));
110 EXPECT_FALSE(pb_entity.deleted()); 108 EXPECT_FALSE(pb_entity.deleted());
111 EXPECT_EQ(specifics.preference().name(), 109 EXPECT_EQ(specifics.preference().name(),
112 pb_entity.specifics().preference().name()); 110 pb_entity.specifics().preference().name());
113 EXPECT_EQ(specifics.preference().value(), 111 EXPECT_EQ(specifics.preference().value(),
114 pb_entity.specifics().preference().value()); 112 pb_entity.specifics().preference().value());
115 113
116 CommitResponseData ack; 114 CommitResponseData ack;
117 ack.response_version = kBaseVersion + 1; 115 ack.response_version = kBaseVersion + 1;
118 ack.id = kServerId; 116 ack.id = kServerId;
119 entity_->ReceiveCommitResponse(&ack); 117 entity_->ReceiveCommitResponse(&ack);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 ack.response_version = kCommitResponseVersion; 177 ack.response_version = kCommitResponseVersion;
180 ack.id = kServerId; 178 ack.id = kServerId;
181 entity_->ReceiveCommitResponse(&ack); 179 entity_->ReceiveCommitResponse(&ack);
182 180
183 entity_->RequestCommit(MakeCommitRequestData(1, kLocalBaseVersion)); 181 entity_->RequestCommit(MakeCommitRequestData(1, kLocalBaseVersion));
184 sync_pb::SyncEntity pb_entity; 182 sync_pb::SyncEntity pb_entity;
185 entity_->PopulateCommitProto(&pb_entity); 183 entity_->PopulateCommitProto(&pb_entity);
186 EXPECT_EQ(kCommitResponseVersion, pb_entity.version()); 184 EXPECT_EQ(kCommitResponseVersion, pb_entity.version());
187 } 185 }
188 186
189 } // namespace syncer_v2 187 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/worker_entity_tracker.cc ('k') | components/sync/syncable/dir_open_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698