Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/kateview_test.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 188 | { | |||
---|---|---|---|---|---|
262 | QCoreApplication::sendEvent(internalView, new QMouseEvent(QEvent::MouseButtonRelease, afterB, | 262 | QCoreApplication::sendEvent(internalView, new QMouseEvent(QEvent::MouseButtonRelease, afterB, | ||
263 | Qt::LeftButton, Qt::LeftButton, | 263 | Qt::LeftButton, Qt::LeftButton, | ||
264 | Qt::ShiftModifier)); | 264 | Qt::ShiftModifier)); | ||
265 | 265 | | |||
266 | QCOMPARE(view->cursorPosition(), Cursor(1, 1)); | 266 | QCOMPARE(view->cursorPosition(), Cursor(1, 1)); | ||
267 | QCOMPARE(view->selectionRange(), Range(1, 1, 2, 1)); | 267 | QCOMPARE(view->selectionRange(), Range(1, 1, 2, 1)); | ||
268 | } | 268 | } | ||
269 | 269 | | |||
270 | void KateViewTest::testDeselectByArrowKeys() | ||||
271 | { | ||||
272 | KTextEditor::DocumentPrivate doc; | ||||
273 | doc.setText("foobarhaz"); | ||||
274 | | ||||
275 | KTextEditor::ViewPrivate *view = new KTextEditor::ViewPrivate(&doc, nullptr); | ||||
276 | KTextEditor::Cursor cur1(0, 3); // Start of bar: foo|barhaz | ||||
277 | KTextEditor::Cursor cur2(0, 6); // End of bar: foobar|haz | ||||
278 | KTextEditor::Cursor curDelta(0, 1); | ||||
279 | Range range(cur1, cur2); // Select "bar" | ||||
280 | | ||||
281 | view->setSelection(range); | ||||
282 | QCOMPARE(view->selectionText(), QLatin1String("bar")); | ||||
283 | | ||||
284 | view->setCursorPositionInternal(cur1); | ||||
285 | view->cursorLeft(); | ||||
286 | QCOMPARE(view->cursorPosition(), cur1); // Be at begin: foo|barhaz | ||||
287 | QCOMPARE(view->selection(), false); | ||||
288 | | ||||
289 | view->setSelection(range); | ||||
290 | view->setCursorPositionInternal(cur1); | ||||
291 | view->cursorRight(); | ||||
292 | QCOMPARE(view->cursorPosition(), cur2); // Be at end: foobar|haz | ||||
293 | QCOMPARE(view->selection(), false); | ||||
294 | | ||||
295 | view->config()->setPersistentSelection(true); | ||||
296 | | ||||
297 | view->setSelection(range); | ||||
298 | view->setCursorPositionInternal(cur1); | ||||
299 | view->cursorLeft(); | ||||
300 | QCOMPARE(view->cursorPosition(), cur1 - curDelta); // Be one left: fo|obarhaz | ||||
301 | QCOMPARE(view->selection(), true); | ||||
302 | | ||||
303 | view->setSelection(range); | ||||
304 | view->setCursorPositionInternal(cur1); | ||||
305 | view->cursorRight(); | ||||
306 | QCOMPARE(view->cursorPosition(), cur1 + curDelta); // Be one right: foob|arhaz | ||||
307 | QCOMPARE(view->selection(), true); | ||||
308 | } | ||||
309 | | ||||
270 | void KateViewTest::testKillline() | 310 | void KateViewTest::testKillline() | ||
271 | { | 311 | { | ||
272 | KTextEditor::DocumentPrivate doc; | 312 | KTextEditor::DocumentPrivate doc; | ||
273 | doc.insertLines(0, { "foo", "bar", "baz" }); | 313 | doc.insertLines(0, { "foo", "bar", "baz" }); | ||
274 | 314 | | |||
275 | KTextEditor::ViewPrivate *view = new KTextEditor::ViewPrivate(&doc, nullptr); | 315 | KTextEditor::ViewPrivate *view = new KTextEditor::ViewPrivate(&doc, nullptr); | ||
276 | 316 | | |||
277 | view->setCursorPositionInternal(KTextEditor::Cursor(1, 2)); | 317 | view->setCursorPositionInternal(KTextEditor::Cursor(1, 2)); | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |