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

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

Issue 7795002: [Sync] Gracefully handle writing to a node when the cryptographer is not ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 vector<syncable::Id> expected_order; 536 vector<syncable::Id> expected_order;
537 // The expected order is "x", "b", "c", "e", truncated appropriately. 537 // The expected order is "x", "b", "c", "e", truncated appropriately.
538 unsynced_handle_view.push_back(handle_e); 538 unsynced_handle_view.push_back(handle_e);
539 expected_order.push_back(ids_.MakeLocal("x")); 539 expected_order.push_back(ids_.MakeLocal("x"));
540 expected_order.push_back(ids_.MakeLocal("b")); 540 expected_order.push_back(ids_.MakeLocal("b"));
541 expected_order.push_back(ids_.MakeLocal("c")); 541 expected_order.push_back(ids_.MakeLocal("c"));
542 expected_order.push_back(ids_.MakeLocal("e")); 542 expected_order.push_back(ids_.MakeLocal("e"));
543 DoTruncationTest(dir, unsynced_handle_view, expected_order); 543 DoTruncationTest(dir, unsynced_handle_view, expected_order);
544 } 544 }
545 545
546 TEST_F(SyncerTest, GetCommitIdsFilterEntriesNeedingEncryption) {
547 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
548 ASSERT_TRUE(dir.good());
549 int64 handle_x = CreateUnsyncedDirectory("X", ids_.MakeLocal("x"));
550 int64 handle_b = CreateUnsyncedDirectory("B", ids_.MakeLocal("b"));
551 int64 handle_c = CreateUnsyncedDirectory("C", ids_.MakeLocal("c"));
552 int64 handle_e = CreateUnsyncedDirectory("E", ids_.MakeLocal("e"));
553 int64 handle_f = CreateUnsyncedDirectory("F", ids_.MakeLocal("f"));
554 sync_pb::EncryptedData encrypted;
555 sync_pb::EntitySpecifics encrypted_bookmark;
556 encrypted_bookmark.mutable_encrypted();
557 AddDefaultExtensionValue(syncable::BOOKMARKS, &encrypted_bookmark);
558 {
559 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
560 MutableEntry entry_x(&wtrans, GET_BY_HANDLE, handle_x);
561 MutableEntry entry_b(&wtrans, GET_BY_HANDLE, handle_b);
562 MutableEntry entry_c(&wtrans, GET_BY_HANDLE, handle_c);
563 MutableEntry entry_e(&wtrans, GET_BY_HANDLE, handle_e);
564 MutableEntry entry_f(&wtrans, GET_BY_HANDLE, handle_f);
565 entry_x.Put(SPECIFICS, encrypted_bookmark);
566 entry_b.Put(SPECIFICS, DefaultBookmarkSpecifics());
567 entry_c.Put(SPECIFICS, DefaultBookmarkSpecifics());
568 entry_e.Put(SPECIFICS, encrypted_bookmark);
569 entry_f.Put(SPECIFICS, DefaultPreferencesSpecifics());
570 }
571
572 syncable::ModelTypeSet encrypted_types;
573 encrypted_types.insert(syncable::BOOKMARKS);
574 syncable::Directory::UnsyncedMetaHandles unsynced_handles;
575 unsynced_handles.push_back(handle_x);
576 unsynced_handles.push_back(handle_b);
577 unsynced_handles.push_back(handle_c);
578 unsynced_handles.push_back(handle_e);
579 unsynced_handles.push_back(handle_f);
580 // The unencrypted bookmarks should be removed from the list.
581 syncable::Directory::UnsyncedMetaHandles expected_handles;
582 expected_handles.push_back(handle_x); // Was encrypted.
583 expected_handles.push_back(handle_e); // Was encrypted.
584 expected_handles.push_back(handle_f); // Does not require encryption.
585 {
586 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
587 GetCommitIdsCommand::FilterEntriesNeedingEncryption(
588 encrypted_types,
589 &wtrans,
590 &unsynced_handles);
591 EXPECT_EQ(expected_handles, unsynced_handles);
592 }
593 }
594
546 // TODO(chron): More corner case unit tests around validation. 595 // TODO(chron): More corner case unit tests around validation.
547 TEST_F(SyncerTest, TestCommitMetahandleIterator) { 596 TEST_F(SyncerTest, TestCommitMetahandleIterator) {
548 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); 597 ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
549 ASSERT_TRUE(dir.good()); 598 ASSERT_TRUE(dir.good());
550 StatusController* status = session_->status_controller(); 599 StatusController* status = session_->status_controller();
551 const vector<int64>& unsynced(status->unsynced_handles()); 600 const vector<int64>& unsynced(status->unsynced_handles());
552 601
553 { 602 {
554 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir); 603 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir);
555 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans); 604 ScopedSetSessionWriteTransaction set_trans(session_.get(), &wtrans);
(...skipping 4632 matching lines...) Expand 10 before | Expand all | Expand 10 after
5188 Add(low_id_); 5237 Add(low_id_);
5189 Add(high_id_); 5238 Add(high_id_);
5190 SyncShareAsDelegate(); 5239 SyncShareAsDelegate();
5191 ExpectLocalOrderIsByServerId(); 5240 ExpectLocalOrderIsByServerId();
5192 } 5241 }
5193 5242
5194 const SyncerTest::CommitOrderingTest 5243 const SyncerTest::CommitOrderingTest
5195 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()}; 5244 SyncerTest::CommitOrderingTest::LAST_COMMIT_ITEM = {-1, TestIdFactory::root()};
5196 5245
5197 } // namespace browser_sync 5246 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/nigori_util_unittest.cc ('k') | chrome/browser/sync/internal_api/sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698