Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: chrome/browser/autofill/autofill_manager_unittest.cc

Issue 8490017: Setting up external delegate calls to allow a future delegate to handle autofill (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removing unneeded IPC calls Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
33 #include "content/browser/tab_contents/test_tab_contents.h" 33 #include "content/browser/tab_contents/test_tab_contents.h"
34 #include "content/test/test_browser_thread.h" 34 #include "content/test/test_browser_thread.h"
35 #include "googleurl/src/gurl.h" 35 #include "googleurl/src/gurl.h"
36 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
37 #include "ipc/ipc_test_sink.h" 37 #include "ipc/ipc_test_sink.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/gfx/rect.h"
41 #include "webkit/glue/form_data.h" 42 #include "webkit/glue/form_data.h"
42 #include "webkit/glue/form_field.h" 43 #include "webkit/glue/form_field.h"
43 44
44 using content::BrowserThread; 45 using content::BrowserThread;
45 using testing::_; 46 using testing::_;
46 using webkit_glue::FormData; 47 using webkit_glue::FormData;
47 using webkit_glue::FormField; 48 using webkit_glue::FormField;
48 49
49 namespace { 50 namespace {
50 51
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 561 }
561 562
562 virtual void TearDown() OVERRIDE { 563 virtual void TearDown() OVERRIDE {
563 file_thread_.Stop(); 564 file_thread_.Stop();
564 TabContentsWrapperTestHarness::TearDown(); 565 TabContentsWrapperTestHarness::TearDown();
565 } 566 }
566 567
567 void GetAutofillSuggestions(int query_id, 568 void GetAutofillSuggestions(int query_id,
568 const webkit_glue::FormData& form, 569 const webkit_glue::FormData& form,
569 const webkit_glue::FormField& field) { 570 const webkit_glue::FormField& field) {
570 autofill_manager_->OnQueryFormFieldAutofill(query_id, form, field); 571 autofill_manager_->OnQueryFormFieldAutofill(query_id,
572 form,
573 field,
574 gfx::Rect());
571 } 575 }
572 576
573 void GetAutofillSuggestions(const webkit_glue::FormData& form, 577 void GetAutofillSuggestions(const webkit_glue::FormData& form,
574 const webkit_glue::FormField& field) { 578 const webkit_glue::FormField& field) {
575 GetAutofillSuggestions(kDefaultPageID, form, field); 579 GetAutofillSuggestions(kDefaultPageID, form, field);
576 } 580 }
577 581
578 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { 582 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) {
579 contents_wrapper()->autocomplete_history_manager()-> 583 contents_wrapper()->autocomplete_history_manager()->
580 SendSuggestions(&result); 584 SendSuggestions(&result);
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2864 virtual ~MockAutofillExternalDelegate() {} 2868 virtual ~MockAutofillExternalDelegate() {}
2865 2869
2866 MOCK_METHOD3(OnQuery, void(int query_id, 2870 MOCK_METHOD3(OnQuery, void(int query_id,
2867 const webkit_glue::FormData& form, 2871 const webkit_glue::FormData& form,
2868 const webkit_glue::FormField& field)); 2872 const webkit_glue::FormField& field));
2869 virtual void OnSuggestionsReturned( 2873 virtual void OnSuggestionsReturned(
2870 int query_id, 2874 int query_id,
2871 const std::vector<string16>& autofill_values, 2875 const std::vector<string16>& autofill_values,
2872 const std::vector<string16>& autofill_labels, 2876 const std::vector<string16>& autofill_labels,
2873 const std::vector<string16>& autofill_icons, 2877 const std::vector<string16>& autofill_icons,
2874 const std::vector<int>& autofill_unique_ids) {} 2878 const std::vector<int>& autofill_unique_ids) OVERRIDE {}
2879
2880 virtual void SetAutofillElementBounds(const gfx::Rect& bounds) OVERRIDE {}
2881
2882 virtual void HideAutofillPopup() OVERRIDE {}
2875 2883
2876 private: 2884 private:
2877 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 2885 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
2878 }; 2886 };
2879 2887
2880 } // namespace 2888 } // namespace
2881 2889
2882 // Test our external delegate is called at the right time. 2890 // Test our external delegate is called at the right time.
2883 TEST_F(AutofillManagerTest, TestExternalDelegate) { 2891 TEST_F(AutofillManagerTest, TestExternalDelegate) {
2884 MockAutofillExternalDelegate external_delegate(contents_wrapper()); 2892 MockAutofillExternalDelegate external_delegate(contents_wrapper());
(...skipping 27 matching lines...) Expand all
2912 2920
2913 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); 2921 AutofillManager* autofill_manager = contents_wrapper()->autofill_manager();
2914 EXPECT_TRUE(autofill_manager->external_delegate()); 2922 EXPECT_TRUE(autofill_manager->external_delegate());
2915 2923
2916 AutocompleteHistoryManager* autocomplete_history_manager = 2924 AutocompleteHistoryManager* autocomplete_history_manager =
2917 contents_wrapper()->autocomplete_history_manager(); 2925 contents_wrapper()->autocomplete_history_manager();
2918 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); 2926 EXPECT_TRUE(autocomplete_history_manager->external_delegate());
2919 } 2927 }
2920 2928
2921 #endif // OS_ANDROID 2929 #endif // OS_ANDROID
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698