OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 file_thread_.Stop(); | 564 file_thread_.Stop(); |
565 TabContentsWrapperTestHarness::TearDown(); | 565 TabContentsWrapperTestHarness::TearDown(); |
566 } | 566 } |
567 | 567 |
568 void GetAutofillSuggestions(int query_id, | 568 void GetAutofillSuggestions(int query_id, |
569 const webkit_glue::FormData& form, | 569 const webkit_glue::FormData& form, |
570 const webkit_glue::FormField& field) { | 570 const webkit_glue::FormField& field) { |
571 autofill_manager_->OnQueryFormFieldAutofill(query_id, | 571 autofill_manager_->OnQueryFormFieldAutofill(query_id, |
572 form, | 572 form, |
573 field, | 573 field, |
574 gfx::Rect()); | 574 gfx::Rect(), |
| 575 false); |
575 } | 576 } |
576 | 577 |
577 void GetAutofillSuggestions(const webkit_glue::FormData& form, | 578 void GetAutofillSuggestions(const webkit_glue::FormData& form, |
578 const webkit_glue::FormField& field) { | 579 const webkit_glue::FormField& field) { |
579 GetAutofillSuggestions(kDefaultPageID, form, field); | 580 GetAutofillSuggestions(kDefaultPageID, form, field); |
580 } | 581 } |
581 | 582 |
582 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { | 583 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { |
583 contents_wrapper()->autocomplete_history_manager()-> | 584 contents_wrapper()->autocomplete_history_manager()-> |
584 SendSuggestions(&result); | 585 SendSuggestions(&result); |
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 } | 2861 } |
2861 | 2862 |
2862 namespace { | 2863 namespace { |
2863 | 2864 |
2864 class MockAutofillExternalDelegate : public AutofillExternalDelegate { | 2865 class MockAutofillExternalDelegate : public AutofillExternalDelegate { |
2865 public: | 2866 public: |
2866 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper) | 2867 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper) |
2867 : AutofillExternalDelegate(wrapper) {} | 2868 : AutofillExternalDelegate(wrapper) {} |
2868 virtual ~MockAutofillExternalDelegate() {} | 2869 virtual ~MockAutofillExternalDelegate() {} |
2869 | 2870 |
2870 MOCK_METHOD4(OnQuery, void(int query_id, | 2871 MOCK_METHOD5(OnQuery, void(int query_id, |
2871 const webkit_glue::FormData& form, | 2872 const webkit_glue::FormData& form, |
2872 const webkit_glue::FormField& field, | 2873 const webkit_glue::FormField& field, |
2873 const gfx::Rect& bounds)); | 2874 const gfx::Rect& bounds, |
2874 virtual void OnSuggestionsReturned( | 2875 bool display_warning)); |
2875 int query_id, | 2876 |
| 2877 virtual void HideAutofillPopup() OVERRIDE {} |
| 2878 |
| 2879 virtual void ApplyAutofillSuggestions( |
2876 const std::vector<string16>& autofill_values, | 2880 const std::vector<string16>& autofill_values, |
2877 const std::vector<string16>& autofill_labels, | 2881 const std::vector<string16>& autofill_labels, |
2878 const std::vector<string16>& autofill_icons, | 2882 const std::vector<string16>& autofill_icons, |
2879 const std::vector<int>& autofill_unique_ids) OVERRIDE {} | 2883 const std::vector<int>& autofill_unique_ids, |
| 2884 int separator_index) OVERRIDE {} |
2880 | 2885 |
2881 virtual void HideAutofillPopup() OVERRIDE {} | 2886 virtual void OnQueryPlatformSpecific( |
| 2887 int query_id, |
| 2888 const webkit_glue::FormData& form, |
| 2889 const webkit_glue::FormField& field) OVERRIDE {} |
2882 | 2890 |
2883 private: | 2891 private: |
2884 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 2892 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
2885 }; | 2893 }; |
2886 | 2894 |
2887 } // namespace | 2895 } // namespace |
2888 | 2896 |
2889 // Test our external delegate is called at the right time. | 2897 // Test our external delegate is called at the right time. |
2890 TEST_F(AutofillManagerTest, TestExternalDelegate) { | 2898 TEST_F(AutofillManagerTest, TestExternalDelegate) { |
2891 MockAutofillExternalDelegate external_delegate(contents_wrapper()); | 2899 MockAutofillExternalDelegate external_delegate(contents_wrapper()); |
2892 EXPECT_CALL(external_delegate, OnQuery(_, _, _, _)); | 2900 EXPECT_CALL(external_delegate, OnQuery(_, _, _, _, _)); |
2893 autofill_manager_->SetExternalDelegate(&external_delegate); | 2901 autofill_manager_->SetExternalDelegate(&external_delegate); |
2894 | 2902 |
2895 FormData form; | 2903 FormData form; |
2896 CreateTestAddressFormData(&form); | 2904 CreateTestAddressFormData(&form); |
2897 std::vector<FormData> forms(1, form); | 2905 std::vector<FormData> forms(1, form); |
2898 FormsSeen(forms); | 2906 FormsSeen(forms); |
2899 const FormField& field = form.fields[0]; | 2907 const FormField& field = form.fields[0]; |
2900 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2908 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
2901 | 2909 |
2902 autofill_manager_->SetExternalDelegate(NULL); | 2910 autofill_manager_->SetExternalDelegate(NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
2919 | 2927 |
2920 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); | 2928 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); |
2921 EXPECT_TRUE(autofill_manager->external_delegate()); | 2929 EXPECT_TRUE(autofill_manager->external_delegate()); |
2922 | 2930 |
2923 AutocompleteHistoryManager* autocomplete_history_manager = | 2931 AutocompleteHistoryManager* autocomplete_history_manager = |
2924 contents_wrapper()->autocomplete_history_manager(); | 2932 contents_wrapper()->autocomplete_history_manager(); |
2925 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); | 2933 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); |
2926 } | 2934 } |
2927 | 2935 |
2928 #endif // OS_ANDROID | 2936 #endif // OS_ANDROID |
OLD | NEW |