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

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

Issue 2478043002: HTTP Bad: Add warning message to autofill dropdown for http sites (Closed)
Patch Set: nit change Created 4 years, 1 month 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
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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 static_cast<int>(POPUP_ITEM_ID_WARNING_MESSAGE))), 469 static_cast<int>(POPUP_ITEM_ID_WARNING_MESSAGE))),
470 _)); 470 _));
471 471
472 // This should call ShowAutofillPopup. 472 // This should call ShowAutofillPopup.
473 std::vector<Suggestion> autofill_item; 473 std::vector<Suggestion> autofill_item;
474 autofill_item.push_back(Suggestion()); 474 autofill_item.push_back(Suggestion());
475 autofill_item[0].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 475 autofill_item[0].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE;
476 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); 476 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item);
477 } 477 }
478 478
479 // Test that Autofill warnings are removed if there are also autocomplete
480 // entries in the vector.
481 TEST_F(AutofillExternalDelegateUnitTest,
482 AutofillWarningsNotShown_WithSuggestions) {
483 IssueOnQuery(kQueryId);
484
485 // The enums must be cast to ints to prevent compile errors on linux_rel.
486 EXPECT_CALL(
487 autofill_client_,
488 ShowAutofillPopup(
489 _, _, SuggestionVectorIdsAre(testing::ElementsAre(
490 static_cast<int>(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY))),
491 _));
492
493 // This should call ShowAutofillPopup.
494 std::vector<Suggestion> suggestions;
495 suggestions.push_back(Suggestion());
496 suggestions[0].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE;
497 suggestions.push_back(Suggestion());
498 suggestions[1].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE;
499 suggestions.push_back(Suggestion());
500 suggestions[2].value = ASCIIToUTF16("Rick");
501 suggestions[2].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY;
502 external_delegate_->OnSuggestionsReturned(kQueryId, suggestions);
503 }
504
479 // Test that the Autofill delegate doesn't try and fill a form with a 505 // Test that the Autofill delegate doesn't try and fill a form with a
480 // negative unique id. 506 // negative unique id.
481 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { 507 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
482 // Ensure it doesn't try to preview the negative id. 508 // Ensure it doesn't try to preview the negative id.
483 EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0); 509 EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0);
484 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1); 510 EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
485 external_delegate_->DidSelectSuggestion(base::string16(), -1); 511 external_delegate_->DidSelectSuggestion(base::string16(), -1);
486 512
487 // Ensure it doesn't try to fill the form in with the negative id. 513 // Ensure it doesn't try to fill the form in with the negative id.
488 EXPECT_CALL(autofill_client_, HideAutofillPopup()); 514 EXPECT_CALL(autofill_client_, HideAutofillPopup());
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 RendererShouldFillFieldWithValue(dummy_string)); 711 RendererShouldFillFieldWithValue(dummy_string));
686 base::HistogramTester histogram_tester; 712 base::HistogramTester histogram_tester;
687 external_delegate_->DidAcceptSuggestion(dummy_string, 713 external_delegate_->DidAcceptSuggestion(dummy_string,
688 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, 714 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY,
689 0); 715 0);
690 histogram_tester.ExpectUniqueSample( 716 histogram_tester.ExpectUniqueSample(
691 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); 717 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1);
692 } 718 }
693 719
694 } // namespace autofill 720 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_external_delegate.cc ('k') | components/autofill/core/browser/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698