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

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

Issue 5213002: Fix for Bug 50726 "Save extension list and "winning" prefs from extensions" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Temporary hack to fix regression in unit tests Created 10 years, 1 month 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 2cbb2d16857e1db7e58a60001988a81f1d76913d..a9d507da9c6dbc175e7a729c02d9911c8ac42b3f 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -17,6 +17,24 @@
#include "chrome/common/json_pref_store.h"
#include "testing/gtest/include/gtest/gtest.h"
+// 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 TestingExtensionPrefs : public ExtensionPrefs {
Aaron Boodman 2010/11/23 20:35:13 Maybe name this MockExtensionPrefs to distinguish
battre (please use the other) 2010/11/30 17:46:53 Done.
+ public:
+ TestingExtensionPrefs(PrefService* prefs, const FilePath& root_dir_)
+ : ExtensionPrefs(prefs, root_dir_), currentTime(base::Time::Now()) {}
+ ~TestingExtensionPrefs() {}
+
+ protected:
+ mutable base::Time currentTime;
+
+ virtual base::Time GetCurrentTime() const {
+ currentTime += base::TimeDelta::FromSeconds(10);
+ return currentTime;
+ }
+};
+
TestExtensionPrefs::TestExtensionPrefs() {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
preferences_file_ = temp_dir_.path().AppendASCII("Preferences");
@@ -42,7 +60,8 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
// Create a |PrefService| instance that contains only user defined values.
pref_service_.reset(PrefService::CreateUserPrefService(preferences_file_));
ExtensionPrefs::RegisterUserPrefs(pref_service_.get());
- prefs_.reset(new ExtensionPrefs(pref_service_.get(), temp_dir_.path()));
+ prefs_.reset(new TestingExtensionPrefs(pref_service_.get(),
+ temp_dir_.path()));
}
scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) {

Powered by Google App Engine
This is Rietveld 408576698