OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 using content::BrowserThread; | 22 using content::BrowserThread; |
23 using testing::_; | 23 using testing::_; |
24 using webkit::forms::FormData; | 24 using webkit::forms::FormData; |
25 using webkit::forms::FormField; | 25 using webkit::forms::FormField; |
26 using WebKit::WebAutofillClient; | 26 using WebKit::WebAutofillClient; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate { | 30 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate { |
31 public: | 31 public: |
32 MockAutofillExternalDelegate(TabContentsWrapper* wrapper, | 32 MockAutofillExternalDelegate(TabContents* tab_contents, |
33 AutofillManager* autofill_manger) | 33 AutofillManager* autofill_manger) |
34 : TestAutofillExternalDelegate(wrapper, autofill_manger) {} | 34 : TestAutofillExternalDelegate(tab_contents, autofill_manger) {} |
35 ~MockAutofillExternalDelegate() {} | 35 ~MockAutofillExternalDelegate() {} |
36 | 36 |
37 MOCK_METHOD4(ApplyAutofillSuggestions, void( | 37 MOCK_METHOD4(ApplyAutofillSuggestions, void( |
38 const std::vector<string16>& autofill_values, | 38 const std::vector<string16>& autofill_values, |
39 const std::vector<string16>& autofill_labels, | 39 const std::vector<string16>& autofill_labels, |
40 const std::vector<string16>& autofill_icons, | 40 const std::vector<string16>& autofill_icons, |
41 const std::vector<int>& autofill_unique_ids)); | 41 const std::vector<int>& autofill_unique_ids)); |
42 | 42 |
43 MOCK_METHOD4(OnQueryPlatformSpecific, | 43 MOCK_METHOD4(OnQueryPlatformSpecific, |
44 void(int query_id, | 44 void(int query_id, |
45 const webkit::forms::FormData& form, | 45 const webkit::forms::FormData& form, |
46 const webkit::forms::FormField& field, | 46 const webkit::forms::FormField& field, |
47 const gfx::Rect& bounds)); | 47 const gfx::Rect& bounds)); |
48 | 48 |
49 MOCK_METHOD0(ClearPreviewedForm, void()); | 49 MOCK_METHOD0(ClearPreviewedForm, void()); |
50 | 50 |
51 MOCK_METHOD0(HideAutofillPopup, void()); | 51 MOCK_METHOD0(HideAutofillPopup, void()); |
52 | 52 |
53 private: | 53 private: |
54 virtual void HideAutofillPopupInternal() {}; | 54 virtual void HideAutofillPopupInternal() {}; |
55 }; | 55 }; |
56 | 56 |
57 class MockAutofillManager : public AutofillManager { | 57 class MockAutofillManager : public AutofillManager { |
58 public: | 58 public: |
59 explicit MockAutofillManager(TabContentsWrapper* tab_contents) | 59 explicit MockAutofillManager(TabContents* tab_contents) |
60 // Force to use the constructor designated for unit test, but we don't | 60 // Force to use the constructor designated for unit test, but we don't |
61 // really need personal_data in this test so we pass a NULL pointer. | 61 // really need personal_data in this test so we pass a NULL pointer. |
62 : AutofillManager(tab_contents, NULL) {} | 62 : AutofillManager(tab_contents, NULL) {} |
63 | 63 |
64 MOCK_METHOD4(OnFillAutofillFormData, | 64 MOCK_METHOD4(OnFillAutofillFormData, |
65 void(int query_id, | 65 void(int query_id, |
66 const webkit::forms::FormData& form, | 66 const webkit::forms::FormData& form, |
67 const webkit::forms::FormField& field, | 67 const webkit::forms::FormField& field, |
68 int unique_id)); | 68 int unique_id)); |
69 | 69 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 external_delegate_->SelectAutofillSuggestionAtIndex(1); | 166 external_delegate_->SelectAutofillSuggestionAtIndex(1); |
167 } | 167 } |
168 | 168 |
169 // Test that the popup is hidden once we are done editing the autofill field. | 169 // Test that the popup is hidden once we are done editing the autofill field. |
170 TEST_F(AutofillExternalDelegateUnitTest, | 170 TEST_F(AutofillExternalDelegateUnitTest, |
171 ExternalDelegateHidePopupAfterEditing) { | 171 ExternalDelegateHidePopupAfterEditing) { |
172 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); | 172 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); |
173 | 173 |
174 external_delegate_->DidEndTextFieldEditing(); | 174 external_delegate_->DidEndTextFieldEditing(); |
175 } | 175 } |
OLD | NEW |