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

Side by Side Diff: sync/engine/apply_control_data_updates_unittest.cc

Issue 11474036: Remove initial_sync_ended bits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another rebase Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "base/format_macros.h" 5 #include "base/format_macros.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "sync/engine/apply_control_data_updates.h" 9 #include "sync/engine/apply_control_data_updates.h"
10 #include "sync/engine/syncer.h" 10 #include "sync/engine/syncer.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Verify that applying a nigori node sets initial sync ended properly, 61 // Verify that applying a nigori node sets initial sync ended properly,
62 // updates the set of encrypted types, and updates the cryptographer. 62 // updates the set of encrypted types, and updates the cryptographer.
63 TEST_F(ApplyControlDataUpdatesTest, NigoriUpdate) { 63 TEST_F(ApplyControlDataUpdatesTest, NigoriUpdate) {
64 // Storing the cryptographer separately is bad, but for this test we 64 // Storing the cryptographer separately is bad, but for this test we
65 // know it's safe. 65 // know it's safe.
66 Cryptographer* cryptographer; 66 Cryptographer* cryptographer;
67 ModelTypeSet encrypted_types; 67 ModelTypeSet encrypted_types;
68 encrypted_types.PutAll(SyncEncryptionHandler::SensitiveTypes()); 68 encrypted_types.PutAll(SyncEncryptionHandler::SensitiveTypes());
69 69
70 // We start with initial_sync_ended == false. This is wrong, since we would
71 // have no nigori node if that were the case. However, it makes it easier to
72 // verify that ApplyControlDataUpdates sets initial_sync_ended correctly.
73 EXPECT_FALSE(directory()->initial_sync_ended_types().Has(NIGORI));
74
75 { 70 {
76 syncable::ReadTransaction trans(FROM_HERE, directory()); 71 syncable::ReadTransaction trans(FROM_HERE, directory());
77 cryptographer = directory()->GetCryptographer(&trans); 72 cryptographer = directory()->GetCryptographer(&trans);
78 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 73 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
79 .Equals(encrypted_types)); 74 .Equals(encrypted_types));
80 } 75 }
81 76
82 // Nigori node updates should update the Cryptographer. 77 // Nigori node updates should update the Cryptographer.
83 Cryptographer other_cryptographer(cryptographer->encryptor()); 78 Cryptographer other_cryptographer(cryptographer->encryptor());
84 KeyParams params = {"localhost", "dummy", "foobar"}; 79 KeyParams params = {"localhost", "dummy", "foobar"};
85 other_cryptographer.AddKey(params); 80 other_cryptographer.AddKey(params);
86 81
87 sync_pb::EntitySpecifics specifics; 82 sync_pb::EntitySpecifics specifics;
88 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 83 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
89 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag()); 84 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
90 nigori->set_encrypt_everything(true); 85 nigori->set_encrypt_everything(true);
91 entry_factory_->CreateUnappliedNewItem( 86 entry_factory_->CreateUnappliedNewItem(
92 ModelTypeToRootTag(NIGORI), specifics, true); 87 ModelTypeToRootTag(NIGORI), specifics, true);
93 EXPECT_FALSE(cryptographer->has_pending_keys()); 88 EXPECT_FALSE(cryptographer->has_pending_keys());
94 89
95 ApplyControlDataUpdates(session()); 90 ApplyControlDataUpdates(session());
96 91
97 EXPECT_FALSE(cryptographer->is_ready()); 92 EXPECT_FALSE(cryptographer->is_ready());
98 EXPECT_TRUE(cryptographer->has_pending_keys()); 93 EXPECT_TRUE(cryptographer->has_pending_keys());
99 { 94 {
100 syncable::ReadTransaction trans(FROM_HERE, directory()); 95 syncable::ReadTransaction trans(FROM_HERE, directory());
101 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 96 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
102 .Equals(ModelTypeSet::All())); 97 .Equals(ModelTypeSet::All()));
103 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
104 } 98 }
105 } 99 }
106 100
107 // Create some local unsynced and unencrypted data. Apply a nigori update that 101 // Create some local unsynced and unencrypted data. Apply a nigori update that
108 // turns on encryption for the unsynced data. Ensure we properly encrypt the 102 // turns on encryption for the unsynced data. Ensure we properly encrypt the
109 // data as part of the nigori update. Apply another nigori update with no 103 // data as part of the nigori update. Apply another nigori update with no
110 // changes. Ensure we ignore already-encrypted unsynced data and that nothing 104 // changes. Ensure we ignore already-encrypted unsynced data and that nothing
111 // breaks. 105 // breaks.
112 TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { 106 TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) {
113 // Storing the cryptographer separately is bad, but for this test we 107 // Storing the cryptographer separately is bad, but for this test we
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 370 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
377 nigori().encryption_keybag())); 371 nigori().encryption_keybag()));
378 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 372 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
379 nigori().keybag_is_frozen()); 373 nigori().keybag_is_frozen());
380 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 374 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
381 nigori().encrypt_everything()); 375 nigori().encrypt_everything());
382 { 376 {
383 syncable::ReadTransaction trans(FROM_HERE, directory()); 377 syncable::ReadTransaction trans(FROM_HERE, directory());
384 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 378 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
385 .Equals(ModelTypeSet::All())); 379 .Equals(ModelTypeSet::All()));
386 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
387 } 380 }
388 } 381 }
389 382
390 // Verify we handle a nigori node conflict by merging encryption keys and 383 // Verify we handle a nigori node conflict by merging encryption keys and
391 // types, but preserve the custom passphrase state of the server. 384 // types, but preserve the custom passphrase state of the server.
392 // Initial sync ended should be set. 385 // Initial sync ended should be set.
393 TEST_F(ApplyControlDataUpdatesTest, 386 TEST_F(ApplyControlDataUpdatesTest,
394 NigoriConflictPendingKeysLocalEncryptEverythingCustom) { 387 NigoriConflictPendingKeysLocalEncryptEverythingCustom) {
395 Cryptographer* cryptographer; 388 Cryptographer* cryptographer;
396 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 389 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 448 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
456 nigori().encryption_keybag())); 449 nigori().encryption_keybag()));
457 EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 450 EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
458 nigori().keybag_is_frozen()); 451 nigori().keybag_is_frozen());
459 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 452 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
460 nigori().encrypt_everything()); 453 nigori().encrypt_everything());
461 { 454 {
462 syncable::ReadTransaction trans(FROM_HERE, directory()); 455 syncable::ReadTransaction trans(FROM_HERE, directory());
463 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 456 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
464 .Equals(ModelTypeSet::All())); 457 .Equals(ModelTypeSet::All()));
465 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
466 } 458 }
467 } 459 }
468 460
469 // If the conflicting nigori has a subset of the local keys, the conflict 461 // If the conflicting nigori has a subset of the local keys, the conflict
470 // resolution should preserve the full local keys. Initial sync ended should be 462 // resolution should preserve the full local keys. Initial sync ended should be
471 // set. 463 // set.
472 TEST_F(ApplyControlDataUpdatesTest, 464 TEST_F(ApplyControlDataUpdatesTest,
473 NigoriConflictOldKeys) { 465 NigoriConflictOldKeys) {
474 Cryptographer* cryptographer; 466 Cryptographer* cryptographer;
475 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 467 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 519 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
528 nigori().encryption_keybag())); 520 nigori().encryption_keybag()));
529 EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 521 EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
530 nigori().keybag_is_frozen()); 522 nigori().keybag_is_frozen());
531 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 523 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
532 nigori().encrypt_everything()); 524 nigori().encrypt_everything());
533 { 525 {
534 syncable::ReadTransaction trans(FROM_HERE, directory()); 526 syncable::ReadTransaction trans(FROM_HERE, directory());
535 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 527 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
536 .Equals(ModelTypeSet::All())); 528 .Equals(ModelTypeSet::All()));
537 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
538 } 529 }
539 } 530 }
540 531
541 // If both nigoris are migrated, but we also set a custom passphrase locally, 532 // If both nigoris are migrated, but we also set a custom passphrase locally,
542 // the local nigori should be preserved. 533 // the local nigori should be preserved.
543 TEST_F(ApplyControlDataUpdatesTest, 534 TEST_F(ApplyControlDataUpdatesTest,
544 NigoriConflictBothMigratedLocalCustom) { 535 NigoriConflictBothMigratedLocalCustom) {
545 Cryptographer* cryptographer; 536 Cryptographer* cryptographer;
546 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 537 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
547 KeyParams old_params = {"localhost", "dummy", "old"}; 538 KeyParams old_params = {"localhost", "dummy", "old"};
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 nigori().keybag_is_frozen()); 601 nigori().keybag_is_frozen());
611 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 602 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
612 nigori().encrypt_everything()); 603 nigori().encrypt_everything());
613 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, 604 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
614 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 605 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
615 nigori().passphrase_type()); 606 nigori().passphrase_type());
616 { 607 {
617 syncable::ReadTransaction trans(FROM_HERE, directory()); 608 syncable::ReadTransaction trans(FROM_HERE, directory());
618 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 609 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
619 .Equals(ModelTypeSet::All())); 610 .Equals(ModelTypeSet::All()));
620 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
621 } 611 }
622 } 612 }
623 613
624 // If both nigoris are migrated, but a custom passphrase with a new key was 614 // If both nigoris are migrated, but a custom passphrase with a new key was
625 // set remotely, the remote nigori should be preserved. 615 // set remotely, the remote nigori should be preserved.
626 TEST_F(ApplyControlDataUpdatesTest, 616 TEST_F(ApplyControlDataUpdatesTest,
627 NigoriConflictBothMigratedServerCustom) { 617 NigoriConflictBothMigratedServerCustom) {
628 Cryptographer* cryptographer; 618 Cryptographer* cryptographer;
629 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 619 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
630 KeyParams old_params = {"localhost", "dummy", "old"}; 620 KeyParams old_params = {"localhost", "dummy", "old"};
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 nigori().keybag_is_frozen()); 684 nigori().keybag_is_frozen());
695 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 685 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
696 nigori().encrypt_everything()); 686 nigori().encrypt_everything());
697 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, 687 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
698 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 688 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
699 nigori().passphrase_type()); 689 nigori().passphrase_type());
700 { 690 {
701 syncable::ReadTransaction trans(FROM_HERE, directory()); 691 syncable::ReadTransaction trans(FROM_HERE, directory());
702 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 692 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
703 .Equals(ModelTypeSet::All())); 693 .Equals(ModelTypeSet::All()));
704 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
705 } 694 }
706 } 695 }
707 696
708 // If the local nigori is migrated but the server is not, preserve the local 697 // If the local nigori is migrated but the server is not, preserve the local
709 // nigori. 698 // nigori.
710 TEST_F(ApplyControlDataUpdatesTest, 699 TEST_F(ApplyControlDataUpdatesTest,
711 NigoriConflictLocalMigrated) { 700 NigoriConflictLocalMigrated) {
712 Cryptographer* cryptographer; 701 Cryptographer* cryptographer;
713 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 702 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
714 KeyParams old_params = {"localhost", "dummy", "old"}; 703 KeyParams old_params = {"localhost", "dummy", "old"};
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 nigori().keybag_is_frozen()); 763 nigori().keybag_is_frozen());
775 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 764 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
776 nigori().encrypt_everything()); 765 nigori().encrypt_everything());
777 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, 766 EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE,
778 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 767 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
779 nigori().passphrase_type()); 768 nigori().passphrase_type());
780 { 769 {
781 syncable::ReadTransaction trans(FROM_HERE, directory()); 770 syncable::ReadTransaction trans(FROM_HERE, directory());
782 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans) 771 EXPECT_TRUE(directory()->GetNigoriHandler()->GetEncryptedTypes(&trans)
783 .Equals(ModelTypeSet::All())); 772 .Equals(ModelTypeSet::All()));
784 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
785 } 773 }
786 } 774 }
787 775
788 // If the server nigori is migrated but the local is not, preserve the server 776 // If the server nigori is migrated but the local is not, preserve the server
789 // nigori. 777 // nigori.
790 TEST_F(ApplyControlDataUpdatesTest, 778 TEST_F(ApplyControlDataUpdatesTest,
791 NigoriConflictServerMigrated) { 779 NigoriConflictServerMigrated) {
792 Cryptographer* cryptographer; 780 Cryptographer* cryptographer;
793 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); 781 ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes());
794 KeyParams old_params = {"localhost", "dummy", "old"}; 782 KeyParams old_params = {"localhost", "dummy", "old"};
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 nigori().encryption_keybag())); 847 nigori().encryption_keybag()));
860 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 848 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
861 nigori().keybag_is_frozen()); 849 nigori().keybag_is_frozen());
862 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). 850 EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle).
863 nigori().has_keystore_decryptor_token()); 851 nigori().has_keystore_decryptor_token());
864 EXPECT_EQ(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE, 852 EXPECT_EQ(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE,
865 entry_factory_->GetLocalSpecificsForItem(nigori_handle). 853 entry_factory_->GetLocalSpecificsForItem(nigori_handle).
866 nigori().passphrase_type()); 854 nigori().passphrase_type());
867 { 855 {
868 syncable::ReadTransaction trans(FROM_HERE, directory()); 856 syncable::ReadTransaction trans(FROM_HERE, directory());
869 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(NIGORI));
870 } 857 }
871 } 858 }
872 859
873 // Check that we can apply a simple control datatype node successfully. 860 // Check that we can apply a simple control datatype node successfully.
874 TEST_F(ApplyControlDataUpdatesTest, ControlApply) { 861 TEST_F(ApplyControlDataUpdatesTest, ControlApply) {
875 EXPECT_FALSE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
876
877 std::string experiment_id = "experiment"; 862 std::string experiment_id = "experiment";
878 sync_pb::EntitySpecifics specifics; 863 sync_pb::EntitySpecifics specifics;
879 specifics.mutable_experiments()->mutable_keystore_encryption()-> 864 specifics.mutable_experiments()->mutable_keystore_encryption()->
880 set_enabled(true); 865 set_enabled(true);
881 int64 experiment_handle = entry_factory_->CreateUnappliedNewItem( 866 int64 experiment_handle = entry_factory_->CreateUnappliedNewItem(
882 experiment_id, specifics, false); 867 experiment_id, specifics, false);
883 ApplyControlDataUpdates(session()); 868 ApplyControlDataUpdates(session());
884 869
885 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
886 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); 870 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
887 EXPECT_TRUE( 871 EXPECT_TRUE(
888 entry_factory_->GetLocalSpecificsForItem(experiment_handle). 872 entry_factory_->GetLocalSpecificsForItem(experiment_handle).
889 experiments().keystore_encryption().enabled()); 873 experiments().keystore_encryption().enabled());
890 } 874 }
891 875
892 // Verify that we apply top level folders before their children. 876 // Verify that we apply top level folders before their children.
893 TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { 877 TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) {
894 EXPECT_FALSE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
895
896 std::string parent_id = "parent"; 878 std::string parent_id = "parent";
897 std::string experiment_id = "experiment"; 879 std::string experiment_id = "experiment";
898 sync_pb::EntitySpecifics specifics; 880 sync_pb::EntitySpecifics specifics;
899 specifics.mutable_experiments()->mutable_keystore_encryption()-> 881 specifics.mutable_experiments()->mutable_keystore_encryption()->
900 set_enabled(true); 882 set_enabled(true);
901 int64 experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent( 883 int64 experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent(
902 experiment_id, specifics, parent_id); 884 experiment_id, specifics, parent_id);
903 int64 parent_handle = entry_factory_->CreateUnappliedNewItem( 885 int64 parent_handle = entry_factory_->CreateUnappliedNewItem(
904 parent_id, specifics, true); 886 parent_id, specifics, true);
905 ApplyControlDataUpdates(session()); 887 ApplyControlDataUpdates(session());
906 888
907 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
908 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle)); 889 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle));
909 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); 890 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
910 EXPECT_TRUE( 891 EXPECT_TRUE(
911 entry_factory_->GetLocalSpecificsForItem(experiment_handle). 892 entry_factory_->GetLocalSpecificsForItem(experiment_handle).
912 experiments().keystore_encryption().enabled()); 893 experiments().keystore_encryption().enabled());
913 } 894 }
914 895
915 // Verify that we handle control datatype conflicts by preserving the server 896 // Verify that we handle control datatype conflicts by preserving the server
916 // data. 897 // data.
917 TEST_F(ApplyControlDataUpdatesTest, ControlConflict) { 898 TEST_F(ApplyControlDataUpdatesTest, ControlConflict) {
918 EXPECT_FALSE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
919
920 std::string experiment_id = "experiment"; 899 std::string experiment_id = "experiment";
921 sync_pb::EntitySpecifics local_specifics, server_specifics; 900 sync_pb::EntitySpecifics local_specifics, server_specifics;
922 server_specifics.mutable_experiments()->mutable_keystore_encryption()-> 901 server_specifics.mutable_experiments()->mutable_keystore_encryption()->
923 set_enabled(true); 902 set_enabled(true);
924 local_specifics.mutable_experiments()->mutable_keystore_encryption()-> 903 local_specifics.mutable_experiments()->mutable_keystore_encryption()->
925 set_enabled(false); 904 set_enabled(false);
926 int64 experiment_handle = entry_factory_->CreateSyncedItem( 905 int64 experiment_handle = entry_factory_->CreateSyncedItem(
927 experiment_id, EXPERIMENTS, false); 906 experiment_id, EXPERIMENTS, false);
928 entry_factory_->SetServerSpecificsForItem(experiment_handle, 907 entry_factory_->SetServerSpecificsForItem(experiment_handle,
929 server_specifics); 908 server_specifics);
930 entry_factory_->SetLocalSpecificsForItem(experiment_handle, 909 entry_factory_->SetLocalSpecificsForItem(experiment_handle,
931 local_specifics); 910 local_specifics);
932 ApplyControlDataUpdates(session()); 911 ApplyControlDataUpdates(session());
933 912
934 EXPECT_TRUE(directory()->initial_sync_ended_types().Has(EXPERIMENTS));
935 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); 913 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle));
936 EXPECT_TRUE( 914 EXPECT_TRUE(
937 entry_factory_->GetLocalSpecificsForItem(experiment_handle). 915 entry_factory_->GetLocalSpecificsForItem(experiment_handle).
938 experiments().keystore_encryption().enabled()); 916 experiments().keystore_encryption().enabled());
939 } 917 }
940 918
941 } // namespace syncer 919 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/apply_control_data_updates.cc ('k') | sync/engine/apply_updates_and_resolve_conflicts_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698