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

Side by Side Diff: chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc

Issue 1396883005: Reland: Enable Wallet metadata sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, EnabledViaPreference) { 132 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, EnabledViaPreference) {
133 SetPreexistingPreferencesFileContents(kWalletSyncEnabledPreferencesContents); 133 SetPreexistingPreferencesFileContents(kWalletSyncEnabledPreferencesContents);
134 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 134 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
135 // The type should not be enabled without the experiment enabled. 135 // The type should not be enabled without the experiment enabled.
136 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( 136 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
137 syncer::AUTOFILL_WALLET_DATA)); 137 syncer::AUTOFILL_WALLET_DATA));
138 // TODO(pvalenzuela): Assert that the local root node for AUTOFILL_WALLET_DATA 138 // TODO(pvalenzuela): Assert that the local root node for AUTOFILL_WALLET_DATA
139 // exists. 139 // exists.
140 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes().Has( 140 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
141 syncer::AUTOFILL_WALLET_METADATA)); 141 syncer::AUTOFILL_WALLET_METADATA));
142 } 142 }
143 143
144 // Tests that an experiment received at sync startup time (during sign-in) 144 // Tests that an experiment received at sync startup time (during sign-in)
145 // enables the wallet datatype. 145 // enables the wallet datatype.
146 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, 146 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest,
147 EnabledViaExperimentStartup) { 147 EnabledViaExperimentStartup) {
148 sync_pb::EntitySpecifics experiment_entity; 148 sync_pb::EntitySpecifics experiment_entity;
149 sync_pb::ExperimentsSpecifics* experiment_specifics = 149 sync_pb::ExperimentsSpecifics* experiment_specifics =
150 experiment_entity.mutable_experiments(); 150 experiment_entity.mutable_experiments();
151 experiment_specifics->mutable_wallet_sync()->set_enabled(true); 151 experiment_specifics->mutable_wallet_sync()->set_enabled(true);
152 GetFakeServer()->InjectEntity( 152 GetFakeServer()->InjectEntity(
153 fake_server::UniqueClientEntity::CreateForInjection( 153 fake_server::UniqueClientEntity::CreateForInjection(
154 kWalletSyncExperimentTag, 154 kWalletSyncExperimentTag,
155 experiment_entity)); 155 experiment_entity));
156 156
157 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 157 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
158 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( 158 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
159 syncer::AUTOFILL_WALLET_DATA)); 159 syncer::AUTOFILL_WALLET_DATA));
160 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes().Has( 160 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
161 syncer::AUTOFILL_WALLET_METADATA)); 161 syncer::AUTOFILL_WALLET_METADATA));
162 } 162 }
163 163
164 // Tests receiving an enable experiment at runtime, followed by a disabled 164 // Tests receiving an enable experiment at runtime, followed by a disabled
165 // experiment, and verifies the datatype is enabled/disabled as necessary. 165 // experiment, and verifies the datatype is enabled/disabled as necessary.
166 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, 166 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest,
167 EnabledDisabledViaExperiment) { 167 EnabledDisabledViaExperiment) {
168 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 168 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
169 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes(). 169 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes().
170 Has(syncer::AUTOFILL_WALLET_DATA)); 170 Has(syncer::AUTOFILL_WALLET_DATA));
171 171
172 sync_pb::EntitySpecifics experiment_entity; 172 sync_pb::EntitySpecifics experiment_entity;
173 sync_pb::ExperimentsSpecifics* experiment_specifics = 173 sync_pb::ExperimentsSpecifics* experiment_specifics =
174 experiment_entity.mutable_experiments(); 174 experiment_entity.mutable_experiments();
175 175
176 // First enable the experiment. 176 // First enable the experiment.
177 experiment_specifics->mutable_wallet_sync()->set_enabled(true); 177 experiment_specifics->mutable_wallet_sync()->set_enabled(true);
178 GetFakeServer()->InjectEntity( 178 GetFakeServer()->InjectEntity(
179 fake_server::UniqueClientEntity::CreateForInjection( 179 fake_server::UniqueClientEntity::CreateForInjection(
180 kWalletSyncExperimentTag, experiment_entity)); 180 kWalletSyncExperimentTag, experiment_entity));
181 TriggerSyncCycle(); 181 TriggerSyncCycle();
182 182
183 WalletEnabledChecker enabled_checker; 183 WalletEnabledChecker enabled_checker;
184 enabled_checker.Wait(); 184 enabled_checker.Wait();
185 ASSERT_FALSE(enabled_checker.TimedOut()); 185 ASSERT_FALSE(enabled_checker.TimedOut());
186 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( 186 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
187 syncer::AUTOFILL_WALLET_DATA)); 187 syncer::AUTOFILL_WALLET_DATA));
188 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes().Has( 188 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
189 syncer::AUTOFILL_WALLET_METADATA)); 189 syncer::AUTOFILL_WALLET_METADATA));
190 190
191 // Then disable the experiment. 191 // Then disable the experiment.
192 experiment_specifics->mutable_wallet_sync()->set_enabled(false); 192 experiment_specifics->mutable_wallet_sync()->set_enabled(false);
193 GetFakeServer()->InjectEntity( 193 GetFakeServer()->InjectEntity(
194 fake_server::UniqueClientEntity::CreateForInjection( 194 fake_server::UniqueClientEntity::CreateForInjection(
195 kWalletSyncExperimentTag, experiment_entity)); 195 kWalletSyncExperimentTag, experiment_entity));
196 TriggerSyncCycle(); 196 TriggerSyncCycle();
197 197
198 WalletDisabledChecker disable_checker; 198 WalletDisabledChecker disable_checker;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); 276 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards();
277 ASSERT_EQ(1uL, cards.size()); 277 ASSERT_EQ(1uL, cards.size());
278 278
279 // Turn off the wallet autofill pref, the card should be gone as a side 279 // Turn off the wallet autofill pref, the card should be gone as a side
280 // effect of the wallet data type controller noticing. 280 // effect of the wallet data type controller noticing.
281 GetProfile(0)->GetPrefs()->SetBoolean( 281 GetProfile(0)->GetPrefs()->SetBoolean(
282 autofill::prefs::kAutofillWalletImportEnabled, false); 282 autofill::prefs::kAutofillWalletImportEnabled, false);
283 cards = pdm->GetCreditCards(); 283 cards = pdm->GetCreditCards();
284 ASSERT_EQ(0uL, cards.size()); 284 ASSERT_EQ(0uL, cards.size());
285 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698