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

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

Issue 23809005: sync: Implement per-type GetCommitIds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments + algorithm improvements Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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>
11 #include <map> 11 #include <map>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/location.h" 19 #include "base/location.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "sync/engine/get_commit_ids_command.h" 26 #include "sync/engine/get_commit_ids.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/traffic_recorder.h" 32 #include "sync/engine/traffic_recorder.h"
33 #include "sync/internal_api/public/base/model_type.h" 33 #include "sync/internal_api/public/base/model_type.h"
34 #include "sync/internal_api/public/engine/model_safe_worker.h" 34 #include "sync/internal_api/public/engine/model_safe_worker.h"
35 #include "sync/protocol/bookmark_specifics.pb.h" 35 #include "sync/protocol/bookmark_specifics.pb.h"
36 #include "sync/protocol/nigori_specifics.pb.h" 36 #include "sync/protocol/nigori_specifics.pb.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 void DoTruncationTest(const vector<int64>& unsynced_handle_view, 395 void DoTruncationTest(const vector<int64>& unsynced_handle_view,
396 const vector<int64>& expected_handle_order) { 396 const vector<int64>& expected_handle_order) {
397 for (size_t limit = expected_handle_order.size() + 2; limit > 0; --limit) { 397 for (size_t limit = expected_handle_order.size() + 2; limit > 0; --limit) {
398 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); 398 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
399 399
400 ModelSafeRoutingInfo routes; 400 ModelSafeRoutingInfo routes;
401 GetModelSafeRoutingInfo(&routes); 401 GetModelSafeRoutingInfo(&routes);
402 ModelTypeSet types = GetRoutingInfoTypes(routes); 402 ModelTypeSet types = GetRoutingInfoTypes(routes);
403 sessions::OrderedCommitSet output_set(routes); 403 sessions::OrderedCommitSet output_set(routes);
404 GetCommitIdsCommand command(&wtrans, types, limit, &output_set); 404 GetCommitIds(&wtrans, types, limit, &output_set);
405 std::set<int64> ready_unsynced_set;
406 command.FilterUnreadyEntries(&wtrans, types,
407 ModelTypeSet(), false,
408 unsynced_handle_view, &ready_unsynced_set);
409 command.BuildCommitIds(&wtrans, routes, ready_unsynced_set);
410 size_t truncated_size = std::min(limit, expected_handle_order.size()); 405 size_t truncated_size = std::min(limit, expected_handle_order.size());
411 ASSERT_EQ(truncated_size, output_set.Size()); 406 ASSERT_EQ(truncated_size, output_set.Size());
412 for (size_t i = 0; i < truncated_size; ++i) { 407 for (size_t i = 0; i < truncated_size; ++i) {
413 ASSERT_EQ(expected_handle_order[i], output_set.GetCommitHandleAt(i)) 408 ASSERT_EQ(expected_handle_order[i], output_set.GetCommitHandleAt(i))
414 << "At index " << i << " with batch size limited to " << limit; 409 << "At index " << i << " with batch size limited to " << limit;
415 } 410 }
416 sessions::OrderedCommitSet::Projection proj; 411 sessions::OrderedCommitSet::Projection proj;
417 proj = output_set.GetCommitIdProjection(GROUP_PASSIVE); 412 proj = output_set.GetCommitIdProjection(GROUP_PASSIVE);
418 ASSERT_EQ(truncated_size, proj.size()); 413 ASSERT_EQ(truncated_size, proj.size());
419 for (size_t i = 0; i < truncated_size; ++i) { 414 for (size_t i = 0; i < truncated_size; ++i) {
(...skipping 4386 matching lines...) Expand 10 before | Expand all | Expand 10 after
4806 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); 4801 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id);
4807 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); 4802 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count);
4808 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); 4803 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count);
4809 } else { 4804 } else {
4810 EXPECT_TRUE(final_monitor_records.empty()) 4805 EXPECT_TRUE(final_monitor_records.empty())
4811 << "Should not restore records after successful bookmark commit."; 4806 << "Should not restore records after successful bookmark commit.";
4812 } 4807 }
4813 } 4808 }
4814 4809
4815 } // namespace syncer 4810 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698