OLD | NEW |
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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <algorithm> | 11 #include <algorithm> |
9 #include <limits> | 12 #include <limits> |
10 #include <list> | 13 #include <list> |
11 #include <map> | 14 #include <map> |
12 #include <set> | 15 #include <set> |
13 #include <string> | 16 #include <string> |
14 | 17 |
15 #include "base/bind.h" | 18 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 19 #include "base/bind_helpers.h" |
17 #include "base/callback.h" | 20 #include "base/callback.h" |
18 #include "base/compiler_specific.h" | 21 #include "base/compiler_specific.h" |
19 #include "base/location.h" | 22 #include "base/location.h" |
| 23 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | 24 #include "base/memory/scoped_ptr.h" |
21 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
22 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
23 #include "base/test/histogram_tester.h" | 27 #include "base/test/histogram_tester.h" |
24 #include "base/time/time.h" | 28 #include "base/time/time.h" |
25 #include "build/build_config.h" | 29 #include "build/build_config.h" |
26 #include "sync/engine/backoff_delay_provider.h" | 30 #include "sync/engine/backoff_delay_provider.h" |
27 #include "sync/engine/get_commit_ids.h" | 31 #include "sync/engine/get_commit_ids.h" |
28 #include "sync/engine/net/server_connection_manager.h" | 32 #include "sync/engine/net/server_connection_manager.h" |
29 #include "sync/engine/sync_scheduler_impl.h" | 33 #include "sync/engine/sync_scheduler_impl.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 498 } |
495 | 499 |
496 const std::string local_cache_guid() { | 500 const std::string local_cache_guid() { |
497 return directory()->cache_guid(); | 501 return directory()->cache_guid(); |
498 } | 502 } |
499 | 503 |
500 const std::string foreign_cache_guid() { | 504 const std::string foreign_cache_guid() { |
501 return "kqyg7097kro6GSUod+GSg=="; | 505 return "kqyg7097kro6GSUod+GSg=="; |
502 } | 506 } |
503 | 507 |
504 int64 CreateUnsyncedDirectory(const string& entry_name, | 508 int64_t CreateUnsyncedDirectory(const string& entry_name, |
505 const string& idstring) { | 509 const string& idstring) { |
506 return CreateUnsyncedDirectory(entry_name, | 510 return CreateUnsyncedDirectory(entry_name, |
507 syncable::Id::CreateFromServerId(idstring)); | 511 syncable::Id::CreateFromServerId(idstring)); |
508 } | 512 } |
509 | 513 |
510 int64 CreateUnsyncedDirectory(const string& entry_name, | 514 int64_t CreateUnsyncedDirectory(const string& entry_name, |
511 const syncable::Id& id) { | 515 const syncable::Id& id) { |
512 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 516 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
513 MutableEntry entry( | 517 MutableEntry entry( |
514 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entry_name); | 518 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entry_name); |
515 EXPECT_TRUE(entry.good()); | 519 EXPECT_TRUE(entry.good()); |
516 entry.PutIsUnsynced(true); | 520 entry.PutIsUnsynced(true); |
517 entry.PutIsDir(true); | 521 entry.PutIsDir(true); |
518 entry.PutSpecifics(DefaultBookmarkSpecifics()); | 522 entry.PutSpecifics(DefaultBookmarkSpecifics()); |
519 entry.PutBaseVersion(id.ServerKnows() ? 1 : 0); | 523 entry.PutBaseVersion(id.ServerKnows() ? 1 : 0); |
520 entry.PutId(id); | 524 entry.PutId(id); |
521 return entry.GetMetahandle(); | 525 return entry.GetMetahandle(); |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 wtrans.root_id(), | 1930 wtrans.root_id(), |
1927 parent_name); | 1931 parent_name); |
1928 ASSERT_TRUE(parent.good()); | 1932 ASSERT_TRUE(parent.good()); |
1929 parent.PutIsUnsynced(true); | 1933 parent.PutIsUnsynced(true); |
1930 parent.PutIsDir(true); | 1934 parent.PutIsDir(true); |
1931 parent.PutSpecifics(DefaultBookmarkSpecifics()); | 1935 parent.PutSpecifics(DefaultBookmarkSpecifics()); |
1932 parent.PutId(parent_id_); | 1936 parent.PutId(parent_id_); |
1933 parent.PutBaseVersion(1); | 1937 parent.PutBaseVersion(1); |
1934 } | 1938 } |
1935 | 1939 |
1936 int64 meta_handle_b; | 1940 int64_t meta_handle_b; |
1937 const Id parent2_local_id = ids_.NewLocalId(); | 1941 const Id parent2_local_id = ids_.NewLocalId(); |
1938 const Id child_local_id = ids_.NewLocalId(); | 1942 const Id child_local_id = ids_.NewLocalId(); |
1939 { | 1943 { |
1940 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 1944 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
1941 MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name); | 1945 MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, parent_id_, parent2_name); |
1942 ASSERT_TRUE(parent2.good()); | 1946 ASSERT_TRUE(parent2.good()); |
1943 parent2.PutIsUnsynced(true); | 1947 parent2.PutIsUnsynced(true); |
1944 parent2.PutIsDir(true); | 1948 parent2.PutIsDir(true); |
1945 parent2.PutSpecifics(DefaultBookmarkSpecifics()); | 1949 parent2.PutSpecifics(DefaultBookmarkSpecifics()); |
1946 | 1950 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 mock_server_->AddUpdateDirectory( | 2002 mock_server_->AddUpdateDirectory( |
1999 2, 0, std::string(), 2, 20, foreign_cache_guid(), "-2"); | 2003 2, 0, std::string(), 2, 20, foreign_cache_guid(), "-2"); |
2000 mock_server_->SetLastUpdateDeleted(); | 2004 mock_server_->SetLastUpdateDeleted(); |
2001 EXPECT_TRUE(SyncShareNudge()); | 2005 EXPECT_TRUE(SyncShareNudge()); |
2002 } | 2006 } |
2003 | 2007 |
2004 TEST_F(SyncerTest, TestBasicUpdate) { | 2008 TEST_F(SyncerTest, TestBasicUpdate) { |
2005 string id = "some_id"; | 2009 string id = "some_id"; |
2006 string parent_id = "0"; | 2010 string parent_id = "0"; |
2007 string name = "in_root"; | 2011 string name = "in_root"; |
2008 int64 version = 10; | 2012 int64_t version = 10; |
2009 int64 timestamp = 10; | 2013 int64_t timestamp = 10; |
2010 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp, | 2014 mock_server_->AddUpdateDirectory(id, parent_id, name, version, timestamp, |
2011 foreign_cache_guid(), "-1"); | 2015 foreign_cache_guid(), "-1"); |
2012 | 2016 |
2013 EXPECT_TRUE(SyncShareNudge()); | 2017 EXPECT_TRUE(SyncShareNudge()); |
2014 { | 2018 { |
2015 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2019 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2016 Entry entry(&trans, GET_BY_ID, | 2020 Entry entry(&trans, GET_BY_ID, |
2017 syncable::Id::CreateFromServerId("some_id")); | 2021 syncable::Id::CreateFromServerId("some_id")); |
2018 ASSERT_TRUE(entry.good()); | 2022 ASSERT_TRUE(entry.good()); |
2019 EXPECT_TRUE(entry.GetIsDir()); | 2023 EXPECT_TRUE(entry.GetIsDir()); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 | 2175 |
2172 EXPECT_EQ( | 2176 EXPECT_EQ( |
2173 4, | 2177 4, |
2174 GetUpdateCounters(BOOKMARKS).num_hierarchy_conflict_application_failures); | 2178 GetUpdateCounters(BOOKMARKS).num_hierarchy_conflict_application_failures); |
2175 } | 2179 } |
2176 | 2180 |
2177 // A commit with a lost response produces an update that has to be reunited with | 2181 // A commit with a lost response produces an update that has to be reunited with |
2178 // its parent. | 2182 // its parent. |
2179 TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { | 2183 TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { |
2180 // Create a folder in the root. | 2184 // Create a folder in the root. |
2181 int64 metahandle_folder; | 2185 int64_t metahandle_folder; |
2182 { | 2186 { |
2183 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2187 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2184 MutableEntry entry( | 2188 MutableEntry entry( |
2185 &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder"); | 2189 &trans, CREATE, BOOKMARKS, trans.root_id(), "new_folder"); |
2186 ASSERT_TRUE(entry.good()); | 2190 ASSERT_TRUE(entry.good()); |
2187 entry.PutIsDir(true); | 2191 entry.PutIsDir(true); |
2188 entry.PutSpecifics(DefaultBookmarkSpecifics()); | 2192 entry.PutSpecifics(DefaultBookmarkSpecifics()); |
2189 entry.PutIsUnsynced(true); | 2193 entry.PutIsUnsynced(true); |
2190 metahandle_folder = entry.GetMetahandle(); | 2194 metahandle_folder = entry.GetMetahandle(); |
2191 } | 2195 } |
2192 | 2196 |
2193 // Verify it and pull the ID out of the folder. | 2197 // Verify it and pull the ID out of the folder. |
2194 syncable::Id folder_id; | 2198 syncable::Id folder_id; |
2195 int64 metahandle_entry; | 2199 int64_t metahandle_entry; |
2196 { | 2200 { |
2197 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2201 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2198 Entry entry(&trans, GET_BY_HANDLE, metahandle_folder); | 2202 Entry entry(&trans, GET_BY_HANDLE, metahandle_folder); |
2199 ASSERT_TRUE(entry.good()); | 2203 ASSERT_TRUE(entry.good()); |
2200 folder_id = entry.GetId(); | 2204 folder_id = entry.GetId(); |
2201 ASSERT_TRUE(!folder_id.ServerKnows()); | 2205 ASSERT_TRUE(!folder_id.ServerKnows()); |
2202 } | 2206 } |
2203 | 2207 |
2204 // Create an entry in the newly created folder. | 2208 // Create an entry in the newly created folder. |
2205 { | 2209 { |
(...skipping 11 matching lines...) Expand all Loading... |
2217 Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); | 2221 Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); |
2218 ASSERT_TRUE(entry.good()); | 2222 ASSERT_TRUE(entry.good()); |
2219 EXPECT_EQ(folder_id, entry.GetParentId()); | 2223 EXPECT_EQ(folder_id, entry.GetParentId()); |
2220 EXPECT_EQ("new_entry", entry.GetNonUniqueName()); | 2224 EXPECT_EQ("new_entry", entry.GetNonUniqueName()); |
2221 entry_id = entry.GetId(); | 2225 entry_id = entry.GetId(); |
2222 EXPECT_TRUE(!entry_id.ServerKnows()); | 2226 EXPECT_TRUE(!entry_id.ServerKnows()); |
2223 VerifyTestDataInEntry(&trans, &entry); | 2227 VerifyTestDataInEntry(&trans, &entry); |
2224 } | 2228 } |
2225 | 2229 |
2226 // Now, to emulate a commit response failure, we just don't commit it. | 2230 // Now, to emulate a commit response failure, we just don't commit it. |
2227 int64 new_version = 150; // any larger value. | 2231 int64_t new_version = 150; // any larger value. |
2228 int64 timestamp = 20; // arbitrary value. | 2232 int64_t timestamp = 20; // arbitrary value. |
2229 syncable::Id new_folder_id = | 2233 syncable::Id new_folder_id = |
2230 syncable::Id::CreateFromServerId("folder_server_id"); | 2234 syncable::Id::CreateFromServerId("folder_server_id"); |
2231 | 2235 |
2232 // The following update should cause the folder to both apply the update, as | 2236 // The following update should cause the folder to both apply the update, as |
2233 // well as reassociate the id. | 2237 // well as reassociate the id. |
2234 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, | 2238 mock_server_->AddUpdateDirectory(new_folder_id, root_id_, |
2235 "new_folder", new_version, timestamp, | 2239 "new_folder", new_version, timestamp, |
2236 local_cache_guid(), folder_id.GetServerId()); | 2240 local_cache_guid(), folder_id.GetServerId()); |
2237 | 2241 |
2238 // We don't want it accidentally committed, just the update applied. | 2242 // We don't want it accidentally committed, just the update applied. |
(...skipping 23 matching lines...) Expand all Loading... |
2262 EXPECT_EQ(new_folder_id, entry.GetParentId()); | 2266 EXPECT_EQ(new_folder_id, entry.GetParentId()); |
2263 EXPECT_TRUE(!entry.GetId().ServerKnows()); | 2267 EXPECT_TRUE(!entry.GetId().ServerKnows()); |
2264 VerifyTestDataInEntry(&trans, &entry); | 2268 VerifyTestDataInEntry(&trans, &entry); |
2265 } | 2269 } |
2266 } | 2270 } |
2267 | 2271 |
2268 // A commit with a lost response produces an update that has to be reunited with | 2272 // A commit with a lost response produces an update that has to be reunited with |
2269 // its parent. | 2273 // its parent. |
2270 TEST_F(SyncerTest, CommitReuniteUpdate) { | 2274 TEST_F(SyncerTest, CommitReuniteUpdate) { |
2271 // Create an entry in the root. | 2275 // Create an entry in the root. |
2272 int64 entry_metahandle; | 2276 int64_t entry_metahandle; |
2273 { | 2277 { |
2274 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2278 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2275 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); | 2279 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); |
2276 ASSERT_TRUE(entry.good()); | 2280 ASSERT_TRUE(entry.good()); |
2277 entry_metahandle = entry.GetMetahandle(); | 2281 entry_metahandle = entry.GetMetahandle(); |
2278 WriteTestDataToEntry(&trans, &entry); | 2282 WriteTestDataToEntry(&trans, &entry); |
2279 } | 2283 } |
2280 | 2284 |
2281 // Verify it and pull the ID out. | 2285 // Verify it and pull the ID out. |
2282 syncable::Id entry_id; | 2286 syncable::Id entry_id; |
2283 { | 2287 { |
2284 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2288 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2285 | 2289 |
2286 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 2290 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
2287 ASSERT_TRUE(entry.good()); | 2291 ASSERT_TRUE(entry.good()); |
2288 entry_id = entry.GetId(); | 2292 entry_id = entry.GetId(); |
2289 EXPECT_TRUE(!entry_id.ServerKnows()); | 2293 EXPECT_TRUE(!entry_id.ServerKnows()); |
2290 VerifyTestDataInEntry(&trans, &entry); | 2294 VerifyTestDataInEntry(&trans, &entry); |
2291 } | 2295 } |
2292 | 2296 |
2293 // Now, to emulate a commit response failure, we just don't commit it. | 2297 // Now, to emulate a commit response failure, we just don't commit it. |
2294 int64 new_version = 150; // any larger value. | 2298 int64_t new_version = 150; // any larger value. |
2295 int64 timestamp = 20; // arbitrary value. | 2299 int64_t timestamp = 20; // arbitrary value. |
2296 syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id"); | 2300 syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id"); |
2297 | 2301 |
2298 // Generate an update from the server with a relevant ID reassignment. | 2302 // Generate an update from the server with a relevant ID reassignment. |
2299 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, | 2303 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, |
2300 "new_entry", new_version, timestamp, | 2304 "new_entry", new_version, timestamp, |
2301 local_cache_guid(), entry_id.GetServerId()); | 2305 local_cache_guid(), entry_id.GetServerId()); |
2302 | 2306 |
2303 // We don't want it accidentally committed, just the update applied. | 2307 // We don't want it accidentally committed, just the update applied. |
2304 mock_server_->set_conflict_all_commits(true); | 2308 mock_server_->set_conflict_all_commits(true); |
2305 | 2309 |
2306 // Alright! Apply that update! | 2310 // Alright! Apply that update! |
2307 EXPECT_TRUE(SyncShareNudge()); | 2311 EXPECT_TRUE(SyncShareNudge()); |
2308 { | 2312 { |
2309 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2313 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2310 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 2314 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
2311 ASSERT_TRUE(entry.good()); | 2315 ASSERT_TRUE(entry.good()); |
2312 EXPECT_EQ(new_version, entry.GetBaseVersion()); | 2316 EXPECT_EQ(new_version, entry.GetBaseVersion()); |
2313 EXPECT_EQ(new_entry_id, entry.GetId()); | 2317 EXPECT_EQ(new_entry_id, entry.GetId()); |
2314 EXPECT_EQ("new_entry", entry.GetNonUniqueName()); | 2318 EXPECT_EQ("new_entry", entry.GetNonUniqueName()); |
2315 } | 2319 } |
2316 } | 2320 } |
2317 | 2321 |
2318 // A commit with a lost response must work even if the local entry was deleted | 2322 // A commit with a lost response must work even if the local entry was deleted |
2319 // before the update is applied. We should not duplicate the local entry in | 2323 // before the update is applied. We should not duplicate the local entry in |
2320 // this case, but just create another one alongside. We may wish to examine | 2324 // this case, but just create another one alongside. We may wish to examine |
2321 // this behavior in the future as it can create hanging uploads that never | 2325 // this behavior in the future as it can create hanging uploads that never |
2322 // finish, that must be cleaned up on the server side after some time. | 2326 // finish, that must be cleaned up on the server side after some time. |
2323 TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { | 2327 TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { |
2324 // Create a entry in the root. | 2328 // Create a entry in the root. |
2325 int64 entry_metahandle; | 2329 int64_t entry_metahandle; |
2326 { | 2330 { |
2327 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2331 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2328 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); | 2332 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "new_entry"); |
2329 ASSERT_TRUE(entry.good()); | 2333 ASSERT_TRUE(entry.good()); |
2330 entry_metahandle = entry.GetMetahandle(); | 2334 entry_metahandle = entry.GetMetahandle(); |
2331 WriteTestDataToEntry(&trans, &entry); | 2335 WriteTestDataToEntry(&trans, &entry); |
2332 } | 2336 } |
2333 // Verify it and pull the ID out. | 2337 // Verify it and pull the ID out. |
2334 syncable::Id entry_id; | 2338 syncable::Id entry_id; |
2335 { | 2339 { |
2336 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2340 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2337 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); | 2341 Entry entry(&trans, GET_BY_HANDLE, entry_metahandle); |
2338 ASSERT_TRUE(entry.good()); | 2342 ASSERT_TRUE(entry.good()); |
2339 entry_id = entry.GetId(); | 2343 entry_id = entry.GetId(); |
2340 EXPECT_TRUE(!entry_id.ServerKnows()); | 2344 EXPECT_TRUE(!entry_id.ServerKnows()); |
2341 VerifyTestDataInEntry(&trans, &entry); | 2345 VerifyTestDataInEntry(&trans, &entry); |
2342 } | 2346 } |
2343 | 2347 |
2344 // Now, to emulate a commit response failure, we just don't commit it. | 2348 // Now, to emulate a commit response failure, we just don't commit it. |
2345 int64 new_version = 150; // any larger value. | 2349 int64_t new_version = 150; // any larger value. |
2346 int64 timestamp = 20; // arbitrary value. | 2350 int64_t timestamp = 20; // arbitrary value. |
2347 syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id"); | 2351 syncable::Id new_entry_id = syncable::Id::CreateFromServerId("server_id"); |
2348 | 2352 |
2349 // Generate an update from the server with a relevant ID reassignment. | 2353 // Generate an update from the server with a relevant ID reassignment. |
2350 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, | 2354 mock_server_->AddUpdateBookmark(new_entry_id, root_id_, |
2351 "new_entry", new_version, timestamp, | 2355 "new_entry", new_version, timestamp, |
2352 local_cache_guid(), entry_id.GetServerId()); | 2356 local_cache_guid(), entry_id.GetServerId()); |
2353 | 2357 |
2354 // We don't want it accidentally committed, just the update applied. | 2358 // We don't want it accidentally committed, just the update applied. |
2355 mock_server_->set_conflict_all_commits(true); | 2359 mock_server_->set_conflict_all_commits(true); |
2356 | 2360 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 } | 2538 } |
2535 | 2539 |
2536 TEST_F(SyncerTest, NegativeIDInUpdate) { | 2540 TEST_F(SyncerTest, NegativeIDInUpdate) { |
2537 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40, | 2541 mock_server_->AddUpdateBookmark(-10, 0, "bad", 40, 40, |
2538 foreign_cache_guid(), "-100"); | 2542 foreign_cache_guid(), "-100"); |
2539 EXPECT_TRUE(SyncShareNudge()); | 2543 EXPECT_TRUE(SyncShareNudge()); |
2540 // The negative id would make us CHECK! | 2544 // The negative id would make us CHECK! |
2541 } | 2545 } |
2542 | 2546 |
2543 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { | 2547 TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { |
2544 int64 metahandle_fred; | 2548 int64_t metahandle_fred; |
2545 syncable::Id orig_id; | 2549 syncable::Id orig_id; |
2546 { | 2550 { |
2547 // Create an item. | 2551 // Create an item. |
2548 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2552 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2549 MutableEntry fred_match(&trans, CREATE, BOOKMARKS, trans.root_id(), | 2553 MutableEntry fred_match(&trans, CREATE, BOOKMARKS, trans.root_id(), |
2550 "fred_match"); | 2554 "fred_match"); |
2551 ASSERT_TRUE(fred_match.good()); | 2555 ASSERT_TRUE(fred_match.good()); |
2552 metahandle_fred = fred_match.GetMetahandle(); | 2556 metahandle_fred = fred_match.GetMetahandle(); |
2553 orig_id = fred_match.GetId(); | 2557 orig_id = fred_match.GetId(); |
2554 WriteTestDataToEntry(&trans, &fred_match); | 2558 WriteTestDataToEntry(&trans, &fred_match); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2617 | 2621 |
2618 // Only one entry, since we just overwrite one. | 2622 // Only one entry, since we just overwrite one. |
2619 EXPECT_EQ(1u, children.size()); | 2623 EXPECT_EQ(1u, children.size()); |
2620 } | 2624 } |
2621 | 2625 |
2622 // We got this repro case when someone was editing bookmarks while sync was | 2626 // We got this repro case when someone was editing bookmarks while sync was |
2623 // occuring. The entry had changed out underneath the user. | 2627 // occuring. The entry had changed out underneath the user. |
2624 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { | 2628 TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { |
2625 const base::Time& test_time = ProtoTimeToTime(123456); | 2629 const base::Time& test_time = ProtoTimeToTime(123456); |
2626 syncable::Id local_id; | 2630 syncable::Id local_id; |
2627 int64 entry_metahandle; | 2631 int64_t entry_metahandle; |
2628 { | 2632 { |
2629 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 2633 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
2630 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, root_id_, "Pete"); | 2634 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, root_id_, "Pete"); |
2631 ASSERT_TRUE(entry.good()); | 2635 ASSERT_TRUE(entry.good()); |
2632 EXPECT_FALSE(entry.GetId().ServerKnows()); | 2636 EXPECT_FALSE(entry.GetId().ServerKnows()); |
2633 local_id = entry.GetId(); | 2637 local_id = entry.GetId(); |
2634 entry.PutIsDir(true); | 2638 entry.PutIsDir(true); |
2635 entry.PutSpecifics(DefaultBookmarkSpecifics()); | 2639 entry.PutSpecifics(DefaultBookmarkSpecifics()); |
2636 entry.PutIsUnsynced(true); | 2640 entry.PutIsUnsynced(true); |
2637 entry.PutMtime(test_time); | 2641 entry.PutMtime(test_time); |
2638 entry_metahandle = entry.GetMetahandle(); | 2642 entry_metahandle = entry.GetMetahandle(); |
2639 } | 2643 } |
2640 EXPECT_TRUE(SyncShareNudge()); | 2644 EXPECT_TRUE(SyncShareNudge()); |
2641 syncable::Id id; | 2645 syncable::Id id; |
2642 int64 version; | 2646 int64_t version; |
2643 { | 2647 { |
2644 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2648 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2645 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); | 2649 Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); |
2646 ASSERT_TRUE(entry.good()); | 2650 ASSERT_TRUE(entry.good()); |
2647 id = entry.GetId(); | 2651 id = entry.GetId(); |
2648 EXPECT_TRUE(id.ServerKnows()); | 2652 EXPECT_TRUE(id.ServerKnows()); |
2649 version = entry.GetBaseVersion(); | 2653 version = entry.GetBaseVersion(); |
2650 } | 2654 } |
2651 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); | 2655 sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); |
2652 update->set_originator_cache_guid(local_cache_guid()); | 2656 update->set_originator_cache_guid(local_cache_guid()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 EXPECT_TRUE(SyncShareNudge()); | 2710 EXPECT_TRUE(SyncShareNudge()); |
2707 EXPECT_TRUE(SyncShareNudge()); | 2711 EXPECT_TRUE(SyncShareNudge()); |
2708 EXPECT_TRUE(SyncShareNudge()); | 2712 EXPECT_TRUE(SyncShareNudge()); |
2709 { | 2713 { |
2710 syncable::ReadTransaction trans(FROM_HERE, directory()); | 2714 syncable::ReadTransaction trans(FROM_HERE, directory()); |
2711 Directory::Metahandles children; | 2715 Directory::Metahandles children; |
2712 directory()->GetChildHandlesById(&trans, root_id_, &children); | 2716 directory()->GetChildHandlesById(&trans, root_id_, &children); |
2713 EXPECT_EQ(1u, children.size()); | 2717 EXPECT_EQ(1u, children.size()); |
2714 directory()->GetChildHandlesById(&trans, parent_id, &children); | 2718 directory()->GetChildHandlesById(&trans, parent_id, &children); |
2715 EXPECT_EQ(1u, children.size()); | 2719 EXPECT_EQ(1u, children.size()); |
2716 std::vector<int64> unapplied; | 2720 std::vector<int64_t> unapplied; |
2717 directory()->GetUnappliedUpdateMetaHandles(&trans, all_types, &unapplied); | 2721 directory()->GetUnappliedUpdateMetaHandles(&trans, all_types, &unapplied); |
2718 EXPECT_EQ(0u, unapplied.size()); | 2722 EXPECT_EQ(0u, unapplied.size()); |
2719 syncable::Directory::Metahandles unsynced; | 2723 syncable::Directory::Metahandles unsynced; |
2720 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); | 2724 directory()->GetUnsyncedMetaHandles(&trans, &unsynced); |
2721 EXPECT_EQ(0u, unsynced.size()); | 2725 EXPECT_EQ(0u, unsynced.size()); |
2722 } | 2726 } |
2723 } | 2727 } |
2724 | 2728 |
2725 TEST_F(SyncerTest, CommittingNewDeleted) { | 2729 TEST_F(SyncerTest, CommittingNewDeleted) { |
2726 { | 2730 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 // Unexpected error during sync if we: | 2770 // Unexpected error during sync if we: |
2767 // make a new folder bob | 2771 // make a new folder bob |
2768 // wait for sync | 2772 // wait for sync |
2769 // make a new folder fred | 2773 // make a new folder fred |
2770 // move bob into fred | 2774 // move bob into fred |
2771 // remove bob | 2775 // remove bob |
2772 // remove fred | 2776 // remove fred |
2773 // if no syncing occured midway, bob will have an illegal parent | 2777 // if no syncing occured midway, bob will have an illegal parent |
2774 TEST_F(SyncerTest, DeletingEntryInFolder) { | 2778 TEST_F(SyncerTest, DeletingEntryInFolder) { |
2775 // This test is a little fake. | 2779 // This test is a little fake. |
2776 int64 existing_metahandle; | 2780 int64_t existing_metahandle; |
2777 { | 2781 { |
2778 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2782 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2779 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing"); | 2783 MutableEntry entry(&trans, CREATE, BOOKMARKS, trans.root_id(), "existing"); |
2780 ASSERT_TRUE(entry.good()); | 2784 ASSERT_TRUE(entry.good()); |
2781 entry.PutIsDir(true); | 2785 entry.PutIsDir(true); |
2782 entry.PutSpecifics(DefaultBookmarkSpecifics()); | 2786 entry.PutSpecifics(DefaultBookmarkSpecifics()); |
2783 entry.PutIsUnsynced(true); | 2787 entry.PutIsUnsynced(true); |
2784 existing_metahandle = entry.GetMetahandle(); | 2788 existing_metahandle = entry.GetMetahandle(); |
2785 } | 2789 } |
2786 EXPECT_TRUE(SyncShareNudge()); | 2790 EXPECT_TRUE(SyncShareNudge()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 } | 2846 } |
2843 | 2847 |
2844 EXPECT_TRUE(SyncShareNudge()); | 2848 EXPECT_TRUE(SyncShareNudge()); |
2845 // Since the hierarchy isn't really changed (the type has flat hierarchy) | 2849 // Since the hierarchy isn't really changed (the type has flat hierarchy) |
2846 // this conflict must be discarded. | 2850 // this conflict must be discarded. |
2847 EXPECT_EQ(0, session_->status_controller().num_local_overwrites()); | 2851 EXPECT_EQ(0, session_->status_controller().num_local_overwrites()); |
2848 EXPECT_EQ(0, session_->status_controller().num_server_overwrites()); | 2852 EXPECT_EQ(0, session_->status_controller().num_server_overwrites()); |
2849 } | 2853 } |
2850 | 2854 |
2851 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { | 2855 TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { |
2852 int64 newfolder_metahandle; | 2856 int64_t newfolder_metahandle; |
2853 | 2857 |
2854 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, | 2858 mock_server_->AddUpdateDirectory(1, 0, "bob", 1, 10, |
2855 foreign_cache_guid(), "-1"); | 2859 foreign_cache_guid(), "-1"); |
2856 EXPECT_TRUE(SyncShareNudge()); | 2860 EXPECT_TRUE(SyncShareNudge()); |
2857 { | 2861 { |
2858 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2862 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2859 MutableEntry newfolder( | 2863 MutableEntry newfolder( |
2860 &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local"); | 2864 &trans, CREATE, BOOKMARKS, ids_.FromNumber(1), "local"); |
2861 ASSERT_TRUE(newfolder.good()); | 2865 ASSERT_TRUE(newfolder.good()); |
2862 newfolder.PutIsUnsynced(true); | 2866 newfolder.PutIsUnsynced(true); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 ASSERT_TRUE(id3.good()); | 2947 ASSERT_TRUE(id3.good()); |
2944 EXPECT_EQ("bob", id3.GetNonUniqueName()); | 2948 EXPECT_EQ("bob", id3.GetNonUniqueName()); |
2945 EXPECT_EQ(root_id_, id3.GetParentId()); | 2949 EXPECT_EQ(root_id_, id3.GetParentId()); |
2946 } | 2950 } |
2947 } | 2951 } |
2948 | 2952 |
2949 // Committing more than kDefaultMaxCommitBatchSize items requires that | 2953 // Committing more than kDefaultMaxCommitBatchSize items requires that |
2950 // we post more than one commit command to the server. This test makes | 2954 // we post more than one commit command to the server. This test makes |
2951 // sure that scenario works as expected. | 2955 // sure that scenario works as expected. |
2952 TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) { | 2956 TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) { |
2953 uint32 num_batches = 3; | 2957 uint32_t num_batches = 3; |
2954 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2958 uint32_t items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
2955 { | 2959 { |
2956 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2960 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2957 for (uint32 i = 0; i < items_to_commit; i++) { | 2961 for (uint32_t i = 0; i < items_to_commit; i++) { |
2958 string nameutf8 = base::UintToString(i); | 2962 string nameutf8 = base::UintToString(i); |
2959 string name(nameutf8.begin(), nameutf8.end()); | 2963 string name(nameutf8.begin(), nameutf8.end()); |
2960 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 2964 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); |
2961 e.PutIsUnsynced(true); | 2965 e.PutIsUnsynced(true); |
2962 e.PutIsDir(true); | 2966 e.PutIsDir(true); |
2963 e.PutSpecifics(DefaultBookmarkSpecifics()); | 2967 e.PutSpecifics(DefaultBookmarkSpecifics()); |
2964 } | 2968 } |
2965 } | 2969 } |
2966 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2970 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2967 | 2971 |
2968 EXPECT_TRUE(SyncShareNudge()); | 2972 EXPECT_TRUE(SyncShareNudge()); |
2969 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); | 2973 EXPECT_EQ(num_batches, mock_server_->commit_messages().size()); |
2970 EXPECT_EQ(0, directory()->unsynced_entity_count()); | 2974 EXPECT_EQ(0, directory()->unsynced_entity_count()); |
2971 } | 2975 } |
2972 | 2976 |
2973 // Test that a single failure to contact the server will cause us to exit the | 2977 // Test that a single failure to contact the server will cause us to exit the |
2974 // commit loop immediately. | 2978 // commit loop immediately. |
2975 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { | 2979 TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) { |
2976 uint32 num_batches = 3; | 2980 uint32_t num_batches = 3; |
2977 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 2981 uint32_t items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
2978 { | 2982 { |
2979 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 2983 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
2980 for (uint32 i = 0; i < items_to_commit; i++) { | 2984 for (uint32_t i = 0; i < items_to_commit; i++) { |
2981 string nameutf8 = base::UintToString(i); | 2985 string nameutf8 = base::UintToString(i); |
2982 string name(nameutf8.begin(), nameutf8.end()); | 2986 string name(nameutf8.begin(), nameutf8.end()); |
2983 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 2987 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); |
2984 e.PutIsUnsynced(true); | 2988 e.PutIsUnsynced(true); |
2985 e.PutIsDir(true); | 2989 e.PutIsDir(true); |
2986 e.PutSpecifics(DefaultBookmarkSpecifics()); | 2990 e.PutSpecifics(DefaultBookmarkSpecifics()); |
2987 } | 2991 } |
2988 } | 2992 } |
2989 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 2993 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
2990 | 2994 |
2991 // The second commit should fail. It will be preceded by one successful | 2995 // The second commit should fail. It will be preceded by one successful |
2992 // GetUpdate and one succesful commit. | 2996 // GetUpdate and one succesful commit. |
2993 mock_server_->FailNthPostBufferToPathCall(3); | 2997 mock_server_->FailNthPostBufferToPathCall(3); |
2994 EXPECT_FALSE(SyncShareNudge()); | 2998 EXPECT_FALSE(SyncShareNudge()); |
2995 | 2999 |
2996 EXPECT_EQ(1U, mock_server_->commit_messages().size()); | 3000 EXPECT_EQ(1U, mock_server_->commit_messages().size()); |
2997 EXPECT_EQ(SYNC_SERVER_ERROR, | 3001 EXPECT_EQ(SYNC_SERVER_ERROR, |
2998 session_->status_controller().model_neutral_state().commit_result); | 3002 session_->status_controller().model_neutral_state().commit_result); |
2999 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize, | 3003 EXPECT_EQ(items_to_commit - kDefaultMaxCommitBatchSize, |
3000 directory()->unsynced_entity_count()); | 3004 directory()->unsynced_entity_count()); |
3001 } | 3005 } |
3002 | 3006 |
3003 // Test that a single conflict response from the server will cause us to exit | 3007 // Test that a single conflict response from the server will cause us to exit |
3004 // the commit loop immediately. | 3008 // the commit loop immediately. |
3005 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) { | 3009 TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) { |
3006 uint32 num_batches = 2; | 3010 uint32_t num_batches = 2; |
3007 uint32 items_to_commit = kDefaultMaxCommitBatchSize * num_batches; | 3011 uint32_t items_to_commit = kDefaultMaxCommitBatchSize * num_batches; |
3008 { | 3012 { |
3009 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3013 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3010 for (uint32 i = 0; i < items_to_commit; i++) { | 3014 for (uint32_t i = 0; i < items_to_commit; i++) { |
3011 string nameutf8 = base::UintToString(i); | 3015 string nameutf8 = base::UintToString(i); |
3012 string name(nameutf8.begin(), nameutf8.end()); | 3016 string name(nameutf8.begin(), nameutf8.end()); |
3013 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); | 3017 MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), name); |
3014 e.PutIsUnsynced(true); | 3018 e.PutIsUnsynced(true); |
3015 e.PutIsDir(true); | 3019 e.PutIsDir(true); |
3016 e.PutSpecifics(DefaultBookmarkSpecifics()); | 3020 e.PutSpecifics(DefaultBookmarkSpecifics()); |
3017 } | 3021 } |
3018 } | 3022 } |
3019 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); | 3023 ASSERT_EQ(items_to_commit, directory()->unsynced_entity_count()); |
3020 | 3024 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 mock_server_->set_conflict_all_commits(true); | 3251 mock_server_->set_conflict_all_commits(true); |
3248 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20, | 3252 mock_server_->AddUpdateDirectory(2, 0, "bob", 2, 20, |
3249 foreign_cache_guid(), "-2"); | 3253 foreign_cache_guid(), "-2"); |
3250 EXPECT_TRUE(SyncShareNudge()); // USED TO CAUSE AN ASSERT | 3254 EXPECT_TRUE(SyncShareNudge()); // USED TO CAUSE AN ASSERT |
3251 } | 3255 } |
3252 | 3256 |
3253 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { | 3257 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { |
3254 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, | 3258 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, |
3255 foreign_cache_guid(), "-1"); | 3259 foreign_cache_guid(), "-1"); |
3256 EXPECT_TRUE(SyncShareNudge()); | 3260 EXPECT_TRUE(SyncShareNudge()); |
3257 int64 local_folder_handle; | 3261 int64_t local_folder_handle; |
3258 syncable::Id local_folder_id; | 3262 syncable::Id local_folder_id; |
3259 { | 3263 { |
3260 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3264 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3261 MutableEntry new_entry( | 3265 MutableEntry new_entry( |
3262 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); | 3266 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); |
3263 ASSERT_TRUE(new_entry.good()); | 3267 ASSERT_TRUE(new_entry.good()); |
3264 local_folder_id = new_entry.GetId(); | 3268 local_folder_id = new_entry.GetId(); |
3265 local_folder_handle = new_entry.GetMetahandle(); | 3269 local_folder_handle = new_entry.GetMetahandle(); |
3266 new_entry.PutIsUnsynced(true); | 3270 new_entry.PutIsUnsynced(true); |
3267 new_entry.PutSpecifics(DefaultBookmarkSpecifics()); | 3271 new_entry.PutSpecifics(DefaultBookmarkSpecifics()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 server.GetSpecifics().bookmark().url()); | 3318 server.GetSpecifics().bookmark().url()); |
3315 } | 3319 } |
3316 } | 3320 } |
3317 | 3321 |
3318 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. | 3322 // Same as NewEntryAnddServerEntrySharePath, but using the old-style protocol. |
3319 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { | 3323 TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath_OldBookmarksProto) { |
3320 mock_server_->set_use_legacy_bookmarks_protocol(true); | 3324 mock_server_->set_use_legacy_bookmarks_protocol(true); |
3321 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, | 3325 mock_server_->AddUpdateBookmark(1, 0, "Foo.htm", 10, 10, |
3322 foreign_cache_guid(), "-1"); | 3326 foreign_cache_guid(), "-1"); |
3323 EXPECT_TRUE(SyncShareNudge()); | 3327 EXPECT_TRUE(SyncShareNudge()); |
3324 int64 local_folder_handle; | 3328 int64_t local_folder_handle; |
3325 syncable::Id local_folder_id; | 3329 syncable::Id local_folder_id; |
3326 { | 3330 { |
3327 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3331 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3328 MutableEntry new_entry( | 3332 MutableEntry new_entry( |
3329 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); | 3333 &wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "Bar.htm"); |
3330 ASSERT_TRUE(new_entry.good()); | 3334 ASSERT_TRUE(new_entry.good()); |
3331 local_folder_id = new_entry.GetId(); | 3335 local_folder_id = new_entry.GetId(); |
3332 local_folder_handle = new_entry.GetMetahandle(); | 3336 local_folder_handle = new_entry.GetMetahandle(); |
3333 new_entry.PutIsUnsynced(true); | 3337 new_entry.PutIsUnsynced(true); |
3334 new_entry.PutSpecifics(DefaultBookmarkSpecifics()); | 3338 new_entry.PutSpecifics(DefaultBookmarkSpecifics()); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3460 ASSERT_TRUE(B.good()); | 3464 ASSERT_TRUE(B.good()); |
3461 EXPECT_FALSE(B.GetIsUnsynced()); | 3465 EXPECT_FALSE(B.GetIsUnsynced()); |
3462 EXPECT_FALSE(B.GetIsUnappliedUpdate()); | 3466 EXPECT_FALSE(B.GetIsUnappliedUpdate()); |
3463 } | 3467 } |
3464 } | 3468 } |
3465 | 3469 |
3466 // When we undelete an entity as a result of conflict resolution, we reuse the | 3470 // When we undelete an entity as a result of conflict resolution, we reuse the |
3467 // existing server id and preserve the old version, simply updating the server | 3471 // existing server id and preserve the old version, simply updating the server |
3468 // version with the new non-deleted entity. | 3472 // version with the new non-deleted entity. |
3469 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { | 3473 TEST_F(SyncerTest, ResolveWeWroteTheyDeleted) { |
3470 int64 bob_metahandle; | 3474 int64_t bob_metahandle; |
3471 | 3475 |
3472 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10, | 3476 mock_server_->AddUpdateBookmark(1, 0, "bob", 1, 10, |
3473 foreign_cache_guid(), "-1"); | 3477 foreign_cache_guid(), "-1"); |
3474 EXPECT_TRUE(SyncShareNudge()); | 3478 EXPECT_TRUE(SyncShareNudge()); |
3475 { | 3479 { |
3476 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 3480 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
3477 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); | 3481 MutableEntry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); |
3478 ASSERT_TRUE(bob.good()); | 3482 ASSERT_TRUE(bob.good()); |
3479 bob_metahandle = bob.GetMetahandle(); | 3483 bob_metahandle = bob.GetMetahandle(); |
3480 WriteTestDataToEntry(&trans, &bob); | 3484 WriteTestDataToEntry(&trans, &bob); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3729 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1, | 3733 mock_server_->AddUpdateDirectory(1, 0, "foo", 1, 1, |
3730 foreign_cache_guid(), "-1"); | 3734 foreign_cache_guid(), "-1"); |
3731 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2, | 3735 mock_server_->AddUpdateDirectory(2, 1, "bar", 1, 2, |
3732 foreign_cache_guid(), "-2"); | 3736 foreign_cache_guid(), "-2"); |
3733 EXPECT_TRUE(SyncShareNudge()); | 3737 EXPECT_TRUE(SyncShareNudge()); |
3734 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3, | 3738 mock_server_->AddUpdateDirectory(2, 1, "bar", 2, 3, |
3735 foreign_cache_guid(), "-2"); | 3739 foreign_cache_guid(), "-2"); |
3736 mock_server_->SetLastUpdateDeleted(); | 3740 mock_server_->SetLastUpdateDeleted(); |
3737 EXPECT_TRUE(SyncShareNudge()); | 3741 EXPECT_TRUE(SyncShareNudge()); |
3738 | 3742 |
3739 int64 metahandle; | 3743 int64_t metahandle; |
3740 { | 3744 { |
3741 syncable::ReadTransaction trans(FROM_HERE, directory()); | 3745 syncable::ReadTransaction trans(FROM_HERE, directory()); |
3742 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); | 3746 Entry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); |
3743 ASSERT_TRUE(entry.good()); | 3747 ASSERT_TRUE(entry.good()); |
3744 EXPECT_TRUE(entry.GetIsDel()); | 3748 EXPECT_TRUE(entry.GetIsDel()); |
3745 metahandle = entry.GetMetahandle(); | 3749 metahandle = entry.GetMetahandle(); |
3746 } | 3750 } |
3747 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4, | 3751 mock_server_->AddUpdateDirectory(1, 0, "foo", 2, 4, |
3748 foreign_cache_guid(), "-1"); | 3752 foreign_cache_guid(), "-1"); |
3749 mock_server_->SetLastUpdateDeleted(); | 3753 mock_server_->SetLastUpdateDeleted(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3823 | 3827 |
3824 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); | 3828 Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); |
3825 ASSERT_TRUE(in_in_root.good()); | 3829 ASSERT_TRUE(in_in_root.good()); |
3826 EXPECT_EQ("in_in_root_name", in_in_root.GetNonUniqueName()); | 3830 EXPECT_EQ("in_in_root_name", in_in_root.GetNonUniqueName()); |
3827 EXPECT_EQ(in_root_id, in_in_root.GetParentId()); | 3831 EXPECT_EQ(in_root_id, in_in_root.GetParentId()); |
3828 } | 3832 } |
3829 } | 3833 } |
3830 | 3834 |
3831 TEST_F(SyncerTest, DirectoryCommitTest) { | 3835 TEST_F(SyncerTest, DirectoryCommitTest) { |
3832 syncable::Id in_root_id, in_dir_id; | 3836 syncable::Id in_root_id, in_dir_id; |
3833 int64 foo_metahandle; | 3837 int64_t foo_metahandle; |
3834 int64 bar_metahandle; | 3838 int64_t bar_metahandle; |
3835 | 3839 |
3836 { | 3840 { |
3837 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 3841 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3838 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "foo"); | 3842 MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root_id_, "foo"); |
3839 ASSERT_TRUE(parent.good()); | 3843 ASSERT_TRUE(parent.good()); |
3840 parent.PutIsUnsynced(true); | 3844 parent.PutIsUnsynced(true); |
3841 parent.PutIsDir(true); | 3845 parent.PutIsDir(true); |
3842 parent.PutSpecifics(DefaultBookmarkSpecifics()); | 3846 parent.PutSpecifics(DefaultBookmarkSpecifics()); |
3843 in_root_id = parent.GetId(); | 3847 in_root_id = parent.GetId(); |
3844 foo_metahandle = parent.GetMetahandle(); | 3848 foo_metahandle = parent.GetMetahandle(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3982 } | 3986 } |
3983 EXPECT_TRUE(SyncShareNudge()); | 3987 EXPECT_TRUE(SyncShareNudge()); |
3984 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); | 3988 const sync_pb::CommitMessage& commit = mock_server_->last_sent_commit(); |
3985 ASSERT_EQ(2, commit.entries_size()); | 3989 ASSERT_EQ(2, commit.entries_size()); |
3986 EXPECT_EQ("2", commit.entries(0).parent_id_string()); | 3990 EXPECT_EQ("2", commit.entries(0).parent_id_string()); |
3987 EXPECT_EQ("0", commit.entries(0).old_parent_id()); | 3991 EXPECT_EQ("0", commit.entries(0).old_parent_id()); |
3988 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); | 3992 EXPECT_FALSE(commit.entries(1).has_old_parent_id()); |
3989 } | 3993 } |
3990 | 3994 |
3991 TEST_F(SyncerTest, Test64BitVersionSupport) { | 3995 TEST_F(SyncerTest, Test64BitVersionSupport) { |
3992 int64 really_big_int = std::numeric_limits<int64>::max() - 12; | 3996 int64_t really_big_int = std::numeric_limits<int64_t>::max() - 12; |
3993 const string name("ringo's dang orang ran rings around my o-ring"); | 3997 const string name("ringo's dang orang ran rings around my o-ring"); |
3994 int64 item_metahandle; | 3998 int64_t item_metahandle; |
3995 | 3999 |
3996 // Try writing max int64 to the version fields of a meta entry. | 4000 // Try writing max int64_t to the version fields of a meta entry. |
3997 { | 4001 { |
3998 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); | 4002 WriteTransaction wtrans(FROM_HERE, UNITTEST, directory()); |
3999 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); | 4003 MutableEntry entry(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); |
4000 ASSERT_TRUE(entry.good()); | 4004 ASSERT_TRUE(entry.good()); |
4001 entry.PutBaseVersion(really_big_int); | 4005 entry.PutBaseVersion(really_big_int); |
4002 entry.PutServerVersion(really_big_int); | 4006 entry.PutServerVersion(really_big_int); |
4003 entry.PutId(ids_.NewServerId()); | 4007 entry.PutId(ids_.NewServerId()); |
4004 item_metahandle = entry.GetMetahandle(); | 4008 item_metahandle = entry.GetMetahandle(); |
4005 } | 4009 } |
4006 // Now read it back out and make sure the value is max int64. | 4010 // Now read it back out and make sure the value is max int64_t. |
4007 syncable::ReadTransaction rtrans(FROM_HERE, directory()); | 4011 syncable::ReadTransaction rtrans(FROM_HERE, directory()); |
4008 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); | 4012 Entry entry(&rtrans, syncable::GET_BY_HANDLE, item_metahandle); |
4009 ASSERT_TRUE(entry.good()); | 4013 ASSERT_TRUE(entry.good()); |
4010 EXPECT_EQ(really_big_int, entry.GetBaseVersion()); | 4014 EXPECT_EQ(really_big_int, entry.GetBaseVersion()); |
4011 } | 4015 } |
4012 | 4016 |
4013 TEST_F(SyncerTest, TestSimpleUndelete) { | 4017 TEST_F(SyncerTest, TestSimpleUndelete) { |
4014 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); | 4018 Id id = ids_.MakeServer("undeletion item"), root = TestIdFactory::root(); |
4015 mock_server_->set_conflict_all_commits(true); | 4019 mock_server_->set_conflict_all_commits(true); |
4016 // Let there be an entry from the server. | 4020 // Let there be an entry from the server. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4203 | 4207 |
4204 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); | 4208 Entry perm_folder(&trans, GET_BY_CLIENT_TAG, "permfolder"); |
4205 ASSERT_TRUE(perm_folder.good()); | 4209 ASSERT_TRUE(perm_folder.good()); |
4206 EXPECT_FALSE(perm_folder.GetIsUnappliedUpdate()); | 4210 EXPECT_FALSE(perm_folder.GetIsUnappliedUpdate()); |
4207 EXPECT_FALSE(perm_folder.GetIsUnsynced()); | 4211 EXPECT_FALSE(perm_folder.GetIsUnsynced()); |
4208 EXPECT_EQ("permitem1", perm_folder.GetNonUniqueName()); | 4212 EXPECT_EQ("permitem1", perm_folder.GetNonUniqueName()); |
4209 } | 4213 } |
4210 } | 4214 } |
4211 | 4215 |
4212 TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) { | 4216 TEST_F(SyncerTest, ClientTagUncommittedTagMatchesUpdate) { |
4213 int64 original_metahandle = 0; | 4217 int64_t original_metahandle = 0; |
4214 | 4218 |
4215 { | 4219 { |
4216 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); | 4220 WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
4217 MutableEntry pref( | 4221 MutableEntry pref( |
4218 &trans, CREATE, PREFERENCES, ids_.root(), "name"); | 4222 &trans, CREATE, PREFERENCES, ids_.root(), "name"); |
4219 ASSERT_TRUE(pref.good()); | 4223 ASSERT_TRUE(pref.good()); |
4220 pref.PutUniqueClientTag("tag"); | 4224 pref.PutUniqueClientTag("tag"); |
4221 pref.PutIsUnsynced(true); | 4225 pref.PutIsUnsynced(true); |
4222 EXPECT_FALSE(pref.GetIsUnappliedUpdate()); | 4226 EXPECT_FALSE(pref.GetIsUnappliedUpdate()); |
4223 EXPECT_FALSE(pref.GetId().ServerKnows()); | 4227 EXPECT_FALSE(pref.GetId().ServerKnows()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4316 | 4320 |
4317 syncable::Id id1 = TestIdFactory::MakeServer("1"); | 4321 syncable::Id id1 = TestIdFactory::MakeServer("1"); |
4318 mock_server_->AddUpdatePref(id1.GetServerId(), "", "tag1", 10, 100); | 4322 mock_server_->AddUpdatePref(id1.GetServerId(), "", "tag1", 10, 100); |
4319 | 4323 |
4320 syncable::Id id4 = TestIdFactory::MakeServer("4"); | 4324 syncable::Id id4 = TestIdFactory::MakeServer("4"); |
4321 mock_server_->AddUpdatePref(id4.GetServerId(), "", "tag2", 11, 110); | 4325 mock_server_->AddUpdatePref(id4.GetServerId(), "", "tag2", 11, 110); |
4322 | 4326 |
4323 mock_server_->set_conflict_all_commits(true); | 4327 mock_server_->set_conflict_all_commits(true); |
4324 | 4328 |
4325 EXPECT_TRUE(SyncShareNudge()); | 4329 EXPECT_TRUE(SyncShareNudge()); |
4326 int64 tag1_metahandle = syncable::kInvalidMetaHandle; | 4330 int64_t tag1_metahandle = syncable::kInvalidMetaHandle; |
4327 int64 tag2_metahandle = syncable::kInvalidMetaHandle; | 4331 int64_t tag2_metahandle = syncable::kInvalidMetaHandle; |
4328 // This should cause client tag overwrite. | 4332 // This should cause client tag overwrite. |
4329 { | 4333 { |
4330 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4334 syncable::ReadTransaction trans(FROM_HERE, directory()); |
4331 | 4335 |
4332 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); | 4336 Entry tag1(&trans, GET_BY_CLIENT_TAG, "tag1"); |
4333 ASSERT_TRUE(tag1.good()); | 4337 ASSERT_TRUE(tag1.good()); |
4334 ASSERT_TRUE(tag1.GetId().ServerKnows()); | 4338 ASSERT_TRUE(tag1.GetId().ServerKnows()); |
4335 ASSERT_EQ(id1, tag1.GetId()); | 4339 ASSERT_EQ(id1, tag1.GetId()); |
4336 EXPECT_FALSE(tag1.GetIsDel()); | 4340 EXPECT_FALSE(tag1.GetIsDel()); |
4337 EXPECT_FALSE(tag1.GetIsUnappliedUpdate()); | 4341 EXPECT_FALSE(tag1.GetIsUnappliedUpdate()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4548 // Verify that there is still one node under the type root. | 4552 // Verify that there is still one node under the type root. |
4549 syncable::Directory::Metahandles children; | 4553 syncable::Directory::Metahandles children; |
4550 directory()->GetChildHandlesById(&trans, pref_root_id, &children); | 4554 directory()->GetChildHandlesById(&trans, pref_root_id, &children); |
4551 ASSERT_EQ(1U, children.size()); | 4555 ASSERT_EQ(1U, children.size()); |
4552 } | 4556 } |
4553 } | 4557 } |
4554 | 4558 |
4555 TEST_F(SyncerTest, UniqueServerTagUpdates) { | 4559 TEST_F(SyncerTest, UniqueServerTagUpdates) { |
4556 // As a hurdle, introduce an item whose name is the same as the tag value | 4560 // As a hurdle, introduce an item whose name is the same as the tag value |
4557 // we'll use later. | 4561 // we'll use later. |
4558 int64 hurdle_handle = CreateUnsyncedDirectory("bob", "id_bob"); | 4562 int64_t hurdle_handle = CreateUnsyncedDirectory("bob", "id_bob"); |
4559 { | 4563 { |
4560 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4564 syncable::ReadTransaction trans(FROM_HERE, directory()); |
4561 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); | 4565 Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); |
4562 ASSERT_TRUE(hurdle.good()); | 4566 ASSERT_TRUE(hurdle.good()); |
4563 ASSERT_TRUE(!hurdle.GetIsDel()); | 4567 ASSERT_TRUE(!hurdle.GetIsDel()); |
4564 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); | 4568 ASSERT_TRUE(hurdle.GetUniqueServerTag().empty()); |
4565 ASSERT_EQ("bob", hurdle.GetNonUniqueName()); | 4569 ASSERT_EQ("bob", hurdle.GetNonUniqueName()); |
4566 | 4570 |
4567 // Try to lookup by the tagname. These should fail. | 4571 // Try to lookup by the tagname. These should fail. |
4568 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); | 4572 Entry tag_alpha(&trans, GET_BY_SERVER_TAG, "alpha"); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4635 } | 4639 } |
4636 | 4640 |
4637 // A typical scenario: server and client each have one update for the other. | 4641 // A typical scenario: server and client each have one update for the other. |
4638 // This is the "happy path" alternative to UpdateFailsThenDontCommit. | 4642 // This is the "happy path" alternative to UpdateFailsThenDontCommit. |
4639 TEST_F(SyncerTest, UpdateThenCommit) { | 4643 TEST_F(SyncerTest, UpdateThenCommit) { |
4640 syncable::Id to_receive = ids_.NewServerId(); | 4644 syncable::Id to_receive = ids_.NewServerId(); |
4641 syncable::Id to_commit = ids_.NewLocalId(); | 4645 syncable::Id to_commit = ids_.NewLocalId(); |
4642 | 4646 |
4643 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10, | 4647 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10, |
4644 foreign_cache_guid(), "-1"); | 4648 foreign_cache_guid(), "-1"); |
4645 int64 commit_handle = CreateUnsyncedDirectory("y", to_commit); | 4649 int64_t commit_handle = CreateUnsyncedDirectory("y", to_commit); |
4646 EXPECT_TRUE(SyncShareNudge()); | 4650 EXPECT_TRUE(SyncShareNudge()); |
4647 | 4651 |
4648 // The sync cycle should have included a GetUpdate, then a commit. By the | 4652 // The sync cycle should have included a GetUpdate, then a commit. By the |
4649 // time the commit happened, we should have known for sure that there were no | 4653 // time the commit happened, we should have known for sure that there were no |
4650 // hierarchy conflicts, and reported this fact to the server. | 4654 // hierarchy conflicts, and reported this fact to the server. |
4651 ASSERT_TRUE(mock_server_->last_request().has_commit()); | 4655 ASSERT_TRUE(mock_server_->last_request().has_commit()); |
4652 VerifyNoHierarchyConflictsReported(mock_server_->last_request()); | 4656 VerifyNoHierarchyConflictsReported(mock_server_->last_request()); |
4653 | 4657 |
4654 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4658 syncable::ReadTransaction trans(FROM_HERE, directory()); |
4655 | 4659 |
(...skipping 10 matching lines...) Expand all Loading... |
4666 | 4670 |
4667 // Same as above, but this time we fail to download updates. | 4671 // Same as above, but this time we fail to download updates. |
4668 // We should not attempt to commit anything unless we successfully downloaded | 4672 // We should not attempt to commit anything unless we successfully downloaded |
4669 // updates, otherwise we risk causing a server-side conflict. | 4673 // updates, otherwise we risk causing a server-side conflict. |
4670 TEST_F(SyncerTest, UpdateFailsThenDontCommit) { | 4674 TEST_F(SyncerTest, UpdateFailsThenDontCommit) { |
4671 syncable::Id to_receive = ids_.NewServerId(); | 4675 syncable::Id to_receive = ids_.NewServerId(); |
4672 syncable::Id to_commit = ids_.NewLocalId(); | 4676 syncable::Id to_commit = ids_.NewLocalId(); |
4673 | 4677 |
4674 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10, | 4678 mock_server_->AddUpdateDirectory(to_receive, ids_.root(), "x", 1, 10, |
4675 foreign_cache_guid(), "-1"); | 4679 foreign_cache_guid(), "-1"); |
4676 int64 commit_handle = CreateUnsyncedDirectory("y", to_commit); | 4680 int64_t commit_handle = CreateUnsyncedDirectory("y", to_commit); |
4677 mock_server_->FailNextPostBufferToPathCall(); | 4681 mock_server_->FailNextPostBufferToPathCall(); |
4678 EXPECT_FALSE(SyncShareNudge()); | 4682 EXPECT_FALSE(SyncShareNudge()); |
4679 | 4683 |
4680 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4684 syncable::ReadTransaction trans(FROM_HERE, directory()); |
4681 | 4685 |
4682 // We did not receive this update. | 4686 // We did not receive this update. |
4683 Entry received(&trans, GET_BY_ID, to_receive); | 4687 Entry received(&trans, GET_BY_ID, to_receive); |
4684 ASSERT_FALSE(received.good()); | 4688 ASSERT_FALSE(received.good()); |
4685 | 4689 |
4686 // And our local update remains unapplied. | 4690 // And our local update remains unapplied. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4870 MutableEntry entry(&trans, GET_BY_HANDLE, metahandle_); | 4874 MutableEntry entry(&trans, GET_BY_HANDLE, metahandle_); |
4871 ASSERT_TRUE(entry.good()); | 4875 ASSERT_TRUE(entry.good()); |
4872 EXPECT_EQ(metahandle_, entry.GetMetahandle()); | 4876 EXPECT_EQ(metahandle_, entry.GetMetahandle()); |
4873 EXPECT_TRUE(entry.GetIsDel()); | 4877 EXPECT_TRUE(entry.GetIsDel()); |
4874 entry.PutIsDel(false); | 4878 entry.PutIsDel(false); |
4875 entry.PutIsUnsynced(true); | 4879 entry.PutIsUnsynced(true); |
4876 if (entry.GetSyncing()) | 4880 if (entry.GetSyncing()) |
4877 entry.PutDirtySync(true); | 4881 entry.PutDirtySync(true); |
4878 } | 4882 } |
4879 | 4883 |
4880 int64 GetMetahandleOfTag() { | 4884 int64_t GetMetahandleOfTag() { |
4881 syncable::ReadTransaction trans(FROM_HERE, directory()); | 4885 syncable::ReadTransaction trans(FROM_HERE, directory()); |
4882 Entry entry(&trans, GET_BY_HANDLE, metahandle_); | 4886 Entry entry(&trans, GET_BY_HANDLE, metahandle_); |
4883 EXPECT_TRUE(entry.good()); | 4887 EXPECT_TRUE(entry.good()); |
4884 if (!entry.good()) { | 4888 if (!entry.good()) { |
4885 return syncable::kInvalidMetaHandle; | 4889 return syncable::kInvalidMetaHandle; |
4886 } | 4890 } |
4887 return entry.GetMetahandle(); | 4891 return entry.GetMetahandle(); |
4888 } | 4892 } |
4889 | 4893 |
4890 Id GetServerId() { | 4894 Id GetServerId() { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4969 EXPECT_TRUE(entry.GetIsDel()); | 4973 EXPECT_TRUE(entry.GetIsDel()); |
4970 EXPECT_TRUE(entry.GetServerIsDel()); | 4974 EXPECT_TRUE(entry.GetServerIsDel()); |
4971 EXPECT_FALSE(entry.GetIsUnsynced()); | 4975 EXPECT_FALSE(entry.GetIsUnsynced()); |
4972 EXPECT_FALSE(entry.GetIsUnappliedUpdate()); | 4976 EXPECT_FALSE(entry.GetIsUnappliedUpdate()); |
4973 EXPECT_GE(entry.GetBaseVersion(), 0); | 4977 EXPECT_GE(entry.GetBaseVersion(), 0); |
4974 EXPECT_GE(entry.GetServerVersion(), 0); | 4978 EXPECT_GE(entry.GetServerVersion(), 0); |
4975 } | 4979 } |
4976 | 4980 |
4977 protected: | 4981 protected: |
4978 syncable::Id local_id_; | 4982 syncable::Id local_id_; |
4979 int64 metahandle_; | 4983 int64_t metahandle_; |
4980 }; | 4984 }; |
4981 | 4985 |
4982 TEST_F(SyncerBookmarksTest, CreateSyncThenDeleteSync) { | 4986 TEST_F(SyncerBookmarksTest, CreateSyncThenDeleteSync) { |
4983 Create(); | 4987 Create(); |
4984 ExpectUnsyncedCreation(); | 4988 ExpectUnsyncedCreation(); |
4985 EXPECT_TRUE(SyncShareNudge()); | 4989 EXPECT_TRUE(SyncShareNudge()); |
4986 ExpectSyncedAndCreated(); | 4990 ExpectSyncedAndCreated(); |
4987 Delete(); | 4991 Delete(); |
4988 ExpectUnsyncedDeletion(); | 4992 ExpectUnsyncedDeletion(); |
4989 EXPECT_TRUE(SyncShareNudge()); | 4993 EXPECT_TRUE(SyncShareNudge()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5117 MutableEntry entry(&trans, GET_BY_CLIENT_TAG, client_tag_); | 5121 MutableEntry entry(&trans, GET_BY_CLIENT_TAG, client_tag_); |
5118 ASSERT_TRUE(entry.good()); | 5122 ASSERT_TRUE(entry.good()); |
5119 EXPECT_EQ(metahandle_, entry.GetMetahandle()); | 5123 EXPECT_EQ(metahandle_, entry.GetMetahandle()); |
5120 EXPECT_TRUE(entry.GetIsDel()); | 5124 EXPECT_TRUE(entry.GetIsDel()); |
5121 entry.PutIsDel(false); | 5125 entry.PutIsDel(false); |
5122 entry.PutIsUnsynced(true); | 5126 entry.PutIsUnsynced(true); |
5123 if (entry.GetSyncing()) | 5127 if (entry.GetSyncing()) |
5124 entry.PutDirtySync(true); | 5128 entry.PutDirtySync(true); |
5125 } | 5129 } |
5126 | 5130 |
5127 int64 GetMetahandleOfTag() { | 5131 int64_t GetMetahandleOfTag() { |
5128 syncable::ReadTransaction trans(FROM_HERE, directory()); | 5132 syncable::ReadTransaction trans(FROM_HERE, directory()); |
5129 Entry entry(&trans, GET_BY_CLIENT_TAG, client_tag_); | 5133 Entry entry(&trans, GET_BY_CLIENT_TAG, client_tag_); |
5130 EXPECT_TRUE(entry.good()); | 5134 EXPECT_TRUE(entry.good()); |
5131 if (!entry.good()) { | 5135 if (!entry.good()) { |
5132 return syncable::kInvalidMetaHandle; | 5136 return syncable::kInvalidMetaHandle; |
5133 } | 5137 } |
5134 return entry.GetMetahandle(); | 5138 return entry.GetMetahandle(); |
5135 } | 5139 } |
5136 | 5140 |
5137 void ExpectUnsyncedCreation() { | 5141 void ExpectUnsyncedCreation() { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5207 EXPECT_TRUE(entry.GetServerIsDel()); | 5211 EXPECT_TRUE(entry.GetServerIsDel()); |
5208 EXPECT_FALSE(entry.GetIsUnsynced()); | 5212 EXPECT_FALSE(entry.GetIsUnsynced()); |
5209 EXPECT_FALSE(entry.GetIsUnappliedUpdate()); | 5213 EXPECT_FALSE(entry.GetIsUnappliedUpdate()); |
5210 EXPECT_GE(entry.GetBaseVersion(), 0); | 5214 EXPECT_GE(entry.GetBaseVersion(), 0); |
5211 EXPECT_GE(entry.GetServerVersion(), 0); | 5215 EXPECT_GE(entry.GetServerVersion(), 0); |
5212 } | 5216 } |
5213 | 5217 |
5214 protected: | 5218 protected: |
5215 const std::string client_tag_; | 5219 const std::string client_tag_; |
5216 syncable::Id local_id_; | 5220 syncable::Id local_id_; |
5217 int64 metahandle_; | 5221 int64_t metahandle_; |
5218 }; | 5222 }; |
5219 | 5223 |
5220 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { | 5224 TEST_F(SyncerUndeletionTest, UndeleteDuringCommit) { |
5221 Create(); | 5225 Create(); |
5222 ExpectUnsyncedCreation(); | 5226 ExpectUnsyncedCreation(); |
5223 EXPECT_TRUE(SyncShareNudge()); | 5227 EXPECT_TRUE(SyncShareNudge()); |
5224 | 5228 |
5225 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); | 5229 EXPECT_EQ(1, mock_server_->GetAndClearNumGetUpdatesRequests()); |
5226 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); | 5230 EXPECT_EQ(0, session_->status_controller().TotalNumConflictingItems()); |
5227 ExpectSyncedAndCreated(); | 5231 ExpectSyncedAndCreated(); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5644 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); | 5648 EXPECT_EQ("xyz", final_monitor_records["xyz"].extension_id); |
5645 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 5649 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
5646 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 5650 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
5647 } else { | 5651 } else { |
5648 EXPECT_TRUE(final_monitor_records.empty()) | 5652 EXPECT_TRUE(final_monitor_records.empty()) |
5649 << "Should not restore records after successful bookmark commit."; | 5653 << "Should not restore records after successful bookmark commit."; |
5650 } | 5654 } |
5651 } | 5655 } |
5652 | 5656 |
5653 } // namespace syncer | 5657 } // namespace syncer |
OLD | NEW |