| Index: chrome/test/mini_installer/registry_verifier.py
|
| diff --git a/chrome/test/mini_installer/registry_verifier.py b/chrome/test/mini_installer/registry_verifier.py
|
| index ceac20dd00868c8e28afe90d00c88b763a9790b2..f76c9873af3d3e9166c742177812b6cd153b3ab5 100644
|
| --- a/chrome/test/mini_installer/registry_verifier.py
|
| +++ b/chrome/test/mini_installer/registry_verifier.py
|
| @@ -4,20 +4,14 @@
|
|
|
| import _winreg
|
|
|
| -import settings
|
|
|
| -
|
| -def VerifyRegistryEntries(entries):
|
| +def VerifyRegistryEntries(entries, testcase):
|
| """Verifies that the current registry matches the specified criteria."""
|
| for key, entry in entries.iteritems():
|
| - # TODO(sukolsak): Use unittest framework instead of prints.
|
| - if VerifyRegistryEntry(key, entry):
|
| - print 'Passed'
|
| - else:
|
| - print 'Failed'
|
| + VerifyRegistryEntry(key, entry, testcase)
|
|
|
|
|
| -def RootKeyConstant(key):
|
| +def RootKeyConstant(key, testcase):
|
| if key == 'HKEY_CLASSES_ROOT':
|
| return _winreg.HKEY_CLASSES_ROOT
|
| if key == 'HKEY_CURRENT_USER':
|
| @@ -26,11 +20,10 @@ def RootKeyConstant(key):
|
| return _winreg.HKEY_LOCAL_MACHINE
|
| if key == 'HKEY_USERS':
|
| return _winreg.HKEY_USERS
|
| - # TODO(sukolsak): Use unittest framework instead of exceptions.
|
| - raise Exception('Unknown registry key')
|
| + testcase.fail('Unknown registry key')
|
|
|
|
|
| -def VerifyRegistryEntry(key, entry):
|
| +def VerifyRegistryEntry(key, entry, testcase):
|
| """Verifies that a registry entry exists or doesn't exist and has
|
| the specified value.
|
|
|
| @@ -39,26 +32,20 @@ def VerifyRegistryEntry(key, entry):
|
| entry: A dictionary with the following keys and values:
|
| 'expected' a boolean indicating whether the registry entry exists.
|
| 'value' (optional) a string representing the value of the registry entry.
|
| + testcase: A TestCase instance.
|
|
|
| Returns:
|
| A boolean indicating whether the registry entry matches the criteria.
|
| """
|
| expected = entry['expected']
|
| - # TODO(sukolsak): Debug prints to be removed later.
|
| - print settings.PRINT_VERIFIER_PREFIX + key,
|
| - if expected:
|
| - print 'exists...',
|
| - else:
|
| - print "doesn't exist...",
|
| root_key, sub_key = key.split('\\', 1)
|
| try:
|
| - reg_key = _winreg.OpenKey(RootKeyConstant(root_key),
|
| - sub_key, 0, _winreg.KEY_READ)
|
| + reg_key = _winreg.OpenKey(RootKeyConstant(root_key, testcase), sub_key, 0,
|
| + _winreg.KEY_READ)
|
| except WindowsError:
|
| - return not expected
|
| - if not expected:
|
| - return False
|
| + testcase.assertFalse(expected, 'Registry entry %s should not exist' % key)
|
| + return
|
| + testcase.assertTrue(expected, 'Registry entry %s should exist' % key)
|
| if 'value' in entry:
|
| # TODO(sukolsak): implement value
|
| pass
|
| - return True
|
|
|