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

Side by Side Diff: components/omnibox/browser/history_url_provider_unittest.cc

Issue 2397873002: Reject some previuosly-escaped chars in hostnames.
Patch Set: Some tests fixed 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/omnibox/browser/history_url_provider.h" 5 #include "components/omnibox/browser/history_url_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 const UrlAndLegalDefault results_1[] = { 544 const UrlAndLegalDefault results_1[] = {
545 { "http://wytmatch/", true } 545 { "http://wytmatch/", true }
546 }; 546 };
547 RunTest(ASCIIToUTF16("wytmatch"), std::string(), false, results_1, 547 RunTest(ASCIIToUTF16("wytmatch"), std::string(), false, results_1,
548 arraysize(results_1)); 548 arraysize(results_1));
549 549
550 RunTest(ASCIIToUTF16("wytmatch foo bar"), std::string(), false, NULL, 0); 550 RunTest(ASCIIToUTF16("wytmatch foo bar"), std::string(), false, NULL, 0);
551 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), std::string(), false, NULL, 0); 551 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), std::string(), false, NULL, 0);
552 552
553 const UrlAndLegalDefault results_2[] = { 553 const UrlAndLegalDefault results_2[] = {
554 { "http://wytmatch+foo+bar.com/", true } 554 { "http://wytmatch_foo_bar.com/", true }
555 }; 555 };
556 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), std::string(), false, 556 RunTest(ASCIIToUTF16("wytmatch_foo_bar.com"), std::string(), false,
557 results_2, arraysize(results_2)); 557 results_2, arraysize(results_2));
558 } 558 }
559 559
560 TEST_F(HistoryURLProviderTest, WhatYouTyped) { 560 TEST_F(HistoryURLProviderTest, WhatYouTyped) {
561 // Make sure we suggest a What You Typed match at the right times. 561 // Make sure we suggest a What You Typed match at the right times.
562 RunTest(ASCIIToUTF16("wytmatch"), std::string(), false, NULL, 0); 562 RunTest(ASCIIToUTF16("wytmatch"), std::string(), false, NULL, 0);
563 RunTest(ASCIIToUTF16("wytmatch foo bar"), std::string(), false, NULL, 0); 563 RunTest(ASCIIToUTF16("wytmatch foo bar"), std::string(), false, NULL, 0);
564 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), std::string(), false, NULL, 0); 564 RunTest(ASCIIToUTF16("wytmatch+foo+bar"), std::string(), false, NULL, 0);
565 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), std::string(), false, NULL, 0); 565 RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), std::string(), false, NULL, 0);
566 566
567 const UrlAndLegalDefault results_1[] = { 567 const UrlAndLegalDefault results_1[] = {
568 { "http://www.wytmatch.com/", true } 568 { "http://www.wytmatch.com/", true }
569 }; 569 };
570 RunTest(ASCIIToUTF16("wytmatch"), "com", false, results_1, 570 RunTest(ASCIIToUTF16("wytmatch"), "com", false, results_1,
571 arraysize(results_1)); 571 arraysize(results_1));
572 572
573 const UrlAndLegalDefault results_2[] = { 573 const UrlAndLegalDefault results_2[] = {
574 { "http://wytmatch%20foo%20bar/", false } 574 { "http://wytmatch/", true }
575 }; 575 };
576 RunTest(ASCIIToUTF16("http://wytmatch foo bar"), std::string(), false, 576 RunTest(ASCIIToUTF16("http://wytmatch"), std::string(), false,
577 results_2, arraysize(results_2)); 577 results_2, arraysize(results_2));
578
579 const UrlAndLegalDefault results_3[] = {
580 { "https://wytmatch%20foo%20bar/", false }
581 };
582 RunTest(ASCIIToUTF16("https://wytmatch foo bar"), std::string(), false,
583 results_3, arraysize(results_3));
584 } 578 }
585 579
586 TEST_F(HistoryURLProviderTest, Fixup) { 580 TEST_F(HistoryURLProviderTest, Fixup) {
587 // Test for various past crashes we've had. 581 // Test for various past crashes we've had.
588 RunTest(ASCIIToUTF16("\\"), std::string(), false, NULL, 0); 582 RunTest(ASCIIToUTF16("\\"), std::string(), false, NULL, 0);
589 RunTest(ASCIIToUTF16("#"), std::string(), false, NULL, 0); 583 RunTest(ASCIIToUTF16("#"), std::string(), false, NULL, 0);
590 RunTest(ASCIIToUTF16("%20"), std::string(), false, NULL, 0); 584 RunTest(ASCIIToUTF16("%20"), std::string(), false, NULL, 0);
591 const UrlAndLegalDefault fixup_crash[] = { 585 const UrlAndLegalDefault fixup_crash[] = {
592 { "http://%EF%BD%A5@s/", false } 586 { "http://%EF%BD%A5@s/", false }
593 }; 587 };
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // the default experimental scoring. 1112 // the default experimental scoring.
1119 autocomplete_->scoring_params_.experimental_scoring_enabled = true; 1113 autocomplete_->scoring_params_.experimental_scoring_enabled = true;
1120 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), 1114 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
1121 std::string(), false, output, max_matches)); 1115 std::string(), false, output, max_matches));
1122 for (int j = 0; j < max_matches; ++j) { 1116 for (int j = 0; j < max_matches; ++j) {
1123 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, 1117 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance,
1124 matches_[j].relevance); 1118 matches_[j].relevance);
1125 } 1119 }
1126 } 1120 }
1127 } 1121 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/autocomplete_input_unittest.cc ('k') | components/safe_browsing_db/v4_protocol_manager_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698