#1268 UI Tester update List Editor implementation to not only work with nested uis

Merged aaronayres35 Pseudo commit used to compare (81902cc...5a03076)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Changes found in between 81902cc...5a03076 (pseudo...base) which prevent comparing this pull request.

Showing 46 of 106 files from the diff.
Newly tracked file
traitsui/wx/enum_editor.py changed.
Newly tracked file
traitsui/__init__.py changed.
Other files ignored by Codecov
etstool.py has changed.
setup.cfg is new.
.travis.yml has changed.

@@ -10,13 +10,17 @@
Loading
10 10
#
11 11
12 12
from traitsui.testing.tester.registry import TargetRegistry
13 -
from traitsui.testing.tester.wx import common_ui_targets
14 -
from traitsui.testing.tester.wx.implementation import (
13 +
from traitsui.testing.tester._ui_tester_registry.wx._traitsui import (
15 14
    button_editor,
16 15
    check_list_editor,
16 +
    editor_factory,
17 +
    enum_editor,
18 +
    font_editor,
19 +
    instance_editor,
17 20
    list_editor,
18 21
    range_editor,
19 22
    text_editor,
23 +
    ui_base,
20 24
)
21 25
22 26
@@ -31,14 +35,18 @@
Loading
31 35
    """
32 36
    registry = TargetRegistry()
33 37
34 -
    common_ui_targets.LocatedTextbox.register(registry)
35 -
36 38
    # ButtonEditor
37 39
    button_editor.register(registry)
38 40
39 41
    # CheckListEditor
40 42
    check_list_editor.register(registry)
41 43
44 +
    # EnumEditor
45 +
    enum_editor.register(registry)
46 +
47 +
    # FontEditor
48 +
    font_editor.register(registry)
49 +
42 50
    # TextEditor
43 51
    text_editor.register(registry)
44 52
@@ -48,4 +56,13 @@
Loading
48 56
    # RangeEditor
49 57
    range_editor.register(registry)
50 58
59 +
    # ui_base
60 +
    ui_base.register(registry)
61 +
62 +
    # InstanceEditor
63 +
    instance_editor.register(registry)
64 +
65 +
    # Editor Factory
66 +
    editor_factory.register(registry)
67 +
51 68
    return registry

@@ -0,0 +1,186 @@
Loading
1 +
#  Copyright (c) 2005-2020, Enthought, Inc.
2 +
#  All rights reserved.
3 +
#
4 +
#  This software is provided without warranty under the terms of the BSD
5 +
#  license included in LICENSE.txt and may be redistributed only
6 +
#  under the conditions described in the aforementioned license.  The license
7 +
#  is also available online at http://www.enthought.com/licenses/BSD.txt
8 +
#
9 +
#  Thanks for using Enthought open source!
10 +
#
11 +
import wx
12 +
13 +
from traitsui.wx.enum_editor import (
14 +
    ListEditor,
15 +
    RadioEditor,
16 +
    SimpleEditor,
17 +
)
18 +
from traitsui.testing.tester import command, locator, query
19 +
from traitsui.testing.tester._ui_tester_registry._common_ui_targets import (
20 +
    _BaseSourceWithLocation
21 +
)
22 +
from traitsui.testing.tester._ui_tester_registry.wx import _interaction_helpers
23 +
from traitsui.testing.tester._ui_tester_registry._layout import (
24 +
    column_major_to_row_major
25 +
)
26 +
27 +
28 +
class _IndexedListEditor(_BaseSourceWithLocation):
29 +
    """ Wrapper class for EnumListEditor and Index.
30 +
    """
31 +
    source_class = ListEditor
32 +
    locator_class = locator.Index
33 +
    handlers = [
34 +
        (command.MouseClick,
35 +
            (lambda wrapper, _:
36 +
                _interaction_helpers.mouse_click_listbox(
37 +
                    control=wrapper._target.source.control,
38 +
                    index=wrapper._target.location.index,
39 +
                    delay=wrapper.delay))),
40 +
    ]
41 +
42 +
43 +
class _IndexedRadioEditor(_BaseSourceWithLocation):
44 +
    """ Wrapper class for EnumRadioEditor and Index.
45 +
    """
46 +
    source_class = RadioEditor
47 +
    locator_class = locator.Index
48 +
    handlers = [
49 +
        (command.MouseClick,
50 +
            (lambda wrapper, _:
51 +
                _interaction_helpers.mouse_click_radiobutton_child_in_panel(
52 +
                    control=wrapper._target.source.control,
53 +
                    index=convert_index(
54 +
                        source=wrapper._target.source,
55 +
                        index=wrapper._target.location.index
56 +
                    ),
57 +
                    delay=wrapper.delay))),
58 +
    ]
59 +
60 +
61 +
def convert_index(source, index):
62 +
    """ Helper function to convert an index for a GridSizer so that the
63 +
    index counts over the grid in the correct direction.
64 +
    The grid is always populated in row major order, however, the elements
65 +
    are assigned to each entry in the grid so that when displayed they appear
66 +
    in column major order.
67 +
    Sizers are indexed in the order they are populated, so to access
68 +
    the correct element we may need to convert a column-major based index
69 +
    into a row-major one.
70 +
71 +
    Parameters
72 +
    ----------
73 +
    control : RadioEditor
74 +
        The RadioEditor of interest. Its control is the wx.Panel containing
75 +
        child objects organized with a wx.GridSizer
76 +
    index : int
77 +
        the index of interest
78 +
    """
79 +
    sizer = source.control.GetSizer()
80 +
    if isinstance(sizer, wx.BoxSizer):
81 +
        return index
82 +
    n = len(source.names)
83 +
    num_cols = sizer.GetCols()
84 +
    num_rows = sizer.GetEffectiveRowsCount()
85 +
    return column_major_to_row_major(index, n, num_rows, num_cols)
86 +
87 +
88 +
class _IndexedSimpleEditor(_BaseSourceWithLocation):
89 +
    """ Wrapper class for Simple EnumEditor and Index.
90 +
    """
91 +
    source_class = SimpleEditor
92 +
    locator_class = locator.Index
93 +
    handlers = [
94 +
        (command.MouseClick,
95 +
            (lambda wrapper, _:
96 +
                _interaction_helpers.mouse_click_combobox_or_choice(
97 +
                    control=wrapper._target.source.control,
98 +
                    index=wrapper._target.location.index,
99 +
                    delay=wrapper.delay))),
100 +
    ]
101 +
102 +
103 +
def simple_displayed_selected_text_handler(wrapper, interaction):
104 +
    """ Handler function used to query DisplayedText for Simple Enum Editor.
105 +
    Note that depending on the factories evaluaute trait, the control for a
106 +
    Simple Enum Editor can either be a wx.ComboBox or a wx.Choice.
107 +
108 +
    Parameters
109 +
    ----------
110 +
    wrapper : UIWrapper
111 +
        The UIWrapper containing that object with text to be displayed.
112 +
    interaction : query.DisplayedText
113 +
        Unused in this function but included to match the expected format of a
114 +
        handler.  Should only be query.DisplayedText
115 +
    """
116 +
    control = wrapper._target.control
117 +
    if isinstance(control, wx.ComboBox):
118 +
        return control.GetValue()
119 +
    else:  # wx.Choice
120 +
        return control.GetString(control.GetSelection())
121 +
122 +
123 +
def radio_selected_text_handler(wrapper, interaction):
124 +
    """ Handler function used to query SelectedText for EnumRadioEditor.
125 +
126 +
    Parameters
127 +
    ----------
128 +
    wrapper : UIWrapper
129 +
        The UIWrapper containing that object with text that is selected.
130 +
    interaction : query.SelectedText
131 +
        Unused in this function but included to match the expected format of a
132 +
        handler.  Should only be query.SelectedText
133 +
    """
134 +
    children_list = wrapper._target.control.GetSizer().GetChildren()
135 +
    for child in children_list:
136 +
        if child.GetWindow().GetValue():
137 +
            return child.GetWindow().GetLabel()
138 +
    return None
139 +
140 +
141 +
def register(registry):
142 +
    """ Registry location and interaction handlers for EnumEditor.
143 +
144 +
    Parameters
145 +
    ----------
146 +
    registry : InteractionRegistry
147 +
    """
148 +
    _IndexedListEditor.register(registry)
149 +
    _IndexedRadioEditor.register(registry)
150 +
    _IndexedSimpleEditor.register(registry)
151 +
152 +
    simple_editor_text_handlers = [
153 +
        (command.KeyClick,
154 +
            (lambda wrapper, interaction:
155 +
                _interaction_helpers.key_click_combobox(
156 +
                    control=wrapper._target.control,
157 +
                    interaction=interaction,
158 +
                    delay=wrapper.delay))),
159 +
        (command.KeySequence,
160 +
            (lambda wrapper, interaction:
161 +
                _interaction_helpers.key_sequence_text_ctrl(
162 +
                    control=wrapper._target.control,
163 +
                    interaction=interaction,
164 +
                    delay=wrapper.delay))),
165 +
        (query.DisplayedText, simple_displayed_selected_text_handler),
166 +
        (query.SelectedText, simple_displayed_selected_text_handler)
167 +
    ]
168 +
169 +
    for interaction_class, handler in simple_editor_text_handlers:
170 +
        registry.register_handler(
171 +
            target_class=SimpleEditor,
172 +
            interaction_class=interaction_class,
173 +
            handler=handler
174 +
        )
175 +
176 +
    registry.register_handler(
177 +
        target_class=RadioEditor,
178 +
        interaction_class=query.SelectedText,
179 +
        handler=radio_selected_text_handler,
180 +
    )
181 +
    registry.register_handler(
182 +
        target_class=ListEditor,
183 +
        interaction_class=query.SelectedText,
184 +
        handler=lambda wrapper, _: wrapper._target.control.GetString(
185 +
            wrapper._target.control.GetSelection()),
186 +
    )

@@ -259,6 +259,7 @@
Loading
259 259
260 260
        if action.on_perform is not None:
261 261
            action.on_perform(selection)
262 +
            return
262 263
263 264
        action.perform(selection)
264 265

@@ -0,0 +1,42 @@
Loading
1 +
#  Copyright (c) 2005-2020, Enthought, Inc.
2 +
#  All rights reserved.
3 +
#
4 +
#  This software is provided without warranty under the terms of the BSD
5 +
#  license included in LICENSE.txt and may be redistributed only
6 +
#  under the conditions described in the aforementioned license.  The license
7 +
#  is also available online at http://www.enthought.com/licenses/BSD.txt
8 +
#
9 +
#  Thanks for using Enthought open source!
10 +
#
11 +
from traitsui.wx.text_editor import CustomEditor, ReadonlyEditor, SimpleEditor
12 +
from traitsui.testing.tester import query
13 +
from traitsui.testing.tester._ui_tester_registry.wx import _interaction_helpers
14 +
from traitsui.testing.tester._ui_tester_registry.wx._registry_helper import (
15 +
    register_editable_textbox_handlers,
16 +
)
17 +
18 +
19 +
def register(registry):
20 +
    """ Register interactions for the given registry.
21 +
22 +
    If there are any conflicts, an error will occur.
23 +
24 +
    Parameters
25 +
    ----------
26 +
    registry : TargetRegistry
27 +
        The registry being registered to.
28 +
    """
29 +
    for target_class in [CustomEditor, SimpleEditor]:
30 +
        register_editable_textbox_handlers(
31 +
            registry=registry,
32 +
            target_class=target_class,
33 +
            widget_getter=lambda wrapper: wrapper._target.control,
34 +
        )
35 +
36 +
    registry.register_handler(
37 +
        target_class=ReadonlyEditor,
38 +
        interaction_class=query.DisplayedText,
39 +
        handler=lambda wrapper, _:
40 +
            _interaction_helpers.readonly_textbox_displayed_text(
41 +
                wrapper._target.control),
42 +
    )

@@ -0,0 +1,40 @@
Loading
1 +
#  Copyright (c) 2005-2020, Enthought, Inc.
2 +
#  All rights reserved.
3 +
#
4 +
#  This software is provided without warranty under the terms of the BSD
5 +
#  license included in LICENSE.txt and may be redistributed only
6 +
#  under the conditions described in the aforementioned license.  The license
7 +
#  is also available online at http://www.enthought.com/licenses/BSD.txt
8 +
#
9 +
#  Thanks for using Enthought open source!
10 +
#
11 +
from traitsui.wx.editor_factory import ReadonlyEditor, TextEditor
12 +
from traitsui.testing.tester import query
13 +
from traitsui.testing.tester._ui_tester_registry.wx import _interaction_helpers
14 +
from traitsui.testing.tester._ui_tester_registry.wx._registry_helper import (
15 +
    register_editable_textbox_handlers,
16 +
)
17 +
18 +
19 +
def register(registry):
20 +
    """ Register interactions for the given registry.
21 +
22 +
    If there are any conflicts, an error will occur.
23 +
24 +
    Parameters
25 +
    ----------
26 +
    registry : TargetRegistry
27 +
        The registry being registered to.
28 +
    """
29 +
    register_editable_textbox_handlers(
30 +
        registry=registry,
31 +
        target_class=TextEditor,
32 +
        widget_getter=lambda wrapper: wrapper._target.control,
33 +
    )
34 +
    registry.register_handler(
35 +
        target_class=ReadonlyEditor,
36 +
        interaction_class=query.DisplayedText,
37 +
        handler=lambda wrapper, _:
38 +
            _interaction_helpers.readonly_textbox_displayed_text(
39 +
                wrapper._target.control),
40 +
    )

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Unable to process changes.

No base report to compare against.

46 Commits

+1 Files
+7
+1
+6
Hiding 44 contexual commits
+12 Files
+370
+416
+14
-60
Pull Request Base Commit
Files Coverage
traitsui 34.6%
Project Totals (296 files) 34.6%
Loading