Show More
@@ -42,21 +42,32 class TestConsoleWidget(unittest.TestCase): | |||||
42 | cursor.insertText('') |
|
42 | cursor.insertText('') | |
43 |
|
43 | |||
44 | def test_link_handling(self): |
|
44 | def test_link_handling(self): | |
45 | class event(object): |
|
45 | noKeys = QtCore.Qt | |
46 | def __init__(self, pos): |
|
46 | noButton = QtCore.Qt.MouseButton(0) | |
47 | self._pos = pos |
|
47 | noButtons = QtCore.Qt.MouseButtons(0) | |
48 | def pos(self): |
|
48 | noModifiers = QtCore.Qt.KeyboardModifiers(0) | |
49 | return self._pos |
|
49 | MouseMove = QtCore.QEvent.MouseMove | |
50 |
|
50 | QMouseEvent = QtGui.QMouseEvent | ||
|
51 | ||||
51 | w = ConsoleWidget() |
|
52 | w = ConsoleWidget() | |
52 | cursor = w._get_prompt_cursor() |
|
53 | cursor = w._get_prompt_cursor() | |
53 | w._insert_html(cursor, '<a href="http://python.org">written in</a>') |
|
54 | w._insert_html(cursor, '<a href="http://python.org">written in</a>') | |
|
55 | obj = w._control | |||
54 | self.assertEqual(w._anchor, None) |
|
56 | self.assertEqual(w._anchor, None) | |
|
57 | ||||
55 | # should be over text |
|
58 | # should be over text | |
56 | w.mouseMoveEvent(event(QtCore.QPoint(1,5))) |
|
59 | overTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), | |
|
60 | noButton, noButtons, noModifiers) | |||
|
61 | w.eventFilter(obj, overTextEvent) | |||
57 | self.assertEqual(w._anchor, "http://python.org") |
|
62 | self.assertEqual(w._anchor, "http://python.org") | |
|
63 | ||||
58 | # should still be over text |
|
64 | # should still be over text | |
59 | w.mouseMoveEvent(event(QtCore.QPoint(5,5))) |
|
65 | stillOverTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), | |
|
66 | noButton, noButtons, noModifiers) | |||
|
67 | w.eventFilter(obj, stillOverTextEvent) | |||
|
68 | ||||
60 | # should be somewhere else |
|
69 | # should be somewhere else | |
61 |
|
|
70 | elsewhereEvent = QMouseEvent(MouseMove, QtCore.QPoint(50,50), | |
|
71 | noButton, noButtons, noModifiers) | |||
|
72 | w.eventFilter(obj, elsewhereEvent) | |||
62 | self.assertEqual(w._anchor, None) |
|
73 | self.assertEqual(w._anchor, None) |
General Comments 0
You need to be logged in to leave comments.
Login now