| Index: components/omnibox/autocomplete_match_unittest.cc
|
| diff --git a/components/omnibox/autocomplete_match_unittest.cc b/components/omnibox/autocomplete_match_unittest.cc
|
| index 2fba94c1dfe8189fc7239ea53be8d8975e78fe11..24ab3dce3cae292fa9a79c1e1f2193bff381ee2d 100644
|
| --- a/components/omnibox/autocomplete_match_unittest.cc
|
| +++ b/components/omnibox/autocomplete_match_unittest.cc
|
| @@ -5,6 +5,8 @@
|
| #include "components/omnibox/autocomplete_match.h"
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/strings/utf_string_conversions.cc"
|
| +#include "components/omnibox/test_scheme_classifier.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| TEST(AutocompleteMatchTest, MoreRelevant) {
|
| @@ -127,3 +129,65 @@ TEST(AutocompleteMatchTest, SupportsDeletion) {
|
| NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED));
|
| EXPECT_TRUE(m.SupportsDeletion());
|
| }
|
| +
|
| +TEST(AutocompleteMatchTest, Duplicates) {
|
| + struct DuplicateCases {
|
| + std::string input;
|
| + std::string url1;
|
| + std::string url2;
|
| + bool expected_duplicate;
|
| + } cases[] = {
|
| + { "g", "http://www.google.com/", "https://www.google.com/", true },
|
| + { "g", "http://www.google.com/", "http://www.google.com", true },
|
| + { "g", "http://google.com/", "http://www.google.com/", true },
|
| + { "g", "http://www.google.com/", "HTTP://www.GOOGLE.com/", true },
|
| + { "g", "http://www.google.com/1", "http://www.google.com/1/", true },
|
| + { "g", "http://www.google.com/", "http://www.google.com", true },
|
| + { "g", "https://www.google.com/", "http://google.com", true },
|
| + { "g", "http://www.google.com/", "wss://www.google.com/", false },
|
| + { "g", "http://www.google.com/", "http://www.google.com/1", false },
|
| + { "g", "http://www.google.com/", "http://www.goo.com/", false },
|
| + { "g", "http://www.google.com/", "http://w2.google.com/", false },
|
| + { "g", "http://www.google.com/", "http://m.google.com/", false },
|
| + { "g", "http://www.google.com/", "http://www.google.com/?foo", false },
|
| +
|
| + // Some tests to verify that, depending on the user's input, we don't
|
| + // allow URL with different schemes to be considered duplicates.
|
| + { "http://g", "http://www.google.com/",
|
| + "https://www.google.com/", false },
|
| + { "http://g", "http://www.blah.com/",
|
| + "https://www.blah.com/", true },
|
| + { "http://g", "http://www.google.com/1",
|
| + "https://www.google.com/1", false },
|
| + { "http://g hello", "http://www.google.com/",
|
| + "https://www.google.com/", false },
|
| + { "hello http://g", "http://www.google.com/",
|
| + "https://www.google.com/", false },
|
| + { "hello http://g", "http://www.blah.com/",
|
| + "https://www.blah.com/", true },
|
| + { "http://b http://g", "http://www.google.com/",
|
| + "https://www.google.com/", false },
|
| + { "http://b http://g", "http://www.blah.com/",
|
| + "https://www.blah.com/", false },
|
| +
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(cases); ++i) {
|
| + SCOPED_TRACE("input=" + cases[i].input + " url1=" + cases[i].url1 +
|
| + " url2=" + cases[i].url2);
|
| + AutocompleteInput input(
|
| + base::ASCIIToUTF16(cases[i].input), base::string16::npos, std::string(),
|
| + GURL(), metrics::OmniboxEventProto::INVALID_SPEC, false, false, true,
|
| + true, TestSchemeClassifier());
|
| + AutocompleteMatch m1(NULL, 100, false,
|
| + AutocompleteMatchType::URL_WHAT_YOU_TYPED);
|
| + m1.destination_url = GURL(cases[i].url1);
|
| + m1.ComputeStrippedDestinationURL(input, NULL);
|
| + AutocompleteMatch m2(NULL, 100, false,
|
| + AutocompleteMatchType::URL_WHAT_YOU_TYPED);
|
| + m2.destination_url = GURL(cases[i].url2);
|
| + m2.ComputeStrippedDestinationURL(input, NULL);
|
| + EXPECT_EQ(cases[i].expected_duplicate,
|
| + AutocompleteMatch::DestinationsEqual(m1, m2));
|
| + }
|
| +}
|
|
|