| 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/strings/string16.h" | 8 #include "base/strings/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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Test that the Autofill delegate doesn't try and fill a form with a | 346 // Test that the Autofill delegate doesn't try and fill a form with a |
| 347 // negative unique id. | 347 // negative unique id. |
| 348 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { | 348 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { |
| 349 // Ensure it doesn't try to preview the negative id. | 349 // Ensure it doesn't try to preview the negative id. |
| 350 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0); | 350 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0); |
| 351 EXPECT_CALL(*autofill_driver_, | 351 EXPECT_CALL(*autofill_driver_, |
| 352 SetRendererActionOnFormDataReception(_)).Times(0); | 352 SetRendererActionOnFormDataReception(_)).Times(0); |
| 353 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); | 353 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
| 354 external_delegate_->DidSelectSuggestion(-1); | 354 external_delegate_->DidPreselectSuggestion(-1); |
| 355 | 355 |
| 356 // Ensure it doesn't try to fill the form in with the negative id. | 356 // Ensure it doesn't try to fill the form in with the negative id. |
| 357 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 357 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
| 358 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0); | 358 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)).Times(0); |
| 359 EXPECT_CALL(*autofill_driver_, | 359 EXPECT_CALL(*autofill_driver_, |
| 360 SetRendererActionOnFormDataReception(_)).Times(0); | 360 SetRendererActionOnFormDataReception(_)).Times(0); |
| 361 external_delegate_->DidAcceptSuggestion(base::string16(), -1); | 361 external_delegate_->DidAcceptSuggestion(base::string16(), -1); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Test that the ClearPreview call is only sent if the form was being previewed | 364 // Test that the ClearPreview call is only sent if the form was being previewed |
| 365 // (i.e. it isn't autofilling a password). | 365 // (i.e. it isn't autofilling a password). |
| 366 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { | 366 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) { |
| 367 // Called by DidSelectSuggestion, add expectation to remove warning. | 367 // Called by DidPreselectSuggestion, add expectation to remove warning. |
| 368 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)); | 368 EXPECT_CALL(*autofill_manager_, OnFillAutofillFormData(_, _, _, _)); |
| 369 | 369 |
| 370 // Ensure selecting a new password entries or Autofill entries will | 370 // Ensure preselecting a new password entries or Autofill entries will |
| 371 // cause any previews to get cleared. | 371 // cause any previews to get cleared. |
| 372 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); | 372 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
| 373 external_delegate_->DidSelectSuggestion( | 373 external_delegate_->DidPreselectSuggestion( |
| 374 WebAutofillClient::MenuItemIDPasswordEntry); | 374 WebAutofillClient::MenuItemIDPasswordEntry); |
| 375 | 375 |
| 376 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); | 376 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); |
| 377 EXPECT_CALL(*autofill_driver_, SetRendererActionOnFormDataReception( | 377 EXPECT_CALL(*autofill_driver_, SetRendererActionOnFormDataReception( |
| 378 AutofillDriver::FORM_DATA_ACTION_PREVIEW)); | 378 AutofillDriver::FORM_DATA_ACTION_PREVIEW)); |
| 379 external_delegate_->DidSelectSuggestion(1); | 379 external_delegate_->DidPreselectSuggestion(1); |
| 380 } | 380 } |
| 381 | 381 |
| 382 // Test that the popup is hidden once we are done editing the autofill field. | 382 // Test that the popup is hidden once we are done editing the autofill field. |
| 383 TEST_F(AutofillExternalDelegateUnitTest, | 383 TEST_F(AutofillExternalDelegateUnitTest, |
| 384 ExternalDelegateHidePopupAfterEditing) { | 384 ExternalDelegateHidePopupAfterEditing) { |
| 385 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); | 385 EXPECT_CALL(manager_delegate_, ShowAutofillPopup(_, _, _, _, _, _, _)); |
| 386 autofill::GenerateTestAutofillPopup(external_delegate_.get()); | 386 autofill::GenerateTestAutofillPopup(external_delegate_.get()); |
| 387 | 387 |
| 388 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 388 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
| 389 external_delegate_->DidEndTextFieldEditing(); | 389 external_delegate_->DidEndTextFieldEditing(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 464 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
| 465 | 465 |
| 466 external_delegate_->OnSuggestionsReturned(kQueryId, | 466 external_delegate_->OnSuggestionsReturned(kQueryId, |
| 467 autofill_items, | 467 autofill_items, |
| 468 autofill_items, | 468 autofill_items, |
| 469 autofill_items, | 469 autofill_items, |
| 470 autofill_ids); | 470 autofill_ids); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace autofill | 473 } // namespace autofill |
| OLD | NEW |