Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/browser/extensions/test_extension_prefs.cc

Issue 5646003: Sanitize PrefStore interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefService mock construction in PrefServiceTest to include command line store. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/test_extension_prefs.cc
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index d7f83fdb16a3f6567d91a4de80d29ebbcacd3043..5b0ee7b94884196d0189421ef4e7310c7168be26 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -6,26 +6,32 @@
#include "base/file_util.h"
#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
#include "base/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/extensions/extension_pref_store.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/pref_value_store.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/json_pref_store.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+
// Mock ExtensionPrefs class with artificial clock to guarantee that no two
// extensions get the same installation time stamp and we can reliably
// assert the installation order in the tests below.
class MockExtensionPrefs : public ExtensionPrefs {
public:
- MockExtensionPrefs(PrefService* prefs, const FilePath& root_dir_)
- : ExtensionPrefs(prefs, root_dir_),
- currentTime(base::Time::Now())
- {}
+ MockExtensionPrefs(PrefService* prefs,
+ const FilePath& root_dir_,
+ ExtensionPrefStore* pref_store)
+ : ExtensionPrefs(prefs, root_dir_, pref_store),
+ currentTime(base::Time::Now()) {}
~MockExtensionPrefs() {}
protected:
@@ -37,6 +43,8 @@ class MockExtensionPrefs : public ExtensionPrefs {
}
};
+} // namespace
+
TestExtensionPrefs::TestExtensionPrefs() : pref_service_(NULL) {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
preferences_file_ = temp_dir_.path().AppendASCII("Preferences");
@@ -62,10 +70,14 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
file_loop.RunAllPending();
}
- // Create a |PrefService| instance that contains only user defined values.
- pref_service_.reset(PrefService::CreateUserPrefService(preferences_file_));
+ ExtensionPrefStore* pref_store = new ExtensionPrefStore;
+ PrefServiceMockBuilder builder;
+ builder.WithUserFilePrefs(preferences_file_);
+ builder.WithExtensionPrefs(pref_store);
+ pref_service_.reset(builder.Create());
ExtensionPrefs::RegisterUserPrefs(pref_service_.get());
- prefs_.reset(new MockExtensionPrefs(pref_service_.get(), temp_dir_.path()));
+ prefs_.reset(new MockExtensionPrefs(pref_service_.get(), temp_dir_.path(),
+ pref_store));
}
scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {
« no previous file with comments | « chrome/browser/extensions/extensions_service_unittest.cc ('k') | chrome/browser/metrics/metrics_service_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698