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

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

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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 { 19 namespace syncer_v2 {
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(syncable::GenerateSyncableHash(PREFERENCES, kClientTag)), 34 kClientTagHash(
35 syncer::syncable::GenerateSyncableHash(syncer::PREFERENCES,
36 kClientTag)),
35 kSpecificsHash("somehash"), 37 kSpecificsHash("somehash"),
36 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)), 38 kCtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(10)),
37 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)), 39 kMtime(base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)),
38 entity_(new WorkerEntityTracker(kClientTagHash)) { 40 entity_(new WorkerEntityTracker(kClientTagHash)) {
39 specifics.mutable_preference()->set_name(kClientTag); 41 specifics.mutable_preference()->set_name(kClientTag);
40 specifics.mutable_preference()->set_value("pref.value"); 42 specifics.mutable_preference()->set_value("pref.value");
41 } 43 }
42 44
43 ~WorkerEntityTrackerTest() override {} 45 ~WorkerEntityTrackerTest() override {}
44 46
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 CommitRequestData data = MakeCommitRequestData(kSequenceNumber, kBaseVersion); 98 CommitRequestData data = MakeCommitRequestData(kSequenceNumber, kBaseVersion);
97 entity_->RequestCommit(data); 99 entity_->RequestCommit(data);
98 EXPECT_EQ("", entity_->id()); 100 EXPECT_EQ("", entity_->id());
99 101
100 ASSERT_TRUE(entity_->HasPendingCommit()); 102 ASSERT_TRUE(entity_->HasPendingCommit());
101 sync_pb::SyncEntity pb_entity; 103 sync_pb::SyncEntity pb_entity;
102 entity_->PopulateCommitProto(&pb_entity); 104 entity_->PopulateCommitProto(&pb_entity);
103 EXPECT_EQ("", pb_entity.id_string()); 105 EXPECT_EQ("", pb_entity.id_string());
104 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag()); 106 EXPECT_EQ(kClientTagHash, pb_entity.client_defined_unique_tag());
105 EXPECT_EQ(kBaseVersion, pb_entity.version()); 107 EXPECT_EQ(kBaseVersion, pb_entity.version());
106 EXPECT_EQ(kCtime, ProtoTimeToTime(pb_entity.ctime())); 108 EXPECT_EQ(kCtime, syncer::ProtoTimeToTime(pb_entity.ctime()));
107 EXPECT_EQ(kMtime, ProtoTimeToTime(pb_entity.mtime())); 109 EXPECT_EQ(kMtime, syncer::ProtoTimeToTime(pb_entity.mtime()));
108 EXPECT_FALSE(pb_entity.deleted()); 110 EXPECT_FALSE(pb_entity.deleted());
109 EXPECT_EQ(specifics.preference().name(), 111 EXPECT_EQ(specifics.preference().name(),
110 pb_entity.specifics().preference().name()); 112 pb_entity.specifics().preference().name());
111 EXPECT_EQ(specifics.preference().value(), 113 EXPECT_EQ(specifics.preference().value(),
112 pb_entity.specifics().preference().value()); 114 pb_entity.specifics().preference().value());
113 115
114 CommitResponseData ack; 116 CommitResponseData ack;
115 ack.response_version = kBaseVersion + 1; 117 ack.response_version = kBaseVersion + 1;
116 ack.id = kServerId; 118 ack.id = kServerId;
117 entity_->ReceiveCommitResponse(&ack); 119 entity_->ReceiveCommitResponse(&ack);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ack.response_version = kCommitResponseVersion; 179 ack.response_version = kCommitResponseVersion;
178 ack.id = kServerId; 180 ack.id = kServerId;
179 entity_->ReceiveCommitResponse(&ack); 181 entity_->ReceiveCommitResponse(&ack);
180 182
181 entity_->RequestCommit(MakeCommitRequestData(1, kLocalBaseVersion)); 183 entity_->RequestCommit(MakeCommitRequestData(1, kLocalBaseVersion));
182 sync_pb::SyncEntity pb_entity; 184 sync_pb::SyncEntity pb_entity;
183 entity_->PopulateCommitProto(&pb_entity); 185 entity_->PopulateCommitProto(&pb_entity);
184 EXPECT_EQ(kCommitResponseVersion, pb_entity.version()); 186 EXPECT_EQ(kCommitResponseVersion, pb_entity.version());
185 } 187 }
186 188
187 } // namespace syncer 189 } // namespace syncer_v2
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