Chromium Code Reviews| Index: telemetry/telemetry/testing/browser_test_context.py |
| diff --git a/telemetry/telemetry/testing/browser_test_context.py b/telemetry/telemetry/testing/browser_test_context.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6dcf28efcfef9db2f5e8ade2b80f13e5c2e9c03 |
| --- /dev/null |
| +++ b/telemetry/telemetry/testing/browser_test_context.py |
| @@ -0,0 +1,64 @@ |
| +# Copyright 2016 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. |
| + |
| +import copy |
| +import sets |
| + |
| + |
| +_global_test_context = None |
| + |
| + |
| +def GetCopy(): |
| + return copy.deepcopy(_global_test_context) |
| + |
| + |
| +class TypTestContext(object): |
| + """ The TestContext that is used for passing data from the main test process |
| + to typ's subprocesses. Those includes: |
| + _ finder_options: the commandline options object. This is an instance of |
| + telemetry.internal.browser.browser_options.BrowserFinderOptions. |
| + _ test_class_name: the name of the test class to be run. |
| + _ test_cases_ids_to_run: the ids of the test cases to be run. |
|
Ken Russell (switch to Gerrit)
2016/12/21 00:12:59
Grammar: here and throughout: test_cases_ids -> te
nednguyen
2016/12/21 20:29:04
Done.
|
| + |
| + This object is designed to be pickle-able so that it can be easily pass from |
| + the main process to test subprocesses. It also supports immutable mode to |
| + ensure its data won't be changed by the subprocesses. |
| + """ |
| + def __init__(self): |
| + self._finder_options = None |
| + self._test_class_name = None |
| + self._test_cases_ids_to_run = set() |
| + self._frozen = False |
| + |
| + def Freeze(self): |
| + """ Makes the |self| object immutable. |
| + |
| + Calling setter on |self|'s property will throw exception. |
| + """ |
| + assert self._finder_options |
| + assert self._test_class_name |
| + self._frozen = True |
| + self._test_cases_ids_to_run = sets.ImmutableSet(self._test_cases_ids_to_run) |
| + |
| + @property |
| + def finder_options(self): |
| + return self._finder_options |
| + |
| + @property |
| + def test_class_name(self): |
| + return self._test_class_name |
| + |
| + @property |
| + def test_cases_ids_to_run(self): |
| + return self._test_cases_ids_to_run |
| + |
| + @finder_options.setter |
| + def finder_options(self, value): |
| + assert not self._frozen |
| + self._finder_options = value |
| + |
| + @test_class_name.setter |
| + def test_class_name(self, value): |
| + assert not self._test_class_name |
| + self._test_class_name = value |