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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 560 } |
561 | 561 |
562 virtual void TearDown() OVERRIDE { | 562 virtual void TearDown() OVERRIDE { |
563 file_thread_.Stop(); | 563 file_thread_.Stop(); |
564 TabContentsWrapperTestHarness::TearDown(); | 564 TabContentsWrapperTestHarness::TearDown(); |
565 } | 565 } |
566 | 566 |
567 void GetAutofillSuggestions(int query_id, | 567 void GetAutofillSuggestions(int query_id, |
568 const webkit_glue::FormData& form, | 568 const webkit_glue::FormData& form, |
569 const webkit_glue::FormField& field) { | 569 const webkit_glue::FormField& field) { |
570 autofill_manager_->OnQueryFormFieldAutofill(query_id, form, field); | 570 autofill_manager_->OnQueryFormFieldAutofill(query_id, form, field, false); |
571 } | 571 } |
572 | 572 |
573 void GetAutofillSuggestions(const webkit_glue::FormData& form, | 573 void GetAutofillSuggestions(const webkit_glue::FormData& form, |
574 const webkit_glue::FormField& field) { | 574 const webkit_glue::FormField& field) { |
575 GetAutofillSuggestions(kDefaultPageID, form, field); | 575 GetAutofillSuggestions(kDefaultPageID, form, field); |
576 } | 576 } |
577 | 577 |
578 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { | 578 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { |
579 contents_wrapper()->autocomplete_history_manager()-> | 579 contents_wrapper()->autocomplete_history_manager()-> |
580 SendSuggestions(&result); | 580 SendSuggestions(&result); |
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 } | 2856 } |
2857 | 2857 |
2858 namespace { | 2858 namespace { |
2859 | 2859 |
2860 class MockAutofillExternalDelegate : public AutofillExternalDelegate { | 2860 class MockAutofillExternalDelegate : public AutofillExternalDelegate { |
2861 public: | 2861 public: |
2862 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper) | 2862 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper) |
2863 : AutofillExternalDelegate(wrapper) {} | 2863 : AutofillExternalDelegate(wrapper) {} |
2864 virtual ~MockAutofillExternalDelegate() {} | 2864 virtual ~MockAutofillExternalDelegate() {} |
2865 | 2865 |
2866 MOCK_METHOD3(OnQuery, void(int query_id, | 2866 MOCK_METHOD4(OnQuery, void(int query_id, |
2867 const webkit_glue::FormData& form, | 2867 const webkit_glue::FormData& form, |
2868 const webkit_glue::FormField& field)); | 2868 const webkit_glue::FormField& field, |
2869 virtual void OnSuggestionsReturned( | 2869 bool display_warning)); |
2870 int query_id, | 2870 virtual void ApplyAutofillSuggestions( |
2871 const std::vector<string16>& autofill_values, | 2871 const std::vector<string16>& autofill_values, |
2872 const std::vector<string16>& autofill_labels, | 2872 const std::vector<string16>& autofill_labels, |
2873 const std::vector<string16>& autofill_icons, | 2873 const std::vector<string16>& autofill_icons, |
2874 const std::vector<int>& autofill_unique_ids) {} | 2874 const std::vector<int>& autofill_unique_ids, |
| 2875 int separator_index) {} |
2875 | 2876 |
2876 private: | 2877 private: |
2877 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 2878 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
2878 }; | 2879 }; |
2879 | 2880 |
2880 } // namespace | 2881 } // namespace |
2881 | 2882 |
2882 // Test our external delegate is called at the right time. | 2883 // Test our external delegate is called at the right time. |
2883 TEST_F(AutofillManagerTest, TestExternalDelegate) { | 2884 TEST_F(AutofillManagerTest, TestExternalDelegate) { |
2884 MockAutofillExternalDelegate external_delegate(contents_wrapper()); | 2885 MockAutofillExternalDelegate external_delegate(contents_wrapper()); |
2885 EXPECT_CALL(external_delegate, OnQuery(_, _, _)); | 2886 EXPECT_CALL(external_delegate, OnQuery(_, _, _, _)); |
2886 autofill_manager_->SetExternalDelegate(&external_delegate); | 2887 autofill_manager_->SetExternalDelegate(&external_delegate); |
2887 | 2888 |
2888 FormData form; | 2889 FormData form; |
2889 CreateTestAddressFormData(&form); | 2890 CreateTestAddressFormData(&form); |
2890 std::vector<FormData> forms(1, form); | 2891 std::vector<FormData> forms(1, form); |
2891 FormsSeen(forms); | 2892 FormsSeen(forms); |
2892 const FormField& field = form.fields[0]; | 2893 const FormField& field = form.fields[0]; |
2893 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2894 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
2894 | 2895 |
2895 autofill_manager_->SetExternalDelegate(NULL); | 2896 autofill_manager_->SetExternalDelegate(NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
2912 | 2913 |
2913 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); | 2914 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); |
2914 EXPECT_TRUE(autofill_manager->external_delegate()); | 2915 EXPECT_TRUE(autofill_manager->external_delegate()); |
2915 | 2916 |
2916 AutocompleteHistoryManager* autocomplete_history_manager = | 2917 AutocompleteHistoryManager* autocomplete_history_manager = |
2917 contents_wrapper()->autocomplete_history_manager(); | 2918 contents_wrapper()->autocomplete_history_manager(); |
2918 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); | 2919 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); |
2919 } | 2920 } |
2920 | 2921 |
2921 #endif // OS_ANDROID | 2922 #endif // OS_ANDROID |
OLD | NEW |