| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 "Phone Number", "phonenumber", "", "text", &field); | 176 "Phone Number", "phonenumber", "", "text", &field); |
| 177 form->fields.push_back(field); | 177 form->fields.push_back(field); |
| 178 autofill_test::CreateTestFormField( | 178 autofill_test::CreateTestFormField( |
| 179 "Fax", "fax", "", "text", &field); | 179 "Fax", "fax", "", "text", &field); |
| 180 form->fields.push_back(field); | 180 form->fields.push_back(field); |
| 181 autofill_test::CreateTestFormField( | 181 autofill_test::CreateTestFormField( |
| 182 "Email", "email", "", "text", &field); | 182 "Email", "email", "", "text", &field); |
| 183 form->fields.push_back(field); | 183 form->fields.push_back(field); |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Populates |form| with data corresponding to a simple credit card form, with. | 186 // Populates |form| with data corresponding to a simple credit card form. |
| 187 // Note that this actually appends fields to the form data, which can be useful | 187 // Note that this actually appends fields to the form data, which can be useful |
| 188 // for building up more complex test forms. | 188 // for building up more complex test forms. |
| 189 void CreateTestCreditCardFormData(FormData* form, bool is_https) { | 189 void CreateTestCreditCardFormData(FormData* form, bool is_https) { |
| 190 form->name = ASCIIToUTF16("MyForm"); | 190 form->name = ASCIIToUTF16("MyForm"); |
| 191 form->method = ASCIIToUTF16("POST"); | 191 form->method = ASCIIToUTF16("POST"); |
| 192 if (is_https) { | 192 if (is_https) { |
| 193 form->origin = GURL("https://myform.com/form.html"); | 193 form->origin = GURL("https://myform.com/form.html"); |
| 194 form->action = GURL("https://myform.com/submit.html"); | 194 form->action = GURL("https://myform.com/submit.html"); |
| 195 } else { | 195 } else { |
| 196 form->origin = GURL("http://myform.com/form.html"); | 196 form->origin = GURL("http://myform.com/form.html"); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 "Elvis Presley", "4234567890123456", "04", "2012", | 363 "Elvis Presley", "4234567890123456", "04", "2012", |
| 364 has_address_fields, true); | 364 has_address_fields, true); |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace | 367 } // namespace |
| 368 | 368 |
| 369 class TestAutoFillManager : public AutoFillManager { | 369 class TestAutoFillManager : public AutoFillManager { |
| 370 public: | 370 public: |
| 371 TestAutoFillManager(TabContents* tab_contents, | 371 TestAutoFillManager(TabContents* tab_contents, |
| 372 TestPersonalDataManager* personal_manager) | 372 TestPersonalDataManager* personal_manager) |
| 373 : AutoFillManager(tab_contents, NULL), | 373 : AutoFillManager(tab_contents, personal_manager), |
| 374 autofill_enabled_(true) { | 374 autofill_enabled_(true) { |
| 375 test_personal_data_ = personal_manager; | 375 test_personal_data_ = personal_manager; |
| 376 set_personal_data_manager(personal_manager); | |
| 377 // Download manager requests are disabled for purposes of this unit test. | |
| 378 // These requests are tested in autofill_download_unittest.cc. | |
| 379 set_disable_download_manager_requests(true); | |
| 380 } | 376 } |
| 381 | 377 |
| 382 virtual bool IsAutoFillEnabled() const { return autofill_enabled_; } | 378 virtual bool IsAutoFillEnabled() const { return autofill_enabled_; } |
| 383 | 379 |
| 384 void set_autofill_enabled(bool autofill_enabled) { | 380 void set_autofill_enabled(bool autofill_enabled) { |
| 385 autofill_enabled_ = autofill_enabled; | 381 autofill_enabled_ = autofill_enabled; |
| 386 } | 382 } |
| 387 | 383 |
| 388 AutoFillProfile* GetLabeledProfile(const char* label) { | 384 AutoFillProfile* GetLabeledProfile(const char* label) { |
| 389 return test_personal_data_->GetLabeledProfile(label); | 385 return test_personal_data_->GetLabeledProfile(label); |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1518 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1523 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1519 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1524 profile()->GetPrefs()->SetBoolean( | 1520 profile()->GetPrefs()->SetBoolean( |
| 1525 prefs::kAutoFillAuxiliaryProfilesEnabled, true); | 1521 prefs::kAutoFillAuxiliaryProfilesEnabled, true); |
| 1526 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); | 1522 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); |
| 1527 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 1523 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 1528 prefs::kAutoFillAuxiliaryProfilesEnabled)); | 1524 prefs::kAutoFillAuxiliaryProfilesEnabled)); |
| 1529 #endif | 1525 #endif |
| 1530 } | 1526 } |
| 1531 | 1527 |
| OLD | NEW |