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

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

Issue 7802003: Merge 98758 - [Sync] Gracefully handle writing to a node when the cryptographer is not ready. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: '' Created 9 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 (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>
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 vector<syncable::Id> expected_order; 531 vector<syncable::Id> expected_order;
532 // The expected order is "x", "b", "c", "e", truncated appropriately. 532 // The expected order is "x", "b", "c", "e", truncated appropriately.
533 unsynced_handle_view.push_back(handle_e); 533 unsynced_handle_view.push_back(handle_e);
534 expected_order.push_back(ids_.MakeLocal("x")); 534 expected_order.push_back(ids_.MakeLocal("x"));
535 expected_order.push_back(ids_.MakeLocal("b")); 535 expected_order.push_back(ids_.MakeLocal("b"));
536 expected_order.push_back(ids_.MakeLocal("c")); 536 expected_order.push_back(ids_.MakeLocal("c"));
537 expected_order.push_back(ids_.MakeLocal("e")); 537 expected_order.push_back(ids_.MakeLocal("e"));
538 DoTruncationTest(dir, unsynced_handle_view, expected_order); 538 DoTruncationTest(dir, unsynced_handle_view, expected_order);
539 } 539 }
540 540
541 TEST_F(SyncerTest, GetCommitIdsFilterEntriesNeedingEncryption) {
542 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
543 ASSERT_TRUE(dir.good());
544 int64 handle_x = CreateUnsyncedDirectory("X", ids_.MakeLocal("x"));
545 int64 handle_b = CreateUnsyncedDirectory("B", ids_.MakeLocal("b"));
546 int64 handle_c = CreateUnsyncedDirectory("C", ids_.MakeLocal("c"));
547 int64 handle_e = CreateUnsyncedDirectory("E", ids_.MakeLocal("e"));
548 int64 handle_f = CreateUnsyncedDirectory("F", ids_.MakeLocal("f"));
549 sync_pb::EncryptedData encrypted;
550 sync_pb::EntitySpecifics encrypted_bookmark;
551 encrypted_bookmark.mutable_encrypted();
552 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
553 {
554 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
555 MutableEntry entry_x(&wtrans, GET_BY_HANDLE, handle_x);
556 MutableEntry entry_b(&wtrans, GET_BY_HANDLE, handle_b);
557 MutableEntry entry_c(&wtrans, GET_BY_HANDLE, handle_c);
558 MutableEntry entry_e(&wtrans, GET_BY_HANDLE, handle_e);
559 MutableEntry entry_f(&wtrans, GET_BY_HANDLE, handle_f);
560 entry_x.Put(SPECIFICS, encrypted_bookmark);
561 entry_b.Put(SPECIFICS, DefaultBookmarkSpecifics());
562 entry_c.Put(SPECIFICS, DefaultBookmarkSpecifics());
563 entry_e.Put(SPECIFICS, encrypted_bookmark);
564 entry_f.Put(SPECIFICS, DefaultPreferencesSpecifics());
565 }
566
567 syncable::ModelTypeSet encrypted_types;
568 encrypted_types.insert(syncable::BOOKMARKS);
569 syncable::Directory::UnsyncedMetaHandles unsynced_handles;
570 unsynced_handles.push_back(handle_x);
571 unsynced_handles.push_back(handle_b);
572 unsynced_handles.push_back(handle_c);
573 unsynced_handles.push_back(handle_e);
574 unsynced_handles.push_back(handle_f);
575 // The unencrypted bookmarks should be removed from the list.
576 syncable::Directory::UnsyncedMetaHandles expected_handles;
577 expected_handles.push_back(handle_x); // Was encrypted.
578 expected_handles.push_back(handle_e); // Was encrypted.
579 expected_handles.push_back(handle_f); // Does not require encryption.
580 {
581 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
582 GetCommitIdsCommand::FilterEntriesNeedingEncryption(
583 encrypted_types,
584 &wtrans,
585 &unsynced_handles);
586 EXPECT_EQ(expected_handles, unsynced_handles);
587 }
588 }
589
541 // TODO(chron): More corner case unit tests around validation. 590 // TODO(chron): More corner case unit tests around validation.
542 TEST_F(SyncerTest, TestCommitMetahandleIterator) { 591 TEST_F(SyncerTest, TestCommitMetahandleIterator) {
543 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 592 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
544 ASSERT_TRUE(dir.good()); 593 ASSERT_TRUE(dir.good());
545 StatusController* status = session_->status_controller(); 594 StatusController* status = session_->status_controller();
546 const vector<int64>& unsynced(status->unsynced_handles()); 595 const vector<int64>& unsynced(status->unsynced_handles());
547 596
548 { 597 {
549 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 598 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
550 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); 599 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans);
(...skipping 4626 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 Add(low_id_); 5226 Add(low_id_);
5178 Add(high_id_); 5227 Add(high_id_);
5179 SyncShareAsDelegate(); 5228 SyncShareAsDelegate();
5180 ExpectLocalOrderIsByServerId(); 5229 ExpectLocalOrderIsByServerId();
5181 } 5230 }
5182 5231
5183 const SyncerTest::CommitOrderingTest 5232 const SyncerTest::CommitOrderingTest
5184 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; 5233 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()};
5185 5234
5186 } // namespace browser_sync 5235 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/get_commit_ids_command.cc ('k') | chrome/browser/sync/syncable/nigori_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698