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/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 | 289 |
290 if (can_inline_top_result) { | 290 if (can_inline_top_result) { |
291 // When the top scorer is inline-able make sure we get the expected | 291 // When the top scorer is inline-able make sure we get the expected |
292 // fill_into_edit and autocomplete offset. | 292 // fill_into_edit and autocomplete offset. |
293 EXPECT_EQ(expected_fill_into_edit, ac_matches_[0].fill_into_edit) | 293 EXPECT_EQ(expected_fill_into_edit, ac_matches_[0].fill_into_edit) |
294 << "fill_into_edit was: '" << ac_matches_[0].fill_into_edit | 294 << "fill_into_edit was: '" << ac_matches_[0].fill_into_edit |
295 << "' but we expected '" << expected_fill_into_edit << "'."; | 295 << "' but we expected '" << expected_fill_into_edit << "'."; |
296 size_t text_pos = expected_fill_into_edit.find(text); | 296 size_t text_pos = expected_fill_into_edit.find(text); |
297 ASSERT_NE(string16::npos, text_pos); | 297 ASSERT_NE(string16::npos, text_pos); |
298 EXPECT_EQ(text_pos + text.size(), | 298 EXPECT_EQ(ac_matches_[0].fill_into_edit.substr(text_pos + text.size()), |
299 ac_matches_[0].inline_autocomplete_offset); | 299 ac_matches_[0].inline_autocompletion); |
300 } else { | 300 } else { |
301 // When the top scorer is not inline-able autocomplete offset must be npos. | 301 // When the top scorer is not inline-able autocomplete offset must be npos. |
302 EXPECT_EQ(string16::npos, ac_matches_[0].inline_autocomplete_offset); | 302 EXPECT_TRUE(ac_matches_[0].inline_autocompletion.empty()); |
303 // Also, the score must be too low to be inlineable. | 303 // Also, the score must be too low to be inlineable. |
304 EXPECT_LT(ac_matches_[0].relevance, | 304 EXPECT_LT(ac_matches_[0].relevance, |
305 AutocompleteResult::kLowestDefaultScore); | 305 AutocompleteResult::kLowestDefaultScore); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { | 309 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { |
310 std::vector<std::string> expected_urls; | 310 std::vector<std::string> expected_urls; |
311 expected_urls.push_back("http://slashdot.org/favorite_page.html"); | 311 expected_urls.push_back("http://slashdot.org/favorite_page.html"); |
312 RunTest(ASCIIToUTF16("slashdot"), expected_urls, true, | 312 RunTest(ASCIIToUTF16("slashdot"), expected_urls, true, |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 621 } |
622 | 622 |
623 TEST_F(HQPOrderingTest, TEAMatch) { | 623 TEST_F(HQPOrderingTest, TEAMatch) { |
624 std::vector<std::string> expected_urls; | 624 std::vector<std::string> expected_urls; |
625 expected_urls.push_back("http://www.teamliquid.net/"); | 625 expected_urls.push_back("http://www.teamliquid.net/"); |
626 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 626 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
627 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 627 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
628 RunTest(ASCIIToUTF16("tea"), expected_urls, true, | 628 RunTest(ASCIIToUTF16("tea"), expected_urls, true, |
629 ASCIIToUTF16("www.teamliquid.net")); | 629 ASCIIToUTF16("www.teamliquid.net")); |
630 } | 630 } |
OLD | NEW |