| 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 <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 FormData response_data; | 1544 FormData response_data; |
| 1545 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], | 1545 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], |
| 1546 PackGUIDs(empty, guid), &response_page_id, &response_data); | 1546 PackGUIDs(empty, guid), &response_page_id, &response_data); |
| 1547 ExpectFilledAddressFormElvis( | 1547 ExpectFilledAddressFormElvis( |
| 1548 response_page_id, response_data, kDefaultPageID, false); | 1548 response_page_id, response_data, kDefaultPageID, false); |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 // Test that we correctly fill an address form from an auxiliary profile. | 1551 // Test that we correctly fill an address form from an auxiliary profile. |
| 1552 TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { | 1552 TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { |
| 1553 personal_data_.ClearAutofillProfiles(); | 1553 personal_data_.ClearAutofillProfiles(); |
| 1554 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 1555 autofill_client_.GetPrefs()->SetBoolean( |
| 1556 ::autofill::prefs::kAutofillUseMacAddressBook, true); |
| 1557 #else |
| 1554 autofill_client_.GetPrefs()->SetBoolean( | 1558 autofill_client_.GetPrefs()->SetBoolean( |
| 1555 ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); | 1559 ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); |
| 1560 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1561 |
| 1556 personal_data_.CreateTestAuxiliaryProfiles(); | 1562 personal_data_.CreateTestAuxiliaryProfiles(); |
| 1557 | 1563 |
| 1558 // Set up our form data. | 1564 // Set up our form data. |
| 1559 FormData form; | 1565 FormData form; |
| 1560 test::CreateTestAddressFormData(&form); | 1566 test::CreateTestAddressFormData(&form); |
| 1561 std::vector<FormData> forms(1, form); | 1567 std::vector<FormData> forms(1, form); |
| 1562 FormsSeen(forms); | 1568 FormsSeen(forms); |
| 1563 | 1569 |
| 1564 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); | 1570 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); |
| 1565 GUIDPair empty(std::string(), 0); | 1571 GUIDPair empty(std::string(), 0); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); | 2473 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); |
| 2468 FormSubmitted(response_data); | 2474 FormSubmitted(response_data); |
| 2469 } | 2475 } |
| 2470 | 2476 |
| 2471 // Checks that resetting the auxiliary profile enabled preference does the right | 2477 // Checks that resetting the auxiliary profile enabled preference does the right |
| 2472 // thing on all platforms. | 2478 // thing on all platforms. |
| 2473 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { | 2479 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { |
| 2474 PrefService* prefs = autofill_client_.GetPrefs(); | 2480 PrefService* prefs = autofill_client_.GetPrefs(); |
| 2475 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 2481 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 2476 // Auxiliary profiles is implemented on Mac and Android only. | 2482 // Auxiliary profiles is implemented on Mac and Android only. |
| 2477 // OSX: enables Mac Address Book integration. | 2483 // OSX: This preference exists for legacy reasons. It is no longer used. |
| 2478 // Android: enables integration with user's contact profile. | 2484 // Android: enables integration with user's contact profile. |
| 2479 ASSERT_TRUE( | 2485 ASSERT_TRUE( |
| 2480 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2486 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2481 prefs->SetBoolean( | 2487 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, |
| 2482 ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, false); | 2488 false); |
| 2483 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); | 2489 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); |
| 2484 ASSERT_TRUE( | 2490 ASSERT_TRUE( |
| 2485 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2491 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2486 #else | 2492 #else |
| 2487 ASSERT_FALSE( | 2493 ASSERT_FALSE( |
| 2488 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2494 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2489 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); | 2495 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); |
| 2490 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); | 2496 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); |
| 2491 ASSERT_FALSE( | 2497 ASSERT_FALSE( |
| 2492 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2498 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2493 #endif | 2499 #endif // defined(OS_MACOSX) || defined(OS_ANDROID) |
| 2494 } | 2500 } |
| 2495 | 2501 |
| 2496 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { | 2502 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { |
| 2497 FormData form; | 2503 FormData form; |
| 2498 form.name = ASCIIToUTF16("MyForm"); | 2504 form.name = ASCIIToUTF16("MyForm"); |
| 2499 form.method = ASCIIToUTF16("POST"); | 2505 form.method = ASCIIToUTF16("POST"); |
| 2500 form.origin = GURL("http://myform.com/form.html"); | 2506 form.origin = GURL("http://myform.com/form.html"); |
| 2501 form.action = GURL("http://myform.com/submit.html"); | 2507 form.action = GURL("http://myform.com/submit.html"); |
| 2502 form.user_submitted = true; | 2508 form.user_submitted = true; |
| 2503 | 2509 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 test::CreateTestAddressFormData(&form); | 2871 test::CreateTestAddressFormData(&form); |
| 2866 std::vector<FormData> forms(1, form); | 2872 std::vector<FormData> forms(1, form); |
| 2867 FormsSeen(forms); | 2873 FormsSeen(forms); |
| 2868 const FormFieldData& field = form.fields[0]; | 2874 const FormFieldData& field = form.fields[0]; |
| 2869 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2875 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 2870 | 2876 |
| 2871 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2877 EXPECT_TRUE(external_delegate_->on_query_seen()); |
| 2872 } | 2878 } |
| 2873 | 2879 |
| 2874 } // namespace autofill | 2880 } // namespace autofill |
| OLD | NEW |