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

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

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed memory leak error in unittest Created 8 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
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Syncer unit tests. Unfortunately a lot of these tests 5 // Syncer unit tests. Unfortunately a lot of these tests
6 // are outdated and need to be reworked and updated. 6 // are outdated and need to be reworked and updated.
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 15 matching lines...) Expand all
26 #include "sync/engine/get_commit_ids_command.h" 26 #include "sync/engine/get_commit_ids_command.h"
27 #include "sync/engine/net/server_connection_manager.h" 27 #include "sync/engine/net/server_connection_manager.h"
28 #include "sync/engine/process_updates_command.h" 28 #include "sync/engine/process_updates_command.h"
29 #include "sync/engine/sync_scheduler_impl.h" 29 #include "sync/engine/sync_scheduler_impl.h"
30 #include "sync/engine/syncer.h" 30 #include "sync/engine/syncer.h"
31 #include "sync/engine/syncer_proto_util.h" 31 #include "sync/engine/syncer_proto_util.h"
32 #include "sync/engine/throttled_data_type_tracker.h" 32 #include "sync/engine/throttled_data_type_tracker.h"
33 #include "sync/engine/traffic_recorder.h" 33 #include "sync/engine/traffic_recorder.h"
34 #include "sync/internal_api/public/base/model_type.h" 34 #include "sync/internal_api/public/base/model_type.h"
35 #include "sync/internal_api/public/engine/model_safe_worker.h" 35 #include "sync/internal_api/public/engine/model_safe_worker.h"
36 #include "sync/internal_api/public/base/node_ordinal.h"
36 #include "sync/protocol/bookmark_specifics.pb.h" 37 #include "sync/protocol/bookmark_specifics.pb.h"
37 #include "sync/protocol/nigori_specifics.pb.h" 38 #include "sync/protocol/nigori_specifics.pb.h"
38 #include "sync/protocol/preference_specifics.pb.h" 39 #include "sync/protocol/preference_specifics.pb.h"
39 #include "sync/protocol/sync.pb.h" 40 #include "sync/protocol/sync.pb.h"
40 #include "sync/sessions/sync_session_context.h" 41 #include "sync/sessions/sync_session_context.h"
41 #include "sync/syncable/mutable_entry.h" 42 #include "sync/syncable/mutable_entry.h"
42 #include "sync/syncable/nigori_util.h" 43 #include "sync/syncable/nigori_util.h"
43 #include "sync/syncable/read_transaction.h" 44 #include "sync/syncable/read_transaction.h"
44 #include "sync/syncable/syncable_util.h" 45 #include "sync/syncable/syncable_util.h"
45 #include "sync/syncable/write_transaction.h" 46 #include "sync/syncable/write_transaction.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 using syncable::IS_UNSYNCED; 90 using syncable::IS_UNSYNCED;
90 using syncable::META_HANDLE; 91 using syncable::META_HANDLE;
91 using syncable::MTIME; 92 using syncable::MTIME;
92 using syncable::NEXT_ID; 93 using syncable::NEXT_ID;
93 using syncable::NON_UNIQUE_NAME; 94 using syncable::NON_UNIQUE_NAME;
94 using syncable::PARENT_ID; 95 using syncable::PARENT_ID;
95 using syncable::PREV_ID; 96 using syncable::PREV_ID;
96 using syncable::BASE_SERVER_SPECIFICS; 97 using syncable::BASE_SERVER_SPECIFICS;
97 using syncable::SERVER_IS_DEL; 98 using syncable::SERVER_IS_DEL;
98 using syncable::SERVER_PARENT_ID; 99 using syncable::SERVER_PARENT_ID;
99 using syncable::SERVER_POSITION_IN_PARENT; 100 using syncable::SERVER_ORDINAL_IN_PARENT;
100 using syncable::SERVER_SPECIFICS; 101 using syncable::SERVER_SPECIFICS;
101 using syncable::SERVER_VERSION; 102 using syncable::SERVER_VERSION;
102 using syncable::UNIQUE_CLIENT_TAG; 103 using syncable::UNIQUE_CLIENT_TAG;
103 using syncable::UNIQUE_SERVER_TAG; 104 using syncable::UNIQUE_SERVER_TAG;
104 using syncable::SPECIFICS; 105 using syncable::SPECIFICS;
105 using syncable::SYNCING; 106 using syncable::SYNCING;
106 using syncable::UNITTEST; 107 using syncable::UNITTEST;
107 108
108 using sessions::ConflictProgress; 109 using sessions::ConflictProgress;
109 using sessions::ScopedSetSessionWriteTransaction; 110 using sessions::ScopedSetSessionWriteTransaction;
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 EXPECT_FALSE(entry.Get(ID).ServerKnows()); 2233 EXPECT_FALSE(entry.Get(ID).ServerKnows());
2233 entry.Put(syncable::IS_DIR, true); 2234 entry.Put(syncable::IS_DIR, true);
2234 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics()); 2235 entry.Put(syncable::SPECIFICS, DefaultBookmarkSpecifics());
2235 entry.Put(syncable::IS_UNSYNCED, true); 2236 entry.Put(syncable::IS_UNSYNCED, true);
2236 entry.Put(syncable::MTIME, test_time); 2237 entry.Put(syncable::MTIME, test_time);
2237 entry_metahandle = entry.Get(META_HANDLE); 2238 entry_metahandle = entry.Get(META_HANDLE);
2238 } 2239 }
2239 SyncShareNudge(); 2240 SyncShareNudge();
2240 syncable::Id id; 2241 syncable::Id id;
2241 int64 version; 2242 int64 version;
2242 int64 server_position_in_parent; 2243 NodeOrdinal server_ordinal_in_parent;
2243 { 2244 {
2244 syncable::ReadTransaction trans(FROM_HERE, directory()); 2245 syncable::ReadTransaction trans(FROM_HERE, directory());
2245 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); 2246 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle);
2246 ASSERT_TRUE(entry.good()); 2247 ASSERT_TRUE(entry.good());
2247 id = entry.Get(ID); 2248 id = entry.Get(ID);
2248 EXPECT_TRUE(id.ServerKnows()); 2249 EXPECT_TRUE(id.ServerKnows());
2249 version = entry.Get(BASE_VERSION); 2250 version = entry.Get(BASE_VERSION);
2250 server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); 2251 server_ordinal_in_parent = entry.Get(SERVER_ORDINAL_IN_PARENT);
2251 } 2252 }
2252 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); 2253 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit();
2253 EXPECT_EQ("Pete", update->name()); 2254 EXPECT_EQ("Pete", update->name());
2254 EXPECT_EQ(id.GetServerId(), update->id_string()); 2255 EXPECT_EQ(id.GetServerId(), update->id_string());
2255 EXPECT_EQ(root_id_.GetServerId(), update->parent_id_string()); 2256 EXPECT_EQ(root_id_.GetServerId(), update->parent_id_string());
2256 EXPECT_EQ(version, update->version()); 2257 EXPECT_EQ(version, update->version());
2257 EXPECT_EQ(server_position_in_parent, update->position_in_parent()); 2258 EXPECT_EQ(
2259 NodeOrdinalToInt64(server_ordinal_in_parent),
2260 update->position_in_parent());
2258 SyncShareNudge(); 2261 SyncShareNudge();
2259 { 2262 {
2260 syncable::ReadTransaction trans(FROM_HERE, directory()); 2263 syncable::ReadTransaction trans(FROM_HERE, directory());
2261 Entry entry(&trans, syncable::GET_BY_ID, id); 2264 Entry entry(&trans, syncable::GET_BY_ID, id);
2262 ASSERT_TRUE(entry.good()); 2265 ASSERT_TRUE(entry.good());
2263 EXPECT_TRUE(entry.Get(MTIME) == test_time); 2266 EXPECT_TRUE(entry.Get(MTIME) == test_time);
2264 } 2267 }
2265 } 2268 }
2266 2269
2267 TEST_F(SyncerTest, ParentAndChildBothMatch) { 2270 TEST_F(SyncerTest, ParentAndChildBothMatch) {
(...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4498 syncable::ReadTransaction trans(FROM_HERE, directory()); 4501 syncable::ReadTransaction trans(FROM_HERE, directory());
4499 4502
4500 Id prev_id; 4503 Id prev_id;
4501 DCHECK(prev_id.IsRoot()); 4504 DCHECK(prev_id.IsRoot());
4502 PosMap::iterator next = position_map_.begin(); 4505 PosMap::iterator next = position_map_.begin();
4503 for (PosMap::iterator i = next++; i != position_map_.end(); ++i) { 4506 for (PosMap::iterator i = next++; i != position_map_.end(); ++i) {
4504 Id id = i->second; 4507 Id id = i->second;
4505 Entry entry_with_id(&trans, GET_BY_ID, id); 4508 Entry entry_with_id(&trans, GET_BY_ID, id);
4506 EXPECT_TRUE(entry_with_id.good()); 4509 EXPECT_TRUE(entry_with_id.good());
4507 EXPECT_EQ(prev_id, entry_with_id.Get(PREV_ID)); 4510 EXPECT_EQ(prev_id, entry_with_id.Get(PREV_ID));
4508 EXPECT_EQ(i->first, entry_with_id.Get(SERVER_POSITION_IN_PARENT)); 4511 EXPECT_EQ(
4512 i->first,
4513 NodeOrdinalToInt64(entry_with_id.Get(SERVER_ORDINAL_IN_PARENT)));
4509 if (next == position_map_.end()) { 4514 if (next == position_map_.end()) {
4510 EXPECT_EQ(Id(), entry_with_id.Get(NEXT_ID)); 4515 EXPECT_EQ(Id(), entry_with_id.Get(NEXT_ID));
4511 } else { 4516 } else {
4512 EXPECT_EQ(next->second, entry_with_id.Get(NEXT_ID)); 4517 EXPECT_EQ(next->second, entry_with_id.Get(NEXT_ID));
4513 next++; 4518 next++;
4514 } 4519 }
4515 prev_id = id; 4520 prev_id = id;
4516 } 4521 }
4517 } 4522 }
4518 4523
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
4692 4697
4693 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) { 4698 TEST_F(SyncerPositionTiebreakingTest, MidLowHigh) {
4694 Add(mid_id_); 4699 Add(mid_id_);
4695 Add(low_id_); 4700 Add(low_id_);
4696 Add(high_id_); 4701 Add(high_id_);
4697 SyncShareNudge(); 4702 SyncShareNudge();
4698 ExpectLocalOrderIsByServerId(); 4703 ExpectLocalOrderIsByServerId();
4699 } 4704 }
4700 4705
4701 } // namespace syncer 4706 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698