1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
# (C) Copyright 2004-2023 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
""" Interface of a registry depended on by the UIWrapper.
This module is currently labelled as for internal use, but it can be made
public when there is an external need.
"""
import abc
class AbstractTargetRegistry(abc.ABC):
"""Abstract base class which defines the registry interface expected
by :class:`~traitsui.testing.tester.ui_wrapper.UIWrapper`.
"""
@abc.abstractmethod
def _get_handler(self, target, interaction):
"""Return a callable for handling an interaction for a given target.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target being operated on.
interaction : any
Any interaction object.
Returns
-------
handler : callable(UIWrapper, interaction) -> any
The function to handle the given interaction on a target.
Raises
------
InteractionNotSupported
If the given target and interaction types are not supported
by this registry.
"""
@abc.abstractmethod
def _get_interactions(self, target):
"""Returns all the interactions supported for the given target.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target for which supported interactions are queried.
Returns
-------
interaction_classes : set
Supported interaction types for the given target type.
"""
@abc.abstractmethod
def _get_interaction_doc(self, target, interaction_class):
"""Return the documentation for the given target and interaction type.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target for which the interaction will be applied.
interaction_class : subclass of type
Any class.
Returns
-------
doc : str
Raises
------
InteractionNotSupported
If the given target and interaction types are not supported
by this registry.
"""
@abc.abstractmethod
def _get_solver(self, target, location):
"""Return a callable registered for resolving a location for the
given target and location.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target being operated on.
location : subclass of type
The location to be resolved on the target.
Raises
------
LocationNotSupported
If the given locator and target types are not supported.
"""
@abc.abstractmethod
def _get_locations(self, target):
"""Returns all the location types supported for the given target.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target for which supported location types are queried.
Returns
-------
locators_classes : set
Supported locator types for the given target type.
"""
@abc.abstractmethod
def _get_location_doc(self, target, locator_class):
"""Return the documentation for the given target and locator type.
This is a protected method expected to be implemented by a subclass.
Parameters
----------
target : any
The UI target being operated on.
locator_class : subclass of type
Any class.
Returns
-------
doc : str
Raises
------
LocationNotSupported
If the given locator and target types are not supported.
"""
|