OLD | NEW |
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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/autofill/autofill_profile.h" | 6 #include "chrome/browser/autofill/autofill_profile.h" |
| 7 #include "chrome/browser/autofill/credit_card.h" |
| 8 #include "chrome/browser/autofill/personal_data_manager.h" |
7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 9 #include "chrome/browser/sync/profile_sync_service_harness.h" |
8 #include "chrome/browser/sync/test/integration/autofill_helper.h" | 10 #include "chrome/browser/sync/test/integration/autofill_helper.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 11 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/sync_test.h" | 12 #include "chrome/browser/sync/test/integration/sync_test.h" |
11 #include "chrome/browser/webdata/autofill_entry.h" | 13 #include "chrome/browser/webdata/autofill_entry.h" |
12 #include "chrome/browser/webdata/autofill_table.h" | 14 #include "chrome/browser/webdata/autofill_table.h" |
13 | 15 |
14 using autofill_helper::AddKeys; | 16 using autofill_helper::AddKeys; |
15 using autofill_helper::AddProfile; | 17 using autofill_helper::AddProfile; |
16 using autofill_helper::CreateAutofillProfile; | 18 using autofill_helper::CreateAutofillProfile; |
17 using autofill_helper::GetAllKeys; | 19 using autofill_helper::GetAllKeys; |
18 using autofill_helper::GetAllProfiles; | 20 using autofill_helper::GetAllProfiles; |
| 21 using autofill_helper::GetPersonalDataManager; |
19 using autofill_helper::KeysMatch; | 22 using autofill_helper::KeysMatch; |
20 using autofill_helper::ProfilesMatch; | 23 using autofill_helper::ProfilesMatch; |
21 using autofill_helper::PROFILE_FRASIER; | 24 using autofill_helper::PROFILE_FRASIER; |
22 using autofill_helper::PROFILE_HOMER; | 25 using autofill_helper::PROFILE_HOMER; |
23 using autofill_helper::PROFILE_MARION; | 26 using autofill_helper::PROFILE_MARION; |
24 using autofill_helper::PROFILE_NULL; | 27 using autofill_helper::PROFILE_NULL; |
25 using autofill_helper::RemoveKey; | 28 using autofill_helper::RemoveKey; |
26 using autofill_helper::RemoveProfile; | 29 using autofill_helper::RemoveProfile; |
| 30 using autofill_helper::SetCreditCards; |
27 using autofill_helper::UpdateProfile; | 31 using autofill_helper::UpdateProfile; |
28 using bookmarks_helper::AddFolder; | 32 using bookmarks_helper::AddFolder; |
29 using bookmarks_helper::AddURL; | 33 using bookmarks_helper::AddURL; |
30 using bookmarks_helper::IndexedURL; | 34 using bookmarks_helper::IndexedURL; |
31 using bookmarks_helper::IndexedURLTitle; | 35 using bookmarks_helper::IndexedURLTitle; |
32 | 36 |
33 class TwoClientAutofillSyncTest : public SyncTest { | 37 class TwoClientAutofillSyncTest : public SyncTest { |
34 public: | 38 public: |
35 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; } | 39 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; } |
36 virtual ~TwoClientAutofillSyncTest() {} | 40 virtual ~TwoClientAutofillSyncTest() {} |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 exceeds_max_length_string); | 444 exceeds_max_length_string); |
441 UpdateProfile(0, | 445 UpdateProfile(0, |
442 GetAllProfiles(0)[0]->guid(), | 446 GetAllProfiles(0)[0]->guid(), |
443 AutofillType(ADDRESS_HOME_LINE1), | 447 AutofillType(ADDRESS_HOME_LINE1), |
444 exceeds_max_length_string); | 448 exceeds_max_length_string); |
445 | 449 |
446 MakeABookmarkChange(0); | 450 MakeABookmarkChange(0); |
447 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 451 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
448 ASSERT_FALSE(ProfilesMatch(0, 1)); | 452 ASSERT_FALSE(ProfilesMatch(0, 1)); |
449 } | 453 } |
| 454 |
| 455 // Test credit cards don't sync. |
| 456 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, NoCreditCardSync) { |
| 457 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 458 |
| 459 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 460 |
| 461 CreditCard card; |
| 462 card.SetInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("6011111111111117")); |
| 463 std::vector<CreditCard> credit_cards; |
| 464 credit_cards.push_back(card); |
| 465 SetCreditCards(0, &credit_cards); |
| 466 |
| 467 MakeABookmarkChange(0); |
| 468 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 469 ASSERT_TRUE(ProfilesMatch(0, 1)); |
| 470 ASSERT_EQ(1U, GetAllProfiles(0).size()); |
| 471 |
| 472 PersonalDataManager* pdm = GetPersonalDataManager(1); |
| 473 ASSERT_EQ(0U, pdm->credit_cards().size()); |
| 474 } |
OLD | NEW |