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 #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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "sync/engine/apply_control_data_updates.h" | 10 #include "sync/engine/apply_control_data_updates.h" |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 entry_factory_->SetLocalSpecificsForItem(experiment_handle, | 907 entry_factory_->SetLocalSpecificsForItem(experiment_handle, |
908 local_specifics); | 908 local_specifics); |
909 ApplyControlDataUpdates(directory()); | 909 ApplyControlDataUpdates(directory()); |
910 | 910 |
911 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); | 911 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
912 EXPECT_TRUE( | 912 EXPECT_TRUE( |
913 entry_factory_->GetLocalSpecificsForItem(experiment_handle). | 913 entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
914 experiments().keystore_encryption().enabled()); | 914 experiments().keystore_encryption().enabled()); |
915 } | 915 } |
916 | 916 |
| 917 // Check that applying a EXPERIMENTS update marks the datatype as downloaded. |
| 918 TEST_F(ApplyControlDataUpdatesTest, ExperimentsApplyMarksDownloadCompleted) { |
| 919 EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS)); |
| 920 |
| 921 // Create root node for EXPERIMENTS datatype |
| 922 { |
| 923 syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory()); |
| 924 syncable::ModelNeutralMutableEntry entry( |
| 925 &trans, syncable::CREATE_NEW_TYPE_ROOT, EXPERIMENTS); |
| 926 ASSERT_TRUE(entry.good()); |
| 927 entry.PutServerIsDir(true); |
| 928 entry.PutUniqueServerTag(ModelTypeToRootTag(EXPERIMENTS)); |
| 929 } |
| 930 |
| 931 // Initial sync isn't marked as ended for EXPERIMENTS even though the |
| 932 // root folder exists. |
| 933 EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS)); |
| 934 |
| 935 std::string experiment_id = "experiment"; |
| 936 sync_pb::EntitySpecifics specifics; |
| 937 specifics.mutable_experiments()->mutable_keystore_encryption()->set_enabled( |
| 938 true); |
| 939 entry_factory_->CreateUnappliedNewItem(experiment_id, specifics, false); |
| 940 |
| 941 ApplyControlDataUpdates(directory()); |
| 942 |
| 943 // After applying the updates EXPERIMENTS should be marked as having its |
| 944 // initial sync completed. |
| 945 EXPECT_TRUE(directory()->InitialSyncEndedForType(EXPERIMENTS)); |
| 946 // Verify that there is no side effect on another control type. |
| 947 EXPECT_FALSE(directory()->InitialSyncEndedForType(NIGORI)); |
| 948 } |
| 949 |
| 950 // Check that applying a NIGORI update marks the datatype as downloaded. |
| 951 TEST_F(ApplyControlDataUpdatesTest, NigoriApplyMarksDownloadCompleted) { |
| 952 EXPECT_FALSE(directory()->InitialSyncEndedForType(NIGORI)); |
| 953 |
| 954 Cryptographer* cryptographer; |
| 955 |
| 956 { |
| 957 syncable::ReadTransaction trans(FROM_HERE, directory()); |
| 958 cryptographer = directory()->GetCryptographer(&trans); |
| 959 } |
| 960 |
| 961 KeyParams params = {"localhost", "dummy", "foobar"}; |
| 962 cryptographer->AddKey(params); |
| 963 sync_pb::EntitySpecifics specifics; |
| 964 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
| 965 cryptographer->GetKeys(nigori->mutable_encryption_keybag()); |
| 966 nigori->set_encrypt_everything(true); |
| 967 |
| 968 entry_factory_->CreateUnappliedNewItem(ModelTypeToRootTag(NIGORI), specifics, |
| 969 true); |
| 970 |
| 971 ApplyControlDataUpdates(directory()); |
| 972 |
| 973 // After applying the updates NIGORI should be marked as having its |
| 974 // initial sync completed. |
| 975 EXPECT_TRUE(directory()->InitialSyncEndedForType(NIGORI)); |
| 976 // Verify that there is no side effect on another control type. |
| 977 EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS)); |
| 978 } |
| 979 |
917 } // namespace syncer | 980 } // namespace syncer |
OLD | NEW |