Skip to content

Commit

Permalink
interactor -> wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
kitchoi committed Aug 18, 2020
1 parent acb6561 commit ceb8fee
Show file tree
Hide file tree
Showing 24 changed files with 195 additions and 195 deletions.
10 changes: 5 additions & 5 deletions traitsui/testing/default_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def _get_editor_by_name(ui, name):
return editor


def _resolve_ui_editor_by_id(interactor, location):
return _get_editor_by_id(interactor.editor, location.id)
def _resolve_ui_editor_by_id(wrapper, location):
return _get_editor_by_id(wrapper.editor, location.id)


def _resolve_ui_editor_by_name(interactor, location):
return _get_editor_by_name(interactor.editor, location.name)
def _resolve_ui_editor_by_name(wrapper, location):
return _get_editor_by_name(wrapper.editor, location.name)


def get_ui_registry():
Expand All @@ -92,6 +92,6 @@ def get_ui_registry():
registry.register_location_solver(
target_class=UI,
locator_class=locator.NestedUI,
solver=lambda interactor, _: interactor.editor,
solver=lambda wrapper, _: wrapper.editor,
)
return registry
2 changes: 1 addition & 1 deletion traitsui/testing/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Disabled(SimulationError):


class ActionNotSupported(SimulationError):
""" Raised when an action is not supported by an interactor.
""" Raised when an action is not supported by an wrapper.
"""

def __init__(self, target_class, interaction_class, supported):
Expand Down
48 changes: 24 additions & 24 deletions traitsui/testing/qt4/default_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,43 @@
from traitsui.testing.interactor_registry import InteractionRegistry


def resolve_location_simple_editor(interactor, location):
if interactor.editor._dialog_ui is None:
interactor.editor._button.click()
return interactor.editor._dialog_ui
def resolve_location_simple_editor(wrapper, location):
if wrapper.editor._dialog_ui is None:
wrapper.editor._button.click()
return wrapper.editor._dialog_ui


def resolve_location_custom_instance_editor(interactor, location):
return interactor.editor._ui
def resolve_location_custom_instance_editor(wrapper, location):
return wrapper.editor._ui


def resolve_location_range_editor(interactor, location):
def resolve_location_range_editor(wrapper, location):
type_to_widget = {
locator.WidgetType.slider: interactor.editor.control.slider,
locator.WidgetType.textbox: interactor.editor.control.text,
locator.WidgetType.slider: wrapper.editor.control.slider,
locator.WidgetType.textbox: wrapper.editor.control.text,
}
return type_to_widget[location]


def key_sequence_qwidget(interactor, action):
if not interactor.editor.isEnabled():
raise Disabled("{!r} is disabled.".format(interactor.editor))
QTest.keyClicks(interactor.editor, action.sequence, delay=interactor.delay)
def key_sequence_qwidget(wrapper, action):
if not wrapper.editor.isEnabled():
raise Disabled("{!r} is disabled.".format(wrapper.editor))
QTest.keyClicks(wrapper.editor, action.sequence, delay=wrapper.delay)


def key_press_qwidget(interactor, action):
if not interactor.editor.isEnabled():
raise Disabled("{!r} is disabled.".format(interactor.editor))
def key_press_qwidget(wrapper, action):
if not wrapper.editor.isEnabled():
raise Disabled("{!r} is disabled.".format(wrapper.editor))
helpers.key_press(
interactor.editor, action.key, delay=interactor.delay
wrapper.editor, action.key, delay=wrapper.delay
)


def mouse_click_qwidget(interactor, action):
def mouse_click_qwidget(wrapper, action):
QTest.mouseClick(
interactor.editor,
wrapper.editor,
QtCore.Qt.LeftButton,
delay=interactor.delay,
delay=wrapper.delay,
)


Expand Down Expand Up @@ -160,21 +160,21 @@ def get_generic_registry():
registry.register(
target_class=QtGui.QPushButton,
interaction_class=query.DisplayedText,
handler=lambda interactor, _: interactor.editor.text(),
handler=lambda wrapper, _: wrapper.editor.text(),
)
registry.register(
target_class=QtGui.QLineEdit,
interaction_class=query.DisplayedText,
handler=lambda interactor, _: interactor.editor.displayText(),
handler=lambda wrapper, _: wrapper.editor.displayText(),
)
registry.register(
target_class=QtGui.QTextEdit,
interaction_class=query.DisplayedText,
handler=lambda interactor, _: interactor.editor.toPlainText(),
handler=lambda wrapper, _: wrapper.editor.toPlainText(),
)
registry.register(
target_class=QtGui.QLabel,
interaction_class=query.DisplayedText,
handler=lambda interactor, _: interactor.editor.text(),
handler=lambda wrapper, _: wrapper.editor.text(),
)
return registry
4 changes: 2 additions & 2 deletions traitsui/testing/qt4/implementation/button_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def register(registry):
registry.register_location_solver(
target_class=SimpleEditor,
locator_class=locator.DefaultTarget,
solver=lambda interactor, _: interactor.editor.control,
solver=lambda wrapper, _: wrapper.editor.control,
)
registry.register_location_solver(
target_class=CustomEditor,
locator_class=locator.DefaultTarget,
solver=lambda interactor, _: interactor.editor.control,
solver=lambda wrapper, _: wrapper.editor.control,
)
8 changes: 4 additions & 4 deletions traitsui/testing/qt4/implementation/check_list_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def __init__(self, editor, index):
self.index = index

@classmethod
def from_location_index(cls, interactor, location):
def from_location_index(cls, wrapper, location):
# Conform to the call signature specified in the register
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand All @@ -28,8 +28,8 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: interactor.editor.mouse_click(
delay=interactor.delay,
handler=lambda wrapper, _: wrapper.editor.mouse_click(
delay=wrapper.delay,
)
)

Expand Down
24 changes: 12 additions & 12 deletions traitsui/testing/qt4/implementation/enum_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self, editor, index):
self.index = index

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand All @@ -31,8 +31,8 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: (
interactor.editor.mouse_click(delay=interactor.delay)
handler=lambda wrapper, _: (
wrapper.editor.mouse_click(delay=wrapper.delay)
)
)

Expand All @@ -54,9 +54,9 @@ def __init__(self, editor, index):
self.index = index

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand All @@ -70,8 +70,8 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: interactor.editor.mouse_click(
delay=interactor.delay,
handler=lambda wrapper, _: wrapper.editor.mouse_click(
delay=wrapper.delay,
),
)

Expand Down Expand Up @@ -99,15 +99,15 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: interactor.editor.mouse_click(
delay=interactor.delay,
handler=lambda wrapper, _: wrapper.editor.mouse_click(
delay=wrapper.delay,
),
)

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand Down
8 changes: 4 additions & 4 deletions traitsui/testing/qt4/implementation/group_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def mouse_click(self, delay=0):
self.editor.container.setCurrentIndex(self.index)

@classmethod
def from_location_index(cls, interactor, location):
def from_location_index(cls, wrapper, location):
return cls(
editor=interactor.editor, index=location.index,
editor=wrapper.editor, index=location.index,
)


Expand All @@ -34,7 +34,7 @@ def register_tabbed_fold_group_editor(registry):
registry.register(
target_class=_IndexedTabbedFoldGroupEditor,
interaction_class=command.MouseClick,
handler=lambda interactor, _: (
interactor.editor.mouse_click(delay=interactor.delay)
handler=lambda wrapper, _: (
wrapper.editor.mouse_click(delay=wrapper.delay)
)
)
18 changes: 9 additions & 9 deletions traitsui/testing/qt4/implementation/list_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def __init__(self, editor, index):
self.index = index

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
# Raise IndexError early
interactor.editor._uis[location.index]
wrapper.editor._uis[location.index]
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand All @@ -37,7 +37,7 @@ def register(cls, registry):
registry.register_location_solver(
target_class=cls,
locator_class=locator.NestedUI,
solver=lambda interactor, _: interactor.editor.get_nested_ui(),
solver=lambda wrapper, _: wrapper.editor.get_nested_ui(),
)
registry_helper.register_find_by_in_nested_ui(
registry=registry,
Expand All @@ -46,8 +46,8 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: (
interactor.editor.mouse_click(delay=interactor.delay)
handler=lambda wrapper, _: (
wrapper.editor.mouse_click(delay=wrapper.delay)
),
)

Expand All @@ -67,9 +67,9 @@ def __init__(self, editor, index):
self.index = index

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
return cls(
editor=interactor.editor,
editor=wrapper.editor,
index=location.index,
)

Expand All @@ -83,7 +83,7 @@ def register(cls, registry):
registry.register_location_solver(
target_class=cls,
locator_class=locator.NestedUI,
solver=lambda interactor, _: interactor.editor._get_nested_ui(),
solver=lambda wrapper, _: wrapper.editor._get_nested_ui(),
)
registry_helper.register_find_by_in_nested_ui(
registry=registry,
Expand Down
20 changes: 10 additions & 10 deletions traitsui/testing/qt4/implementation/table_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def __init__(self, editor, cell):
self.cell = cell

@classmethod
def from_location(cls, interactor, location):
def from_location(cls, wrapper, location):
return cls(
editor=interactor.editor,
editor=wrapper.editor,
cell=location,
)

Expand All @@ -26,31 +26,31 @@ def register(cls, registry):
registry.register(
target_class=cls,
interaction_class=command.MouseClick,
handler=lambda interactor, _: interactor.editor._mouse_click(
delay=interactor.delay,
handler=lambda wrapper, _: wrapper.editor._mouse_click(
delay=wrapper.delay,
),
)
registry.register(
target_class=cls,
interaction_class=command.KeySequence,
handler=lambda interactor, action: interactor.editor._key_sequence(
handler=lambda wrapper, action: wrapper.editor._key_sequence(
sequence=action.sequence,
delay=interactor.delay,
delay=wrapper.delay,
),
)
registry.register(
target_class=cls,
interaction_class=command.KeyClick,
handler=lambda interactor, action: interactor.editor._key_press(
handler=lambda wrapper, action: wrapper.editor._key_press(
key=action.key,
delay=interactor.delay,
delay=wrapper.delay,
),
)
registry.register(
target_class=cls,
interaction_class=query.DisplayedText,
handler=lambda interactor, _: (
interactor.editor._get_displayed_text()
handler=lambda wrapper, _: (
wrapper.editor._get_displayed_text()
),
)

Expand Down
6 changes: 3 additions & 3 deletions traitsui/testing/qt4/implementation/text_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def register(registry):
registry.register_location_solver(
target_class=SimpleEditor,
locator_class=locator.DefaultTarget,
solver=lambda interactor, _: interactor.editor.control,
solver=lambda wrapper, _: wrapper.editor.control,
)
registry.register_location_solver(
target_class=CustomEditor,
locator_class=locator.DefaultTarget,
solver=lambda interactor, _: interactor.editor.control,
solver=lambda wrapper, _: wrapper.editor.control,
)
registry.register_location_solver(
target_class=ReadonlyEditor,
locator_class=locator.DefaultTarget,
solver=lambda interactor, _: interactor.editor.control,
solver=lambda wrapper, _: wrapper.editor.control,
)
Loading

0 comments on commit ceb8fee

Please sign in to comment.