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

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

Issue 2496683003: Http Bad: Add a PopupItemId to identify http warning message (Closed)
Patch Set: minor 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Test that the Autofill popup is able to display warnings explaining why 456 // Test that the Autofill popup is able to display warnings explaining why
457 // Autofill is disabled for a website. 457 // Autofill is disabled for a website.
458 // Regression test for http://crbug.com/247880 458 // Regression test for http://crbug.com/247880
459 TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) { 459 TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
460 IssueOnQuery(kQueryId); 460 IssueOnQuery(kQueryId);
461 461
462 // The enums must be cast to ints to prevent compile errors on linux_rel. 462 // The enums must be cast to ints to prevent compile errors on linux_rel.
463 EXPECT_CALL( 463 EXPECT_CALL(
464 autofill_client_, 464 autofill_client_,
465 ShowAutofillPopup( 465 ShowAutofillPopup(
466 _, 466 _, _, SuggestionVectorIdsAre(testing::ElementsAre(static_cast<int>(
467 _, 467 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE))),
468 SuggestionVectorIdsAre(testing::ElementsAre(
469 static_cast<int>(POPUP_ITEM_ID_WARNING_MESSAGE))),
470 _)); 468 _));
471 469
472 // This should call ShowAutofillPopup. 470 // This should call ShowAutofillPopup.
473 std::vector<Suggestion> autofill_item; 471 std::vector<Suggestion> autofill_item;
474 autofill_item.push_back(Suggestion()); 472 autofill_item.push_back(Suggestion());
475 autofill_item[0].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 473 autofill_item[0].frontend_id =
474 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE;
476 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); 475 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item);
477 } 476 }
478 477
479 // Test that Autofill warnings are removed if there are also autocomplete 478 // Test that Autofill warnings are removed if there are also autocomplete
480 // entries in the vector. 479 // entries in the vector.
481 TEST_F(AutofillExternalDelegateUnitTest, 480 TEST_F(AutofillExternalDelegateUnitTest,
482 AutofillWarningsNotShown_WithSuggestions) { 481 AutofillWarningsNotShown_WithSuggestions) {
483 IssueOnQuery(kQueryId); 482 IssueOnQuery(kQueryId);
484 483
485 // The enums must be cast to ints to prevent compile errors on linux_rel. 484 // The enums must be cast to ints to prevent compile errors on linux_rel.
486 EXPECT_CALL( 485 EXPECT_CALL(
487 autofill_client_, 486 autofill_client_,
488 ShowAutofillPopup( 487 ShowAutofillPopup(
489 _, _, SuggestionVectorIdsAre(testing::ElementsAre( 488 _, _, SuggestionVectorIdsAre(testing::ElementsAre(
490 static_cast<int>(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY))), 489 static_cast<int>(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY))),
491 _)); 490 _));
492 491
493 // This should call ShowAutofillPopup. 492 // This should call ShowAutofillPopup.
494 std::vector<Suggestion> suggestions; 493 std::vector<Suggestion> suggestions;
495 suggestions.push_back(Suggestion()); 494 suggestions.push_back(Suggestion());
496 suggestions[0].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 495 suggestions[0].frontend_id = POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE;
497 suggestions.push_back(Suggestion()); 496 suggestions.push_back(Suggestion());
498 suggestions[1].frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 497 suggestions[1].frontend_id =
498 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE;
499 suggestions.push_back(Suggestion()); 499 suggestions.push_back(Suggestion());
500 suggestions[2].value = ASCIIToUTF16("Rick"); 500 suggestions[2].value = ASCIIToUTF16("Rick");
501 suggestions[2].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; 501 suggestions[2].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY;
502 external_delegate_->OnSuggestionsReturned(kQueryId, suggestions); 502 external_delegate_->OnSuggestionsReturned(kQueryId, suggestions);
503 } 503 }
504 504
505 // 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
506 // negative unique id. 506 // negative unique id.
507 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) { 507 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
508 // Ensure it doesn't try to preview the negative id. 508 // Ensure it doesn't try to preview the negative id.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 RendererShouldFillFieldWithValue(dummy_string)); 711 RendererShouldFillFieldWithValue(dummy_string));
712 base::HistogramTester histogram_tester; 712 base::HistogramTester histogram_tester;
713 external_delegate_->DidAcceptSuggestion(dummy_string, 713 external_delegate_->DidAcceptSuggestion(dummy_string,
714 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, 714 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY,
715 0); 715 0);
716 histogram_tester.ExpectUniqueSample( 716 histogram_tester.ExpectUniqueSample(
717 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); 717 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1);
718 } 718 }
719 719
720 } // namespace autofill 720 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698