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

Unified Diff: chrome/installer/automation_test/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/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

Powered by Google App Engine
This is Rietveld 408576698