Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // results' destination URLs match those provided. |expected_urls| does not | 127 // results' destination URLs match those provided. |expected_urls| does not |
| 128 // need to be in sorted order. | 128 // need to be in sorted order. |
| 129 void RunTest(const string16 text, | 129 void RunTest(const string16 text, |
| 130 std::vector<std::string> expected_urls, | 130 std::vector<std::string> expected_urls, |
| 131 bool can_inline_top_result, | 131 bool can_inline_top_result, |
| 132 string16 expected_fill_into_edit); | 132 string16 expected_fill_into_edit); |
| 133 | 133 |
| 134 // Pass-through functions to simplify our friendship with URLIndexPrivateData. | 134 // Pass-through functions to simplify our friendship with URLIndexPrivateData. |
| 135 bool UpdateURL(const history::URLRow& row); | 135 bool UpdateURL(const history::URLRow& row); |
| 136 | 136 |
| 137 MessageLoopForUI message_loop_; | 137 base::MessageLoopForUI message_loop_; |
| 138 content::TestBrowserThread ui_thread_; | 138 content::TestBrowserThread ui_thread_; |
| 139 content::TestBrowserThread file_thread_; | 139 content::TestBrowserThread file_thread_; |
| 140 | 140 |
| 141 scoped_ptr<TestingProfile> profile_; | 141 scoped_ptr<TestingProfile> profile_; |
| 142 HistoryService* history_service_; | 142 HistoryService* history_service_; |
| 143 | 143 |
| 144 ACMatches ac_matches_; // The resulting matches after running RunTest. | 144 ACMatches ac_matches_; // The resulting matches after running RunTest. |
| 145 | 145 |
| 146 scoped_refptr<HistoryQuickProvider> provider_; | 146 scoped_refptr<HistoryQuickProvider> provider_; |
| 147 }; | 147 }; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 EXPECT_EQ(1U, matches_.erase(expected)) | 220 EXPECT_EQ(1U, matches_.erase(expected)) |
| 221 << "Results did not contain '" << expected << "' but should have."; | 221 << "Results did not contain '" << expected << "' but should have."; |
| 222 } | 222 } |
| 223 | 223 |
| 224 | 224 |
| 225 void HistoryQuickProviderTest::RunTest(const string16 text, | 225 void HistoryQuickProviderTest::RunTest(const string16 text, |
| 226 std::vector<std::string> expected_urls, | 226 std::vector<std::string> expected_urls, |
| 227 bool can_inline_top_result, | 227 bool can_inline_top_result, |
| 228 string16 expected_fill_into_edit) { | 228 string16 expected_fill_into_edit) { |
| 229 SCOPED_TRACE(text); // Minimal hint to query being run. | 229 SCOPED_TRACE(text); // Minimal hint to query being run. |
| 230 MessageLoop::current()->RunUntilIdle(); | 230 base::MessageLoop::current()->RunUntilIdle(); |
| 231 AutocompleteInput input(text, string16::npos, string16(), GURL(),false, false, | 231 AutocompleteInput input(text, |
|
brettw
2013/04/28 04:26:27
I wouldn't bother changing this (I would normally
| |
| 232 true, AutocompleteInput::ALL_MATCHES); | 232 string16::npos, |
| 233 string16(), | |
| 234 GURL(), | |
| 235 false, | |
| 236 false, | |
| 237 true, | |
| 238 AutocompleteInput::ALL_MATCHES); | |
| 233 provider_->Start(input, false); | 239 provider_->Start(input, false); |
| 234 EXPECT_TRUE(provider_->done()); | 240 EXPECT_TRUE(provider_->done()); |
| 235 | 241 |
| 236 ac_matches_ = provider_->matches(); | 242 ac_matches_ = provider_->matches(); |
| 237 | 243 |
| 238 // We should have gotten back at most AutocompleteProvider::kMaxMatches. | 244 // We should have gotten back at most AutocompleteProvider::kMaxMatches. |
| 239 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); | 245 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); |
| 240 | 246 |
| 241 // If the number of expected and actual matches aren't equal then we need | 247 // If the number of expected and actual matches aren't equal then we need |
| 242 // test no further, but let's do anyway so that we know which URLs failed. | 248 // test no further, but let's do anyway so that we know which URLs failed. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 } | 620 } |
| 615 | 621 |
| 616 TEST_F(HQPOrderingTest, TEAMatch) { | 622 TEST_F(HQPOrderingTest, TEAMatch) { |
| 617 std::vector<std::string> expected_urls; | 623 std::vector<std::string> expected_urls; |
| 618 expected_urls.push_back("http://www.teamliquid.net/"); | 624 expected_urls.push_back("http://www.teamliquid.net/"); |
| 619 expected_urls.push_back("http://www.teamliquid.net/tlpd"); | 625 expected_urls.push_back("http://www.teamliquid.net/tlpd"); |
| 620 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); | 626 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); |
| 621 RunTest(ASCIIToUTF16("tea"), expected_urls, true, | 627 RunTest(ASCIIToUTF16("tea"), expected_urls, true, |
| 622 ASCIIToUTF16("www.teamliquid.net")); | 628 ASCIIToUTF16("www.teamliquid.net")); |
| 623 } | 629 } |
| OLD | NEW |