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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 for (size_t i = 0; i < size; ++i) { | 397 for (size_t i = 0; i < size; ++i) { |
398 EXPECT_EQ(aqs_test_data[i].expected_aqs, | 398 EXPECT_EQ(aqs_test_data[i].expected_aqs, |
399 result_.match_at(i)->search_terms_args->assisted_query_stats); | 399 result_.match_at(i)->search_terms_args->assisted_query_stats); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 void AutocompleteProviderTest::RunQuery(const base::string16 query) { | 403 void AutocompleteProviderTest::RunQuery(const base::string16 query) { |
404 result_.Reset(); | 404 result_.Reset(); |
405 controller_->Start(AutocompleteInput( | 405 controller_->Start(AutocompleteInput( |
406 query, base::string16::npos, base::string16(), GURL(), | 406 query, base::string16::npos, base::string16(), GURL(), |
407 AutocompleteInput::INVALID_SPEC, true, false, true, true)); | 407 metrics::OmniboxEventProto::INVALID_SPEC, true, false, true, true)); |
408 | 408 |
409 if (!controller_->done()) | 409 if (!controller_->done()) |
410 // The message loop will terminate when all autocomplete input has been | 410 // The message loop will terminate when all autocomplete input has been |
411 // collected. | 411 // collected. |
412 base::MessageLoop::current()->Run(); | 412 base::MessageLoop::current()->Run(); |
413 } | 413 } |
414 | 414 |
415 void AutocompleteProviderTest::RunExactKeymatchTest( | 415 void AutocompleteProviderTest::RunExactKeymatchTest( |
416 bool allow_exact_keyword_match) { | 416 bool allow_exact_keyword_match) { |
417 // Send the controller input which exactly matches the keyword provider we | 417 // Send the controller input which exactly matches the keyword provider we |
418 // created in ResetControllerWithKeywordAndSearchProviders(). The default | 418 // created in ResetControllerWithKeywordAndSearchProviders(). The default |
419 // match should thus be a search-other-engine match iff | 419 // match should thus be a search-other-engine match iff |
420 // |allow_exact_keyword_match| is true. Regardless, the match should | 420 // |allow_exact_keyword_match| is true. Regardless, the match should |
421 // be from SearchProvider. (It provides all verbatim search matches, | 421 // be from SearchProvider. (It provides all verbatim search matches, |
422 // keyword or not.) | 422 // keyword or not.) |
423 controller_->Start(AutocompleteInput( | 423 controller_->Start(AutocompleteInput( |
424 base::ASCIIToUTF16("k test"), base::string16::npos, base::string16(), | 424 base::ASCIIToUTF16("k test"), base::string16::npos, base::string16(), |
425 GURL(), AutocompleteInput::INVALID_SPEC, true, false, | 425 GURL(), metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
426 allow_exact_keyword_match, false)); | 426 allow_exact_keyword_match, false)); |
427 EXPECT_TRUE(controller_->done()); | 427 EXPECT_TRUE(controller_->done()); |
428 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, | 428 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH, |
429 controller_->result().default_match()->provider->type()); | 429 controller_->result().default_match()->provider->type()); |
430 EXPECT_EQ(allow_exact_keyword_match ? | 430 EXPECT_EQ(allow_exact_keyword_match ? |
431 AutocompleteMatchType::SEARCH_OTHER_ENGINE : | 431 AutocompleteMatchType::SEARCH_OTHER_ENGINE : |
432 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, | 432 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, |
433 controller_->result().default_match()->type); | 433 controller_->result().default_match()->type); |
434 } | 434 } |
435 | 435 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j0&", url.path()); | 641 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j0&", url.path()); |
642 | 642 |
643 // Test field trial triggered bit set. | 643 // Test field trial triggered bit set. |
644 controller_->search_provider_->field_trial_triggered_in_session_ = true; | 644 controller_->search_provider_->field_trial_triggered_in_session_ = true; |
645 EXPECT_TRUE( | 645 EXPECT_TRUE( |
646 controller_->search_provider_->field_trial_triggered_in_session()); | 646 controller_->search_provider_->field_trial_triggered_in_session()); |
647 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 647 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
648 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j0&", url.path()); | 648 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j0&", url.path()); |
649 | 649 |
650 // Test page classification set. | 650 // Test page classification set. |
651 controller_->input_.current_page_classification_ = AutocompleteInput::OTHER; | 651 controller_->input_.current_page_classification_ = |
| 652 metrics::OmniboxEventProto::OTHER; |
652 controller_->search_provider_->field_trial_triggered_in_session_ = false; | 653 controller_->search_provider_->field_trial_triggered_in_session_ = false; |
653 EXPECT_FALSE( | 654 EXPECT_FALSE( |
654 controller_->search_provider_->field_trial_triggered_in_session()); | 655 controller_->search_provider_->field_trial_triggered_in_session()); |
655 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 656 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
656 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 657 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
657 | 658 |
658 // Test page classification and field trial triggered set. | 659 // Test page classification and field trial triggered set. |
659 controller_->search_provider_->field_trial_triggered_in_session_ = true; | 660 controller_->search_provider_->field_trial_triggered_in_session_ = true; |
660 EXPECT_TRUE( | 661 EXPECT_TRUE( |
661 controller_->search_provider_->field_trial_triggered_in_session()); | 662 controller_->search_provider_->field_trial_triggered_in_session()); |
662 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 663 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
663 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 664 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
664 } | 665 } |
OLD | NEW |