| 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 <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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 const char* year, | 432 const char* year, |
| 433 const char* month) { | 433 const char* month) { |
| 434 ExpectFilledForm(page_id, filled_form, expected_page_id, | 434 ExpectFilledForm(page_id, filled_form, expected_page_id, |
| 435 "", "", "", "", "", "", "", "", "", "", "", | 435 "", "", "", "", "", "", "", "", "", "", "", |
| 436 "Miku Hatsune", "4234567890654321", month, year, | 436 "Miku Hatsune", "4234567890654321", month, year, |
| 437 has_address_fields, true, true); | 437 has_address_fields, true, true); |
| 438 } | 438 } |
| 439 | 439 |
| 440 class TestAutofillManager : public AutofillManager { | 440 class TestAutofillManager : public AutofillManager { |
| 441 public: | 441 public: |
| 442 TestAutofillManager(autofill::AutofillManagerDelegate* delegate, | 442 TestAutofillManager(content::WebContents* web_contents, |
| 443 TabContents* tab_contents, | 443 autofill::AutofillManagerDelegate* delegate, |
| 444 TestPersonalDataManager* personal_data) | 444 TestPersonalDataManager* personal_data) |
| 445 : AutofillManager(delegate, tab_contents, personal_data), | 445 : AutofillManager(web_contents, delegate, personal_data), |
| 446 personal_data_(personal_data), | 446 personal_data_(personal_data), |
| 447 autofill_enabled_(true), | 447 autofill_enabled_(true), |
| 448 did_finish_async_form_submit_(false), | 448 did_finish_async_form_submit_(false), |
| 449 message_loop_is_running_(false) { | 449 message_loop_is_running_(false) { |
| 450 } | 450 } |
| 451 | 451 |
| 452 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } | 452 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } |
| 453 | 453 |
| 454 void set_autofill_enabled(bool autofill_enabled) { | 454 void set_autofill_enabled(bool autofill_enabled) { |
| 455 autofill_enabled_ = autofill_enabled; | 455 autofill_enabled_ = autofill_enabled; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 598 |
| 599 virtual void SetUp() OVERRIDE { | 599 virtual void SetUp() OVERRIDE { |
| 600 Profile* profile = new TestingProfile(); | 600 Profile* profile = new TestingProfile(); |
| 601 browser_context_.reset(profile); | 601 browser_context_.reset(profile); |
| 602 PersonalDataManagerFactory::GetInstance()->SetTestingFactory( | 602 PersonalDataManagerFactory::GetInstance()->SetTestingFactory( |
| 603 profile, TestPersonalDataManager::Build); | 603 profile, TestPersonalDataManager::Build); |
| 604 | 604 |
| 605 TabContentsTestHarness::SetUp(); | 605 TabContentsTestHarness::SetUp(); |
| 606 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 606 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
| 607 autofill_manager_ = new TestAutofillManager( | 607 autofill_manager_ = new TestAutofillManager( |
| 608 web_contents(), |
| 608 TabAutofillManagerDelegate::FromWebContents(web_contents()), | 609 TabAutofillManagerDelegate::FromWebContents(web_contents()), |
| 609 tab_contents(), | |
| 610 &personal_data_); | 610 &personal_data_); |
| 611 | 611 |
| 612 file_thread_.Start(); | 612 file_thread_.Start(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 virtual void TearDown() OVERRIDE { | 615 virtual void TearDown() OVERRIDE { |
| 616 file_thread_.Stop(); | 616 file_thread_.Stop(); |
| 617 TabContentsTestHarness::TearDown(); | 617 TabContentsTestHarness::TearDown(); |
| 618 } | 618 } |
| 619 | 619 |
| (...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 // Turn on the external delegate. Recreate a WebContents. Make sure | 3122 // Turn on the external delegate. Recreate a WebContents. Make sure |
| 3123 // an external delegate was set in the proper structures. | 3123 // an external delegate was set in the proper structures. |
| 3124 TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) { | 3124 TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) { |
| 3125 CommandLine::ForCurrentProcess()->AppendSwitch( | 3125 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 3126 switches::kExternalAutofillPopup); | 3126 switches::kExternalAutofillPopup); |
| 3127 | 3127 |
| 3128 // Setting the contents creates a new TabContents. | 3128 // Setting the contents creates a new TabContents. |
| 3129 WebContents* contents = CreateTestWebContents(); | 3129 WebContents* contents = CreateTestWebContents(); |
| 3130 SetContents(contents); | 3130 SetContents(contents); |
| 3131 | 3131 |
| 3132 AutofillManager* autofill_manager = tab_contents()->autofill_manager(); | 3132 AutofillManager* autofill_manager = |
| 3133 AutofillManager::FromWebContents(contents); |
| 3133 EXPECT_TRUE(autofill_manager->external_delegate()); | 3134 EXPECT_TRUE(autofill_manager->external_delegate()); |
| 3134 | 3135 |
| 3135 AutocompleteHistoryManager* autocomplete_history_manager = | 3136 AutocompleteHistoryManager* autocomplete_history_manager = |
| 3136 AutocompleteHistoryManager::FromWebContents(web_contents()); | 3137 AutocompleteHistoryManager::FromWebContents(contents); |
| 3137 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); | 3138 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); |
| 3138 } | 3139 } |
| 3139 | 3140 |
| 3140 #endif // OS_ANDROID | 3141 #endif // OS_ANDROID |
| OLD | NEW |