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

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

Issue 12188020: Adding the page and DPI scale adjustment for Autofill Popups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mock call fix #2 Created 7 years, 10 months 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) 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 30 matching lines...) Expand all
41 ~MockAutofillExternalDelegate() {} 41 ~MockAutofillExternalDelegate() {}
42 42
43 MOCK_METHOD4(ApplyAutofillSuggestions, void( 43 MOCK_METHOD4(ApplyAutofillSuggestions, void(
44 const std::vector<string16>& labels, 44 const std::vector<string16>& labels,
45 const std::vector<string16>& sub_labels, 45 const std::vector<string16>& sub_labels,
46 const std::vector<string16>& icons, 46 const std::vector<string16>& icons,
47 const std::vector<int>& identifiers)); 47 const std::vector<int>& identifiers));
48 48
49 MOCK_METHOD0(ClearPreviewedForm, void()); 49 MOCK_METHOD0(ClearPreviewedForm, void());
50 50
51 MOCK_METHOD1(EnsurePopupForElement, void(const gfx::Rect& element_bounds)); 51 MOCK_METHOD1(EnsurePopupForElement, void(const gfx::RectF& element_bounds));
52 52
53 MOCK_METHOD0(HideAutofillPopup, void()); 53 MOCK_METHOD0(HideAutofillPopup, void());
54 }; 54 };
55 55
56 class MockAutofillManager : public AutofillManager { 56 class MockAutofillManager : public AutofillManager {
57 public: 57 public:
58 explicit MockAutofillManager(content::WebContents* web_contents, 58 explicit MockAutofillManager(content::WebContents* web_contents,
59 autofill::AutofillManagerDelegate* delegate) 59 autofill::AutofillManagerDelegate* delegate)
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.
(...skipping 20 matching lines...) Expand all
82 virtual ~AutofillExternalDelegateUnitTest() {} 82 virtual ~AutofillExternalDelegateUnitTest() {}
83 83
84 protected: 84 protected:
85 // Set up the expectation for a platform specific OnQuery call and then 85 // Set up the expectation for a platform specific OnQuery call and then
86 // execute it with the given QueryId. 86 // execute it with the given QueryId.
87 void IssueOnQuery(int query_id) { 87 void IssueOnQuery(int query_id) {
88 const FormData form; 88 const FormData form;
89 FormFieldData field; 89 FormFieldData field;
90 field.is_focusable = true; 90 field.is_focusable = true;
91 field.should_autocomplete = true; 91 field.should_autocomplete = true;
92 const gfx::Rect element_bounds; 92 const gfx::RectF element_bounds;
93 93
94 EXPECT_CALL(*external_delegate_, EnsurePopupForElement(element_bounds)); 94 EXPECT_CALL(*external_delegate_, EnsurePopupForElement(element_bounds));
95 external_delegate_->OnQuery(query_id, form, field, element_bounds, false); 95 external_delegate_->OnQuery(query_id, form, field, element_bounds, false);
96 } 96 }
97 97
98 scoped_refptr<MockAutofillManager> autofill_manager_; 98 scoped_refptr<MockAutofillManager> autofill_manager_;
99 scoped_ptr<testing::NiceMock<MockAutofillExternalDelegate> > 99 scoped_ptr<testing::NiceMock<MockAutofillExternalDelegate> >
100 external_delegate_; 100 external_delegate_;
101 101
102 private: 102 private:
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 // Test that the popup is marked as visible after recieving password 260 // Test that the popup is marked as visible after recieving password
261 // suggestions. 261 // suggestions.
262 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { 262 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) {
263 std::vector<string16> suggestions; 263 std::vector<string16> suggestions;
264 suggestions.push_back(string16()); 264 suggestions.push_back(string16());
265 265
266 FormFieldData field; 266 FormFieldData field;
267 field.is_focusable = true; 267 field.is_focusable = true;
268 field.should_autocomplete = true; 268 field.should_autocomplete = true;
269 const gfx::Rect element_bounds; 269 const gfx::RectF element_bounds;
270 270
271 EXPECT_CALL(*external_delegate_, EnsurePopupForElement(element_bounds)); 271 EXPECT_CALL(*external_delegate_, EnsurePopupForElement(element_bounds));
272 272
273 // The enums must be cast to ints to prevent compile errors on linux_rel. 273 // The enums must be cast to ints to prevent compile errors on linux_rel.
274 EXPECT_CALL(*external_delegate_, 274 EXPECT_CALL(*external_delegate_,
275 ApplyAutofillSuggestions(_, _, _, testing::ElementsAre( 275 ApplyAutofillSuggestions(_, _, _, testing::ElementsAre(
276 static_cast<int>( 276 static_cast<int>(
277 WebAutofillClient::MenuItemIDPasswordEntry)))); 277 WebAutofillClient::MenuItemIDPasswordEntry))));
278 278
279 external_delegate_->OnShowPasswordSuggestions(suggestions, 279 external_delegate_->OnShowPasswordSuggestions(suggestions,
280 field, 280 field,
281 element_bounds); 281 element_bounds);
282 282
283 // Called by DidAutofillSuggestions, add expectation to remove warning. 283 // Called by DidAutofillSuggestions, add expectation to remove warning.
284 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)); 284 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _));
285 285
286 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 286 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
287 287
288 // This should trigger a call to hide the popup since 288 // This should trigger a call to hide the popup since
289 // we've selected an option. 289 // we've selected an option.
290 external_delegate_->DidAcceptSuggestion( 290 external_delegate_->DidAcceptSuggestion(
291 suggestions[0], 291 suggestions[0],
292 WebAutofillClient::MenuItemIDPasswordEntry); 292 WebAutofillClient::MenuItemIDPasswordEntry);
293 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698