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

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

Issue 8851006: [Sync] Replace all instances of ModelTypeSet with ModelEnumSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup pass #2 Created 9 years 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 #include <string> 5 #include <string>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/sync/engine/apply_updates_command.h" 10 #include "chrome/browser/sync/engine/apply_updates_command.h"
11 #include "chrome/browser/sync/engine/nigori_util.h" 11 #include "chrome/browser/sync/engine/nigori_util.h"
12 #include "chrome/browser/sync/engine/syncer.h" 12 #include "chrome/browser/sync/engine/syncer.h"
13 #include "chrome/browser/sync/engine/syncer_util.h" 13 #include "chrome/browser/sync/engine/syncer_util.h"
14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
15 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 15 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
16 #include "chrome/browser/sync/sessions/sync_session.h" 16 #include "chrome/browser/sync/sessions/sync_session.h"
17 #include "chrome/browser/sync/syncable/directory_manager.h" 17 #include "chrome/browser/sync/syncable/directory_manager.h"
18 #include "chrome/browser/sync/syncable/syncable.h" 18 #include "chrome/browser/sync/syncable/syncable.h"
19 #include "chrome/browser/sync/syncable/syncable_id.h" 19 #include "chrome/browser/sync/syncable/syncable_id.h"
20 #include "chrome/browser/sync/test/engine/fake_model_worker.h" 20 #include "chrome/browser/sync/test/engine/fake_model_worker.h"
21 #include "chrome/browser/sync/test/engine/syncer_command_test.h" 21 #include "chrome/browser/sync/test/engine/syncer_command_test.h"
22 #include "chrome/browser/sync/test/engine/test_id_factory.h" 22 #include "chrome/browser/sync/test/engine/test_id_factory.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace browser_sync { 25 namespace browser_sync {
26 26
27 using sessions::SyncSession; 27 using sessions::SyncSession;
28 using std::string; 28 using std::string;
29 using syncable::Entry; 29 using syncable::Entry;
30 using syncable::GetAllRealModelTypes;
31 using syncable::Id; 30 using syncable::Id;
32 using syncable::MutableEntry; 31 using syncable::MutableEntry;
33 using syncable::ReadTransaction; 32 using syncable::ReadTransaction;
34 using syncable::ScopedDirLookup; 33 using syncable::ScopedDirLookup;
35 using syncable::UNITTEST; 34 using syncable::UNITTEST;
36 using syncable::WriteTransaction; 35 using syncable::WriteTransaction;
37 36
38 namespace { 37 namespace {
39 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { 38 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() {
40 sync_pb::EntitySpecifics result; 39 sync_pb::EntitySpecifics result;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 << "conflict"; 419 << "conflict";
421 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) 420 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount())
422 << "The undecryptable password update shouldn't be applied"; 421 << "The undecryptable password update shouldn't be applied";
423 } 422 }
424 } 423 }
425 424
426 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) { 425 TEST_F(ApplyUpdatesCommandTest, NigoriUpdate) {
427 // Storing the cryptographer separately is bad, but for this test we 426 // Storing the cryptographer separately is bad, but for this test we
428 // know it's safe. 427 // know it's safe.
429 Cryptographer* cryptographer; 428 Cryptographer* cryptographer;
430 syncable::ModelTypeSet encrypted_types; 429 syncable::ModelEnumSet encrypted_types;
431 encrypted_types.insert(syncable::PASSWORDS); 430 encrypted_types.Put(syncable::PASSWORDS);
432 encrypted_types.insert(syncable::NIGORI); 431 encrypted_types.Put(syncable::NIGORI);
433 { 432 {
434 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 433 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
435 ASSERT_TRUE(dir.good()); 434 ASSERT_TRUE(dir.good());
436 ReadTransaction trans(FROM_HERE, dir); 435 ReadTransaction trans(FROM_HERE, dir);
437 cryptographer = 436 cryptographer =
438 session()->context()->directory_manager()->GetCryptographer(&trans); 437 session()->context()->directory_manager()->GetCryptographer(&trans);
439 EXPECT_EQ(encrypted_types, cryptographer->GetEncryptedTypes()); 438 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals(encrypted_types));
440 } 439 }
441 440
442 // Nigori node updates should update the Cryptographer. 441 // Nigori node updates should update the Cryptographer.
443 Cryptographer other_cryptographer; 442 Cryptographer other_cryptographer;
444 KeyParams params = {"localhost", "dummy", "foobar"}; 443 KeyParams params = {"localhost", "dummy", "foobar"};
445 other_cryptographer.AddKey(params); 444 other_cryptographer.AddKey(params);
446 445
447 sync_pb::EntitySpecifics specifics; 446 sync_pb::EntitySpecifics specifics;
448 sync_pb::NigoriSpecifics* nigori = 447 sync_pb::NigoriSpecifics* nigori =
449 specifics.MutableExtension(sync_pb::nigori); 448 specifics.MutableExtension(sync_pb::nigori);
450 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 449 other_cryptographer.GetKeys(nigori->mutable_encrypted());
451 nigori->set_encrypt_bookmarks(true); 450 nigori->set_encrypt_bookmarks(true);
452 encrypted_types.insert(syncable::BOOKMARKS); 451 encrypted_types.Put(syncable::BOOKMARKS);
453 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), 452 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI),
454 specifics, true); 453 specifics, true);
455 EXPECT_FALSE(cryptographer->has_pending_keys()); 454 EXPECT_FALSE(cryptographer->has_pending_keys());
456 455
457 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); 456 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE);
458 apply_updates_command_.ExecuteImpl(session()); 457 apply_updates_command_.ExecuteImpl(session());
459 458
460 sessions::StatusController* status = session()->mutable_status_controller(); 459 sessions::StatusController* status = session()->mutable_status_controller();
461 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); 460 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
462 ASSERT_TRUE(status->update_progress()); 461 ASSERT_TRUE(status->update_progress());
463 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) 462 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize())
464 << "All updates should have been attempted"; 463 << "All updates should have been attempted";
465 ASSERT_TRUE(status->conflict_progress()); 464 ASSERT_TRUE(status->conflict_progress());
466 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) 465 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize())
467 << "The nigori update shouldn't be in conflict"; 466 << "The nigori update shouldn't be in conflict";
468 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) 467 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount())
469 << "The nigori update should be applied"; 468 << "The nigori update should be applied";
470 469
471 EXPECT_FALSE(cryptographer->is_ready()); 470 EXPECT_FALSE(cryptographer->is_ready());
472 EXPECT_TRUE(cryptographer->has_pending_keys()); 471 EXPECT_TRUE(cryptographer->has_pending_keys());
473 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); 472 EXPECT_TRUE(
473 cryptographer->GetEncryptedTypes()
474 .Equals(syncable::ModelEnumSet::All()));
474 } 475 }
475 476
476 TEST_F(ApplyUpdatesCommandTest, NigoriUpdateForDisabledTypes) { 477 TEST_F(ApplyUpdatesCommandTest, NigoriUpdateForDisabledTypes) {
477 // Storing the cryptographer separately is bad, but for this test we 478 // Storing the cryptographer separately is bad, but for this test we
478 // know it's safe. 479 // know it's safe.
479 Cryptographer* cryptographer; 480 Cryptographer* cryptographer;
480 syncable::ModelTypeSet encrypted_types; 481 syncable::ModelEnumSet encrypted_types;
481 encrypted_types.insert(syncable::PASSWORDS); 482 encrypted_types.Put(syncable::PASSWORDS);
482 encrypted_types.insert(syncable::NIGORI); 483 encrypted_types.Put(syncable::NIGORI);
483 { 484 {
484 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 485 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
485 ASSERT_TRUE(dir.good()); 486 ASSERT_TRUE(dir.good());
486 ReadTransaction trans(FROM_HERE, dir); 487 ReadTransaction trans(FROM_HERE, dir);
487 cryptographer = 488 cryptographer =
488 session()->context()->directory_manager()->GetCryptographer(&trans); 489 session()->context()->directory_manager()->GetCryptographer(&trans);
489 EXPECT_EQ(encrypted_types, cryptographer->GetEncryptedTypes()); 490 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals(encrypted_types));
490 } 491 }
491 492
492 // Nigori node updates should update the Cryptographer. 493 // Nigori node updates should update the Cryptographer.
493 Cryptographer other_cryptographer; 494 Cryptographer other_cryptographer;
494 KeyParams params = {"localhost", "dummy", "foobar"}; 495 KeyParams params = {"localhost", "dummy", "foobar"};
495 other_cryptographer.AddKey(params); 496 other_cryptographer.AddKey(params);
496 497
497 sync_pb::EntitySpecifics specifics; 498 sync_pb::EntitySpecifics specifics;
498 sync_pb::NigoriSpecifics* nigori = 499 sync_pb::NigoriSpecifics* nigori =
499 specifics.MutableExtension(sync_pb::nigori); 500 specifics.MutableExtension(sync_pb::nigori);
500 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 501 other_cryptographer.GetKeys(nigori->mutable_encrypted());
501 nigori->set_encrypt_sessions(true); 502 nigori->set_encrypt_sessions(true);
502 nigori->set_encrypt_themes(true); 503 nigori->set_encrypt_themes(true);
503 encrypted_types.insert(syncable::SESSIONS); 504 encrypted_types.Put(syncable::SESSIONS);
504 encrypted_types.insert(syncable::THEMES); 505 encrypted_types.Put(syncable::THEMES);
505 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), 506 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI),
506 specifics, true); 507 specifics, true);
507 EXPECT_FALSE(cryptographer->has_pending_keys()); 508 EXPECT_FALSE(cryptographer->has_pending_keys());
508 509
509 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); 510 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE);
510 apply_updates_command_.ExecuteImpl(session()); 511 apply_updates_command_.ExecuteImpl(session());
511 512
512 sessions::StatusController* status = session()->mutable_status_controller(); 513 sessions::StatusController* status = session()->mutable_status_controller();
513 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); 514 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
514 ASSERT_TRUE(status->update_progress()); 515 ASSERT_TRUE(status->update_progress());
515 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize()) 516 EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize())
516 << "All updates should have been attempted"; 517 << "All updates should have been attempted";
517 ASSERT_TRUE(status->conflict_progress()); 518 ASSERT_TRUE(status->conflict_progress());
518 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize()) 519 EXPECT_EQ(0, status->conflict_progress()->ConflictingItemsSize())
519 << "The nigori update shouldn't be in conflict"; 520 << "The nigori update shouldn't be in conflict";
520 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount()) 521 EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount())
521 << "The nigori update should be applied"; 522 << "The nigori update should be applied";
522 523
523 EXPECT_FALSE(cryptographer->is_ready()); 524 EXPECT_FALSE(cryptographer->is_ready());
524 EXPECT_TRUE(cryptographer->has_pending_keys()); 525 EXPECT_TRUE(cryptographer->has_pending_keys());
525 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); 526 EXPECT_TRUE(
527 cryptographer->GetEncryptedTypes()
528 .Equals(syncable::ModelEnumSet::All()));
526 } 529 }
527 530
528 TEST_F(ApplyUpdatesCommandTest, EncryptUnsyncedChanges) { 531 TEST_F(ApplyUpdatesCommandTest, EncryptUnsyncedChanges) {
529 // Storing the cryptographer separately is bad, but for this test we 532 // Storing the cryptographer separately is bad, but for this test we
530 // know it's safe. 533 // know it's safe.
531 Cryptographer* cryptographer; 534 Cryptographer* cryptographer;
532 syncable::ModelTypeSet encrypted_types; 535 syncable::ModelEnumSet encrypted_types;
533 encrypted_types.insert(syncable::PASSWORDS); 536 encrypted_types.Put(syncable::PASSWORDS);
534 encrypted_types.insert(syncable::NIGORI); 537 encrypted_types.Put(syncable::NIGORI);
535 { 538 {
536 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 539 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
537 ASSERT_TRUE(dir.good()); 540 ASSERT_TRUE(dir.good());
538 ReadTransaction trans(FROM_HERE, dir); 541 ReadTransaction trans(FROM_HERE, dir);
539 cryptographer = 542 cryptographer =
540 session()->context()->directory_manager()->GetCryptographer(&trans); 543 session()->context()->directory_manager()->GetCryptographer(&trans);
541 EXPECT_EQ(encrypted_types, cryptographer->GetEncryptedTypes()); 544 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals(encrypted_types));
542 545
543 546
544 // With default encrypted_types, this should be true. 547 // With default encrypted_types, this should be true.
545 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 548 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
546 549
547 Syncer::UnsyncedMetaHandles handles; 550 Syncer::UnsyncedMetaHandles handles;
548 SyncerUtil::GetUnsyncedEntries(&trans, &handles); 551 SyncerUtil::GetUnsyncedEntries(&trans, &handles);
549 EXPECT_TRUE(handles.empty()); 552 EXPECT_TRUE(handles.empty());
550 } 553 }
551 554
(...skipping 17 matching lines...) Expand all
569 syncable::BOOKMARKS, NULL); 572 syncable::BOOKMARKS, NULL);
570 } 573 }
571 574
572 KeyParams params = {"localhost", "dummy", "foobar"}; 575 KeyParams params = {"localhost", "dummy", "foobar"};
573 cryptographer->AddKey(params); 576 cryptographer->AddKey(params);
574 sync_pb::EntitySpecifics specifics; 577 sync_pb::EntitySpecifics specifics;
575 sync_pb::NigoriSpecifics* nigori = 578 sync_pb::NigoriSpecifics* nigori =
576 specifics.MutableExtension(sync_pb::nigori); 579 specifics.MutableExtension(sync_pb::nigori);
577 cryptographer->GetKeys(nigori->mutable_encrypted()); 580 cryptographer->GetKeys(nigori->mutable_encrypted());
578 nigori->set_encrypt_bookmarks(true); 581 nigori->set_encrypt_bookmarks(true);
579 encrypted_types.insert(syncable::BOOKMARKS); 582 encrypted_types.Put(syncable::BOOKMARKS);
580 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), 583 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI),
581 specifics, true); 584 specifics, true);
582 EXPECT_FALSE(cryptographer->has_pending_keys()); 585 EXPECT_FALSE(cryptographer->has_pending_keys());
583 EXPECT_TRUE(cryptographer->is_ready()); 586 EXPECT_TRUE(cryptographer->is_ready());
584 587
585 { 588 {
586 // Ensure we have unsynced nodes that aren't properly encrypted. 589 // Ensure we have unsynced nodes that aren't properly encrypted.
587 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 590 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
588 ASSERT_TRUE(dir.good()); 591 ASSERT_TRUE(dir.good());
589 ReadTransaction trans(FROM_HERE, dir); 592 ReadTransaction trans(FROM_HERE, dir);
(...skipping 21 matching lines...) Expand all
611 << "The nigori update should be applied"; 614 << "The nigori update should be applied";
612 EXPECT_FALSE(cryptographer->has_pending_keys()); 615 EXPECT_FALSE(cryptographer->has_pending_keys());
613 EXPECT_TRUE(cryptographer->is_ready()); 616 EXPECT_TRUE(cryptographer->is_ready());
614 { 617 {
615 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 618 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
616 ASSERT_TRUE(dir.good()); 619 ASSERT_TRUE(dir.good());
617 ReadTransaction trans(FROM_HERE, dir); 620 ReadTransaction trans(FROM_HERE, dir);
618 621
619 // If ProcessUnsyncedChangesForEncryption worked, all our unsynced changes 622 // If ProcessUnsyncedChangesForEncryption worked, all our unsynced changes
620 // should be encrypted now. 623 // should be encrypted now.
621 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); 624 EXPECT_TRUE(syncable::ModelEnumSet::All().Equals(
625 cryptographer->GetEncryptedTypes()));
622 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 626 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
623 627
624 Syncer::UnsyncedMetaHandles handles; 628 Syncer::UnsyncedMetaHandles handles;
625 SyncerUtil::GetUnsyncedEntries(&trans, &handles); 629 SyncerUtil::GetUnsyncedEntries(&trans, &handles);
626 EXPECT_EQ(2*batch_s+1, handles.size()); 630 EXPECT_EQ(2*batch_s+1, handles.size());
627 } 631 }
628 } 632 }
629 633
630 TEST_F(ApplyUpdatesCommandTest, CannotEncryptUnsyncedChanges) { 634 TEST_F(ApplyUpdatesCommandTest, CannotEncryptUnsyncedChanges) {
631 // Storing the cryptographer separately is bad, but for this test we 635 // Storing the cryptographer separately is bad, but for this test we
632 // know it's safe. 636 // know it's safe.
633 Cryptographer* cryptographer; 637 Cryptographer* cryptographer;
634 syncable::ModelTypeSet encrypted_types; 638 syncable::ModelEnumSet encrypted_types;
635 encrypted_types.insert(syncable::PASSWORDS); 639 encrypted_types.Put(syncable::PASSWORDS);
636 encrypted_types.insert(syncable::NIGORI); 640 encrypted_types.Put(syncable::NIGORI);
637 { 641 {
638 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 642 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
639 ASSERT_TRUE(dir.good()); 643 ASSERT_TRUE(dir.good());
640 ReadTransaction trans(FROM_HERE, dir); 644 ReadTransaction trans(FROM_HERE, dir);
641 cryptographer = 645 cryptographer =
642 session()->context()->directory_manager()->GetCryptographer(&trans); 646 session()->context()->directory_manager()->GetCryptographer(&trans);
643 EXPECT_EQ(encrypted_types, cryptographer->GetEncryptedTypes()); 647 EXPECT_TRUE(cryptographer->GetEncryptedTypes().Equals(encrypted_types));
644
645 648
646 // With default encrypted_types, this should be true. 649 // With default encrypted_types, this should be true.
647 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 650 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
648 651
649 Syncer::UnsyncedMetaHandles handles; 652 Syncer::UnsyncedMetaHandles handles;
650 SyncerUtil::GetUnsyncedEntries(&trans, &handles); 653 SyncerUtil::GetUnsyncedEntries(&trans, &handles);
651 EXPECT_TRUE(handles.empty()); 654 EXPECT_TRUE(handles.empty());
652 } 655 }
653 656
654 // Create unsynced bookmarks without encryption. 657 // Create unsynced bookmarks without encryption.
(...skipping 19 matching lines...) Expand all
674 // We encrypt with new keys, triggering the local cryptographer to be unready 677 // We encrypt with new keys, triggering the local cryptographer to be unready
675 // and unable to decrypt data (once updated). 678 // and unable to decrypt data (once updated).
676 Cryptographer other_cryptographer; 679 Cryptographer other_cryptographer;
677 KeyParams params = {"localhost", "dummy", "foobar"}; 680 KeyParams params = {"localhost", "dummy", "foobar"};
678 other_cryptographer.AddKey(params); 681 other_cryptographer.AddKey(params);
679 sync_pb::EntitySpecifics specifics; 682 sync_pb::EntitySpecifics specifics;
680 sync_pb::NigoriSpecifics* nigori = 683 sync_pb::NigoriSpecifics* nigori =
681 specifics.MutableExtension(sync_pb::nigori); 684 specifics.MutableExtension(sync_pb::nigori);
682 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 685 other_cryptographer.GetKeys(nigori->mutable_encrypted());
683 nigori->set_encrypt_bookmarks(true); 686 nigori->set_encrypt_bookmarks(true);
684 encrypted_types.insert(syncable::BOOKMARKS); 687 encrypted_types.Put(syncable::BOOKMARKS);
685 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI), 688 CreateUnappliedNewItem(syncable::ModelTypeToRootTag(syncable::NIGORI),
686 specifics, true); 689 specifics, true);
687 EXPECT_FALSE(cryptographer->has_pending_keys()); 690 EXPECT_FALSE(cryptographer->has_pending_keys());
688 691
689 { 692 {
690 // Ensure we have unsynced nodes that aren't properly encrypted. 693 // Ensure we have unsynced nodes that aren't properly encrypted.
691 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 694 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
692 ASSERT_TRUE(dir.good()); 695 ASSERT_TRUE(dir.good());
693 ReadTransaction trans(FROM_HERE, dir); 696 ReadTransaction trans(FROM_HERE, dir);
694 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 697 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
(...skipping 23 matching lines...) Expand all
718 EXPECT_TRUE(cryptographer->has_pending_keys()); 721 EXPECT_TRUE(cryptographer->has_pending_keys());
719 { 722 {
720 // Ensure the unsynced nodes are still not encrypted. 723 // Ensure the unsynced nodes are still not encrypted.
721 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name()); 724 ScopedDirLookup dir(syncdb()->manager(), syncdb()->name());
722 ASSERT_TRUE(dir.good()); 725 ASSERT_TRUE(dir.good());
723 ReadTransaction trans(FROM_HERE, dir); 726 ReadTransaction trans(FROM_HERE, dir);
724 727
725 // Since we're in conflict, the specifics don't reflect the unapplied 728 // Since we're in conflict, the specifics don't reflect the unapplied
726 // changes. 729 // changes.
727 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 730 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
728 encrypted_types.clear(); 731 encrypted_types.Clear();
729 encrypted_types.insert(syncable::PASSWORDS); 732 encrypted_types.Put(syncable::PASSWORDS);
730 encrypted_types.insert(syncable::BOOKMARKS); 733 encrypted_types.Put(syncable::BOOKMARKS);
731 EXPECT_EQ(GetAllRealModelTypes(), cryptographer->GetEncryptedTypes()); 734 EXPECT_TRUE(
735 cryptographer->GetEncryptedTypes().Equals(
736 syncable::ModelEnumSet().All()));
732 737
733 Syncer::UnsyncedMetaHandles handles; 738 Syncer::UnsyncedMetaHandles handles;
734 SyncerUtil::GetUnsyncedEntries(&trans, &handles); 739 SyncerUtil::GetUnsyncedEntries(&trans, &handles);
735 EXPECT_EQ(2*batch_s+1, handles.size()); 740 EXPECT_EQ(2*batch_s+1, handles.size());
736 } 741 }
737 } 742 }
738 743
739 } // namespace browser_sync 744 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/all_status.cc ('k') | chrome/browser/sync/engine/get_commit_ids_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698