Beispiel #1
0
    def test_mouse_click(self):
        handler = mock.Mock()
        button = wx.Button(self.frame)
        button.Bind(wx.EVT_BUTTON, handler)

        # when
        _interaction_helpers.mouse_click_button(control=button, delay=0)

        # then
        self.assertEqual(handler.call_count, 1)
Beispiel #2
0
def register(registry):
    """ Register solvers/handlers specific to wx Button Editors
    for the given registry.

    If there are any conflicts, an error will occur.

    Parameters
    ----------
    registry : TargetRegistry
    """

    registry.register_interaction(
        target_class=ButtonEditor,
        interaction_class=MouseClick,
        handler=(lambda wrapper, _: _interaction_helpers.mouse_click_button(
                 control=wrapper._target.control, delay=wrapper.delay))
    )

    registry.register_interaction(
        target_class=ButtonEditor,
        interaction_class=DisplayedText,
        handler=lambda wrapper, _: wrapper._target.control.GetLabel()
    )

    registry.register_interaction(
        target_class=ButtonEditor,
        interaction_class=IsEnabled,
        handler=lambda wrapper, _: wrapper._target.control.IsEnabled()
    )
Beispiel #3
0
def register(registry):
    """ Register interactions for the given registry.

    If there are any conflicts, an error will occur.

    Parameters
    ----------
    registry : TargetRegistry
        The registry being registered to.
    """
    _IndexedCustomEditor.register(registry)

    registry.register_interaction(
        target_class=SimpleEditor,
        interaction_class=MouseClick,
        handler=lambda wrapper, _: mouse_click_button(
            control=wrapper._target._button,
            delay=wrapper.delay,
        ))
    register_traitsui_ui_solvers(registry, SimpleEditor, _get_nested_ui_simple)

    registry.register_interaction(
        target_class=CustomEditor,
        interaction_class=SelectedText,
        handler=_get_choice_text,
    )
    register_traitsui_ui_solvers(registry, CustomEditor, _get_nested_ui_custom)
Beispiel #4
0
 def test_mouse_click_None_warns(self):
     control = None
     with self.assertWarns(UserWarning):
         _interaction_helpers.mouse_click_button(control=control, delay=0)