aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppdoxygen_test.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2014-07-07 14:55:07 +0200
committerOrgad Shaneh <orgads@gmail.com>2014-10-21 12:09:01 +0200
commit3f24bd1e9518556752f6d5bb608e196a44373309 (patch)
treec0e35ddcabe897685804b70c01a5795eb3f2d7c9 /src/plugins/cppeditor/cppdoxygen_test.cpp
parent601ce9baa5938c4efb1aebf0d0ecf83b61f99846 (diff)
C++: fix multi-line continuation handling.
When having doxygen enabled, but leading astriskses disabled, a comment continuation line did not insert an extra space for where the astrisks would have been, thus mis-aligning the second line. Task-number: QTCREATORBUG-12539 Change-Id: I47baa203fd5d9279fa89a06f526f3abed06ce443 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/cppeditor/cppdoxygen_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppdoxygen_test.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp
index b1fc3f785f..3cd9a13f3b 100644
--- a/src/plugins/cppeditor/cppdoxygen_test.cpp
+++ b/src/plugins/cppeditor/cppdoxygen_test.cpp
@@ -32,7 +32,9 @@
#include "cppeditortestcase.h"
#include <coreplugin/editormanager/editormanager.h>
+#include <cpptools/commentssettings.h>
#include <cpptools/cppmodelmanager.h>
+#include <cpptools/cpptoolssettings.h>
#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
@@ -63,9 +65,11 @@ namespace Tests {
class DoxygenTestCase : public Internal::Tests::TestCase
{
+ QScopedPointer<CppTools::CommentsSettings> oldSettings;
public:
/// The '|' in the input denotes the cursor position.
- DoxygenTestCase(const QByteArray &original, const QByteArray &expected)
+ DoxygenTestCase(const QByteArray &original, const QByteArray &expected,
+ CppTools::CommentsSettings *injectedSettings = 0)
{
QVERIFY(succeededSoFar());
@@ -82,6 +86,12 @@ public:
&testDocument.m_editorWidget));
closeEditorAtEndOfTestCase(testDocument.m_editor);
+ if (injectedSettings) {
+ auto *cts = CppTools::CppToolsSettings::instance();
+ oldSettings.reset(new CppTools::CommentsSettings(cts->commentsSettings()));
+ injectSettings(injectedSettings);
+ }
+
// We want to test documents that start with a comment. By default, the
// editor will fold the very first comment it encounters, assuming
// it is a license header. Currently unfoldAll() does not work as
@@ -104,6 +114,19 @@ public:
const QString contentsAfterUndo = testDocument.m_editorWidget->document()->toPlainText();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
+
+ ~DoxygenTestCase()
+ {
+ if (oldSettings)
+ injectSettings(oldSettings.data());
+ }
+
+ static void injectSettings(CppTools::CommentsSettings *injection)
+ {
+ auto *cts = CppTools::CppToolsSettings::instance();
+ QVERIFY(QMetaObject::invokeMethod(cts, "commentsSettingsChanged", Qt::DirectConnection,
+ Q_ARG(CppTools::CommentsSettings, *injection)));
+ }
};
} // namespace Tests
@@ -254,5 +277,30 @@ void CppEditorPlugin::test_doxygen_comments()
Tests::DoxygenTestCase(given, expected);
}
+void CppEditorPlugin::test_doxygen_comments_no_leading_asterisks_data()
+{
+ QTest::addColumn<QByteArray>("given");
+ QTest::addColumn<QByteArray>("expected");
+
+ QTest::newRow("cpp_style_no_astrix") << _(
+ "/* asdf asdf|\n"
+ ) << _(
+ "/* asdf asdf\n"
+ " \n"
+ );
+}
+
+void CppEditorPlugin::test_doxygen_comments_no_leading_asterisks()
+{
+ QFETCH(QByteArray, given);
+ QFETCH(QByteArray, expected);
+
+ CppTools::CommentsSettings injection;
+ injection.m_enableDoxygen = true;
+ injection.m_leadingAsterisks = false;
+
+ Tests::DoxygenTestCase(given, expected, &injection);
+}
+
} // namespace Internal
} // namespace CppEditor