OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "components/autofill/core/browser/autofill_experiments.h" |
18 #include "components/autofill/core/browser/autofill_profile.h" | 19 #include "components/autofill/core/browser/autofill_profile.h" |
19 #include "components/autofill/core/browser/autofill_test_utils.h" | 20 #include "components/autofill/core/browser/autofill_test_utils.h" |
20 #include "components/autofill/core/browser/form_structure.h" | 21 #include "components/autofill/core/browser/form_structure.h" |
21 #include "components/autofill/core/browser/personal_data_manager.h" | 22 #include "components/autofill/core/browser/personal_data_manager.h" |
22 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 23 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
23 #include "components/autofill/core/browser/webdata/autofill_table.h" | 24 #include "components/autofill/core/browser/webdata/autofill_table.h" |
24 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
25 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
26 #include "components/autofill/core/common/autofill_switches.h" | 27 #include "components/autofill/core/common/autofill_switches.h" |
27 #include "components/autofill/core/common/form_data.h" | 28 #include "components/autofill/core/common/form_data.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 "347666888555" /* American Express */, "04", "2015"); | 488 "347666888555" /* American Express */, "04", "2015"); |
488 | 489 |
489 test::SetServerCreditCards(autofill_table_, server_cards); | 490 test::SetServerCreditCards(autofill_table_, server_cards); |
490 personal_data_->Refresh(); | 491 personal_data_->Refresh(); |
491 | 492 |
492 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 493 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
493 .WillOnce(QuitMainMessageLoop()); | 494 .WillOnce(QuitMainMessageLoop()); |
494 base::MessageLoop::current()->Run(); | 495 base::MessageLoop::current()->Run(); |
495 | 496 |
496 ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); | 497 ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); |
| 498 |
| 499 if (!OfferStoreUnmaskedCards()) { |
| 500 for (CreditCard* card : personal_data_->GetCreditCards()) { |
| 501 EXPECT_EQ(CreditCard::MASKED_SERVER_CARD, card->record_type()); |
| 502 } |
| 503 // The rest of this test doesn't work if we're force-masking all unmasked |
| 504 // cards. |
| 505 return; |
| 506 } |
| 507 |
497 // The GUIDs will be different, so just compare the data. | 508 // The GUIDs will be different, so just compare the data. |
498 for (size_t i = 0; i < 3; ++i) | 509 for (size_t i = 0; i < 3; ++i) |
499 EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); | 510 EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); |
500 | 511 |
501 CreditCard* unmasked_card = &server_cards.front(); | 512 CreditCard* unmasked_card = &server_cards.front(); |
502 unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); | 513 unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); |
503 unmasked_card->SetNumber(ASCIIToUTF16("423456789012")); | 514 unmasked_card->SetNumber(ASCIIToUTF16("423456789012")); |
504 EXPECT_NE(0, server_cards.front().Compare( | 515 EXPECT_NE(0, server_cards.front().Compare( |
505 *personal_data_->GetCreditCards().front())); | 516 *personal_data_->GetCreditCards().front())); |
506 personal_data_->UpdateServerCreditCard(*unmasked_card); | 517 personal_data_->UpdateServerCreditCard(*unmasked_card); |
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3136 "347666888555" /* American Express */, "04", "2015"); | 3147 "347666888555" /* American Express */, "04", "2015"); |
3137 | 3148 |
3138 test::SetServerCreditCards(autofill_table_, server_cards); | 3149 test::SetServerCreditCards(autofill_table_, server_cards); |
3139 personal_data_->Refresh(); | 3150 personal_data_->Refresh(); |
3140 | 3151 |
3141 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 3152 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
3142 .WillOnce(QuitMainMessageLoop()); | 3153 .WillOnce(QuitMainMessageLoop()); |
3143 base::MessageLoop::current()->Run(); | 3154 base::MessageLoop::current()->Run(); |
3144 | 3155 |
3145 ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); | 3156 ASSERT_EQ(3U, personal_data_->GetCreditCards().size()); |
| 3157 |
| 3158 if (!OfferStoreUnmaskedCards()) { |
| 3159 for (CreditCard* card : personal_data_->GetCreditCards()) { |
| 3160 EXPECT_EQ(CreditCard::MASKED_SERVER_CARD, card->record_type()); |
| 3161 } |
| 3162 // The rest of this test doesn't work if we're force-masking all unmasked |
| 3163 // cards. |
| 3164 return; |
| 3165 } |
| 3166 |
3146 // The GUIDs will be different, so just compare the data. | 3167 // The GUIDs will be different, so just compare the data. |
3147 for (size_t i = 0; i < 3; ++i) | 3168 for (size_t i = 0; i < 3; ++i) |
3148 EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); | 3169 EXPECT_EQ(0, server_cards[i].Compare(*personal_data_->GetCreditCards()[i])); |
3149 | 3170 |
3150 CreditCard* unmasked_card = &server_cards.front(); | 3171 CreditCard* unmasked_card = &server_cards.front(); |
3151 unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); | 3172 unmasked_card->set_record_type(CreditCard::FULL_SERVER_CARD); |
3152 unmasked_card->SetNumber(ASCIIToUTF16("423456789012")); | 3173 unmasked_card->SetNumber(ASCIIToUTF16("423456789012")); |
3153 EXPECT_NE(0, unmasked_card->Compare( | 3174 EXPECT_NE(0, unmasked_card->Compare( |
3154 *personal_data_->GetCreditCards().front())); | 3175 *personal_data_->GetCreditCards().front())); |
3155 personal_data_->UpdateServerCreditCard(*unmasked_card); | 3176 personal_data_->UpdateServerCreditCard(*unmasked_card); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 | 3268 |
3248 personal_data_->ClearAllServerData(); | 3269 personal_data_->ClearAllServerData(); |
3249 | 3270 |
3250 // Reload the database, everything should be gone. | 3271 // Reload the database, everything should be gone. |
3251 ResetPersonalDataManager(USER_MODE_NORMAL); | 3272 ResetPersonalDataManager(USER_MODE_NORMAL); |
3252 EXPECT_TRUE(personal_data_->GetCreditCards().empty()); | 3273 EXPECT_TRUE(personal_data_->GetCreditCards().empty()); |
3253 EXPECT_TRUE(personal_data_->GetProfiles().empty()); | 3274 EXPECT_TRUE(personal_data_->GetProfiles().empty()); |
3254 } | 3275 } |
3255 | 3276 |
3256 } // namespace autofill | 3277 } // namespace autofill |
OLD | NEW |