Пример #1
0
    def test_mouse_move_while_down(self):
        test_assistant = EnableTestAssistant()
        component = Component(bounds=[100, 200])
        event = test_assistant.mouse_move(component, 10, 20, left_down=True)

        self.assertEqual(event.x, 10)
        self.assertEqual(event.y, 20)
        self.assertIs(event.left_down, True)
def test_mouse_move():
    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])
    event = test_assistant.mouse_move(component, 10, 20)

    nose.tools.assert_equal(event.x, 10)
    nose.tools.assert_equal(event.y, 20)
    assert isinstance(event.window, _MockWindow)
    assert not event.alt_down
    assert not event.control_down
    assert not event.shift_down
    nose.tools.assert_equal(event.window.get_pointer_position(), (10, 20))
Пример #3
0
def test_mouse_move():
    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])
    event = test_assistant.mouse_move(component, 10, 20)

    nose.tools.assert_equal(event.x, 10)
    nose.tools.assert_equal(event.y, 20)
    assert isinstance(event.window, _MockWindow)
    assert not event.alt_down
    assert not event.control_down
    assert not event.shift_down
    nose.tools.assert_equal(event.window.get_pointer_position(), (10, 20))
Пример #4
0
    def test_mouse_move(self):
        test_assistant = EnableTestAssistant()
        component = Component(bounds=[100, 200])
        event = test_assistant.mouse_move(component, 10, 20)

        self.assertEqual(event.x, 10)
        self.assertEqual(event.y, 20)
        self.assertIsInstance(event.window, _MockWindow)
        self.assertFalse(event.alt_down)
        self.assertFalse(event.control_down)
        self.assertFalse(event.shift_down)
        self.assertEqual(event.window.get_pointer_position(), (10, 20))
def test_mouse_move_real_window():
    from enable.api import Window

    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])
    window = Window(None, component=component)

    event = test_assistant.mouse_move(component, 10, 20, window)

    nose.tools.assert_equal(event.x, 10)
    nose.tools.assert_equal(event.y, 20)
    nose.tools.assert_equal(event.window, window)
    assert not event.alt_down
    assert not event.control_down
    assert not event.shift_down
Пример #6
0
def test_mouse_move_real_window():
    from enable.api import Window

    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])
    window = Window(None, component=component)

    event = test_assistant.mouse_move(component, 10, 20, window)

    nose.tools.assert_equal(event.x, 10)
    nose.tools.assert_equal(event.y, 20)
    nose.tools.assert_equal(event.window, window)
    assert not event.alt_down
    assert not event.control_down
    assert not event.shift_down
Пример #7
0
    def test_mouse_move_real_window(self):
        from enable.api import Window

        test_assistant = EnableTestAssistant()
        component = Component(bounds=[100, 200])
        window = Window(None, component=component)

        event = test_assistant.mouse_move(component, 10, 20, window)

        self.assertEqual(event.x, 10)
        self.assertEqual(event.y, 20)
        self.assertEqual(event.window, window)
        self.assertFalse(event.alt_down)
        self.assertFalse(event.control_down)
        self.assertFalse(event.shift_down)
def test_mouse_move_real_window_mocked_position():
    from enable.api import Window

    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])

    with mock.patch.object(Window, 'get_pointer_position', return_value=None):
        window = Window(None, component=component)
        event = test_assistant.mouse_move(component, 10, 20, window)

        nose.tools.assert_equal(event.x, 10)
        nose.tools.assert_equal(event.y, 20)
        nose.tools.assert_equal(event.window, window)
        assert not event.alt_down
        assert not event.control_down
        assert not event.shift_down
        nose.tools.assert_equal(event.window.get_pointer_position(), (10, 20))
Пример #9
0
def test_mouse_move_real_window_mocked_position():
    from enable.api import Window

    test_assistant = EnableTestAssistant()
    component = Component(bounds=[100, 200])

    with mock.patch.object(Window, 'get_pointer_position',
                            return_value=None):
        window = Window(None, component=component)
        event = test_assistant.mouse_move(component, 10, 20, window)

        nose.tools.assert_equal(event.x, 10)
        nose.tools.assert_equal(event.y, 20)
        nose.tools.assert_equal(event.window, window)
        assert not event.alt_down
        assert not event.control_down
        assert not event.shift_down
        nose.tools.assert_equal(event.window.get_pointer_position(), (10, 20))
Пример #10
0
    def test_mouse_move_real_window_mocked_position(self):
        from enable.api import Window

        test_assistant = EnableTestAssistant()
        component = Component(bounds=[100, 200])

        patch = mock.patch.object(Window,
                                  "get_pointer_position",
                                  return_value=None)
        with patch:
            window = Window(None, component=component)
            event = test_assistant.mouse_move(component, 10, 20, window)

            self.assertEqual(event.x, 10)
            self.assertEqual(event.y, 20)
            self.assertEqual(event.window, window)
            self.assertFalse(event.alt_down)
            self.assertFalse(event.control_down)
            self.assertFalse(event.shift_down)
            self.assertEqual(event.window.get_pointer_position(), (10, 20))
Пример #11
0
 def test_mouse_dclick(self):
     test_assistant = EnableTestAssistant()
     component = Component(bounds=[100, 200])
     component.normal_left_dclick = mock.Mock()
     test_assistant.mouse_dclick(component, x=0, y=0)
     component.normal_left_dclick.assert_called_once()