OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 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 class VerifierVisitor(object): |
| 6 |
| 7 def VisitFile(self, entry): |
| 8 """ Verifies that the current files match the expectation dictionaries. |
| 9 |
| 10 Throw AssertionError if |is_file_exists| doesn't match |
| 11 |should_file_exist|. |
| 12 """ |
| 13 error_message = "" |
| 14 if entry.is_file_existed: |
| 15 error_message = 'File %s exists' % entry.file_path |
| 16 else: |
| 17 error_message = 'File %s is missing' % entry.file_path |
| 18 assert entry.should_file_exist == entry.is_file_existed, error_message |
| 19 |
| 20 def VisitProcess(self, entry): |
| 21 """ Verifies that the running processes is launched or shutdown as |
| 22 expectation. |
| 23 """ |
| 24 error_message = "" |
| 25 if entry.is_running: |
| 26 error_message = 'Process %s is running' % entry.process_path |
| 27 else: |
| 28 error_message = 'Process %s is not running' % entry.process_path |
| 29 assert entry.should_process_run == entry.is_running, error_message |
| 30 |
| 31 def VisitRegistryKey(self, entry): |
| 32 """Verifies that the current registry key matches the specified criteria.""" |
| 33 if entry.should_key_exist == 'forbidden': |
| 34 assert entry.key_handle is None, 'Registry key %s exists' % entry.key |
| 35 elif entry.should_key_exist == 'required': |
| 36 assert entry.key_handle is not None, ('Registry key %s is missing' |
| 37 ) % entry.key |
| 38 |
| 39 |
| 40 def VisitRegistryValue(self, entry): |
| 41 """Verifies that the current registry value matches the specified criteria. |
| 42 """ |
| 43 error_message = "" |
| 44 if entry.expected_type == None: |
| 45 error_message = ('Value %s of registry key %s exists ' |
| 46 'with value %s') % (entry.value, entry.key, |
| 47 entry.value_data) |
| 48 elif entry.value_type == None: |
| 49 error_message = 'Value %s of registry key %s is missing' % (entry.value, |
| 50 entry.key) |
| 51 else: |
| 52 error_message = 'Value %s of registry key %s has unexpected type %s' % ( |
| 53 entry.value, entry.key, entry.expected_type) |
| 54 assert entry.expected_type == entry.value_type, error_message |
| 55 assert entry.expected_data == entry.value_data, ( |
| 56 'Value %s of registry key %s has unexpected data.\n' |
| 57 ' Expected: %s\n' |
| 58 ' Actual: %s') % (entry.value, entry.key, entry.expected_data, |
| 59 entry.value_data) |
OLD | NEW |