OLD | NEW |
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // Test that the popup is hidden once we are done editing the autofill field. | 379 // Test that the popup is hidden once we are done editing the autofill field. |
380 TEST_F(AutofillExternalDelegateUnitTest, | 380 TEST_F(AutofillExternalDelegateUnitTest, |
381 ExternalDelegateHidePopupAfterEditing) { | 381 ExternalDelegateHidePopupAfterEditing) { |
382 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); | 382 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); |
383 autofill::GenerateTestAutofillPopup(external_delegate_.get()); | 383 autofill::GenerateTestAutofillPopup(external_delegate_.get()); |
384 | 384 |
385 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 385 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
386 external_delegate_->DidEndTextFieldEditing(); | 386 external_delegate_->DidEndTextFieldEditing(); |
387 } | 387 } |
388 | 388 |
389 // Test that the popup is marked as visible after recieving password | |
390 // suggestions. | |
391 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { | |
392 static const base::string16 kUsername = ASCIIToUTF16("username"); | |
393 static const base::string16 kSignonRealm = ASCIIToUTF16("http://foo.com/"); | |
394 std::vector<base::string16> suggestions; | |
395 suggestions.push_back(kUsername); | |
396 std::vector<base::string16> realms; | |
397 realms.push_back(kSignonRealm); | |
398 | |
399 FormFieldData field; | |
400 field.is_focusable = true; | |
401 field.should_autocomplete = true; | |
402 const gfx::RectF element_bounds; | |
403 | |
404 FormFieldData username_field_data; | |
405 username_field_data.value = kUsername; | |
406 PasswordFormFillData password_form_fill_data; | |
407 password_form_fill_data.basic_data.fields.push_back(username_field_data); | |
408 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data); | |
409 | |
410 // The enums must be cast to ints to prevent compile errors on linux_rel. | |
411 EXPECT_CALL( | |
412 manager_delegate_, | |
413 ShowAutofillPopup( | |
414 _, | |
415 _, | |
416 _, | |
417 _, | |
418 _, | |
419 testing::ElementsAre(static_cast<int>(POPUP_ITEM_ID_PASSWORD_ENTRY)), | |
420 _)); | |
421 | |
422 external_delegate_->OnShowPasswordSuggestions(suggestions, | |
423 realms, | |
424 field, | |
425 element_bounds); | |
426 | |
427 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | |
428 | |
429 // This should trigger a call to hide the popup since | |
430 // we've selected an option. | |
431 external_delegate_->DidAcceptSuggestion(suggestions[0], | |
432 POPUP_ITEM_ID_PASSWORD_ENTRY); | |
433 } | |
434 | |
435 // Test that the driver is directed to accept the data list after being notified | 389 // Test that the driver is directed to accept the data list after being notified |
436 // that the user accepted the data list suggestion. | 390 // that the user accepted the data list suggestion. |
437 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { | 391 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { |
438 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 392 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
439 base::string16 dummy_string(ASCIIToUTF16("baz qux")); | 393 base::string16 dummy_string(ASCIIToUTF16("baz qux")); |
440 EXPECT_CALL(*autofill_driver_, | 394 EXPECT_CALL(*autofill_driver_, |
441 RendererShouldAcceptDataListSuggestion(dummy_string)); | 395 RendererShouldAcceptDataListSuggestion(dummy_string)); |
442 external_delegate_->DidAcceptSuggestion(dummy_string, | 396 external_delegate_->DidAcceptSuggestion(dummy_string, |
443 POPUP_ITEM_ID_DATALIST_ENTRY); | 397 POPUP_ITEM_ID_DATALIST_ENTRY); |
444 } | 398 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateSetNodeText) { | 436 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateSetNodeText) { |
483 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 437 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
484 base::string16 dummy_string(ASCIIToUTF16("baz foo")); | 438 base::string16 dummy_string(ASCIIToUTF16("baz foo")); |
485 EXPECT_CALL(*autofill_driver_, | 439 EXPECT_CALL(*autofill_driver_, |
486 RendererShouldSetNodeText(dummy_string)); | 440 RendererShouldSetNodeText(dummy_string)); |
487 external_delegate_->DidAcceptSuggestion(dummy_string, | 441 external_delegate_->DidAcceptSuggestion(dummy_string, |
488 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); | 442 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); |
489 } | 443 } |
490 | 444 |
491 } // namespace autofill | 445 } // namespace autofill |
OLD | NEW |