OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
6 #include "chrome/browser/cocoa/browser_test_helper.h" | 6 #include "chrome/browser/cocoa/browser_test_helper.h" |
7 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 7 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
8 #include "chrome/browser/cocoa/extensions/extension_popup_controller.h" | 8 #include "chrome/browser/cocoa/extensions/extension_popup_controller.h" |
| 9 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
10 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extensions_service.h" |
11 #include "chrome/test/testing_profile.h" | 12 #include "chrome/test/testing_profile.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 class ExtensionTestingProfile : public TestingProfile { | 16 class ExtensionTestingProfile : public TestingProfile { |
16 public: | 17 public: |
17 ExtensionTestingProfile() {} | 18 ExtensionTestingProfile() {} |
18 | 19 |
19 FilePath GetExtensionsInstallDir() { | 20 FilePath GetExtensionsInstallDir() { |
20 return GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName); | 21 return GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName); |
21 } | 22 } |
22 | 23 |
23 void InitExtensionProfile() { | 24 void InitExtensionProfile() { |
24 DCHECK(!GetExtensionProcessManager()); | 25 DCHECK(!GetExtensionProcessManager()); |
25 DCHECK(!GetExtensionsService()); | 26 DCHECK(!GetExtensionsService()); |
26 | 27 |
27 manager_.reset(ExtensionProcessManager::Create(this)); | 28 manager_.reset(ExtensionProcessManager::Create(this)); |
| 29 extension_prefs_.reset(new ExtensionPrefs(this, |
| 30 GetPrefs(), |
| 31 GetExtensionsInstallDir())); |
28 service_ = new ExtensionsService(this, | 32 service_ = new ExtensionsService(this, |
29 CommandLine::ForCurrentProcess(), | 33 CommandLine::ForCurrentProcess(), |
30 GetExtensionsInstallDir(), | 34 GetExtensionsInstallDir(), |
| 35 extension_prefs_.get(), |
31 false); | 36 false); |
32 service_->set_extensions_enabled(true); | 37 service_->set_extensions_enabled(true); |
33 service_->set_show_extensions_prompts(false); | 38 service_->set_show_extensions_prompts(false); |
34 service_->ClearProvidersForTesting(); | 39 service_->ClearProvidersForTesting(); |
35 service_->Init(); | 40 service_->Init(); |
36 } | 41 } |
37 | 42 |
38 void ShutdownExtensionProfile() { | 43 void ShutdownExtensionProfile() { |
39 manager_.reset(); | 44 manager_.reset(); |
40 service_ = NULL; | 45 service_ = NULL; |
| 46 extension_prefs_.reset(); |
41 } | 47 } |
42 | 48 |
43 virtual ExtensionProcessManager* GetExtensionProcessManager() { | 49 virtual ExtensionProcessManager* GetExtensionProcessManager() { |
44 return manager_.get(); | 50 return manager_.get(); |
45 } | 51 } |
46 | 52 |
47 virtual ExtensionsService* GetExtensionsService() { | 53 virtual ExtensionsService* GetExtensionsService() { |
48 return service_.get(); | 54 return service_.get(); |
49 } | 55 } |
50 | 56 |
51 private: | 57 private: |
52 scoped_ptr<ExtensionProcessManager> manager_; | 58 scoped_ptr<ExtensionProcessManager> manager_; |
| 59 scoped_ptr<ExtensionPrefs> extension_prefs_; |
53 scoped_refptr<ExtensionsService> service_; | 60 scoped_refptr<ExtensionsService> service_; |
54 | 61 |
55 DISALLOW_COPY_AND_ASSIGN(ExtensionTestingProfile); | 62 DISALLOW_COPY_AND_ASSIGN(ExtensionTestingProfile); |
56 }; | 63 }; |
57 | 64 |
58 class ExtensionPopupControllerTest : public CocoaTest { | 65 class ExtensionPopupControllerTest : public CocoaTest { |
59 public: | 66 public: |
60 virtual void SetUp() { | 67 virtual void SetUp() { |
61 CocoaTest::SetUp(); | 68 CocoaTest::SetUp(); |
62 profile_.reset(new ExtensionTestingProfile()); | 69 profile_.reset(new ExtensionTestingProfile()); |
(...skipping 17 matching lines...) Expand all Loading... |
80 }; | 87 }; |
81 | 88 |
82 TEST_F(ExtensionPopupControllerTest, DISABLED_Basics) { | 89 TEST_F(ExtensionPopupControllerTest, DISABLED_Basics) { |
83 // TODO(andybons): Better mechanisms for mocking out the extensions service | 90 // TODO(andybons): Better mechanisms for mocking out the extensions service |
84 // and extensions for easy testing need to be implemented. | 91 // and extensions for easy testing need to be implemented. |
85 // http://crbug.com/28316 | 92 // http://crbug.com/28316 |
86 EXPECT_TRUE([ExtensionPopupController popup]); | 93 EXPECT_TRUE([ExtensionPopupController popup]); |
87 } | 94 } |
88 | 95 |
89 } // namespace | 96 } // namespace |
OLD | NEW |