| 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "components/omnibox/browser/autocomplete_match.h" | 27 #include "components/omnibox/browser/autocomplete_match.h" |
| 28 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 28 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
| 29 #include "components/omnibox/browser/keyword_provider.h" | 29 #include "components/omnibox/browser/keyword_provider.h" |
| 30 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" | 30 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" |
| 31 #include "components/omnibox/browser/search_provider.h" | 31 #include "components/omnibox/browser/search_provider.h" |
| 32 #include "components/search_engines/search_engines_switches.h" | 32 #include "components/search_engines/search_engines_switches.h" |
| 33 #include "components/search_engines/template_url.h" | 33 #include "components/search_engines/template_url.h" |
| 34 #include "components/search_engines/template_url_service.h" | 34 #include "components/search_engines/template_url_service.h" |
| 35 #include "components/search_engines/template_url_service_client.h" | 35 #include "components/search_engines/template_url_service_client.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include "url/url_constants.h" |
| 37 | 38 |
| 38 static std::ostream& operator<<(std::ostream& os, | 39 static std::ostream& operator<<(std::ostream& os, |
| 39 const AutocompleteResult::const_iterator& it) { | 40 const AutocompleteResult::const_iterator& it) { |
| 40 return os << static_cast<const AutocompleteMatch*>(&(*it)); | 41 return os << static_cast<const AutocompleteMatch*>(&(*it)); |
| 41 } | 42 } |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const size_t kResultsPerProvider = 3; | 46 const size_t kResultsPerProvider = 3; |
| 46 const char kTestTemplateURLKeyword[] = "t"; | 47 const char kTestTemplateURLKeyword[] = "t"; |
| 47 | 48 |
| 48 class TestingSchemeClassifier : public AutocompleteSchemeClassifier { | 49 class TestingSchemeClassifier : public AutocompleteSchemeClassifier { |
| 49 public: | 50 public: |
| 50 TestingSchemeClassifier() {} | 51 TestingSchemeClassifier() {} |
| 51 | 52 |
| 52 metrics::OmniboxInputType::Type GetInputTypeForScheme( | 53 metrics::OmniboxInputType::Type GetInputTypeForScheme( |
| 53 const std::string& scheme) const override { | 54 const std::string& scheme) const override { |
| 54 return net::URLRequest::IsHandledProtocol(scheme) | 55 if (scheme == url::kHttpScheme || scheme == url::kHttpsScheme || |
| 55 ? metrics::OmniboxInputType::URL | 56 scheme == url::kWsScheme || scheme == url::kWssScheme) { |
| 56 : metrics::OmniboxInputType::INVALID; | 57 return metrics::OmniboxInputType::URL; |
| 58 } |
| 59 return metrics::OmniboxInputType::INVALID; |
| 57 } | 60 } |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(TestingSchemeClassifier); | 63 DISALLOW_COPY_AND_ASSIGN(TestingSchemeClassifier); |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 // AutocompleteProviderClient implementation that calls the specified closure | 66 // AutocompleteProviderClient implementation that calls the specified closure |
| 64 // when the result is ready. | 67 // when the result is ready. |
| 65 class AutocompleteProviderClientWithClosure | 68 class AutocompleteProviderClientWithClosure |
| 66 : public MockAutocompleteProviderClient { | 69 : public MockAutocompleteProviderClient { |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); | 767 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); |
| 765 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 768 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 766 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); | 769 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); |
| 767 | 770 |
| 768 // Test page classification and field trial triggered set. | 771 // Test page classification and field trial triggered set. |
| 769 set_search_provider_field_trial_triggered_in_session(true); | 772 set_search_provider_field_trial_triggered_in_session(true); |
| 770 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); | 773 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); |
| 771 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); | 774 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); |
| 772 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); | 775 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); |
| 773 } | 776 } |
| OLD | NEW |