OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 15 #include "base/callback.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/stringprintf.h" |
17 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "chrome/browser/sync/engine/conflict_resolver.h" | 20 #include "chrome/browser/sync/engine/conflict_resolver.h" |
20 #include "chrome/browser/sync/engine/get_commit_ids_command.h" | 21 #include "chrome/browser/sync/engine/get_commit_ids_command.h" |
21 #include "chrome/browser/sync/engine/model_safe_worker.h" | 22 #include "chrome/browser/sync/engine/model_safe_worker.h" |
22 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 23 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
23 #include "chrome/browser/sync/engine/process_updates_command.h" | 24 #include "chrome/browser/sync/engine/process_updates_command.h" |
24 #include "chrome/browser/sync/engine/syncer.h" | 25 #include "chrome/browser/sync/engine/syncer.h" |
25 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 26 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
26 #include "chrome/browser/sync/engine/syncer_util.h" | 27 #include "chrome/browser/sync/engine/syncer_util.h" |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2181 } | 2182 } |
2182 | 2183 |
2183 TEST_F(SyncerTest, CommitManyItemsInOneGo) { | 2184 TEST_F(SyncerTest, CommitManyItemsInOneGo) { |
2184 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); | 2185 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); |
2185 uint32 max_batches = 3; | 2186 uint32 max_batches = 3; |
2186 uint32 items_to_commit = kDefaultMaxCommitBatchSize * max_batches; | 2187 uint32 items_to_commit = kDefaultMaxCommitBatchSize * max_batches; |
2187 CHECK(dir.good()); | 2188 CHECK(dir.good()); |
2188 { | 2189 { |
2189 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); | 2190 WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); |
2190 for (uint32 i = 0; i < items_to_commit; i++) { | 2191 for (uint32 i = 0; i < items_to_commit; i++) { |
2191 string nameutf8 = StringPrintf("%d", i); | 2192 string nameutf8 = base::StringPrintf("%d", i); |
2192 string name(nameutf8.begin(), nameutf8.end()); | 2193 string name(nameutf8.begin(), nameutf8.end()); |
2193 MutableEntry e(&trans, CREATE, trans.root_id(), name); | 2194 MutableEntry e(&trans, CREATE, trans.root_id(), name); |
2194 e.Put(IS_UNSYNCED, true); | 2195 e.Put(IS_UNSYNCED, true); |
2195 e.Put(IS_DIR, true); | 2196 e.Put(IS_DIR, true); |
2196 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); | 2197 e.Put(SPECIFICS, DefaultBookmarkSpecifics()); |
2197 } | 2198 } |
2198 } | 2199 } |
2199 uint32 num_loops = 0; | 2200 uint32 num_loops = 0; |
2200 while (SyncShareAsDelegate()) { | 2201 while (SyncShareAsDelegate()) { |
2201 num_loops++; | 2202 num_loops++; |
(...skipping 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5193 Add(low_id_); | 5194 Add(low_id_); |
5194 Add(high_id_); | 5195 Add(high_id_); |
5195 SyncShareAsDelegate(); | 5196 SyncShareAsDelegate(); |
5196 ExpectLocalOrderIsByServerId(); | 5197 ExpectLocalOrderIsByServerId(); |
5197 } | 5198 } |
5198 | 5199 |
5199 const SyncerTest::CommitOrderingTest | 5200 const SyncerTest::CommitOrderingTest |
5200 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; | 5201 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; |
5201 | 5202 |
5202 } // namespace browser_sync | 5203 } // namespace browser_sync |
OLD | NEW |