OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/keyword_extensions_delegate_impl.h" | 5 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
11 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
12 #include "chrome/browser/extensions/test_extension_system.h" | 12 #include "chrome/browser/extensions/test_extension_system.h" |
13 #include "chrome/browser/extensions/unpacked_installer.h" | 13 #include "chrome/browser/extensions/unpacked_installer.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "components/omnibox/keyword_provider.h" | 16 #include "components/omnibox/keyword_provider.h" |
| 17 #include "components/omnibox/mock_autocomplete_provider_client.h" |
17 #include "components/search_engines/template_url_service.h" | 18 #include "components/search_engines/template_url_service.h" |
18 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
19 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
20 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 class ScopedExtensionLoadObserver : public ExtensionRegistryObserver { | 27 class ScopedExtensionLoadObserver : public ExtensionRegistryObserver { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 73 private: |
73 DISALLOW_COPY_AND_ASSIGN(KeywordExtensionsDelegateImplTest); | 74 DISALLOW_COPY_AND_ASSIGN(KeywordExtensionsDelegateImplTest); |
74 }; | 75 }; |
75 | 76 |
76 void KeywordExtensionsDelegateImplTest::SetUp() { | 77 void KeywordExtensionsDelegateImplTest::SetUp() { |
77 ExtensionServiceTestBase::SetUp(); | 78 ExtensionServiceTestBase::SetUp(); |
78 InitializeExtensionService(CreateDefaultInitParams()); | 79 InitializeExtensionService(CreateDefaultInitParams()); |
79 } | 80 } |
80 | 81 |
81 void KeywordExtensionsDelegateImplTest::RunTest(bool incognito) { | 82 void KeywordExtensionsDelegateImplTest::RunTest(bool incognito) { |
82 TemplateURLService empty_model(NULL, 0); | 83 scoped_ptr<TemplateURLService> empty_model(new TemplateURLService(NULL, 0)); |
| 84 MockAutocompleteProviderClient client; |
| 85 client.set_template_url_service(empty_model.Pass()); |
83 scoped_refptr<KeywordProvider> keyword_provider = | 86 scoped_refptr<KeywordProvider> keyword_provider = |
84 new KeywordProvider(NULL, &empty_model); | 87 new KeywordProvider(&client, nullptr); |
85 | 88 |
86 // Load an extension. | 89 // Load an extension. |
87 { | 90 { |
88 base::FilePath path; | 91 base::FilePath path; |
89 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 92 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
90 path = path.AppendASCII("extensions").AppendASCII("good_unpacked"); | 93 path = path.AppendASCII("extensions").AppendASCII("good_unpacked"); |
91 | 94 |
92 base::RunLoop run_loop; | 95 base::RunLoop run_loop; |
93 ScopedExtensionLoadObserver load_observer(registry(), | 96 ScopedExtensionLoadObserver load_observer(registry(), |
94 run_loop.QuitClosure()); | 97 run_loop.QuitClosure()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 RunTest(false); | 136 RunTest(false); |
134 } | 137 } |
135 | 138 |
136 TEST_F(KeywordExtensionsDelegateImplTest, IsEnabledExtensionIncognito) { | 139 TEST_F(KeywordExtensionsDelegateImplTest, IsEnabledExtensionIncognito) { |
137 RunTest(true); | 140 RunTest(true); |
138 } | 141 } |
139 | 142 |
140 } // namespace | 143 } // namespace |
141 | 144 |
142 } // namespace extensions | 145 } // namespace extensions |
OLD | NEW |