OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/common/extensions/extension_unittest.h" | 15 #include "chrome/common/extensions/extension_unittest.h" |
16 #include "chrome/common/extensions/feature_switch.h" | 16 #include "chrome/common/extensions/feature_switch.h" |
| 17 #include "chrome/test/base/scoped_testing_local_state.h" |
17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 19 #include "content/public/test/test_renderer_host.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 class TestingProfile; | 22 class TestingProfile; |
21 | 23 |
22 namespace extensions { | 24 namespace extensions { |
23 class ManagementPolicy; | 25 class ManagementPolicy; |
24 } | 26 } |
| 27 namespace ui { |
| 28 class ScopedOleInitializer; |
| 29 } |
25 | 30 |
26 class ExtensionServiceTestBase : public extensions::ExtensionTest { | 31 class ExtensionServiceTestBase : public extensions::ExtensionTest { |
27 public: | 32 public: |
28 ExtensionServiceTestBase(); | 33 ExtensionServiceTestBase( |
| 34 MessageLoop::Type main_loop_type = MessageLoop::TYPE_UI); |
29 virtual ~ExtensionServiceTestBase(); | 35 virtual ~ExtensionServiceTestBase(); |
30 | 36 |
31 void InitializeExtensionService(const base::FilePath& profile_path, | 37 void InitializeExtensionService(const base::FilePath& profile_path, |
32 const base::FilePath& pref_file, | 38 const base::FilePath& pref_file, |
33 const base::FilePath& extensions_install_dir, | 39 const base::FilePath& extensions_install_dir, |
34 bool autoupdate_enabled); | 40 bool autoupdate_enabled); |
35 | 41 |
36 void InitializeInstalledExtensionService( | 42 void InitializeInstalledExtensionService( |
37 const base::FilePath& prefs_file, | 43 const base::FilePath& prefs_file, |
38 const base::FilePath& source_install_dir); | 44 const base::FilePath& source_install_dir); |
(...skipping 13 matching lines...) Expand all Loading... |
52 void set_extensions_enabled(bool enabled) { | 58 void set_extensions_enabled(bool enabled) { |
53 service_->set_extensions_enabled(enabled); | 59 service_->set_extensions_enabled(enabled); |
54 } | 60 } |
55 | 61 |
56 protected: | 62 protected: |
57 void InitializeExtensionServiceHelper(bool autoupdate_enabled); | 63 void InitializeExtensionServiceHelper(bool autoupdate_enabled); |
58 | 64 |
59 MessageLoop loop_; | 65 MessageLoop loop_; |
60 base::ShadowingAtExitManager at_exit_manager_; | 66 base::ShadowingAtExitManager at_exit_manager_; |
61 base::ScopedTempDir temp_dir_; | 67 base::ScopedTempDir temp_dir_; |
| 68 content::RenderViewHostTestEnabler rvh_enabler_; |
| 69 ScopedTestingLocalState local_state_; |
| 70 #if defined(OS_WIN) |
| 71 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; |
| 72 #endif |
62 scoped_ptr<TestingProfile> profile_; | 73 scoped_ptr<TestingProfile> profile_; |
63 base::FilePath extensions_install_dir_; | 74 base::FilePath extensions_install_dir_; |
64 base::FilePath data_dir_; | 75 base::FilePath data_dir_; |
65 // Managed by extensions::ExtensionSystemFactory. | 76 // Managed by extensions::ExtensionSystemFactory. |
66 ExtensionService* service_; | 77 ExtensionService* service_; |
67 extensions::ManagementPolicy* management_policy_; | 78 extensions::ManagementPolicy* management_policy_; |
68 size_t expected_extensions_count_; | 79 size_t expected_extensions_count_; |
69 content::TestBrowserThread ui_thread_; | 80 content::TestBrowserThread ui_thread_; |
70 content::TestBrowserThread db_thread_; | 81 content::TestBrowserThread db_thread_; |
71 content::TestBrowserThread webkit_thread_; | 82 content::TestBrowserThread webkit_thread_; |
72 content::TestBrowserThread file_thread_; | 83 content::TestBrowserThread file_thread_; |
73 content::TestBrowserThread file_user_blocking_thread_; | 84 content::TestBrowserThread file_user_blocking_thread_; |
74 content::TestBrowserThread io_thread_; | 85 scoped_ptr<content::TestBrowserThread> io_thread_; |
75 extensions::FeatureSwitch::ScopedOverride override_sideload_wipeout_; | 86 extensions::FeatureSwitch::ScopedOverride override_sideload_wipeout_; |
76 }; | 87 }; |
77 | 88 |
78 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ | 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ |
OLD | NEW |