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