| 1 |
.. _testing-how-extension-works: |
| 2 |
|
| 3 |
How extension works |
| 4 |
=================== |
| 5 |
|
| 6 |
|UITester| supports testing TraitsUI editors with various user interaction |
| 7 |
logic. However it is possible that projects' test code may require |
| 8 |
additional logic that is not supported by |UITester| by default. Furthermore, |
| 9 |
some projects may implement and maintain their own custom UI editors. Those |
| 10 |
custom UI editors are also by default not supported by |UITester|. |
| 11 |
|
| 12 |
The API allows extension such that |
| 13 |
|
| 14 |
* projects can test TraitsUI editors with user interactions that do not |
| 15 |
come supported by default. |
| 16 |
* projects can reuse the testing API for testing custom editors. |
| 17 |
|
| 18 |
As described in :ref:`testing-add-new-interaction` and |
| 19 |
:ref:`testing-add-new-location`, the testing API can be extended by providing |
| 20 |
one or many registry objects. Internally, |UITester| maintains a list of |
| 21 |
registries ordered in decreasing priority. For example, if you provide multiple |
| 22 |
registries:: |
| 23 |
|
| 24 |
tester = UITester(registries=[custom_registry, another_registry]) |
| 25 |
|
| 26 |
Interaction and location support registered in the first registry will |
| 27 |
supersede that of the second (if such implementation exists). |
| 28 |
|
| 29 |
This list of registries is passed on to all |UIWrapper| created from the |
| 30 |
|UITester|. When |UIWrapper.perform| or |UIWrapper.inspect| is called, the |
| 31 |
first registry that can support the given target and interaction will be used. |
| 32 |
Likewise, |UIWrapper.locate| follows the same rule for the given target and |
| 33 |
location. See :ref:`testing-target-interaction-location` for an explanation on |
| 34 |
these three types of objects. |
| 35 |
|
| 36 |
This is how |UITester| supports testing on TraitsUI editor: It extends |
| 37 |
the given list of registries with more built-in registries that know how to |
| 38 |
interact with TraitsUI editors, and let |UIWrapper| do most of the work. |
| 39 |
|
| 40 |
.. include:: ../substitutions.rst |