File indexing completed on 2024-04-21 03:57:12

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KATE_DOCUMENT_TEST_H
0009 #define KATE_DOCUMENT_TEST_H
0010 
0011 #include <QTest>
0012 
0013 #include <ktexteditor/movingrange.h>
0014 
0015 class MovingRangeInvalidator : public QObject
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit MovingRangeInvalidator(QObject *parent = nullptr)
0020         : QObject(parent)
0021     {
0022     }
0023 
0024     void addRange(KTextEditor::MovingRange *range)
0025     {
0026         m_ranges << range;
0027     }
0028     QList<KTextEditor::MovingRange *> ranges() const
0029     {
0030         return m_ranges;
0031     }
0032 
0033 public Q_SLOTS:
0034     void aboutToInvalidateMovingInterfaceContent()
0035     {
0036         qDeleteAll(m_ranges);
0037         m_ranges.clear();
0038     }
0039 
0040 private:
0041     QList<KTextEditor::MovingRange *> m_ranges;
0042 };
0043 
0044 /**
0045  * Provides slots to check data sent in specific signals. Slot names are derived from corresponding test names.
0046  */
0047 class SignalHandler : public QObject
0048 {
0049     Q_OBJECT
0050 public Q_SLOTS:
0051     void slotMultipleLinesRemoved(KTextEditor::Document *, const KTextEditor::Range &, const QString &oldText)
0052     {
0053         QCOMPARE(oldText, QStringLiteral("line2\nline3\n"));
0054     }
0055 
0056     void slotNewlineInserted(KTextEditor::Document *, const KTextEditor::Range &range)
0057     {
0058         QCOMPARE(range, KTextEditor::Range(KTextEditor::Cursor(1, 4), KTextEditor::Cursor(2, 0)));
0059     }
0060 };
0061 
0062 class KateDocumentTest : public QObject
0063 {
0064     Q_OBJECT
0065 
0066 public:
0067     KateDocumentTest();
0068     ~KateDocumentTest() override;
0069 
0070 public Q_SLOTS:
0071     void initTestCase();
0072 
0073 private Q_SLOTS:
0074     void testWordWrap();
0075     void testWrapParagraph();
0076     void testReplaceQStringList();
0077     void testMovingInterfaceSignals();
0078     void testSetTextPerformance();
0079     void testRemoveTextPerformance();
0080     void testForgivingApiUsage();
0081     void testRemoveMultipleLines();
0082     void testInsertNewline();
0083     void testInsertAfterEOF();
0084     void testAutoBrackets();
0085     void testReplaceTabs();
0086     void testDigest();
0087     void testModelines();
0088     void testDefStyleNum();
0089     void testTypeCharsWithSurrogateAndNewLine();
0090     void testRemoveComposedCharacters();
0091     void testAutoReload();
0092     void testSearch();
0093     void testMatchingBracket_data();
0094     void testMatchingBracket();
0095     void testIndentOnPaste();
0096     void testAboutToSave();
0097     void testKeepUndoOverReload();
0098     void testToggleComment();
0099     void testInsertTextTooLargeColumn();
0100     void testBug468495();
0101     void testCursorToOffset();
0102     void testBug329247();
0103 };
0104 
0105 #endif // KATE_DOCUMENT_TEST_H