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

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider_unittest.cc

Issue 18878007: Omnibox: Make the Controller Reorder Matches for Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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 | Annotate | Revision Log
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 "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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ++actual, ++expected, ++i) { 281 ++actual, ++expected, ++i) {
282 EXPECT_EQ(*expected, actual->destination_url.spec()) 282 EXPECT_EQ(*expected, actual->destination_url.spec())
283 << "For result #" << i << " we got '" << actual->destination_url.spec() 283 << "For result #" << i << " we got '" << actual->destination_url.spec()
284 << "' but expected '" << *expected << "'."; 284 << "' but expected '" << *expected << "'.";
285 EXPECT_LT(actual->relevance, best_score) 285 EXPECT_LT(actual->relevance, best_score)
286 << "At result #" << i << " (url=" << actual->destination_url.spec() 286 << "At result #" << i << " (url=" << actual->destination_url.spec()
287 << "), we noticed scores are not monotonically decreasing."; 287 << "), we noticed scores are not monotonically decreasing.";
288 best_score = actual->relevance; 288 best_score = actual->relevance;
289 } 289 }
290 290
291 EXPECT_EQ(can_inline_top_result, ac_matches_[0].allowed_to_be_default_match);
291 if (can_inline_top_result) { 292 if (can_inline_top_result) {
292 // When the top scorer is inline-able make sure we get the expected 293 // When the top scorer is inline-able make sure we get the expected
293 // fill_into_edit and autocomplete offset. 294 // fill_into_edit and autocomplete offset.
294 EXPECT_EQ(expected_fill_into_edit, ac_matches_[0].fill_into_edit) 295 EXPECT_EQ(expected_fill_into_edit, ac_matches_[0].fill_into_edit)
295 << "fill_into_edit was: '" << ac_matches_[0].fill_into_edit 296 << "fill_into_edit was: '" << ac_matches_[0].fill_into_edit
296 << "' but we expected '" << expected_fill_into_edit << "'."; 297 << "' but we expected '" << expected_fill_into_edit << "'.";
297 size_t text_pos = expected_fill_into_edit.find(text); 298 size_t text_pos = expected_fill_into_edit.find(text);
298 ASSERT_NE(string16::npos, text_pos); 299 ASSERT_NE(string16::npos, text_pos);
299 EXPECT_EQ(ac_matches_[0].fill_into_edit.substr(text_pos + text.size()), 300 EXPECT_EQ(ac_matches_[0].fill_into_edit.substr(text_pos + text.size()),
300 ac_matches_[0].inline_autocompletion); 301 ac_matches_[0].inline_autocompletion);
301 } else { 302 } else {
302 // When the top scorer is not inline-able autocomplete offset must be npos. 303 // When the top scorer is not inline-able autocomplete offset must be npos.
303 EXPECT_TRUE(ac_matches_[0].inline_autocompletion.empty()); 304 EXPECT_TRUE(ac_matches_[0].inline_autocompletion.empty());
304 // Also, the score must be too low to be inlineable. 305 // Also, the score must be too low to be inlineable.
306 // TODO(mpearson): when the controller reorders for inlining, there's no
307 // longer any connection between scores and what's inlineable / allowed
308 // to be the default match. Remove this test.
305 EXPECT_LT(ac_matches_[0].relevance, 309 EXPECT_LT(ac_matches_[0].relevance,
306 AutocompleteResult::kLowestDefaultScore); 310 AutocompleteResult::kLowestDefaultScore);
307 } 311 }
308 } 312 }
309 313
310 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { 314 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) {
311 std::vector<std::string> expected_urls; 315 std::vector<std::string> expected_urls;
312 expected_urls.push_back("http://slashdot.org/favorite_page.html"); 316 expected_urls.push_back("http://slashdot.org/favorite_page.html");
313 RunTest(ASCIIToUTF16("slashdot"), expected_urls, true, 317 RunTest(ASCIIToUTF16("slashdot"), expected_urls, true,
314 ASCIIToUTF16("slashdot.org/favorite_page.html")); 318 ASCIIToUTF16("slashdot.org/favorite_page.html"));
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 626 }
623 627
624 TEST_F(HQPOrderingTest, TEAMatch) { 628 TEST_F(HQPOrderingTest, TEAMatch) {
625 std::vector<std::string> expected_urls; 629 std::vector<std::string> expected_urls;
626 expected_urls.push_back("http://www.teamliquid.net/"); 630 expected_urls.push_back("http://www.teamliquid.net/");
627 expected_urls.push_back("http://www.teamliquid.net/tlpd"); 631 expected_urls.push_back("http://www.teamliquid.net/tlpd");
628 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); 632 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players");
629 RunTest(ASCIIToUTF16("tea"), expected_urls, true, 633 RunTest(ASCIIToUTF16("tea"), expected_urls, true,
630 ASCIIToUTF16("www.teamliquid.net")); 634 ASCIIToUTF16("www.teamliquid.net"));
631 } 635 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | chrome/browser/autocomplete/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698