Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7456)

Unified Diff: chrome/test/mini_installer/registry_verifier.py

Issue 20578004: Initial commit for the Automated Installer Testing Framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8ee89e21418874c57a2320455086cd8319952480
--- /dev/null
+++ b/chrome/test/mini_installer/registry_verifier.py
@@ -0,0 +1,51 @@
+# 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):
Mathieu 2013/08/05 18:46:13 You should have a docstring to document public fun
sukolsak 2013/08/05 20:34:46 Done.
+ for key, entry in entries.iteritems():
+ # TODO(sukolsak): Use unittest framework instead of prints.
+ 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
+ # TODO(sukolsak: Use unittest framework instead of exceptions.
Mathieu 2013/08/05 18:46:13 nit: missing closing parens
sukolsak 2013/08/05 20:34:46 Done.
+ raise Exception("Unknown registry key")
+
+
+def VerifyRegistryEntry(key, entry):
+ expected = entry["expected"]
Mathieu 2013/08/05 18:46:13 as mentioned above, for non-obvious params such as
sukolsak 2013/08/05 20:34:46 Done.
+ # 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)
+ except WindowsError:
+ return not expected
+ if not expected:
+ return False
+ if "value" in entry:
+ # TODO(sukolsak): implement value
+ pass
+ return True

Powered by Google App Engine
This is Rietveld 408576698