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 "base/memory/scoped_ptr.h" |
5 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
6 #include "chrome/browser/extensions/webstore_startup_installer.h" | 7 #include "chrome/browser/extensions/webstore_startup_installer.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/search/hotword_service.h" | 9 #include "chrome/browser/search/hotword_service.h" |
9 #include "chrome/browser/search/hotword_service_factory.h" | 10 #include "chrome/browser/search/hotword_service_factory.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
12 #include "chrome/common/extensions/webstore_install_result.h" | 13 #include "chrome/common/extensions/webstore_install_result.h" |
13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
14 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 bool success, | 61 bool success, |
61 const std::string& error, | 62 const std::string& error, |
62 extensions::webstore_install::Result result) { | 63 extensions::webstore_install::Result result) { |
63 } | 64 } |
64 | 65 |
65 private: | 66 private: |
66 Profile* profile_; | 67 Profile* profile_; |
67 base::WeakPtrFactory<MockHotwordService> weak_factory_; | 68 base::WeakPtrFactory<MockHotwordService> weak_factory_; |
68 }; | 69 }; |
69 | 70 |
70 KeyedService* BuildMockHotwordService(content::BrowserContext* context) { | 71 scoped_ptr<KeyedService> BuildMockHotwordService( |
71 return new MockHotwordService(static_cast<Profile*>(context)); | 72 content::BrowserContext* context) { |
| 73 return make_scoped_ptr( |
| 74 new MockHotwordService(static_cast<Profile*>(context))); |
72 } | 75 } |
73 | 76 |
74 } // namespace | 77 } // namespace |
75 | 78 |
76 namespace extensions { | 79 namespace extensions { |
77 | 80 |
78 class HotwordInstallerBrowserTest : public ExtensionBrowserTest { | 81 class HotwordInstallerBrowserTest : public ExtensionBrowserTest { |
79 public: | 82 public: |
80 HotwordInstallerBrowserTest() {} | 83 HotwordInstallerBrowserTest() {} |
81 ~HotwordInstallerBrowserTest() override {} | 84 ~HotwordInstallerBrowserTest() override {} |
82 | 85 |
83 private: | 86 private: |
84 DISALLOW_COPY_AND_ASSIGN(HotwordInstallerBrowserTest); | 87 DISALLOW_COPY_AND_ASSIGN(HotwordInstallerBrowserTest); |
85 }; | 88 }; |
86 | 89 |
87 // Test that installing to a non-existent URL (which should hang) does not | 90 // Test that installing to a non-existent URL (which should hang) does not |
88 // crash. This test is successful if it does not crash and trigger any DCHECKS. | 91 // crash. This test is successful if it does not crash and trigger any DCHECKS. |
89 IN_PROC_BROWSER_TEST_F(HotwordInstallerBrowserTest, AbortInstallOnShutdown) { | 92 IN_PROC_BROWSER_TEST_F(HotwordInstallerBrowserTest, AbortInstallOnShutdown) { |
90 TestingProfile test_profile; | 93 TestingProfile test_profile; |
91 HotwordServiceFactory* hotword_service_factory = | 94 HotwordServiceFactory* hotword_service_factory = |
92 HotwordServiceFactory::GetInstance(); | 95 HotwordServiceFactory::GetInstance(); |
93 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( | 96 MockHotwordService* hotword_service = static_cast<MockHotwordService*>( |
94 hotword_service_factory->SetTestingFactoryAndUse( | 97 hotword_service_factory->SetTestingFactoryAndUse( |
95 &test_profile, BuildMockHotwordService)); | 98 &test_profile, BuildMockHotwordService)); |
96 hotword_service->InstallHotwordExtensionFromWebstore(1); | 99 hotword_service->InstallHotwordExtensionFromWebstore(1); |
97 } | 100 } |
98 | 101 |
99 } // namespace extensions | 102 } // namespace extensions |
OLD | NEW |