| Index: chrome/installer/automation_test/verifier.py
|
| diff --git a/chrome/installer/automation_test/verifier.py b/chrome/installer/automation_test/verifier.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42047ec35d0156956df85a9be5e9bdd9a6fe042c
|
| --- /dev/null
|
| +++ b/chrome/installer/automation_test/verifier.py
|
| @@ -0,0 +1,55 @@
|
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import _winreg
|
| +
|
| +
|
| +def Verify(config):
|
| + for verifier_name, value in config.iteritems():
|
| + if verifier_name == "RegistryEntries":
|
| + VerifyRegistryEntries(value)
|
| + else:
|
| + # TODO(sukolsak): implement other verifiers
|
| + pass
|
| +
|
| +
|
| +def VerifyRegistryEntries(entries):
|
| + for key, entry in entries.iteritems():
|
| + if VerifyRegistryEntry(key, entry):
|
| + print "Passed"
|
| + else:
|
| + print "Failed"
|
| +
|
| +
|
| +def RootKeyConstant(key):
|
| + if key == "HKEY_CLASSES_ROOT":
|
| + return _winreg.HKEY_CLASSES_ROOT
|
| + if key == "HKEY_CURRENT_USER":
|
| + return _winreg.HKEY_CURRENT_USER
|
| + if key == "HKEY_LOCAL_MACHINE":
|
| + return _winreg.HKEY_LOCAL_MACHINE
|
| + if key == "HKEY_USERS":
|
| + return _winreg.HKEY_USERS
|
| + raise Exception("Unknown registry key")
|
| +
|
| +
|
| +def VerifyRegistryEntry(key, entry):
|
| + expected = entry["expected"]
|
| + print " - " + key
|
| + if expected:
|
| + print " exists..."
|
| + else:
|
| + print " doesn't exist..."
|
| + try:
|
| + root_key, sub_key = key.split("\\", 1)
|
| + reg_key = _winreg.OpenKey(RootKeyConstant(root_key), \
|
| + sub_key, 0, _winreg.KEY_READ)
|
| + if expected == False:
|
| + return False
|
| + if "value" in entry:
|
| + # TODO(sukolsak): implement value
|
| + pass
|
| + return True
|
| + except WindowsError:
|
| + return expected == False
|
|
|