| 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/autocomplete_provider.h" | 5 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 if (!controller_->done()) | 390 if (!controller_->done()) |
| 391 // The message loop will terminate when all autocomplete input has been | 391 // The message loop will terminate when all autocomplete input has been |
| 392 // collected. | 392 // collected. |
| 393 MessageLoop::current()->Run(); | 393 MessageLoop::current()->Run(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void AutocompleteProviderTest::RunExactKeymatchTest( | 396 void AutocompleteProviderTest::RunExactKeymatchTest( |
| 397 bool allow_exact_keyword_match) { | 397 bool allow_exact_keyword_match) { |
| 398 // Send the controller input which exactly matches the keyword provider we | 398 // Send the controller input which exactly matches the keyword provider we |
| 399 // created in ResetControllerWithKeywordAndSearchProviders(). The default | 399 // created in ResetControllerWithKeywordAndSearchProviders(). The default |
| 400 // match should thus be a keyword match iff |allow_exact_keyword_match| is | 400 // match should thus be a search-other-engine match iff |
| 401 // true. | 401 // |allow_exact_keyword_match| is true. Regardless, the match should |
| 402 // be from SearchProvider. (It provides all verbatim search matches, |
| 403 // keyword or not.) |
| 402 controller_->Start(AutocompleteInput( | 404 controller_->Start(AutocompleteInput( |
| 403 ASCIIToUTF16("k test"), string16::npos, string16(), true, false, | 405 ASCIIToUTF16("k test"), string16::npos, string16(), true, false, |
| 404 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES)); | 406 allow_exact_keyword_match, AutocompleteInput::SYNCHRONOUS_MATCHES)); |
| 405 EXPECT_TRUE(controller_->done()); | 407 EXPECT_TRUE(controller_->done()); |
| 408 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, |
| 409 controller_->result().default_match()->provider->type()); |
| 406 EXPECT_EQ(allow_exact_keyword_match ? | 410 EXPECT_EQ(allow_exact_keyword_match ? |
| 407 AutocompleteProvider::TYPE_KEYWORD : AutocompleteProvider::TYPE_SEARCH, | 411 AutocompleteMatch::SEARCH_OTHER_ENGINE : |
| 408 controller_->result().default_match()->provider->type()); | 412 AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, |
| 413 controller_->result().default_match()->type); |
| 409 } | 414 } |
| 410 | 415 |
| 411 void AutocompleteProviderTest::Observe( | 416 void AutocompleteProviderTest::Observe( |
| 412 int type, | 417 int type, |
| 413 const content::NotificationSource& source, | 418 const content::NotificationSource& source, |
| 414 const content::NotificationDetails& details) { | 419 const content::NotificationDetails& details) { |
| 415 if (controller_->done()) { | 420 if (controller_->done()) { |
| 416 result_.CopyFrom(controller_->result()); | 421 result_.CopyFrom(controller_->result()); |
| 417 MessageLoop::current()->Quit(); | 422 MessageLoop::current()->Quit(); |
| 418 } | 423 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, | 548 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, |
| 544 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, | 549 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, |
| 545 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, | 550 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, |
| 546 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, | 551 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, |
| 547 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, | 552 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, |
| 548 }; | 553 }; |
| 549 SCOPED_TRACE("Multiple matches"); | 554 SCOPED_TRACE("Multiple matches"); |
| 550 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | 555 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); |
| 551 } | 556 } |
| 552 } | 557 } |
| OLD | NEW |