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..7255e4a83d785d25dcb52f1ac585f0b4ad150142 |
--- /dev/null |
+++ b/chrome/installer/automation_test/verifier.py |
@@ -0,0 +1,51 @@ |
+# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
gab
2013/07/26 20:39:48
2013
|
+# 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": |
gab
2013/07/26 20:39:48
Is there some kind of switch statement for strings
sukolsak
2013/07/30 15:40:32
Python doesn't have a switch statement.
|
+ VerifyRegistryEntries(value) |
+ else: |
+ # TODO: implement other verifiers |
robertshield
2013/07/26 19:32:23
TODOs should be attributed:
# TODO(sukolsak): impl
|
+ pass |
+ |
+def VerifyRegistryEntries(entries): |
gab
2013/07/26 20:39:48
I would put individual verifiers in their own modu
|
+ 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 |
gab
2013/07/26 20:39:48
Constantify/document arbitrary formatting spaces
|
+ if expected: |
+ print " exists..." |
+ else: |
+ print " doesn't exist..." |
+ try: |
+ root_key, sub_key = key.split("\\", 1) |
+ reg_key = _winreg.OpenKey(RootKeyConstant(root_key), \ |
gab
2013/07/26 20:39:48
Why do you need a backslash here? (Sorry if this i
|
+ sub_key, 0, _winreg.KEY_READ) |
+ if expected == False: |
+ return False |
+ if "value" in entry: |
+ # TODO: implement value |
gab
2013/07/26 20:39:48
Name your TODO, i.e., TODO(sukolsak)
|
+ pass |
+ return True |
+ except WindowsError: |
+ return expected == False |