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

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

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually fix compile failure. Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Test that the popup is hidden once we are done editing the autofill field. 390 // Test that the popup is hidden once we are done editing the autofill field.
391 TEST_F(AutofillExternalDelegateUnitTest, 391 TEST_F(AutofillExternalDelegateUnitTest,
392 ExternalDelegateHidePopupAfterEditing) { 392 ExternalDelegateHidePopupAfterEditing) {
393 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); 393 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _));
394 autofill::GenerateTestAutofillPopup(external_delegate_.get()); 394 autofill::GenerateTestAutofillPopup(external_delegate_.get());
395 395
396 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 396 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
397 external_delegate_->DidEndTextFieldEditing(); 397 external_delegate_->DidEndTextFieldEditing();
398 } 398 }
399 399
400 // Test that the popup is marked as visible after recieving password
401 // suggestions.
402 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) {
403 static const base::string16 kUsername = ASCIIToUTF16("username");
404 static const base::string16 kSignonRealm = ASCIIToUTF16("http://foo.com/");
405 std::vector<base::string16> suggestions;
406 suggestions.push_back(kUsername);
407 std::vector<base::string16> realms;
408 realms.push_back(kSignonRealm);
409
410 FormFieldData field;
411 field.is_focusable = true;
412 field.should_autocomplete = true;
413 const gfx::RectF element_bounds;
414
415 FormFieldData username_field_data;
416 username_field_data.value = kUsername;
417 PasswordFormFillData password_form_fill_data;
418 password_form_fill_data.basic_data.fields.push_back(username_field_data);
419 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data);
420
421 // The enums must be cast to ints to prevent compile errors on linux_rel.
422 EXPECT_CALL(
423 manager_delegate_,
424 ShowAutofillPopup(
425 _,
426 _,
427 _,
428 _,
429 _,
430 testing::ElementsAre(static_cast<int>(POPUP_ITEM_ID_PASSWORD_ENTRY)),
431 _));
432
433 external_delegate_->OnShowPasswordSuggestions(suggestions,
434 realms,
435 field,
436 element_bounds);
437
438 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
439
440 // This should trigger a call to hide the popup since
441 // we've selected an option.
442 external_delegate_->DidAcceptSuggestion(suggestions[0],
443 POPUP_ITEM_ID_PASSWORD_ENTRY);
444 }
445
446 // Test that the driver is directed to accept the data list after being notified 400 // Test that the driver is directed to accept the data list after being notified
447 // that the user accepted the data list suggestion. 401 // that the user accepted the data list suggestion.
448 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { 402 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) {
449 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 403 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
450 base::string16 dummy_string(ASCIIToUTF16("baz qux")); 404 base::string16 dummy_string(ASCIIToUTF16("baz qux"));
451 EXPECT_CALL(*autofill_driver_, 405 EXPECT_CALL(*autofill_driver_,
452 RendererShouldAcceptDataListSuggestion(dummy_string)); 406 RendererShouldAcceptDataListSuggestion(dummy_string));
453 external_delegate_->DidAcceptSuggestion(dummy_string, 407 external_delegate_->DidAcceptSuggestion(dummy_string,
454 POPUP_ITEM_ID_DATALIST_ENTRY); 408 POPUP_ITEM_ID_DATALIST_ENTRY);
455 } 409 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { 447 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) {
494 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 448 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
495 base::string16 dummy_string(ASCIIToUTF16("baz foo")); 449 base::string16 dummy_string(ASCIIToUTF16("baz foo"));
496 EXPECT_CALL(*autofill_driver_, 450 EXPECT_CALL(*autofill_driver_,
497 RendererShouldFillFieldWithValue(dummy_string)); 451 RendererShouldFillFieldWithValue(dummy_string));
498 external_delegate_->DidAcceptSuggestion(dummy_string, 452 external_delegate_->DidAcceptSuggestion(dummy_string,
499 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); 453 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
500 } 454 }
501 455
502 } // namespace autofill 456 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_external_delegate.cc ('k') | components/autofill/core/browser/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698