OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autocomplete_match.h" | 5 #include "components/omnibox/autocomplete_match.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 TEST(AutocompleteMatchTest, MoreRelevant) { | 10 TEST(AutocompleteMatchTest, MoreRelevant) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
121 m.duplicate_matches.push_back(AutocompleteMatch( | 121 m.duplicate_matches.push_back(AutocompleteMatch( |
122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
123 EXPECT_FALSE(m.SupportsDeletion()); | 123 EXPECT_FALSE(m.SupportsDeletion()); |
124 | 124 |
125 // A non-deletable match, with at least one deletable duplicate. | 125 // A non-deletable match, with at least one deletable duplicate. |
126 m.duplicate_matches.push_back(AutocompleteMatch( | 126 m.duplicate_matches.push_back(AutocompleteMatch( |
127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
128 EXPECT_TRUE(m.SupportsDeletion()); | 128 EXPECT_TRUE(m.SupportsDeletion()); |
129 } | 129 } |
| 130 |
| 131 TEST(AutocompleteMatchTest, Duplicates) { |
| 132 struct DuplicateCases { |
| 133 std::string url1; |
| 134 std::string url2; |
| 135 bool expected_duplicate; |
| 136 } cases[] = { |
| 137 { "http://www.google.com/", "https://www.google.com/", true }, |
| 138 { "http://www.google.com/", "http://www.google.com", true }, |
| 139 { "http://google.com/", "http://www.google.com/", true }, |
| 140 { "http://www.google.com/", "HTTP://www.GOOGLE.com/", true }, |
| 141 { "http://www.google.com/1", "http://www.google.com/1/", true }, |
| 142 { "http://www.google.com/", "http://www.google.com", true }, |
| 143 { "https://www.google.com/", "http://google.com", true }, |
| 144 { "http://www.google.com/", "wss://www.google.com/", false }, |
| 145 { "http://www.google.com/", "http://www.google.com/1", false }, |
| 146 { "http://www.google.com/", "http://www.goo.com/", false }, |
| 147 { "http://www.google.com/", "http://w2.google.com/", false }, |
| 148 { "http://www.google.com/", "http://m.google.com/", false }, |
| 149 { "http://www.google.com/", "http://www.google.com/?foo", false }, |
| 150 }; |
| 151 |
| 152 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 153 SCOPED_TRACE("url1=" + cases[i].url1 + " url2=" + cases[i].url2); |
| 154 AutocompleteMatch m1(NULL, 100, false, |
| 155 AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 156 m1.destination_url = GURL(cases[i].url1); |
| 157 m1.ComputeStrippedDestinationURL(NULL); |
| 158 AutocompleteMatch m2(NULL, 100, false, |
| 159 AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 160 m2.destination_url = GURL(cases[i].url2); |
| 161 m2.ComputeStrippedDestinationURL(NULL); |
| 162 EXPECT_EQ(cases[i].expected_duplicate, |
| 163 AutocompleteMatch::DestinationsEqual(m1, m2)); |
| 164 } |
| 165 } |
OLD | NEW |