| 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 "components/omnibox/browser/autocomplete_provider.h" | 5 #include "components/omnibox/browser/autocomplete_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "components/metrics/proto/omnibox_event.pb.h" | 24 #include "components/metrics/proto/omnibox_event.pb.h" |
| 24 #include "components/omnibox/browser/autocomplete_controller.h" | 25 #include "components/omnibox/browser/autocomplete_controller.h" |
| 25 #include "components/omnibox/browser/autocomplete_input.h" | 26 #include "components/omnibox/browser/autocomplete_input.h" |
| 26 #include "components/omnibox/browser/autocomplete_match.h" | 27 #include "components/omnibox/browser/autocomplete_match.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 bool allow_exact_keyword_match) { | 491 bool allow_exact_keyword_match) { |
| 491 result_.Reset(); | 492 result_.Reset(); |
| 492 controller_->Start(AutocompleteInput( | 493 controller_->Start(AutocompleteInput( |
| 493 base::ASCIIToUTF16(query), base::string16::npos, std::string(), GURL(), | 494 base::ASCIIToUTF16(query), base::string16::npos, std::string(), GURL(), |
| 494 metrics::OmniboxEventProto::INVALID_SPEC, true, false, | 495 metrics::OmniboxEventProto::INVALID_SPEC, true, false, |
| 495 allow_exact_keyword_match, true, false, TestingSchemeClassifier())); | 496 allow_exact_keyword_match, true, false, TestingSchemeClassifier())); |
| 496 | 497 |
| 497 if (!controller_->done()) | 498 if (!controller_->done()) |
| 498 // The message loop will terminate when all autocomplete input has been | 499 // The message loop will terminate when all autocomplete input has been |
| 499 // collected. | 500 // collected. |
| 500 base::MessageLoop::current()->Run(); | 501 base::RunLoop().Run(); |
| 501 } | 502 } |
| 502 | 503 |
| 503 void AutocompleteProviderTest::RunExactKeymatchTest( | 504 void AutocompleteProviderTest::RunExactKeymatchTest( |
| 504 bool allow_exact_keyword_match) { | 505 bool allow_exact_keyword_match) { |
| 505 // Send the controller input which exactly matches the keyword provider we | 506 // Send the controller input which exactly matches the keyword provider we |
| 506 // created in ResetControllerWithKeywordAndSearchProviders(). The default | 507 // created in ResetControllerWithKeywordAndSearchProviders(). The default |
| 507 // match should thus be a search-other-engine match iff | 508 // match should thus be a search-other-engine match iff |
| 508 // |allow_exact_keyword_match| is true. Regardless, the match should | 509 // |allow_exact_keyword_match| is true. Regardless, the match should |
| 509 // be from SearchProvider. (It provides all verbatim search matches, | 510 // be from SearchProvider. (It provides all verbatim search matches, |
| 510 // keyword or not.) | 511 // keyword or not.) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); | 766 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); |
| 766 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 767 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 767 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 768 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
| 768 | 769 |
| 769 // Test page classification and field trial triggered set. | 770 // Test page classification and field trial triggered set. |
| 770 set_search_provider_field_trial_triggered_in_session(true); | 771 set_search_provider_field_trial_triggered_in_session(true); |
| 771 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); | 772 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); |
| 772 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 773 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 773 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 774 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
| 774 } | 775 } |
| OLD | NEW |