void KateFoldingTest::testFolding_py_lang() { KTemporaryFile file; file.setSuffix(".py"); file.open(); QTextStream stream(&file); stream << "if customerName == x\n" << " print x\n" << "elif customerName == y\n" << " print y\n" << "else print z\n"; stream << flush; file.close(); KateDocument doc(false, false, false); QVERIFY(doc.openUrl(KUrl(file.fileName()))); KateView* view = new KateView(&doc, 0); // is set to allow kate's hl to be called view->config()->setDynWordWrap(true); QCOMPARE(doc.visibleLines(), 6u); QAction* action = view->action("folding_toplevel"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 4u); action = view->action("folding_expandtoplevel"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 6u); }
void KateFoldingTest::testFolding_collapse_expand_local() { KTemporaryFile file; file.setSuffix(".c"); file.open(); QTextStream stream(&file); stream << "if () {\n" << " if () {\n" << " if () {\n" << " if () {\n" << " }\n" << " }\n" << " }\n" << " if () {\n" << " foo()\n" << " }\n" << " }\n"; stream << flush; file.close(); KateDocument doc(false, false, false); QVERIFY(doc.openUrl(KUrl(file.fileName()))); KateView* view = new KateView(&doc, 0); // is set to allow kate's hl to be called view->config()->setDynWordWrap(true); QCOMPARE(doc.visibleLines(), 12u); view->setCursorPosition(KTextEditor::Cursor(2,12)); QAction* action = view->action("folding_collapselocal"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 9u); view->setCursorPosition(KTextEditor::Cursor(2,11)); action = view->action("folding_collapselocal"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 7u); view->setCursorPosition(KTextEditor::Cursor(1,9)); action = view->action("folding_expandlocal"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 9u); }
void KateFoldingTest::testFolding_collapse_dsComments_XML() { KTemporaryFile file; file.setSuffix(".xml"); file.open(); QTextStream stream(&file); stream << "<test1>\n" << "</test1>\n" << "<!--\n" << "<test2>\n" << "</test2>\n" << "-->\n" << "<!--\n" << "-->\n"; stream << flush; file.close(); KateDocument doc(false, false, false); QVERIFY(doc.openUrl(KUrl(file.fileName()))); KateView* view = new KateView(&doc, 0); // is set to allow kate's hl to be called view->config()->setDynWordWrap(true); QCOMPARE(doc.visibleLines(), 9u); QAction* action = view->action("folding_collapse_dsComment"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 5u); }
void KateFoldingTest::testFolding() { QFETCH(QString, text); QFETCH(QString, fileExt); QFETCH(QString, firstActionName); QFETCH(QString, secondActionName); QFETCH(unsigned int, initValue); QFETCH(unsigned int, firstResult); QFETCH(unsigned int, secondResult); KTemporaryFile file; file.setSuffix("." + fileExt); file.open(); QTextStream stream(&file); stream << text; stream << flush; file.close(); KateDocument doc(false, false, false); QVERIFY(doc.openUrl(KUrl(file.fileName()))); KateView* view = new KateView(&doc, 0); QAction* firstAction = view->action(qPrintable(firstActionName)); QVERIFY(firstAction); QAction* secondAction = view->action(qPrintable(secondActionName)); QVERIFY(secondAction); // is set to allow kate's hl to be called view->config()->setDynWordWrap(true); QCOMPARE(doc.visibleLines(), initValue); firstAction->trigger(); QCOMPARE(doc.visibleLines(), firstResult); secondAction->trigger(); QCOMPARE(doc.visibleLines(), secondResult); }
void KateFoldingTest::testFoldingReload() { KTemporaryFile file; file.setSuffix(".cpp"); file.open(); QTextStream stream(&file); stream << "int main() {\n" << " asdf;\n" << "}\n"; stream << flush; file.close(); KateDocument doc(false, false, false); QVERIFY(doc.openUrl(KUrl(file.fileName()))); KateView* view = new KateView(&doc, 0); // is set to allow kate's hl to be called view->config()->setDynWordWrap(true); QCOMPARE(doc.visibleLines(), 4u); QAction* action = view->action("folding_toplevel"); QVERIFY(action); action->trigger(); doc.foldingTree()->saveFoldingState(); QList<int> hiddenLines(doc.foldingTree()->m_hiddenLines); QList<int> hiddenColumns(doc.foldingTree()->m_hiddenColumns); QCOMPARE(doc.visibleLines(), 2u); action = view->action("file_reload"); QVERIFY(action); action->trigger(); QCOMPARE(doc.visibleLines(), 2u); QCOMPARE(hiddenLines,doc.foldingTree()->m_hiddenLines); QCOMPARE(hiddenColumns,doc.foldingTree()->m_hiddenColumns); }