| 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 "components/autofill/content/browser/content_autofill_driver.h" | 5 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 6 #include "components/autofill/content/browser/request_autocomplete_manager.h" | 6 #include "components/autofill/content/browser/request_autocomplete_manager.h" |
| 7 #include "components/autofill/content/common/autofill_messages.h" | 7 #include "components/autofill/content/common/autofill_messages.h" |
| 8 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" | 8 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" |
| 9 #include "content/public/test/mock_render_process_host.h" | 9 #include "content/public/test/mock_render_process_host.h" |
| 10 #include "content/public/test/test_renderer_host.h" | 10 #include "content/public/test/test_renderer_host.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 class CustomTestAutofillManagerDelegate : public TestAutofillManagerDelegate { | 42 class CustomTestAutofillManagerDelegate : public TestAutofillManagerDelegate { |
| 43 public: | 43 public: |
| 44 CustomTestAutofillManagerDelegate() : should_simulate_success_(true) {} | 44 CustomTestAutofillManagerDelegate() : should_simulate_success_(true) {} |
| 45 | 45 |
| 46 virtual ~CustomTestAutofillManagerDelegate() {} | 46 virtual ~CustomTestAutofillManagerDelegate() {} |
| 47 | 47 |
| 48 virtual void ShowRequestAutocompleteDialog( | 48 virtual void ShowRequestAutocompleteDialog( |
| 49 const FormData& form, | 49 const FormData& form, |
| 50 const GURL& source_url, | 50 const GURL& source_url, |
| 51 const base::Callback<void(const FormStructure*)>& callback) OVERRIDE { | 51 const ResultCallback& callback) OVERRIDE { |
| 52 if (should_simulate_success_) { | 52 if (should_simulate_success_) { |
| 53 FormStructure form_structure(form); | 53 FormStructure form_structure(form); |
| 54 callback.Run(&form_structure); | 54 callback.Run(AutocompleteResultSuccess, &form_structure); |
| 55 } else { | 55 } else { |
| 56 callback.Run(NULL); | 56 callback.Run(AutofillManagerDelegate::AutocompleteResultErrorDisabled, |
| 57 NULL); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 void set_should_simulate_success(bool should_simulate_success) { | 61 void set_should_simulate_success(bool should_simulate_success) { |
| 61 should_simulate_success_ = should_simulate_success; | 62 should_simulate_success_ = should_simulate_success; |
| 62 } | 63 } |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 // Enable testing the path where a callback is called without a | 66 // Enable testing the path where a callback is called without a |
| 66 // valid FormStructure. | 67 // valid FormStructure. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 TEST_F(RequestAutocompleteManagerTest, | 157 TEST_F(RequestAutocompleteManagerTest, |
| 157 OnRequestAutocompleteWithAutofillDisabled) { | 158 OnRequestAutocompleteWithAutofillDisabled) { |
| 158 blink::WebFormElement::AutocompleteResult result; | 159 blink::WebFormElement::AutocompleteResult result; |
| 159 driver_->mock_autofill_manager()->set_autofill_enabled(false); | 160 driver_->mock_autofill_manager()->set_autofill_enabled(false); |
| 160 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); | 161 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); |
| 161 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); | 162 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); |
| 162 EXPECT_EQ(result, blink::WebFormElement::AutocompleteResultSuccess); | 163 EXPECT_EQ(result, blink::WebFormElement::AutocompleteResultSuccess); |
| 163 } | 164 } |
| 164 | 165 |
| 165 } // namespace autofill | 166 } // namespace autofill |
| OLD | NEW |