Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/inlinenote_test.cpp
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | |||||
134 | 134 | | |||
135 | void InlineNoteTest::testInlineNote() | 135 | void InlineNoteTest::testInlineNote() | ||
136 | { | 136 | { | ||
137 | KTextEditor::DocumentPrivate doc; | 137 | KTextEditor::DocumentPrivate doc; | ||
138 | doc.setText(QLatin1String("xxxxxxxxxx\nxxxxxxxxxx")); | 138 | doc.setText(QLatin1String("xxxxxxxxxx\nxxxxxxxxxx")); | ||
139 | 139 | | |||
140 | KTextEditor::ViewPrivate view(&doc, nullptr); | 140 | KTextEditor::ViewPrivate view(&doc, nullptr); | ||
141 | view.show(); | 141 | view.show(); | ||
142 | | ||||
143 | QTest::qWait(100); | ||||
144 | | ||||
142 | view.setCursorPosition({ 0, 5 }); | 145 | view.setCursorPosition({ 0, 5 }); | ||
143 | QCOMPARE(view.cursorPosition(), Cursor(0, 5)); | 146 | QCOMPARE(view.cursorPosition(), Cursor(0, 5)); | ||
144 | 147 | | |||
145 | const auto coordCol04 = view.cursorToCoordinate({ 0, 4 }); | 148 | const auto coordCol04 = view.cursorToCoordinate({ 0, 4 }); | ||
146 | const auto coordCol05 = view.cursorToCoordinate({ 0, 5 }); | 149 | const auto coordCol05 = view.cursorToCoordinate({ 0, 5 }); | ||
147 | const auto coordCol10 = view.cursorToCoordinate({ 0, 10 }); | 150 | const auto coordCol10 = view.cursorToCoordinate({ 0, 10 }); | ||
148 | QVERIFY(coordCol05.x() > coordCol04.x()); | 151 | QVERIFY(coordCol05.x() > coordCol04.x()); | ||
149 | QVERIFY(coordCol10.x() > coordCol05.x()); | 152 | QVERIFY(coordCol10.x() > coordCol05.x()); | ||
150 | 153 | | |||
151 | const auto xWidth = coordCol05.x() - coordCol04.x(); | 154 | const auto xWidth = coordCol05.x() - coordCol04.x(); | ||
152 | 155 | | |||
153 | auto iface = qobject_cast<KTextEditor::InlineNoteInterface*>(&view); | 156 | auto iface = qobject_cast<KTextEditor::InlineNoteInterface*>(&view); | ||
154 | QVERIFY(iface != nullptr); | 157 | QVERIFY(iface != nullptr); | ||
155 | 158 | | |||
156 | NoteProvider noteProvider; | 159 | NoteProvider noteProvider; | ||
157 | const QVector<int> expectedColumns = { 5, 10 }; | 160 | const QVector<int> expectedColumns = { 5, 10 }; | ||
158 | QCOMPARE(noteProvider.inlineNotes(0), expectedColumns); | 161 | QCOMPARE(noteProvider.inlineNotes(0), expectedColumns); | ||
159 | QCOMPARE(noteProvider.inlineNotes(1), QVector<int>()); | 162 | QCOMPARE(noteProvider.inlineNotes(1), QVector<int>()); | ||
160 | iface->registerInlineNoteProvider(¬eProvider); | 163 | iface->registerInlineNoteProvider(¬eProvider); | ||
161 | 164 | | |||
162 | QTest::qWait(1000); | 165 | QTest::qWait(100); | ||
163 | 166 | | |||
164 | const auto newCoordCol04 = view.cursorToCoordinate({ 0, 4 }); | 167 | const auto newCoordCol04 = view.cursorToCoordinate({ 0, 4 }); | ||
165 | const auto newCoordCol05 = view.cursorToCoordinate({ 0, 5 }); | 168 | const auto newCoordCol05 = view.cursorToCoordinate({ 0, 5 }); | ||
166 | const auto newCoordCol10 = view.cursorToCoordinate({ 0, 10 }); | 169 | const auto newCoordCol10 = view.cursorToCoordinate({ 0, 10 }); | ||
167 | 170 | | |||
168 | QVERIFY(newCoordCol05.x() > newCoordCol04.x()); | 171 | QVERIFY(newCoordCol05.x() > newCoordCol04.x()); | ||
169 | QVERIFY(newCoordCol10.x() > newCoordCol05.x()); | 172 | QVERIFY(newCoordCol10.x() > newCoordCol05.x()); | ||
170 | 173 | | |||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |