| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "content/test/test_browser_thread.h" | 15 #include "content/test/test_browser_thread.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 class TestingProfile; |
| 19 |
| 18 class ExtensionServiceTestBase : public testing::Test { | 20 class ExtensionServiceTestBase : public testing::Test { |
| 19 public: | 21 public: |
| 20 ExtensionServiceTestBase(); | 22 ExtensionServiceTestBase(); |
| 21 virtual ~ExtensionServiceTestBase(); | 23 virtual ~ExtensionServiceTestBase(); |
| 22 | 24 |
| 23 void InitializeExtensionService( | 25 void InitializeExtensionService( |
| 24 const FilePath& pref_file, const FilePath& extensions_install_dir, | 26 const FilePath& pref_file, const FilePath& extensions_install_dir, |
| 25 bool autoupdate_enabled); | 27 bool autoupdate_enabled); |
| 26 | 28 |
| 27 void InitializeInstalledExtensionService( | 29 void InitializeInstalledExtensionService( |
| 28 const FilePath& prefs_file, const FilePath& source_install_dir); | 30 const FilePath& prefs_file, const FilePath& source_install_dir); |
| 29 | 31 |
| 30 void InitializeEmptyExtensionService(); | 32 void InitializeEmptyExtensionService(); |
| 31 | 33 |
| 34 void InitializeExtensionProcessManager(); |
| 35 |
| 32 void InitializeExtensionServiceWithUpdater(); | 36 void InitializeExtensionServiceWithUpdater(); |
| 33 | 37 |
| 34 void InitializeRequestContext(); | 38 void InitializeRequestContext(); |
| 35 | 39 |
| 36 static void SetUpTestCase(); | 40 static void SetUpTestCase(); |
| 37 | 41 |
| 38 virtual void SetUp(); | 42 virtual void SetUp(); |
| 39 | 43 |
| 40 void set_extensions_enabled(bool enabled) { | 44 void set_extensions_enabled(bool enabled) { |
| 41 service_->set_extensions_enabled(enabled); | 45 service_->set_extensions_enabled(enabled); |
| 42 } | 46 } |
| 43 | 47 |
| 44 protected: | 48 protected: |
| 45 void InitializeExtensionServiceHelper(bool autoupdate_enabled); | 49 void InitializeExtensionServiceHelper(bool autoupdate_enabled); |
| 46 | 50 |
| 47 ScopedTempDir temp_dir_; | 51 ScopedTempDir temp_dir_; |
| 48 scoped_ptr<Profile> profile_; | 52 scoped_ptr<TestingProfile> profile_; |
| 49 FilePath extensions_install_dir_; | 53 FilePath extensions_install_dir_; |
| 50 FilePath data_dir_; | 54 FilePath data_dir_; |
| 51 // Owned by |profile_|. | 55 // Owned by |profile_|. |
| 52 ExtensionService* service_; | 56 ExtensionService* service_; |
| 53 size_t total_successes_; | 57 size_t total_successes_; |
| 54 MessageLoop loop_; | 58 MessageLoop loop_; |
| 55 content::TestBrowserThread ui_thread_; | 59 content::TestBrowserThread ui_thread_; |
| 56 content::TestBrowserThread db_thread_; | 60 content::TestBrowserThread db_thread_; |
| 57 content::TestBrowserThread webkit_thread_; | 61 content::TestBrowserThread webkit_thread_; |
| 58 content::TestBrowserThread file_thread_; | 62 content::TestBrowserThread file_thread_; |
| 59 content::TestBrowserThread io_thread_; | 63 content::TestBrowserThread io_thread_; |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ |
| OLD | NEW |