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) { |