| 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 <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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2853 MockAutofillManagerDelegate() {} | 2853 MockAutofillManagerDelegate() {} |
| 2854 | 2854 |
| 2855 virtual ~MockAutofillManagerDelegate() {} | 2855 virtual ~MockAutofillManagerDelegate() {} |
| 2856 | 2856 |
| 2857 virtual void ShowRequestAutocompleteDialog( | 2857 virtual void ShowRequestAutocompleteDialog( |
| 2858 const FormData& form, | 2858 const FormData& form, |
| 2859 const GURL& source_url, | 2859 const GURL& source_url, |
| 2860 const ResultCallback& callback) OVERRIDE { | 2860 const ResultCallback& callback) OVERRIDE { |
| 2861 callback.Run(user_supplied_data_ ? AutocompleteResultSuccess : | 2861 callback.Run(user_supplied_data_ ? AutocompleteResultSuccess : |
| 2862 AutocompleteResultErrorDisabled, | 2862 AutocompleteResultErrorDisabled, |
| 2863 base::string16(), |
| 2863 user_supplied_data_.get()); | 2864 user_supplied_data_.get()); |
| 2864 } | 2865 } |
| 2865 | 2866 |
| 2866 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) { | 2867 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) { |
| 2867 user_supplied_data_.reset(user_supplied_data.release()); | 2868 user_supplied_data_.reset(user_supplied_data.release()); |
| 2868 } | 2869 } |
| 2869 | 2870 |
| 2870 private: | 2871 private: |
| 2871 scoped_ptr<FormStructure> user_supplied_data_; | 2872 scoped_ptr<FormStructure> user_supplied_data_; |
| 2872 | 2873 |
| 2873 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); | 2874 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); |
| 2874 }; | 2875 }; |
| 2875 | 2876 |
| 2876 } // namespace | 2877 } // namespace |
| 2877 | 2878 |
| 2878 // Test our external delegate is called at the right time. | 2879 // Test our external delegate is called at the right time. |
| 2879 TEST_F(AutofillManagerTest, TestExternalDelegate) { | 2880 TEST_F(AutofillManagerTest, TestExternalDelegate) { |
| 2880 FormData form; | 2881 FormData form; |
| 2881 test::CreateTestAddressFormData(&form); | 2882 test::CreateTestAddressFormData(&form); |
| 2882 std::vector<FormData> forms(1, form); | 2883 std::vector<FormData> forms(1, form); |
| 2883 FormsSeen(forms); | 2884 FormsSeen(forms); |
| 2884 const FormFieldData& field = form.fields[0]; | 2885 const FormFieldData& field = form.fields[0]; |
| 2885 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2886 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 2886 | 2887 |
| 2887 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2888 EXPECT_TRUE(external_delegate_->on_query_seen()); |
| 2888 } | 2889 } |
| 2889 | 2890 |
| 2890 } // namespace autofill | 2891 } // namespace autofill |
| OLD | NEW |