Resize destination bus to the actual number of decoded frames.
[chromium-blink-merge.git] / base / test / test_reg_util_win.h
blobb71831f2bf3c2f78bea939ce6d1c1ad8a47bbfeb
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_TEST_TEST_REG_UTIL_H_
6 #define BASE_TEST_TEST_REG_UTIL_H_
8 // Registry utility functions used only by tests.
10 #include <string>
11 #include <vector>
13 #include "base/basictypes.h"
14 #include "base/win/registry.h"
16 namespace registry_util {
18 // Allows a test to easily override registry hives so that it can start from a
19 // known good state, or make sure to not leave any side effects once the test
20 // completes.
21 class RegistryOverrideManager {
22 public:
23 // All overridden hives will be descendents of this registry path under the
24 // main HKCU hive.
25 static const wchar_t kTempTestKeyPath[];
27 RegistryOverrideManager();
28 ~RegistryOverrideManager();
30 // Override the given registry hive using a temporary key named by temp_name
31 // under the temporary test key path.
32 void OverrideRegistry(HKEY override, const std::wstring& temp_name);
34 // Deletes all temporary test keys used by the overrides.
35 static void DeleteAllTempKeys();
37 // Removes all overrides and deletes all temporary test keys used by the
38 // overrides.
39 void RemoveAllOverrides();
41 private:
42 // Keeps track of one override.
43 class ScopedRegistryKeyOverride {
44 public:
45 ScopedRegistryKeyOverride(HKEY override, const std::wstring& temp_name);
46 ~ScopedRegistryKeyOverride();
48 private:
49 HKEY override_;
50 base::win::RegKey temp_key_;
51 std::wstring temp_name_;
53 DISALLOW_COPY_AND_ASSIGN(ScopedRegistryKeyOverride);
56 std::vector<ScopedRegistryKeyOverride*> overrides_;
58 DISALLOW_COPY_AND_ASSIGN(RegistryOverrideManager);
61 } // namespace registry_util
63 #endif // BASE_TEST_TEST_REG_UTIL_H_