Chromium Code Reviews| Index: chrome/browser/autofill/autofill_manager_unittest.cc |
| diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc |
| index cabf531ba85227fd34acc3b59bad195bce0a5a26..9d9aebb88ec3247c9f8c000c94320dac17c3e0cc 100644 |
| --- a/chrome/browser/autofill/autofill_manager_unittest.cc |
| +++ b/chrome/browser/autofill/autofill_manager_unittest.cc |
| @@ -661,6 +661,10 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness { |
| autofill_manager_->OnFormsSeen(forms, base::TimeTicks()); |
| } |
| + void LoadServerPredictions(const std::string& response_xml) { |
| + autofill_manager_->OnLoadedServerPredictions(response_xml); |
| + } |
| + |
| void FormSubmitted(const FormData& form) { |
| if (autofill_manager_->OnFormSubmitted(form, base::TimeTicks::Now())) |
| autofill_manager_->WaitForAsyncFormSubmit(); |
| @@ -1810,6 +1814,49 @@ TEST_F(AutofillManagerTest, FillCreditCardForm) { |
| ExpectFilledCreditCardFormElvis(page_id, results, kDefaultPageID, false); |
| } |
| +TEST_F(AutofillManagerTest, FillCheckableElements) { |
| + FormData form; |
| + CreateTestAddressFormData(&form); |
| + |
| + // Add a checkbox field. |
| + FormFieldData field; |
| + autofill_test::CreateTestFormField( |
| + "Checkbox", "checkbx", "fill-me", "checkbox", &field); |
| + field.is_checkable = true; |
| + form.fields.push_back(field); |
| + |
| + std::vector<FormData> forms(1, form); |
| + FormsSeen(forms); |
| + |
| + // Replicate server response with XML. |
| + const std::string response_xml = |
| + "<autofillqueryresponse>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"0\"/>" |
| + "<field autofilltype=\"61\" defaultvalue=\"fill-me\"/>" |
| + "</autofillqueryresponse>"; |
| + LoadServerPredictions(response_xml); |
| + |
| + GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); |
| + GUIDPair empty(std::string(), 0); |
| + FillAutofillFormData(kDefaultPageID, form, form.fields[0], |
| + PackGUIDs(empty, guid)); |
| + int page_id = 0; |
| + FormData results; |
| + EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); |
| + // Last field is checked. |
| + EXPECT_TRUE(results.fields[results.fields.size()-1].is_checked); |
| +} |
|
Ilya Sherman
2012/12/01 00:54:12
Please also add a test where the field should end
Raman Kakilate
2012/12/06 01:54:05
Done.
|
| + |
| // Test that we correctly fill a credit card form with month input type. |
| // 1. year empty, month empty |
| TEST_F(AutofillManagerTest, FillCreditCardFormNoYearNoMonth) { |