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 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], | 1546 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], |
1547 PackGUIDs(empty, guid), &response_page_id, &response_data); | 1547 PackGUIDs(empty, guid), &response_page_id, &response_data); |
1548 ExpectFilledAddressFormElvis( | 1548 ExpectFilledAddressFormElvis( |
1549 response_page_id, response_data, kDefaultPageID, false); | 1549 response_page_id, response_data, kDefaultPageID, false); |
1550 } | 1550 } |
1551 | 1551 |
1552 // Test that we correctly fill an address form from an auxiliary profile. | 1552 // Test that we correctly fill an address form from an auxiliary profile. |
1553 TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { | 1553 TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { |
1554 personal_data_.ClearAutofillProfiles(); | 1554 personal_data_.ClearAutofillProfiles(); |
1555 autofill_delegate_.GetPrefs()->SetBoolean( | 1555 autofill_delegate_.GetPrefs()->SetBoolean( |
1556 ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); | 1556 ::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled, true); |
1557 personal_data_.CreateTestAuxiliaryProfiles(); | 1557 personal_data_.CreateTestAuxiliaryProfiles(); |
1558 | 1558 |
1559 // Set up our form data. | 1559 // Set up our form data. |
1560 FormData form; | 1560 FormData form; |
1561 test::CreateTestAddressFormData(&form); | 1561 test::CreateTestAddressFormData(&form); |
1562 std::vector<FormData> forms(1, form); | 1562 std::vector<FormData> forms(1, form); |
1563 FormsSeen(forms); | 1563 FormsSeen(forms); |
1564 | 1564 |
1565 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); | 1565 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); |
1566 GUIDPair empty(std::string(), 0); | 1566 GUIDPair empty(std::string(), 0); |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2468 response_data.fields[3].value = ASCIIToUTF16("Enter your address"); | 2468 response_data.fields[3].value = ASCIIToUTF16("Enter your address"); |
2469 | 2469 |
2470 // Simulate form submission. We should not call into the PDM to try to save | 2470 // Simulate form submission. We should not call into the PDM to try to save |
2471 // the filled data, since the filled form is effectively missing an address. | 2471 // the filled data, since the filled form is effectively missing an address. |
2472 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); | 2472 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); |
2473 FormSubmitted(response_data); | 2473 FormSubmitted(response_data); |
2474 } | 2474 } |
2475 | 2475 |
2476 // Checks that resetting the auxiliary profile enabled preference does the right | 2476 // Checks that resetting the auxiliary profile enabled preference does the right |
2477 // thing on all platforms. | 2477 // thing on all platforms. |
2478 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { | 2478 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { |
erikchen
2014/06/03 01:34:19
I refrained from adding a test case for OS_MACOSX,
| |
2479 PrefService* prefs = autofill_delegate_.GetPrefs(); | 2479 PrefService* prefs = autofill_delegate_.GetPrefs(); |
2480 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 2480 #if defined(OS_ANDROID) |
2481 // Auxiliary profiles is implemented on Mac and Android only. | 2481 // Auxiliary profiles is implemented on Android only. |
2482 // OSX: enables Mac Address Book integration. | |
2483 // Android: enables integration with user's contact profile. | 2482 // Android: enables integration with user's contact profile. |
2484 ASSERT_TRUE( | 2483 ASSERT_TRUE(prefs->GetBoolean( |
2485 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2484 ::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled)); |
2486 prefs->SetBoolean( | 2485 prefs->SetBoolean(::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled, |
2487 ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, false); | 2486 false); |
2488 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); | 2487 prefs->ClearPref(::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled); |
2489 ASSERT_TRUE( | 2488 ASSERT_TRUE(prefs->GetBoolean( |
2490 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2489 ::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled)); |
2491 #else | 2490 #else |
2492 ASSERT_FALSE( | 2491 ASSERT_FALSE(prefs->GetBoolean( |
2493 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2492 ::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled)); |
2494 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); | 2493 prefs->SetBoolean(::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled, |
2495 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); | 2494 true); |
2496 ASSERT_FALSE( | 2495 prefs->ClearPref(::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled); |
2497 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); | 2496 ASSERT_FALSE(prefs->GetBoolean( |
2497 ::autofill::prefs::kAutofillAndroidAuxiliaryProfilesEnabled)); | |
2498 #endif | 2498 #endif |
2499 } | 2499 } |
2500 | 2500 |
2501 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { | 2501 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { |
2502 FormData form; | 2502 FormData form; |
2503 form.name = ASCIIToUTF16("MyForm"); | 2503 form.name = ASCIIToUTF16("MyForm"); |
2504 form.method = ASCIIToUTF16("POST"); | 2504 form.method = ASCIIToUTF16("POST"); |
2505 form.origin = GURL("http://myform.com/form.html"); | 2505 form.origin = GURL("http://myform.com/form.html"); |
2506 form.action = GURL("http://myform.com/submit.html"); | 2506 form.action = GURL("http://myform.com/submit.html"); |
2507 form.user_submitted = true; | 2507 form.user_submitted = true; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2870 test::CreateTestAddressFormData(&form); | 2870 test::CreateTestAddressFormData(&form); |
2871 std::vector<FormData> forms(1, form); | 2871 std::vector<FormData> forms(1, form); |
2872 FormsSeen(forms); | 2872 FormsSeen(forms); |
2873 const FormFieldData& field = form.fields[0]; | 2873 const FormFieldData& field = form.fields[0]; |
2874 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2874 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
2875 | 2875 |
2876 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2876 EXPECT_TRUE(external_delegate_->on_query_seen()); |
2877 } | 2877 } |
2878 | 2878 |
2879 } // namespace autofill | 2879 } // namespace autofill |
OLD | NEW |