Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/kateview_test.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 56 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(0, 2))), | |||
---|---|---|---|---|---|
57 | KTextEditor::Cursor(0, 2)); | 57 | KTextEditor::Cursor(0, 2)); | ||
58 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(1, 1))), | 58 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(1, 1))), | ||
59 | KTextEditor::Cursor(1, 1)); | 59 | KTextEditor::Cursor(1, 1)); | ||
60 | // behind end of line should give an invalid cursor | 60 | // behind end of line should give an invalid cursor | ||
61 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(1, 5))), | 61 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(1, 5))), | ||
62 | KTextEditor::Cursor::invalid()); | 62 | KTextEditor::Cursor::invalid()); | ||
63 | QCOMPARE(view1->cursorToCoordinate(KTextEditor::Cursor(3, 1)), QPoint(-1, -1)); | 63 | QCOMPARE(view1->cursorToCoordinate(KTextEditor::Cursor(3, 1)), QPoint(-1, -1)); | ||
64 | 64 | | |||
65 | // check consistency between cursorToCoordinate(view->cursorPosition() and cursorPositionCoordinates() | ||||
66 | // random position | ||||
67 | view1->setCursorPosition(KTextEditor::Cursor(0, 3)); | ||||
68 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(view1->cursorPosition())), | ||||
69 | KTextEditor::Cursor(0, 3)); | ||||
70 | QCOMPARE(view1->coordinatesToCursor(view1->cursorPositionCoordinates()), KTextEditor::Cursor(0, 3)); | ||||
71 | // end of line | ||||
72 | view1->setCursorPosition(KTextEditor::Cursor(0, 9)); | ||||
73 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(0, 9))), | ||||
74 | KTextEditor::Cursor(0, 9)); | ||||
75 | QCOMPARE(view1->coordinatesToCursor(view1->cursorPositionCoordinates()), KTextEditor::Cursor(0, 9)); | ||||
76 | // empty line | ||||
77 | view1->setCursorPosition(KTextEditor::Cursor(2, 0)); | ||||
78 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(2, 0))), | ||||
79 | KTextEditor::Cursor(2, 0)); | ||||
80 | QCOMPARE(view1->coordinatesToCursor(view1->cursorPositionCoordinates()), KTextEditor::Cursor(2, 0)); | ||||
81 | | ||||
65 | // same test again, but with message widget on top visible | 82 | // same test again, but with message widget on top visible | ||
66 | KTextEditor::Message *message = new KTextEditor::Message("Jo World!", KTextEditor::Message::Information); | 83 | KTextEditor::Message *message = new KTextEditor::Message("Jo World!", KTextEditor::Message::Information); | ||
67 | doc.postMessage(message); | 84 | doc.postMessage(message); | ||
68 | 85 | | |||
69 | // wait 500ms until show animation is finished, so the message widget is visible | 86 | // wait 500ms until show animation is finished, so the message widget is visible | ||
70 | QTest::qWait(500); | 87 | QTest::qWait(500); | ||
71 | 88 | | |||
72 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(0, 2))), | 89 | QCOMPARE(view1->coordinatesToCursor(view1->cursorToCoordinate(KTextEditor::Cursor(0, 2))), | ||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |