OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
9 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 10 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 11 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
11 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
12 #include "components/omnibox/browser/autocomplete_controller.h" | 13 #include "components/omnibox/browser/autocomplete_controller.h" |
13 #include "components/omnibox/browser/autocomplete_provider.h" | 14 #include "components/omnibox/browser/autocomplete_provider.h" |
14 #include "components/omnibox/browser/omnibox_client.h" | 15 #include "components/omnibox/browser/omnibox_client.h" |
15 #include "components/omnibox/browser/omnibox_controller.h" | 16 #include "components/omnibox/browser/omnibox_controller.h" |
16 #include "components/sessions/core/session_id.h" | 17 #include "components/sessions/core/session_id.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 class TestOmniboxClient : public OmniboxClient { | 22 class TestOmniboxClient : public OmniboxClient { |
22 public: | 23 public: |
23 explicit TestOmniboxClient(Profile* profile) | 24 explicit TestOmniboxClient(Profile* profile) |
24 : profile_(profile), | 25 : profile_(profile), |
25 scheme_classifier_(profile) {} | 26 scheme_classifier_(profile) {} |
26 ~TestOmniboxClient() override {} | 27 ~TestOmniboxClient() override {} |
27 | 28 |
28 // OmniboxClient: | 29 // OmniboxClient: |
29 scoped_ptr<AutocompleteProviderClient> CreateAutocompleteProviderClient() | 30 std::unique_ptr<AutocompleteProviderClient> CreateAutocompleteProviderClient() |
30 override { | 31 override { |
31 return make_scoped_ptr(new ChromeAutocompleteProviderClient(profile_)); | 32 return base::WrapUnique(new ChromeAutocompleteProviderClient(profile_)); |
32 } | 33 } |
33 scoped_ptr<OmniboxNavigationObserver> CreateOmniboxNavigationObserver( | 34 std::unique_ptr<OmniboxNavigationObserver> CreateOmniboxNavigationObserver( |
34 const base::string16& text, | 35 const base::string16& text, |
35 const AutocompleteMatch& match, | 36 const AutocompleteMatch& match, |
36 const AutocompleteMatch& alternate_nav_match) override { | 37 const AutocompleteMatch& alternate_nav_match) override { |
37 return nullptr; | 38 return nullptr; |
38 } | 39 } |
39 bool CurrentPageExists() const override { return true; } | 40 bool CurrentPageExists() const override { return true; } |
40 const GURL& GetURL() const override { return GURL::EmptyGURL(); } | 41 const GURL& GetURL() const override { return GURL::EmptyGURL(); } |
41 const base::string16& GetTitle() const override { | 42 const base::string16& GetTitle() const override { |
42 return base::EmptyString16(); | 43 return base::EmptyString16(); |
43 } | 44 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return omnibox_controller_->autocomplete_controller()->providers(); | 110 return omnibox_controller_->autocomplete_controller()->providers(); |
110 } | 111 } |
111 | 112 |
112 private: | 113 private: |
113 // testing::Test: | 114 // testing::Test: |
114 void SetUp() override; | 115 void SetUp() override; |
115 void TearDown() override; | 116 void TearDown() override; |
116 | 117 |
117 content::TestBrowserThreadBundle thread_bundle_; | 118 content::TestBrowserThreadBundle thread_bundle_; |
118 TestingProfile profile_; | 119 TestingProfile profile_; |
119 scoped_ptr<TestOmniboxClient> omnibox_client_; | 120 std::unique_ptr<TestOmniboxClient> omnibox_client_; |
120 scoped_ptr<OmniboxController> omnibox_controller_; | 121 std::unique_ptr<OmniboxController> omnibox_controller_; |
121 | 122 |
122 DISALLOW_COPY_AND_ASSIGN(OmniboxControllerTest); | 123 DISALLOW_COPY_AND_ASSIGN(OmniboxControllerTest); |
123 }; | 124 }; |
124 | 125 |
125 OmniboxControllerTest::OmniboxControllerTest() { | 126 OmniboxControllerTest::OmniboxControllerTest() { |
126 } | 127 } |
127 | 128 |
128 OmniboxControllerTest::~OmniboxControllerTest() { | 129 OmniboxControllerTest::~OmniboxControllerTest() { |
129 } | 130 } |
130 | 131 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Ensure we have at least one provider. | 173 // Ensure we have at least one provider. |
173 ASSERT_NE(0, observed_providers); | 174 ASSERT_NE(0, observed_providers); |
174 | 175 |
175 // Ensure instant extended includes all the provides in classic Chrome. | 176 // Ensure instant extended includes all the provides in classic Chrome. |
176 int providers_with_instant_extended = observed_providers; | 177 int providers_with_instant_extended = observed_providers; |
177 // TODO(beaudoin): remove TYPE_SEARCH once it's no longer needed to pass | 178 // TODO(beaudoin): remove TYPE_SEARCH once it's no longer needed to pass |
178 // the Instant suggestion through via FinalizeInstantQuery. | 179 // the Instant suggestion through via FinalizeInstantQuery. |
179 CreateController(); | 180 CreateController(); |
180 AssertProviders(providers_with_instant_extended); | 181 AssertProviders(providers_with_instant_extended); |
181 } | 182 } |
OLD | NEW |