Commit 0d78fa1e authored by Dominik Haumann's avatar Dominik Haumann
Browse files

add folding test again

This test still crashes: The cursor is hidden in a folding
region. Moving the cursor crashes Kate.

CCBUG: 311866
parent cb085d58
......@@ -182,6 +182,17 @@ target_link_libraries( templatehandler_test
katepartinterfaces
)
########### text folding test ###############
kde4_add_unit_test(katecodefoldingtest TESTNAME codefoldingtest katefoldingtest.cpp)
target_link_libraries( katecodefoldingtest
${KDE4_KDEUI_LIBS}
${QT_QTTEST_LIBRARY}
${KATE_TEST_LINK_LIBS}
katepartinterfaces
)
########### indenting test ################
set(indenttest_SRCS
......
int main()
{
int this_line_is_safe=1;
int that_line_will_cause_havoc=1;
}
\ No newline at end of file
/* This file is part of the Kate project.
*
* Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "katefoldingtest.h"
#include <qtest_kde.h>
#include <kateglobal.h>
#include <katebuffer.h>
#include <katedocument.h>
#include <kateview.h>
#include <kateconfig.h>
using namespace KTextEditor;
QTEST_KDEMAIN(KateFoldingTest, GUI)
namespace QTest {
template<>
char *toString(const KTextEditor::Cursor &cursor)
{
QByteArray ba = "Cursor[" + QByteArray::number(cursor.line())
+ ", " + QByteArray::number(cursor.column()) + "]";
return qstrdup(ba.data());
}
}
void KateFoldingTest::initTestCase()
{
KateGlobal::self()->incRef();
}
void KateFoldingTest::cleanupTestCase()
{
KateGlobal::self()->decRef();
}
// This is a unit test for bug 311866 (http://bugs.kde.org/show_bug.cgi?id=311866)
// It loads 5 lines of C++ code, places the cursor in line 4, and then folds
// the code.
// Expected behavior: the cursor should be moved so it stays visible
// Buggy behavior: the cursor is hidden, and moving the hidden cursor crashes kate
void KateFoldingTest::testCrash311866()
{
KateDocument doc(false, false, false);
QString url = KDESRCDIR + QString("data/bug311866.cpp");
doc.openUrl(url);
doc.setHighlightingMode("C++");
doc.buffer().ensureHighlighted (6);
KateView* view = static_cast<KateView*>(doc.createView(0));
view->show();
view->resize(400, 300);
view->setCursorPosition(Cursor(3, 0));
QTest::qWait(100);
view->slotFoldToplevelNodes();
doc.buffer().ensureHighlighted (6);
qDebug() << "!!! Does the next line crash?";
view->up();
}
/* This file is part of the KDE libraries
Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KATE_FOLDING_TEST_H
#define KATE_FOLDING_TEST_H
#include <QtCore/QObject>
class KateFoldingTest : public QObject
{
Q_OBJECT
public Q_SLOTS:
void initTestCase();
void cleanupTestCase();
private Q_SLOTS:
void testCrash311866();
};
#endif // KATE_FOLDING_TEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment