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