| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 15 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/signin/account_tracker_service_factory.h" | 17 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 19 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" | 19 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
| 20 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 20 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 21 #include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h" | 21 #include "chrome/browser/ui/autofill/autofill_dialog_view_tester.h" |
| 22 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" | 22 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
| 23 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 23 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 24 #include "chrome/browser/ui/autofill/mock_address_validator.h" | 24 #include "chrome/browser/ui/autofill/mock_address_validator.h" |
| 25 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" | |
| 26 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_tabstrip.h" | 26 #include "chrome/browser/ui/browser_tabstrip.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/test/base/in_process_browser_test.h" | 31 #include "chrome/test/base/in_process_browser_test.h" |
| 33 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
| 34 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 33 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
| 35 #include "components/autofill/core/browser/autofill_metrics.h" | 34 #include "components/autofill/core/browser/autofill_metrics.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 form.name = ASCIIToUTF16("TestForm"); | 281 form.name = ASCIIToUTF16("TestForm"); |
| 283 | 282 |
| 284 FormFieldData field; | 283 FormFieldData field; |
| 285 field.autocomplete_attribute = "shipping tel"; | 284 field.autocomplete_attribute = "shipping tel"; |
| 286 form.fields.push_back(field); | 285 form.fields.push_back(field); |
| 287 | 286 |
| 288 FormFieldData cc; | 287 FormFieldData cc; |
| 289 cc.autocomplete_attribute = "cc-number"; | 288 cc.autocomplete_attribute = "cc-number"; |
| 290 form.fields.push_back(cc); | 289 form.fields.push_back(cc); |
| 291 | 290 |
| 292 test_generated_bubble_controller_ = | |
| 293 new testing::NiceMock<TestGeneratedCreditCardBubbleController>( | |
| 294 GetActiveWebContents()); | |
| 295 ASSERT_TRUE(test_generated_bubble_controller_->IsInstalled()); | |
| 296 | |
| 297 message_loop_runner_ = new content::MessageLoopRunner; | 291 message_loop_runner_ = new content::MessageLoopRunner; |
| 298 controller_ = new TestAutofillDialogController( | 292 controller_ = new TestAutofillDialogController( |
| 299 GetActiveWebContents(), | 293 GetActiveWebContents(), |
| 300 form, | 294 form, |
| 301 message_loop_runner_); | 295 message_loop_runner_); |
| 302 } | 296 } |
| 303 | 297 |
| 304 void InitializeController() { | 298 void InitializeController() { |
| 305 InitializeControllerWithoutShowing(); | 299 InitializeControllerWithoutShowing(); |
| 306 controller_->Show(); | 300 controller_->Show(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 WaitForWebDB(); | 495 WaitForWebDB(); |
| 502 } | 496 } |
| 503 | 497 |
| 504 void AddAutofillProfileToProfile(Profile* profile, | 498 void AddAutofillProfileToProfile(Profile* profile, |
| 505 const AutofillProfile& autofill_profile) { | 499 const AutofillProfile& autofill_profile) { |
| 506 PersonalDataManagerFactory::GetForProfile(profile)->AddProfile( | 500 PersonalDataManagerFactory::GetForProfile(profile)->AddProfile( |
| 507 autofill_profile); | 501 autofill_profile); |
| 508 WaitForWebDB(); | 502 WaitForWebDB(); |
| 509 } | 503 } |
| 510 | 504 |
| 511 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller() { | |
| 512 return test_generated_bubble_controller_; | |
| 513 } | |
| 514 | |
| 515 private: | 505 private: |
| 516 void WaitForWebDB() { | 506 void WaitForWebDB() { |
| 517 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); | 507 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); |
| 518 } | 508 } |
| 519 | 509 |
| 520 TestAutofillDialogController* controller_; // Weak reference. | 510 TestAutofillDialogController* controller_; // Weak reference. |
| 521 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 511 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 522 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; | 512 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; |
| 523 | 513 |
| 524 // Weak; owned by the active web contents. | |
| 525 TestGeneratedCreditCardBubbleController* test_generated_bubble_controller_; | |
| 526 | |
| 527 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); | 514 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); |
| 528 }; | 515 }; |
| 529 | 516 |
| 530 // Submit the form data. | 517 // Submit the form data. |
| 531 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { | 518 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { |
| 532 base::HistogramTester histogram; | 519 base::HistogramTester histogram; |
| 533 AddCreditcardToProfile(controller()->profile(), | 520 AddCreditcardToProfile(controller()->profile(), |
| 534 test::GetVerifiedCreditCard()); | 521 test::GetVerifiedCreditCard()); |
| 535 AddAutofillProfileToProfile(controller()->profile(), | 522 AddAutofillProfileToProfile(controller()->profile(), |
| 536 test::GetVerifiedProfile()); | 523 test::GetVerifiedProfile()); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 1341 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
| 1355 "navigateFrame();", | 1342 "navigateFrame();", |
| 1356 &unused)); | 1343 &unused)); |
| 1357 ExpectDomMessage("iframe loaded"); | 1344 ExpectDomMessage("iframe loaded"); |
| 1358 ChromeAutofillClient* client = | 1345 ChromeAutofillClient* client = |
| 1359 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); | 1346 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
| 1360 EXPECT_FALSE(client->GetDialogControllerForTesting()); | 1347 EXPECT_FALSE(client->GetDialogControllerForTesting()); |
| 1361 } | 1348 } |
| 1362 | 1349 |
| 1363 } // namespace autofill | 1350 } // namespace autofill |
| OLD | NEW |