summaryrefslogtreecommitdiffstats
path: root/ceee/ie/common
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-27 04:13:27 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-27 04:13:27 +0000
commitd73e5f53bc629a5183dcdf3b78529c43541f0b31 (patch)
treede681e97b7db72d1d94ad4a928d32cb315674808 /ceee/ie/common
parent62884b5e9beaafc9d184f68d81aec868ff0391fb (diff)
downloadchromium_src-d73e5f53bc629a5183dcdf3b78529c43541f0b31.zip
chromium_src-d73e5f53bc629a5183dcdf3b78529c43541f0b31.tar.gz
chromium_src-d73e5f53bc629a5183dcdf3b78529c43541f0b31.tar.bz2
Exctracted helper to override registry.
BUG=none TEST=none Review URL: http://codereview.chromium.org/5354004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee/ie/common')
-rw-r--r--ceee/ie/common/ceee_module_util_unittest.cc39
1 files changed, 5 insertions, 34 deletions
diff --git a/ceee/ie/common/ceee_module_util_unittest.cc b/ceee/ie/common/ceee_module_util_unittest.cc
index 5e41804..5bda65d 100644
--- a/ceee/ie/common/ceee_module_util_unittest.cc
+++ b/ceee/ie/common/ceee_module_util_unittest.cc
@@ -34,13 +34,6 @@ using testing::SetArgumentPointee;
using testing::StrictMock;
using testing::Return;
-const wchar_t* kReplacementRoot =
- L"Software\\Google\\InstallUtilUnittest";
-const wchar_t* kHKCUReplacement =
- L"Software\\Google\\InstallUtilUnittest\\HKCU";
-const wchar_t* kHKLMReplacement =
- L"Software\\Google\\InstallUtilUnittest\\HKLM";
-
MOCK_STATIC_CLASS_BEGIN(MockProcessWinUtils)
MOCK_STATIC_INIT_BEGIN(MockProcessWinUtils)
MOCK_STATIC_INIT2(process_utils_win::IsCurrentProcessUacElevated,
@@ -50,44 +43,22 @@ MOCK_STATIC_CLASS_BEGIN(MockProcessWinUtils)
MOCK_STATIC1(HRESULT, , IsCurrentProcessUacElevated, bool*);
MOCK_STATIC_CLASS_END(MockProcessWinUtils)
-
class CeeeModuleUtilTest : public testing::Test {
- protected:
+ public:
static const DWORD kFalse = 0;
static const DWORD kTrue = 1;
static const DWORD kInvalid = 5;
+ protected:
virtual void SetUp() {
- // Wipe the keys we redirect to.
- // This gives us a stable run, even in the presence of previous
- // crashes or failures.
- LSTATUS err = SHDeleteKey(HKEY_CURRENT_USER, kReplacementRoot);
- EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND);
-
- // Create the keys we're redirecting HKCU and HKLM to.
- ASSERT_TRUE(hkcu_.Create(HKEY_CURRENT_USER, kHKCUReplacement, KEY_READ));
- ASSERT_TRUE(hklm_.Create(HKEY_CURRENT_USER, kHKLMReplacement, KEY_READ));
-
- // And do the switcharoo.
- ASSERT_EQ(ERROR_SUCCESS,
- ::RegOverridePredefKey(HKEY_CURRENT_USER, hkcu_.Handle()));
- ASSERT_EQ(ERROR_SUCCESS,
- ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, hklm_.Handle()));
+ registry_override_.reset(new testing::ScopedRegistryOverride());
}
virtual void TearDown() {
- // Undo the redirection.
- EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_CURRENT_USER, NULL));
- EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, NULL));
-
- // Close our handles and delete the temp keys we redirected to.
- hkcu_.Close();
- hklm_.Close();
- EXPECT_EQ(ERROR_SUCCESS, SHDeleteKey(HKEY_CURRENT_USER, kReplacementRoot));
+ registry_override_.reset();
}
- base::win::RegKey hkcu_;
- base::win::RegKey hklm_;
+ scoped_ptr<testing::ScopedRegistryOverride> registry_override_;
};
// Mock PathService::Get that is used to look up files.