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

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

Issue 1258813002: Implement a new IDN display policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: url_canon test: wchar* needs a surrogate pair on *nix Created 4 years, 9 months 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 10
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 AutocompleteInput input( 845 AutocompleteInput input(
846 ASCIIToUTF16("foo"), base::string16::npos, std::string(), GURL(), 846 ASCIIToUTF16("foo"), base::string16::npos, std::string(), GURL(),
847 metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, true, 847 metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, true,
848 TestSchemeClassifier()); 848 TestSchemeClassifier());
849 autocomplete_->Start(input, false); 849 autocomplete_->Start(input, false);
850 EXPECT_TRUE(autocomplete_->matches().empty()); 850 EXPECT_TRUE(autocomplete_->matches().empty());
851 } 851 }
852 852
853 TEST_F(HistoryURLProviderTest, DoesNotInlinePunycodeMatches) { 853 TEST_F(HistoryURLProviderTest, DoesNotInlinePunycodeMatches) {
854 // A URL that matches due to a match in the punycode URL are allowed to be the 854 // A URL that matches due to a match in the punycode URL are allowed to be the
855 // default match if the URL doesn't get rendered as international characters 855 // default match if the URL doesn't get rendered as international characters.
856 // in the given locale. 856 // When the punycode part of the URL is rendered as international characters,
857 // this match should not be allowed to be the default match if the inline
858 // autocomplete text starts in the middle of the international characters.
857 const UrlAndLegalDefault expected_true[] = { 859 const UrlAndLegalDefault expected_true[] = {
858 { "http://puny.xn--1lq90ic7f1rc.cn/", true }, 860 { "http://puny.xn--1lq90ic7f1rc.cn/", true },
859 }; 861 };
860 UrlAndLegalDefault expected_false[] = { 862 UrlAndLegalDefault expected_false[] = {
861 { "http://puny.xn--1lq90ic7f1rc.cn/", false }, 863 { "http://puny.xn--1lq90ic7f1rc.cn/", false },
862 }; 864 };
863 RunTest(ASCIIToUTF16("pun"), std::string(), false, expected_true, 865 RunTest(ASCIIToUTF16("pun"), std::string(), false, expected_true,
864 arraysize(expected_true)); 866 arraysize(expected_true));
865 RunTest(ASCIIToUTF16("puny."), std::string(), false, expected_true, 867 RunTest(ASCIIToUTF16("puny."), std::string(), false, expected_true,
866 arraysize(expected_true)); 868 arraysize(expected_true));
867 RunTest(ASCIIToUTF16("puny.x"), std::string(), false, expected_true,
868 arraysize(expected_true));
869 RunTest(ASCIIToUTF16("puny.xn"), std::string(), false, expected_true,
870 arraysize(expected_true));
871 RunTest(ASCIIToUTF16("puny.xn--"), std::string(), false, expected_true,
872 arraysize(expected_true));
873 RunTest(ASCIIToUTF16("puny.xn--1l"), std::string(), false, expected_true,
874 arraysize(expected_true));
875 RunTest(ASCIIToUTF16("puny.xn--1lq90ic7f1rc"), std::string(), false,
876 expected_true, arraysize(expected_true));
877 RunTest(ASCIIToUTF16("puny.xn--1lq90ic7f1rc."), std::string(), false,
878 expected_true, arraysize(expected_true));
879 // Set the language so the punycode part of the URL is rendered as
880 // international characters. Then this match should not be allowed to be
881 // the default match if the inline autocomplete text starts in the middle
882 // of the international characters.
883 EXPECT_CALL(*client_, GetAcceptLanguages())
884 .WillRepeatedly(testing::Return("zh-CN"));
885 RunTest(ASCIIToUTF16("pun"), std::string(), false, expected_true,
886 arraysize(expected_true));
887 RunTest(ASCIIToUTF16("puny."), std::string(), false, expected_true,
888 arraysize(expected_true));
889 RunTest(ASCIIToUTF16("puny.x"), std::string(), false, expected_false, 869 RunTest(ASCIIToUTF16("puny.x"), std::string(), false, expected_false,
890 arraysize(expected_false)); 870 arraysize(expected_false));
891 RunTest(ASCIIToUTF16("puny.xn"), std::string(), false, expected_false, 871 RunTest(ASCIIToUTF16("puny.xn"), std::string(), false, expected_false,
892 arraysize(expected_false)); 872 arraysize(expected_false));
893 RunTest(ASCIIToUTF16("puny.xn--"), std::string(), false, expected_false, 873 RunTest(ASCIIToUTF16("puny.xn--"), std::string(), false, expected_false,
894 arraysize(expected_false)); 874 arraysize(expected_false));
895 RunTest(ASCIIToUTF16("puny.xn--1l"), std::string(), false, expected_false, 875 RunTest(ASCIIToUTF16("puny.xn--1l"), std::string(), false, expected_false,
896 arraysize(expected_false)); 876 arraysize(expected_false));
897 RunTest(ASCIIToUTF16("puny.xn--1lq90ic7f1rc"), std::string(), false, 877 RunTest(ASCIIToUTF16("puny.xn--1lq90ic7f1rc"), std::string(), false,
898 expected_true, arraysize(expected_true)); 878 expected_true, arraysize(expected_true));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // the default experimental scoring. 1098 // the default experimental scoring.
1119 autocomplete_->scoring_params_.experimental_scoring_enabled = true; 1099 autocomplete_->scoring_params_.experimental_scoring_enabled = true;
1120 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), 1100 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
1121 std::string(), false, output, max_matches)); 1101 std::string(), false, output, max_matches));
1122 for (int j = 0; j < max_matches; ++j) { 1102 for (int j = 0; j < max_matches; ++j) {
1123 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, 1103 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance,
1124 matches_[j].relevance); 1104 matches_[j].relevance);
1125 } 1105 }
1126 } 1106 }
1127 } 1107 }
OLDNEW
« no previous file with comments | « no previous file | components/url_formatter/url_formatter.h » ('j') | components/url_formatter/url_formatter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698