summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/test_extension_prefs.h
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 21:21:34 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 21:21:34 +0000
commit63c64d193c42c0c5dd819395994031a16c9a3d71 (patch)
treea772e9b87c869649ada5f5a47215b77c92b8dfdd /chrome/browser/extensions/test_extension_prefs.h
parent2b39687f1feb296be488a75ef5286a908be81e3a (diff)
downloadchromium_src-63c64d193c42c0c5dd819395994031a16c9a3d71.zip
chromium_src-63c64d193c42c0c5dd819395994031a16c9a3d71.tar.gz
chromium_src-63c64d193c42c0c5dd819395994031a16c9a3d71.tar.bz2
Adding ExtensionPrefs methods for storing update-when-idle data.
This includes adding a few methods to ExtensionPrefs that I'm going to need to use inside ExtensionUpdater for implementing the "do updates at idle" feature. Instead of adding more call-through stubs to the interface that ExtensionsService providers to the ExtensionUpdater, I instead decided it was time to do some refactoring to expose a ExtensionPrefs getter in the interface. TEST=(Should be covered by unit/browser tests) BUG=37971 Review URL: http://codereview.chromium.org/1695018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/test_extension_prefs.h')
-rw-r--r--chrome/browser/extensions/test_extension_prefs.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/extensions/test_extension_prefs.h b/chrome/browser/extensions/test_extension_prefs.h
new file mode 100644
index 0000000..0ad84c1
--- /dev/null
+++ b/chrome/browser/extensions/test_extension_prefs.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_
+#define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_
+
+#include <string>
+
+#include "base/scoped_ptr.h"
+#include "base/scoped_temp_dir.h"
+
+class DictionaryValue;
+class Extension;
+class ExtensionPrefs;
+class PrefService;
+
+
+// This is a test class intended to make it easier to work with ExtensionPrefs
+// in tests.
+class TestExtensionPrefs {
+ public:
+ TestExtensionPrefs();
+ virtual ~TestExtensionPrefs();
+
+ ExtensionPrefs* prefs() { return prefs_.get(); }
+ PrefService* pref_service() { return pref_service_.get(); }
+ const FilePath& temp_dir() const { return temp_dir_.path(); }
+
+ // This will cause the ExtensionPrefs to be deleted and recreated, based on
+ // any existing backing file we had previously created.
+ void RecreateExtensionPrefs();
+
+ // Creates a new Extension with the given name in our temp dir, adds it to
+ // our ExtensionPrefs, and returns it.
+ Extension* AddExtension(std::string name);
+
+ // Similar to AddExtension, but takes a dictionary with manifest values.
+ Extension* AddExtensionWithManifest(const DictionaryValue& manifest);
+
+ // Similar to AddExtension, this adds a new test Extension. This is useful for
+ // cases when you don't need the Extension object, but just the id it was
+ // assigned.
+ std::string AddExtensionAndReturnId(std::string name);
+
+ protected:
+ ScopedTempDir temp_dir_;
+ FilePath preferences_file_;
+ FilePath extensions_dir_;
+ scoped_ptr<PrefService> pref_service_;
+ scoped_ptr<ExtensionPrefs> prefs_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_