| 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 <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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 public autofill::TestAutofillExternalDelegate { | 3244 public autofill::TestAutofillExternalDelegate { |
| 3245 public: | 3245 public: |
| 3246 explicit MockAutofillExternalDelegate(content::WebContents* web_contents, | 3246 explicit MockAutofillExternalDelegate(content::WebContents* web_contents, |
| 3247 AutofillManager* autofill_manager) | 3247 AutofillManager* autofill_manager) |
| 3248 : TestAutofillExternalDelegate(web_contents, autofill_manager) {} | 3248 : TestAutofillExternalDelegate(web_contents, autofill_manager) {} |
| 3249 virtual ~MockAutofillExternalDelegate() {} | 3249 virtual ~MockAutofillExternalDelegate() {} |
| 3250 | 3250 |
| 3251 MOCK_METHOD5(OnQuery, void(int query_id, | 3251 MOCK_METHOD5(OnQuery, void(int query_id, |
| 3252 const FormData& form, | 3252 const FormData& form, |
| 3253 const FormFieldData& field, | 3253 const FormFieldData& field, |
| 3254 const gfx::Rect& bounds, | 3254 const gfx::RectF& bounds, |
| 3255 bool display_warning)); | 3255 bool display_warning)); |
| 3256 | 3256 |
| 3257 private: | 3257 private: |
| 3258 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 3258 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
| 3259 }; | 3259 }; |
| 3260 | 3260 |
| 3261 } // namespace | 3261 } // namespace |
| 3262 | 3262 |
| 3263 // Test our external delegate is called at the right time. | 3263 // Test our external delegate is called at the right time. |
| 3264 TEST_F(AutofillManagerTest, TestExternalDelegate) { | 3264 TEST_F(AutofillManagerTest, TestExternalDelegate) { |
| 3265 MockAutofillExternalDelegate external_delegate(web_contents(), | 3265 MockAutofillExternalDelegate external_delegate(web_contents(), |
| 3266 autofill_manager_); | 3266 autofill_manager_); |
| 3267 EXPECT_CALL(external_delegate, OnQuery(_, _, _, _, _)); | 3267 EXPECT_CALL(external_delegate, OnQuery(_, _, _, _, _)); |
| 3268 autofill_manager_->SetExternalDelegate(&external_delegate); | 3268 autofill_manager_->SetExternalDelegate(&external_delegate); |
| 3269 | 3269 |
| 3270 FormData form; | 3270 FormData form; |
| 3271 CreateTestAddressFormData(&form); | 3271 CreateTestAddressFormData(&form); |
| 3272 std::vector<FormData> forms(1, form); | 3272 std::vector<FormData> forms(1, form); |
| 3273 FormsSeen(forms); | 3273 FormsSeen(forms); |
| 3274 const FormFieldData& field = form.fields[0]; | 3274 const FormFieldData& field = form.fields[0]; |
| 3275 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3275 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 3276 | 3276 |
| 3277 autofill_manager_->SetExternalDelegate(NULL); | 3277 autofill_manager_->SetExternalDelegate(NULL); |
| 3278 } | 3278 } |
| OLD | NEW |