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

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: Upload with NOTRY=True. 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
« no previous file with comments | « chrome/test/mini_installer/config/config.config ('k') | chrome/test/mini_installer/settings.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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):
11 """Verifies that the current registry matches the specified criteria."""
12 for key, entry in entries.iteritems():
13 # TODO(sukolsak): Use unittest framework instead of prints.
14 if VerifyRegistryEntry(key, entry):
15 print 'Passed'
16 else:
17 print 'Failed'
18
19
20 def RootKeyConstant(key):
21 if key == 'HKEY_CLASSES_ROOT':
22 return _winreg.HKEY_CLASSES_ROOT
23 if key == 'HKEY_CURRENT_USER':
24 return _winreg.HKEY_CURRENT_USER
25 if key == 'HKEY_LOCAL_MACHINE':
26 return _winreg.HKEY_LOCAL_MACHINE
27 if key == 'HKEY_USERS':
28 return _winreg.HKEY_USERS
29 # TODO(sukolsak): Use unittest framework instead of exceptions.
30 raise Exception('Unknown registry key')
31
32
33 def VerifyRegistryEntry(key, entry):
34 """Verifies that a registry entry exists or doesn't exist and has
35 the specified value.
36
37 Args:
38 key: Name of the registry key.
39 entry: A dictionary with the following keys and values:
40 'expected' a boolean indicating whether the registry entry exists.
41 'value' (optional) a string representing the value of the registry entry.
42
43 Returns:
44 A boolean indicating whether the registry entry matches the criteria.
45 """
46 expected = entry['expected']
47 # TODO(sukolsak): Debug prints to be removed later.
48 print settings.PRINT_VERIFIER_PREFIX + key,
49 if expected:
50 print 'exists...',
51 else:
52 print "doesn't exist...",
53 root_key, sub_key = key.split('\\', 1)
54 try:
55 reg_key = _winreg.OpenKey(RootKeyConstant(root_key),
56 sub_key, 0, _winreg.KEY_READ)
57 except WindowsError:
58 return not expected
59 if not expected:
60 return False
61 if 'value' in entry:
62 # TODO(sukolsak): implement value
63 pass
64 return True
OLDNEW
« no previous file with comments | « chrome/test/mini_installer/config/config.config ('k') | chrome/test/mini_installer/settings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698