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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // Ensure selecting a new password entries or Autofill entries will | 368 // Ensure selecting a new password entries or Autofill entries will |
369 // cause any previews to get cleared. | 369 // cause any previews to get cleared. |
370 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); | 370 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
371 external_delegate_->DidSelectSuggestion( | 371 external_delegate_->DidSelectSuggestion( |
372 WebAutofillClient::MenuItemIDPasswordEntry); | 372 WebAutofillClient::MenuItemIDPasswordEntry); |
373 | 373 |
374 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); | 374 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
375 EXPECT_CALL(*autofill_driver_, SetRendererActionOnFormDataReception( | 375 EXPECT_CALL(*autofill_driver_, SetRendererActionOnFormDataReception( |
376 AutofillDriver::FORM_DATA_ACTION_PREVIEW)); | 376 AutofillDriver::FORM_DATA_ACTION_PREVIEW)); |
377 external_delegate_->DidSelectSuggestion(1); | 377 external_delegate_->DidSelectSuggestion(1); |
| 378 |
| 379 // Ensure selecting an AutoComplete entries will cause any previews to |
| 380 // get cleared. |
| 381 base::string16 suggestion_string(ASCIIToUTF16("baz foo")); |
| 382 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
| 383 external_delegate_->DidSelectAutocompleteSuggestion(suggestion_string); |
| 384 } |
| 385 |
| 386 // Test that the ClearAutoCompletePreview call is only sent if the autocomplete |
| 387 // field was being previewed. |
| 388 TEST_F(AutofillExternalDelegateUnitTest, |
| 389 ExternalDelegateClearAutocompletePreviewedField) { |
| 390 base::string16 suggestion_string(ASCIIToUTF16("baz foo")); |
| 391 EXPECT_CALL(*autofill_driver_, |
| 392 RendererShouldSetNodeText(suggestion_string)); |
| 393 |
| 394 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
| 395 EXPECT_CALL(*autofill_driver_, |
| 396 RendererShouldSetNodeText(ASCIIToUTF16(""))); |
| 397 external_delegate_->DidSelectAutocompleteSuggestion(suggestion_string); |
378 } | 398 } |
379 | 399 |
380 // Test that the popup is hidden once we are done editing the autofill field. | 400 // Test that the popup is hidden once we are done editing the autofill field. |
381 TEST_F(AutofillExternalDelegateUnitTest, | 401 TEST_F(AutofillExternalDelegateUnitTest, |
382 ExternalDelegateHidePopupAfterEditing) { | 402 ExternalDelegateHidePopupAfterEditing) { |
383 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); | 403 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); |
384 autofill::GenerateTestAutofillPopup(external_delegate_.get()); | 404 autofill::GenerateTestAutofillPopup(external_delegate_.get()); |
385 | 405 |
386 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 406 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
387 external_delegate_->DidEndTextFieldEditing(); | 407 external_delegate_->DidEndTextFieldEditing(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 504 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
485 base::string16 dummy_string(ASCIIToUTF16("baz foo")); | 505 base::string16 dummy_string(ASCIIToUTF16("baz foo")); |
486 EXPECT_CALL(*autofill_driver_, | 506 EXPECT_CALL(*autofill_driver_, |
487 RendererShouldSetNodeText(dummy_string)); | 507 RendererShouldSetNodeText(dummy_string)); |
488 external_delegate_->DidAcceptSuggestion( | 508 external_delegate_->DidAcceptSuggestion( |
489 dummy_string, | 509 dummy_string, |
490 WebAutofillClient::MenuItemIDAutocompleteEntry); | 510 WebAutofillClient::MenuItemIDAutocompleteEntry); |
491 } | 511 } |
492 | 512 |
493 } // namespace autofill | 513 } // namespace autofill |
OLD | NEW |