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

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

Issue 16344003: [Autofill] Fix popup delegate to show warnings correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « components/autofill/browser/autofill_external_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/string16.h" 8 #include "base/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 // Issue an OnQuery call with the given |query_id|. 114 // Issue an OnQuery call with the given |query_id|.
115 void IssueOnQuery(int query_id) { 115 void IssueOnQuery(int query_id) {
116 const FormData form; 116 const FormData form;
117 FormFieldData field; 117 FormFieldData field;
118 field.is_focusable = true; 118 field.is_focusable = true;
119 field.should_autocomplete = true; 119 field.should_autocomplete = true;
120 const gfx::RectF element_bounds; 120 const gfx::RectF element_bounds;
121 121
122 external_delegate_->OnQuery(query_id, form, field, element_bounds, false); 122 external_delegate_->OnQuery(query_id, form, field, element_bounds, true);
123 } 123 }
124 124
125 MockAutofillManagerDelegate manager_delegate_; 125 MockAutofillManagerDelegate manager_delegate_;
126 scoped_ptr<MockAutofillManager> autofill_manager_; 126 scoped_ptr<MockAutofillManager> autofill_manager_;
127 scoped_ptr<testing::NiceMock<MockAutofillExternalDelegate> > 127 scoped_ptr<testing::NiceMock<MockAutofillExternalDelegate> >
128 external_delegate_; 128 external_delegate_;
129 }; 129 };
130 130
131 // Test that our external delegate called the virtual methods at the right time. 131 // Test that our external delegate called the virtual methods at the right time.
132 TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { 132 TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 autofill_item = std::vector<base::string16>(); 217 autofill_item = std::vector<base::string16>();
218 autofill_ids = std::vector<int>(); 218 autofill_ids = std::vector<int>();
219 external_delegate_->OnSuggestionsReturned(kQueryId, 219 external_delegate_->OnSuggestionsReturned(kQueryId,
220 autofill_item, 220 autofill_item,
221 autofill_item, 221 autofill_item,
222 autofill_item, 222 autofill_item,
223 autofill_ids); 223 autofill_ids);
224 } 224 }
225 225
226 // Test that the Autofill popup is able to display warnings explaining why
227 // Autofill is disabled for a website.
228 // Regression test for http://crbug.com/247880
229 TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
230 IssueOnQuery(kQueryId);
231
232 // The enums must be cast to ints to prevent compile errors on linux_rel.
233 EXPECT_CALL(manager_delegate_,
234 ShowAutofillPopup(
235 _, _, _, _,
236 testing::ElementsAre(
237 static_cast<int>(
238 WebAutofillClient::MenuItemIDWarningMessage)),
239 _));
240
241 // This should call ShowAutofillPopup.
242 std::vector<base::string16> autofill_item;
243 autofill_item.push_back(base::string16());
244 std::vector<int> autofill_ids;
245 autofill_ids.push_back(WebAutofillClient::MenuItemIDWarningMessage);
246 external_delegate_->OnSuggestionsReturned(kQueryId,
247 autofill_item,
248 autofill_item,
249 autofill_item,
250 autofill_ids);
251 }
252
226 // Test that the Autofill delegate doesn't try and fill a form with a 253 // Test that the Autofill delegate doesn't try and fill a form with a
227 // negative unique id. 254 // negative unique id.
228 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { 255 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
229 // Ensure it doesn't try to preview the negative id. 256 // Ensure it doesn't try to preview the negative id.
230 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0); 257 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0);
231 EXPECT_CALL(*external_delegate_, ClearPreviewedForm()).Times(1); 258 EXPECT_CALL(*external_delegate_, ClearPreviewedForm()).Times(1);
232 external_delegate_->DidSelectSuggestion(-1); 259 external_delegate_->DidSelectSuggestion(-1);
233 260
234 // Ensure it doesn't try to fill the form in with the negative id. 261 // Ensure it doesn't try to fill the form in with the negative id.
235 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 262 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 350 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
324 351
325 external_delegate_->OnSuggestionsReturned(kQueryId, 352 external_delegate_->OnSuggestionsReturned(kQueryId,
326 autofill_items, 353 autofill_items,
327 autofill_items, 354 autofill_items,
328 autofill_items, 355 autofill_items,
329 autofill_ids); 356 autofill_ids);
330 } 357 }
331 358
332 } // namespace autofill 359 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/autofill_external_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698