| Index: chrome/test/mini_installer/verifier_visitor.py
|
| diff --git a/chrome/test/mini_installer/verifier_visitor.py b/chrome/test/mini_installer/verifier_visitor.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b89487b96ea5f92f04063b24b244bdb6a5ec9183
|
| --- /dev/null
|
| +++ b/chrome/test/mini_installer/verifier_visitor.py
|
| @@ -0,0 +1,59 @@
|
| +# Copyright 2017 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.
|
| +
|
| +class VerifierVisitor(object):
|
| +
|
| + def VisitFile(self, entry):
|
| + """ Verifies that the current files match the expectation dictionaries.
|
| +
|
| + Throw AssertionError if |is_file_exists| doesn't match
|
| + |should_file_exist|.
|
| + """
|
| + error_message = ""
|
| + if entry.is_file_existed:
|
| + error_message = 'File %s exists' % entry.file_path
|
| + else:
|
| + error_message = 'File %s is missing' % entry.file_path
|
| + assert entry.should_file_exist == entry.is_file_existed, error_message
|
| +
|
| + def VisitProcess(self, entry):
|
| + """ Verifies that the running processes is launched or shutdown as
|
| + expectation.
|
| + """
|
| + error_message = ""
|
| + if entry.is_running:
|
| + error_message = 'Process %s is running' % entry.process_path
|
| + else:
|
| + error_message = 'Process %s is not running' % entry.process_path
|
| + assert entry.should_process_run == entry.is_running, error_message
|
| +
|
| + def VisitRegistryKey(self, entry):
|
| + """Verifies that the current registry key matches the specified criteria."""
|
| + if entry.should_key_exist == 'forbidden':
|
| + assert entry.key_handle is None, 'Registry key %s exists' % entry.key
|
| + elif entry.should_key_exist == 'required':
|
| + assert entry.key_handle is not None, ('Registry key %s is missing'
|
| + ) % entry.key
|
| +
|
| +
|
| + def VisitRegistryValue(self, entry):
|
| + """Verifies that the current registry value matches the specified criteria.
|
| + """
|
| + error_message = ""
|
| + if entry.expected_type == None:
|
| + error_message = ('Value %s of registry key %s exists '
|
| + 'with value %s') % (entry.value, entry.key,
|
| + entry.value_data)
|
| + elif entry.value_type == None:
|
| + error_message = 'Value %s of registry key %s is missing' % (entry.value,
|
| + entry.key)
|
| + else:
|
| + error_message = 'Value %s of registry key %s has unexpected type %s' % (
|
| + entry.value, entry.key, entry.expected_type)
|
| + assert entry.expected_type == entry.value_type, error_message
|
| + assert entry.expected_data == entry.value_data, (
|
| + 'Value %s of registry key %s has unexpected data.\n'
|
| + ' Expected: %s\n'
|
| + ' Actual: %s') % (entry.value, entry.key, entry.expected_data,
|
| + entry.value_data)
|
|
|