Changeset View
Changeset View
Standalone View
Standalone View
autotests/src/templatehandler_test.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 43 | { | |||
---|---|---|---|---|---|
49 | auto doc = new KTextEditor::DocumentPrivate(false, false, nullptr, nullptr); | 49 | auto doc = new KTextEditor::DocumentPrivate(false, false, nullptr, nullptr); | ||
50 | auto view = static_cast<KTextEditor::ViewPrivate*>(doc->createView(nullptr)); | 50 | auto view = static_cast<KTextEditor::ViewPrivate*>(doc->createView(nullptr)); | ||
51 | 51 | | |||
52 | // fixed indentation options | 52 | // fixed indentation options | ||
53 | doc->config()->setTabWidth(8); | 53 | doc->config()->setTabWidth(8); | ||
54 | doc->config()->setIndentationWidth(4); | 54 | doc->config()->setIndentationWidth(4); | ||
55 | doc->config()->setReplaceTabsDyn(true); | 55 | doc->config()->setReplaceTabsDyn(true); | ||
56 | 56 | | |||
57 | view->insertTemplate({0, 0}, snippet); | 57 | view->insertTemplate(KTextEditor::Cursor(0, 0), snippet); | ||
58 | 58 | | |||
59 | const QString result = "for (int i = ; i < ; ++i)\n" | 59 | const QString result = "for (int i = ; i < ; ++i)\n" | ||
60 | "{\n" | 60 | "{\n" | ||
61 | " i\n" | 61 | " i\n" | ||
62 | "}"; | 62 | "}"; | ||
63 | QCOMPARE(doc->text(), result); | 63 | QCOMPARE(doc->text(), result); | ||
64 | 64 | | |||
65 | doc->replaceText(Range(0, 9, 0, 10), "j"); | 65 | doc->replaceText(Range(0, 9, 0, 10), "j"); | ||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Line(s) | |||||
354 | void TemplateHandlerTest::testDefaults() | 354 | void TemplateHandlerTest::testDefaults() | ||
355 | { | 355 | { | ||
356 | auto doc = new KTextEditor::DocumentPrivate(false, false, nullptr, nullptr); | 356 | auto doc = new KTextEditor::DocumentPrivate(false, false, nullptr, nullptr); | ||
357 | auto view = static_cast<KTextEditor::ViewPrivate*>(doc->createView(nullptr)); | 357 | auto view = static_cast<KTextEditor::ViewPrivate*>(doc->createView(nullptr)); | ||
358 | 358 | | |||
359 | QFETCH(QString, input); | 359 | QFETCH(QString, input); | ||
360 | QFETCH(QString, function); | 360 | QFETCH(QString, function); | ||
361 | 361 | | |||
362 | view->insertTemplate({0, 0}, input, function); | 362 | view->insertTemplate(KTextEditor::Cursor(0, 0), input, function); | ||
363 | QTEST(doc->text(), "expected"); | 363 | QTEST(doc->text(), "expected"); | ||
364 | 364 | | |||
365 | view->selectAll(); | 365 | view->selectAll(); | ||
366 | view->keyDelete(); | 366 | view->keyDelete(); | ||
367 | QCOMPARE(doc->text(), QString()); | 367 | QCOMPARE(doc->text(), QString()); | ||
368 | 368 | | |||
369 | delete doc; | 369 | delete doc; | ||
370 | } | 370 | } | ||
371 | 371 | | |||
372 | #include "moc_templatehandler_test.cpp" | 372 | #include "moc_templatehandler_test.cpp" |