summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/chrome_frame_test_utils.h
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 02:56:24 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-09 02:56:24 +0000
commit7dd06a0131c05212100c81ae88ae07f0757ff4db (patch)
tree8b42ff631ecaa927da86b40d47fe6298f972a8a7 /chrome_frame/test/chrome_frame_test_utils.h
parentd077249e28b8163aabf452604716dba216303207 (diff)
downloadchromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.zip
chromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.tar.gz
chromium_src-7dd06a0131c05212100c81ae88ae07f0757ff4db.tar.bz2
Temporary workaround to get tests that reference singletons either directly or indirectly to pass.
With the recent Singleton refactoring, these tests started exposing some inherent problems with singletons, namely that one test can reference a state set by a different test, which can cause all sorts of flakiness. Furthermore, some of these tests could reference the registry which may have some user specific settings that could cause the tests to fail To work around these issues, I'm adding a few utility classes for tests (registry virtualization) and exposing a method to reset singletons before a test is run. TEST=Fixes flakiness and a few tests that could fail on the waterfall. BUG=none Review URL: http://codereview.chromium.org/5564009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/chrome_frame_test_utils.h')
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h
index 82febb2..5d20e8a 100644
--- a/chrome_frame/test/chrome_frame_test_utils.h
+++ b/chrome_frame/test/chrome_frame_test_utils.h
@@ -21,6 +21,8 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/scoped_comptr_win.h"
+#include "base/scoped_ptr.h"
+#include "base/win/registry.h"
#include "chrome_frame/test_utils.h"
#include "chrome_frame/test/simulate_input.h"
@@ -177,6 +179,41 @@ class CloseIeAtEndOfScope {
// during test runs.
base::ProcessHandle StartCrashService();
+class TempRegKeyOverride {
+ public:
+ static const wchar_t kTempTestKeyPath[];
+
+ TempRegKeyOverride(HKEY override, const wchar_t* temp_name);
+ ~TempRegKeyOverride();
+
+ static void DeleteAllTempKeys();
+
+ protected:
+ HKEY override_;
+ base::win::RegKey temp_key_;
+ std::wstring temp_name_;
+};
+
+// Used in tests where we reference the registry and don't want to run into
+// problems where existing registry settings might conflict with the
+// expectations of the test.
+class ScopedVirtualizeHklmAndHkcu {
+ public:
+ ScopedVirtualizeHklmAndHkcu();
+ ~ScopedVirtualizeHklmAndHkcu();
+
+ protected:
+ scoped_ptr<TempRegKeyOverride> hklm_;
+ scoped_ptr<TempRegKeyOverride> hkcu_;
+};
+
} // namespace chrome_frame_test
+// TODO(tommi): This is a temporary workaround while we're getting our
+// Singleton story straight. Ideally each test should clear up any singletons
+// it might have created, but test cases do not implicitly have their own
+// AtExitManager, so we have this workaround method for tests that depend on
+// "fresh" singletons. The implementation is in chrome_frame_unittest_main.cc.
+void DeleteAllSingletons();
+
#endif // CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_