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

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

Issue 108643003: Omnibox: Bug Fixes for Shortcuts Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, post-revert Created 7 years 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
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1, 149 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1,
150 100 }, 150 100 },
151 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F3", "query", "query", 151 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F3", "query", "query",
152 "https://www.google.com/search?q=query", "query", "0,0", 152 "https://www.google.com/search?q=query", "query", "0,0",
153 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED, 153 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED,
154 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 }, 154 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 },
155 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F4", "word", "www.word", 155 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F4", "word", "www.word",
156 "https://www.google.com/search?q=www.word", "www.word", "0,0", 156 "https://www.google.com/search?q=www.word", "www.word", "0,0",
157 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED, 157 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED,
158 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 }, 158 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 },
159 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F5", "about:o", "chrome://omnibox",
160 "chrome://omnibox/", "about:omnibox", "0,3,10,1", "", "",
161 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::NAVSUGGEST, "",
162 1, 100 },
163 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F6", "www/real sp",
164 "http://www/real space/long-url-with-space.html",
165 "http://www/real%20space/long-url-with-space.html",
166 "www/real space/long-url-with-space.html", "0,3,11,1",
167 "Page With Space; Input with Space", "0,0",
168 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "",
169 1, 100 },
159 }; 170 };
160 171
161 } // namespace 172 } // namespace
162 173
163 174
164 // ClassifyTest --------------------------------------------------------------- 175 // ClassifyTest ---------------------------------------------------------------
165 176
166 // Helper class to make running tests of ClassifyAllMatchesInString() more 177 // Helper class to make running tests of ClassifyAllMatchesInString() more
167 // convenient. 178 // convenient.
168 class ClassifyTest { 179 class ClassifyTest {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // non-droppable prefix. ("www.", for instance, is not droppable for 436 // non-droppable prefix. ("www.", for instance, is not droppable for
426 // queries.) 437 // queries.)
427 text = ASCIIToUTF16("word"); 438 text = ASCIIToUTF16("word");
428 expected_url = "https://www.google.com/search?q=www.word"; 439 expected_url = "https://www.google.com/search?q=www.word";
429 expected_urls.clear(); 440 expected_urls.clear();
430 expected_urls.push_back( 441 expected_urls.push_back(
431 ExpectedURLAndAllowedToBeDefault(expected_url, false)); 442 ExpectedURLAndAllowedToBeDefault(expected_url, false));
432 RunTest(text, false, expected_urls, expected_url, base::string16()); 443 RunTest(text, false, expected_urls, expected_url, base::string16());
433 } 444 }
434 445
446 // These tests are like those in SimpleSingleMatch but more complex,
447 // involving URLs that need to be fixed up to match properly.
448 TEST_F(ShortcutsProviderTest, TrickySingleMatch) {
449 // Test that about: URLs are fixed up/transformed to chrome:// URLs.
450 base::string16 text(ASCIIToUTF16("about:o"));
451 std::string expected_url("chrome://omnibox/");
452 ExpectedURLs expected_urls;
453 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(expected_url, true));
454 RunTest(text, false, expected_urls, expected_url, ASCIIToUTF16("mnibox"));
455
456 // Same test with prevent inline autocomplete.
457 expected_urls.clear();
458 expected_urls.push_back(
459 ExpectedURLAndAllowedToBeDefault(expected_url, false));
460 // The match will have an |inline_autocompletion| set, but the value will not
461 // be used because |allowed_to_be_default_match| will be false.
462 RunTest(text, true, expected_urls, expected_url, ASCIIToUTF16("mnibox"));
463
464 // Test that an input with a space can match URLs with a (escaped) space.
465 // This would fail if we didn't try to lookup the un-fixed-up string.
466 text = ASCIIToUTF16("www/real sp");
467 expected_url = "http://www/real%20space/long-url-with-space.html";
468 expected_urls.clear();
469 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(expected_url, true));
470 RunTest(text, false, expected_urls, expected_url,
471 ASCIIToUTF16("ace/long-url-with-space.html"));
472
473 // Same test with prevent inline autocomplete.
474 expected_urls.clear();
475 expected_urls.push_back(
476 ExpectedURLAndAllowedToBeDefault(expected_url, false));
477 // The match will have an |inline_autocompletion| set, but the value will not
478 // be used because |allowed_to_be_default_match| will be false.
479 RunTest(text, true, expected_urls, expected_url,
480 ASCIIToUTF16("ace/long-url-with-space.html"));
481 }
482
435 TEST_F(ShortcutsProviderTest, MultiMatch) { 483 TEST_F(ShortcutsProviderTest, MultiMatch) {
436 base::string16 text(ASCIIToUTF16("NEWS")); 484 base::string16 text(ASCIIToUTF16("NEWS"));
437 ExpectedURLs expected_urls; 485 ExpectedURLs expected_urls;
438 // Scores high because of completion length. 486 // Scores high because of completion length.
439 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault( 487 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(
440 "http://slashdot.org/", false)); 488 "http://slashdot.org/", false));
441 // Scores high because of visit count. 489 // Scores high because of visit count.
442 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault( 490 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(
443 "http://sports.yahoo.com/", false)); 491 "http://sports.yahoo.com/", false));
444 // Scores high because of visit count but less match span, 492 // Scores high because of visit count but less match span,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 content::NotificationService::current()->Notify( 766 content::NotificationService::current()->Notify(
719 chrome::NOTIFICATION_EXTENSION_UNLOADED, 767 chrome::NOTIFICATION_EXTENSION_UNLOADED,
720 content::Source<Profile>(&profile_), 768 content::Source<Profile>(&profile_),
721 content::Details<extensions::UnloadedExtensionInfo>(&details)); 769 content::Details<extensions::UnloadedExtensionInfo>(&details));
722 770
723 // Now the URL should have disappeared. 771 // Now the URL should have disappeared.
724 RunTest(text, false, ExpectedURLs(), std::string(), base::string16()); 772 RunTest(text, false, ExpectedURLs(), std::string(), base::string16());
725 } 773 }
726 774
727 } // namespace history 775 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698