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

Unified Diff: chrome/test/mini_installer_test/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, 5 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_test/registry_verifier.py
diff --git a/chrome/test/mini_installer_test/registry_verifier.py b/chrome/test/mini_installer_test/registry_verifier.py
new file mode 100644
index 0000000000000000000000000000000000000000..44259eca1c6e94cd886d46deea9d5bb47fc0ba1f
--- /dev/null
+++ b/chrome/test/mini_installer_test/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"
+ 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"]
gab 2013/07/31 13:45:16 Does this raise an exception if "expected" hasn't
sukolsak 2013/07/31 18:20:30 Python will raise the KeyError exception when the
+ print settings.PRINT_VERIFIER_PREFIX + key,
+ if expected:
+ print "exists...",
gab 2013/07/31 13:45:16 Don't these prints need the PRINT_VERIFIER_PREFIX
sukolsak 2013/07/31 18:20:30 No. I want it to be on the same line. The output w
gab 2013/08/01 20:30:41 Ah ok my bad, assumed print forced an automatic ne
+ 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)
gab 2013/07/31 13:45:16 Indent to delimiter ('(') or 4 spaces in, not a mi
sukolsak 2013/07/31 18:20:30 Done.
+ if expected == False:
gab 2013/07/31 13:45:16 Doesn't if !expected work here?
sukolsak 2013/07/31 18:20:30 Done.
+ return False
+ if "value" in entry:
+ # TODO(sukolsak): implement value
+ pass
+ return True
+ except WindowsError:
+ return expected == False
gab 2013/07/31 13:45:16 !expected ? I don't know python much, can we not
sukolsak 2013/07/31 18:20:30 Done.

Powered by Google App Engine
This is Rietveld 408576698