OLD | NEW |
---|---|
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 "chrome/browser/autocomplete/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 for_each(expected_urls.begin(), expected_urls.end(), | 247 for_each(expected_urls.begin(), expected_urls.end(), |
248 SetShouldContain(ac_matches_)).Leftovers(); | 248 SetShouldContain(ac_matches_)).Leftovers(); |
249 EXPECT_EQ(0U, Leftovers.size()); | 249 EXPECT_EQ(0U, Leftovers.size()); |
250 | 250 |
251 // See if we got the expected top scorer. | 251 // See if we got the expected top scorer. |
252 if (!ac_matches_.empty()) { | 252 if (!ac_matches_.empty()) { |
253 std::partial_sort(ac_matches_.begin(), ac_matches_.begin() + 1, | 253 std::partial_sort(ac_matches_.begin(), ac_matches_.begin() + 1, |
254 ac_matches_.end(), AutocompleteMatch::MoreRelevant); | 254 ac_matches_.end(), AutocompleteMatch::MoreRelevant); |
255 EXPECT_EQ(expected_top_result, ac_matches_[0].destination_url.spec()); | 255 EXPECT_EQ(expected_top_result, ac_matches_[0].destination_url.spec()); |
256 } | 256 } |
257 | |
258 // No shortcuts matches are allowed to be inlined no matter how highly | |
259 // they score. | |
Peter Kasting
2013/08/06 22:56:16
Nit: Should this have a TODO to change this to all
Mark P
2013/08/07 00:44:31
No. TODOs in code should be trivial. I'm not eve
| |
260 for (ACMatches::const_iterator it = ac_matches_.begin(); | |
261 it != ac_matches_.end(); ++it) | |
262 EXPECT_FALSE(it->allowed_to_be_default_match); | |
257 } | 263 } |
258 | 264 |
259 TEST_F(ShortcutsProviderTest, SimpleSingleMatch) { | 265 TEST_F(ShortcutsProviderTest, SimpleSingleMatch) { |
260 string16 text(ASCIIToUTF16("go")); | 266 string16 text(ASCIIToUTF16("go")); |
261 std::string expected_url("http://www.google.com/"); | 267 std::string expected_url("http://www.google.com/"); |
262 std::vector<std::string> expected_urls; | 268 std::vector<std::string> expected_urls; |
263 expected_urls.push_back(expected_url); | 269 expected_urls.push_back(expected_url); |
264 RunTest(text, expected_urls, expected_url); | 270 RunTest(text, expected_urls, expected_url); |
265 } | 271 } |
266 | 272 |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 | 671 |
666 match.destination_url = GURL(shortcuts_to_test_delete[2].url); | 672 match.destination_url = GURL(shortcuts_to_test_delete[2].url); |
667 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); | 673 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); |
668 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); | 674 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); |
669 | 675 |
670 provider_->DeleteMatch(match); | 676 provider_->DeleteMatch(match); |
671 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size()); | 677 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size()); |
672 EXPECT_TRUE(backend_->shortcuts_map().end() == | 678 EXPECT_TRUE(backend_->shortcuts_map().end() == |
673 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); | 679 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); |
674 } | 680 } |
OLD | NEW |