Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: components/omnibox/browser/autocomplete_provider_unittest.cc

Issue 1868763002: Remove URLRequest::IsHandledProtocol and IsHandledURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: finish removing URLRequest::IsHandledProtocol() Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #include "components/omnibox/browser/autocomplete_match.h" 24 #include "components/omnibox/browser/autocomplete_match.h"
25 #include "components/omnibox/browser/autocomplete_provider_listener.h" 25 #include "components/omnibox/browser/autocomplete_provider_listener.h"
26 #include "components/omnibox/browser/keyword_provider.h" 26 #include "components/omnibox/browser/keyword_provider.h"
27 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" 27 #include "components/omnibox/browser/mock_autocomplete_provider_client.h"
28 #include "components/omnibox/browser/search_provider.h" 28 #include "components/omnibox/browser/search_provider.h"
29 #include "components/search_engines/search_engines_switches.h" 29 #include "components/search_engines/search_engines_switches.h"
30 #include "components/search_engines/template_url.h" 30 #include "components/search_engines/template_url.h"
31 #include "components/search_engines/template_url_service.h" 31 #include "components/search_engines/template_url_service.h"
32 #include "components/search_engines/template_url_service_client.h" 32 #include "components/search_engines/template_url_service_client.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "url/url_constants.h"
34 35
35 static std::ostream& operator<<(std::ostream& os, 36 static std::ostream& operator<<(std::ostream& os,
36 const AutocompleteResult::const_iterator& it) { 37 const AutocompleteResult::const_iterator& it) {
37 return os << static_cast<const AutocompleteMatch*>(&(*it)); 38 return os << static_cast<const AutocompleteMatch*>(&(*it));
38 } 39 }
39 40
40 namespace { 41 namespace {
41 42
42 const size_t kResultsPerProvider = 3; 43 const size_t kResultsPerProvider = 3;
43 const char kTestTemplateURLKeyword[] = "t"; 44 const char kTestTemplateURLKeyword[] = "t";
44 45
45 class TestingSchemeClassifier : public AutocompleteSchemeClassifier { 46 class TestingSchemeClassifier : public AutocompleteSchemeClassifier {
46 public: 47 public:
47 TestingSchemeClassifier() {} 48 TestingSchemeClassifier() {}
48 49
49 metrics::OmniboxInputType::Type GetInputTypeForScheme( 50 metrics::OmniboxInputType::Type GetInputTypeForScheme(
50 const std::string& scheme) const override { 51 const std::string& scheme) const override {
51 return net::URLRequest::IsHandledProtocol(scheme) 52 if (scheme == url::kHttpScheme || scheme == url::kHttpsScheme ||
52 ? metrics::OmniboxInputType::URL 53 scheme == url::kWsScheme || scheme == url::kWssScheme) {
53 : metrics::OmniboxInputType::INVALID; 54 return metrics::OmniboxInputType::URL;
55 }
56 return metrics::OmniboxInputType::INVALID;
54 } 57 }
55 58
56 private: 59 private:
57 DISALLOW_COPY_AND_ASSIGN(TestingSchemeClassifier); 60 DISALLOW_COPY_AND_ASSIGN(TestingSchemeClassifier);
58 }; 61 };
59 62
60 // AutocompleteProviderClient implementation that calls the specified closure 63 // AutocompleteProviderClient implementation that calls the specified closure
61 // when the result is ready. 64 // when the result is ready.
62 class AutocompleteProviderClientWithClosure 65 class AutocompleteProviderClientWithClosure
63 : public MockAutocompleteProviderClient { 66 : public MockAutocompleteProviderClient {
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); 766 EXPECT_FALSE(search_provider_field_trial_triggered_in_session());
764 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 767 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
765 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); 768 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path());
766 769
767 // Test page classification and field trial triggered set. 770 // Test page classification and field trial triggered set.
768 set_search_provider_field_trial_triggered_in_session(true); 771 set_search_provider_field_trial_triggered_in_session(true);
769 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); 772 EXPECT_TRUE(search_provider_field_trial_triggered_in_session());
770 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 773 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
771 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); 774 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path());
772 } 775 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698