| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 wallet_specifics->mutable_masked_card(); | 55 wallet_specifics->mutable_masked_card(); |
| 56 credit_card->set_id(kDefaultCardID); | 56 credit_card->set_id(kDefaultCardID); |
| 57 credit_card->set_exp_month(kDefaultCardExpMonth); | 57 credit_card->set_exp_month(kDefaultCardExpMonth); |
| 58 credit_card->set_exp_year(kDefaultCardExpYear); | 58 credit_card->set_exp_year(kDefaultCardExpYear); |
| 59 credit_card->set_last_four(kDefaultCardLastFour); | 59 credit_card->set_last_four(kDefaultCardLastFour); |
| 60 credit_card->set_name_on_card(kDefaultCardName); | 60 credit_card->set_name_on_card(kDefaultCardName); |
| 61 credit_card->set_status(sync_pb::WalletMaskedCreditCard::VALID); | 61 credit_card->set_status(sync_pb::WalletMaskedCreditCard::VALID); |
| 62 credit_card->set_type(kDefaultCardType); | 62 credit_card->set_type(kDefaultCardType); |
| 63 | 63 |
| 64 server->InjectEntity(fake_server::UniqueClientEntity::CreateForInjection( | 64 server->InjectEntity(fake_server::UniqueClientEntity::CreateForInjection( |
| 65 syncer::AUTOFILL_WALLET_DATA, | |
| 66 kDefaultCardID, | 65 kDefaultCardID, |
| 67 specifics)); | 66 specifics)); |
| 68 } | 67 } |
| 69 | 68 |
| 70 } // namespace | 69 } // namespace |
| 71 | 70 |
| 72 class SingleClientWalletSyncTest : public SyncTest { | 71 class SingleClientWalletSyncTest : public SyncTest { |
| 73 public: | 72 public: |
| 74 SingleClientWalletSyncTest() : SyncTest(SINGLE_CLIENT) {} | 73 SingleClientWalletSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 75 ~SingleClientWalletSyncTest() override {} | 74 ~SingleClientWalletSyncTest() override {} |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Tests that an experiment received at sync startup time (during sign-in) | 143 // Tests that an experiment received at sync startup time (during sign-in) |
| 145 // enables the wallet datatype. | 144 // enables the wallet datatype. |
| 146 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, | 145 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, |
| 147 EnabledViaExperimentStartup) { | 146 EnabledViaExperimentStartup) { |
| 148 sync_pb::EntitySpecifics experiment_entity; | 147 sync_pb::EntitySpecifics experiment_entity; |
| 149 sync_pb::ExperimentsSpecifics* experiment_specifics = | 148 sync_pb::ExperimentsSpecifics* experiment_specifics = |
| 150 experiment_entity.mutable_experiments(); | 149 experiment_entity.mutable_experiments(); |
| 151 experiment_specifics->mutable_wallet_sync()->set_enabled(true); | 150 experiment_specifics->mutable_wallet_sync()->set_enabled(true); |
| 152 GetFakeServer()->InjectEntity( | 151 GetFakeServer()->InjectEntity( |
| 153 fake_server::UniqueClientEntity::CreateForInjection( | 152 fake_server::UniqueClientEntity::CreateForInjection( |
| 154 syncer::EXPERIMENTS, | |
| 155 kWalletSyncExperimentTag, | 153 kWalletSyncExperimentTag, |
| 156 experiment_entity)); | 154 experiment_entity)); |
| 157 | 155 |
| 158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; | 156 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; |
| 159 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( | 157 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( |
| 160 syncer::AUTOFILL_WALLET_DATA)); | 158 syncer::AUTOFILL_WALLET_DATA)); |
| 161 } | 159 } |
| 162 | 160 |
| 163 // Tests receiving an enable experiment at runtime, followed by a disabled | 161 // Tests receiving an enable experiment at runtime, followed by a disabled |
| 164 // experiment, and verifies the datatype is enabled/disabled as necessary. | 162 // experiment, and verifies the datatype is enabled/disabled as necessary. |
| 165 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, | 163 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, |
| 166 EnabledDisabledViaExperiment) { | 164 EnabledDisabledViaExperiment) { |
| 167 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; | 165 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; |
| 168 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes(). | 166 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes(). |
| 169 Has(syncer::AUTOFILL_WALLET_DATA)); | 167 Has(syncer::AUTOFILL_WALLET_DATA)); |
| 170 | 168 |
| 171 sync_pb::EntitySpecifics experiment_entity; | 169 sync_pb::EntitySpecifics experiment_entity; |
| 172 sync_pb::ExperimentsSpecifics* experiment_specifics = | 170 sync_pb::ExperimentsSpecifics* experiment_specifics = |
| 173 experiment_entity.mutable_experiments(); | 171 experiment_entity.mutable_experiments(); |
| 174 | 172 |
| 175 // First enable the experiment. | 173 // First enable the experiment. |
| 176 experiment_specifics->mutable_wallet_sync()->set_enabled(true); | 174 experiment_specifics->mutable_wallet_sync()->set_enabled(true); |
| 177 GetFakeServer()->InjectEntity( | 175 GetFakeServer()->InjectEntity( |
| 178 fake_server::UniqueClientEntity::CreateForInjection( | 176 fake_server::UniqueClientEntity::CreateForInjection( |
| 179 syncer::EXPERIMENTS, kWalletSyncExperimentTag, experiment_entity)); | 177 kWalletSyncExperimentTag, experiment_entity)); |
| 180 TriggerSyncCycle(); | 178 TriggerSyncCycle(); |
| 181 | 179 |
| 182 WalletEnabledChecker enabled_checker; | 180 WalletEnabledChecker enabled_checker; |
| 183 enabled_checker.Wait(); | 181 enabled_checker.Wait(); |
| 184 ASSERT_FALSE(enabled_checker.TimedOut()); | 182 ASSERT_FALSE(enabled_checker.TimedOut()); |
| 185 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( | 183 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( |
| 186 syncer::AUTOFILL_WALLET_DATA)); | 184 syncer::AUTOFILL_WALLET_DATA)); |
| 187 | 185 |
| 188 // Then disable the experiment. | 186 // Then disable the experiment. |
| 189 experiment_specifics->mutable_wallet_sync()->set_enabled(false); | 187 experiment_specifics->mutable_wallet_sync()->set_enabled(false); |
| 190 GetFakeServer()->InjectEntity( | 188 GetFakeServer()->InjectEntity( |
| 191 fake_server::UniqueClientEntity::CreateForInjection( | 189 fake_server::UniqueClientEntity::CreateForInjection( |
| 192 syncer::EXPERIMENTS, kWalletSyncExperimentTag, experiment_entity)); | 190 kWalletSyncExperimentTag, experiment_entity)); |
| 193 TriggerSyncCycle(); | 191 TriggerSyncCycle(); |
| 194 | 192 |
| 195 WalletDisabledChecker disable_checker; | 193 WalletDisabledChecker disable_checker; |
| 196 disable_checker.Wait(); | 194 disable_checker.Wait(); |
| 197 ASSERT_FALSE(disable_checker.TimedOut()); | 195 ASSERT_FALSE(disable_checker.TimedOut()); |
| 198 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes(). | 196 ASSERT_FALSE(GetClient(0)->service()->GetActiveDataTypes(). |
| 199 Has(syncer::AUTOFILL_WALLET_DATA)); | 197 Has(syncer::AUTOFILL_WALLET_DATA)); |
| 200 } | 198 } |
| 201 | 199 |
| 202 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, Download) { | 200 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, Download) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); | 269 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); |
| 272 ASSERT_EQ(1uL, cards.size()); | 270 ASSERT_EQ(1uL, cards.size()); |
| 273 | 271 |
| 274 // Turn off the wallet autofill pref, the card should be gone as a side | 272 // Turn off the wallet autofill pref, the card should be gone as a side |
| 275 // effect of the wallet data type controller noticing. | 273 // effect of the wallet data type controller noticing. |
| 276 GetProfile(0)->GetPrefs()->SetBoolean( | 274 GetProfile(0)->GetPrefs()->SetBoolean( |
| 277 autofill::prefs::kAutofillWalletImportEnabled, false); | 275 autofill::prefs::kAutofillWalletImportEnabled, false); |
| 278 cards = pdm->GetCreditCards(); | 276 cards = pdm->GetCreditCards(); |
| 279 ASSERT_EQ(0uL, cards.size()); | 277 ASSERT_EQ(0uL, cards.size()); |
| 280 } | 278 } |
| OLD | NEW |