aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppquickfix_test.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-07-20 17:47:59 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-07-22 07:46:11 +0000
commitaffd4ee658c66e9666ed38a5ea53cce7fb024a7c (patch)
tree7c6f6aabe9ccbeba87ca6aa1882f7273334da91d /src/plugins/cppeditor/cppquickfix_test.cpp
parent11838105063387aa106f462dcec962a0a33c016f (diff)
CppEditor: Extend Q_PROPERTY quickfix
... to also generate the RESET function. Fixes: QTCREATORBUG-11809 Change-Id: I94789227230a67f074ff5fdc76ad8113d2870dd6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp69
1 files changed, 67 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 396a207ef1..402f1d01ea 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -1552,11 +1552,11 @@ void CppEditorPlugin::test_quickfix_data()
QTest::newRow("InsertQtPropertyMembers")
<< CppQuickFixFactoryPtr(new InsertQtPropertyMembers)
<< _("struct XmarksTheSpot {\n"
- " @Q_PROPERTY(int it READ getIt WRITE setIt NOTIFY itChanged)\n"
+ " @Q_PROPERTY(int it READ getIt WRITE setIt RESET resetIt NOTIFY itChanged)\n"
"};\n"
)
<< _("struct XmarksTheSpot {\n"
- " Q_PROPERTY(int it READ getIt WRITE setIt NOTIFY itChanged)\n"
+ " Q_PROPERTY(int it READ getIt WRITE setIt RESET resetIt NOTIFY itChanged)\n"
"\n"
"public:\n"
" int getIt() const\n"
@@ -1573,6 +1573,44 @@ void CppEditorPlugin::test_quickfix_data()
" m_it = it;\n"
" emit itChanged(m_it);\n"
" }\n"
+ " void resetIt()\n"
+ " {\n"
+ " setIt({}); // TODO: Adapt to use your actual default value\n"
+ " }\n"
+ "\n"
+ "signals:\n"
+ " void itChanged(int it);\n"
+ "\n"
+ "private:\n"
+ " int m_it;\n"
+ "};\n"
+ );
+
+ QTest::newRow("InsertQtPropertyMembersResetWithoutSet")
+ << CppQuickFixFactoryPtr(new InsertQtPropertyMembers)
+ << _("struct XmarksTheSpot {\n"
+ " @Q_PROPERTY(int it READ getIt RESET resetIt NOTIFY itChanged)\n"
+ "};\n"
+ )
+ << _("struct XmarksTheSpot {\n"
+ " Q_PROPERTY(int it READ getIt RESET resetIt NOTIFY itChanged)\n"
+ "\n"
+ "public:\n"
+ " int getIt() const\n"
+ " {\n"
+ " return m_it;\n"
+ " }\n"
+ "\n"
+ "public slots:\n"
+ " void resetIt()\n"
+ " {\n"
+ " static const int defaultValue{}; // TODO: Adapt to use your actual default value\n"
+ " if (m_it == defaultValue)\n"
+ " return;\n"
+ "\n"
+ " m_it = defaultValue;\n"
+ " emit itChanged(m_it);\n"
+ " }\n"
"\n"
"signals:\n"
" void itChanged(int it);\n"
@@ -1582,6 +1620,33 @@ void CppEditorPlugin::test_quickfix_data()
"};\n"
);
+ QTest::newRow("InsertQtPropertyMembersResetWithoutSetAndNotify")
+ << CppQuickFixFactoryPtr(new InsertQtPropertyMembers)
+ << _("struct XmarksTheSpot {\n"
+ " @Q_PROPERTY(int it READ getIt RESET resetIt)\n"
+ "};\n"
+ )
+ << _("struct XmarksTheSpot {\n"
+ " Q_PROPERTY(int it READ getIt RESET resetIt)\n"
+ "\n"
+ "public:\n"
+ " int getIt() const\n"
+ " {\n"
+ " return m_it;\n"
+ " }\n"
+ "\n"
+ "public slots:\n"
+ " void resetIt()\n"
+ " {\n"
+ " static const int defaultValue{}; // TODO: Adapt to use your actual default value\n"
+ " m_it = defaultValue;\n"
+ " }\n"
+ "\n"
+ "private:\n"
+ " int m_it;\n"
+ "};\n"
+ );
+
QTest::newRow("InsertQtPropertyMembersPrivateBeforePublic")
<< CppQuickFixFactoryPtr(new InsertQtPropertyMembers)
<< _("class XmarksTheSpot {\n"