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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import _winreg
6
7 import settings
8
9
10 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.
11 for key, entry in entries.iteritems():
12 # TODO(sukolsak): Use unittest framework instead of prints.
13 if VerifyRegistryEntry(key, entry):
14 print "Passed"
15 else:
16 print "Failed"
17
18
19 def RootKeyConstant(key):
20 if key == "HKEY_CLASSES_ROOT":
21 return _winreg.HKEY_CLASSES_ROOT
22 if key == "HKEY_CURRENT_USER":
23 return _winreg.HKEY_CURRENT_USER
24 if key == "HKEY_LOCAL_MACHINE":
25 return _winreg.HKEY_LOCAL_MACHINE
26 if key == "HKEY_USERS":
27 return _winreg.HKEY_USERS
28 # 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.
29 raise Exception("Unknown registry key")
30
31
32 def VerifyRegistryEntry(key, entry):
33 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.
34 # TODO(sukolsak): Debug prints to be removed later.
35 print settings.PRINT_VERIFIER_PREFIX + key,
36 if expected:
37 print "exists...",
38 else:
39 print "doesn't exist...",
40 root_key, sub_key = key.split("\\", 1)
41 try:
42 reg_key = _winreg.OpenKey(RootKeyConstant(root_key),
43 sub_key, 0, _winreg.KEY_READ)
44 except WindowsError:
45 return not expected
46 if not expected:
47 return False
48 if "value" in entry:
49 # TODO(sukolsak): implement value
50 pass
51 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698