Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_service_unittest.h
blob550a2f7ccd8600d7b7ee7b5cc169fac02ed32eb1
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_
8 #include "base/at_exit.h"
9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "chrome/browser/extensions/extension_service.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "content/public/test/test_utils.h"
17 #include "extensions/common/feature_switch.h"
18 #include "testing/gtest/include/gtest/gtest.h"
20 #if defined(OS_CHROMEOS)
21 #include "chrome/browser/chromeos/login/user_manager.h"
22 #include "chrome/browser/chromeos/settings/cros_settings.h"
23 #include "chrome/browser/chromeos/settings/device_settings_service.h"
24 #endif
26 class TestingProfile;
28 namespace extensions {
29 class ManagementPolicy;
32 class ExtensionServiceTestBase : public testing::Test {
33 public:
34 struct ExtensionServiceInitParams {
35 base::FilePath profile_path;
36 base::FilePath pref_file;
37 base::FilePath extensions_install_dir;
38 bool autoupdate_enabled;
39 bool is_first_run;
40 bool profile_is_managed;
42 ExtensionServiceInitParams();
45 ExtensionServiceTestBase();
46 virtual ~ExtensionServiceTestBase();
48 void InitializeExtensionService(const ExtensionServiceInitParams& params);
50 static scoped_ptr<TestingProfile> CreateTestingProfile(
51 const ExtensionServiceInitParams& params);
53 static ExtensionService* InitializeExtensionServiceForProfile(
54 const ExtensionServiceInitParams& params,
55 Profile* profile);
57 void InitializeInstalledExtensionService(
58 const base::FilePath& prefs_file,
59 const base::FilePath& source_install_dir);
61 void InitializeGoodInstalledExtensionService();
63 void InitializeEmptyExtensionService();
65 void InitializeProcessManager();
67 void InitializeExtensionServiceWithUpdater();
69 void InitializeExtensionSyncService();
71 static void SetUpTestCase();
73 virtual void SetUp() OVERRIDE;
74 virtual void TearDown() OVERRIDE;
76 void set_extensions_enabled(bool enabled) {
77 service_->set_extensions_enabled(enabled);
80 protected:
81 ExtensionServiceInitParams CreateDefaultInitParams();
82 static ExtensionServiceInitParams CreateDefaultInitParamsInTempDir(
83 base::ScopedTempDir* temp_dir);
85 // Destroying at_exit_manager_ will delete all LazyInstances, so it must come
86 // after thread_bundle_ in the destruction order.
87 base::ShadowingAtExitManager at_exit_manager_;
88 content::TestBrowserThreadBundle thread_bundle_;
89 base::ScopedTempDir temp_dir_;
90 scoped_ptr<TestingProfile> profile_;
91 base::FilePath extensions_install_dir_;
92 base::FilePath data_dir_;
93 // Managed by extensions::ExtensionSystemFactory.
94 ExtensionService* service_;
95 extensions::ManagementPolicy* management_policy_;
96 scoped_ptr<ExtensionSyncService> extension_sync_service_;
97 size_t expected_extensions_count_;
98 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_;
100 #if defined OS_CHROMEOS
101 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
102 chromeos::ScopedTestCrosSettings test_cros_settings_;
103 chromeos::ScopedTestUserManager test_user_manager_;
104 #endif
107 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_