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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e0f59ec5ce3751a48ea9f43c42299b326d10718 |
--- /dev/null |
+++ b/chrome/test/mini_installer/registry_verifier.py |
@@ -0,0 +1,47 @@ |
+# Copyright 2013 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 |
+import settings |
+ |
+ |
+def VerifyRegistryEntries(entries): |
+ for key, entry in entries.iteritems(): |
+ if VerifyRegistryEntry(key, entry): |
+ print "Passed" |
gab
2013/08/01 20:30:41
Add TODO to use unittest framework instead of prin
sukolsak
2013/08/02 22:59:55
Done.
|
+ 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") |
gab
2013/08/01 20:30:41
Add TODO to use unittest framework here.
sukolsak
2013/08/02 22:59:55
Done.
|
+ |
+ |
+def VerifyRegistryEntry(key, entry): |
+ expected = entry["expected"] |
+ print settings.PRINT_VERIFIER_PREFIX + key, |
gab
2013/08/01 20:30:41
Add TODO to remove these prints, i.e.:
# TODO(suk
sukolsak
2013/08/02 22:59:55
Done.
|
+ 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 not expected: |
+ return False |
gab
2013/08/01 20:30:41
Add a comment that the code should only continue i
sukolsak
2013/08/02 22:59:55
Fixed by reducing the scope of try/except to the O
|
+ if "value" in entry: |
+ # TODO(sukolsak): implement value |
+ pass |
+ return True |
+ except WindowsError: |
+ return not expected |