summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-10-11 09:27:49 +0200
committerChristian Stenger <christian.stenger@qt.io>2018-11-08 13:19:38 +0000
commitce9b813c377b9f248f994843adfc240f4aacd370 (patch)
tree66acf49eceef7a60505165480d354fb0a59e0271 /tests
parent136e0f69e43fa376df1f4a06845e948eaa19739f (diff)
downloadqt-creator-ce9b813c377b9f248f994843adfc240f4aacd370.tar.gz
Squish: Adapt tst_memberoperator to CCM changes
When using the clang code model the operator '.' does no more automatically change to '->' before applying a proposal. Instead it points out whether a proposal requires to change the operator when applying. So, adapt the test and losen some condition to be able to keep this test generic and maintainable. Change-Id: I215fba9bfa98d5d056cd9493d7aa7192fb7a963f Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/system/suite_editors/tst_memberoperator/test.py51
-rw-r--r--tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv60
2 files changed, 77 insertions, 34 deletions
diff --git a/tests/system/suite_editors/tst_memberoperator/test.py b/tests/system/suite_editors/tst_memberoperator/test.py
index d7b20f8b3d..910e4b35c5 100644
--- a/tests/system/suite_editors/tst_memberoperator/test.py
+++ b/tests/system/suite_editors/tst_memberoperator/test.py
@@ -25,12 +25,29 @@
source("../../shared/qtcreator.py")
+WhatsThisRole = 5 # Qt::WhatsThisRole
+
+def __getGenericProposalListView__(timeout):
+ try:
+ waitForObject(':popupFrame_TextEditor::GenericProposalWidget', timeout)
+ return findObject(':popupFrame_Proposal_QListView')
+ except LookupError:
+ return None
+
+
+def __verifyLineUnderCursor__(cppwindow, record):
+ found = str(lineUnderCursor(cppwindow)).strip()
+ exp = testData.field(record, "expected")
+ test.compare(found, exp)
+
+
def main():
for useClang in [False, True]:
with TestSection(getCodeModelString(useClang)):
if not startCreatorVerifyingClang(useClang):
continue
createProject_Qt_Console(tempDir(), "SquishProject")
+ selectBuildConfig(Targets.DESKTOP_5_6_1_DEFAULT, "Debug") # do not use the default Qt4
checkCodeModelSettings(useClang)
selectFromLocator("main.cpp")
cppwindow = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
@@ -45,10 +62,36 @@ def main():
type(cppwindow, testData.field(record, "usage"))
snooze(1) # maybe find something better
type(cppwindow, testData.field(record, "operator"))
- waitFor("object.exists(':popupFrame_TextEditor::GenericProposalWidget')", 1500)
- found = str(lineUnderCursor(cppwindow)).strip()
- exp = testData.field(record, "expected")
- test.compare(found, exp)
+ genericProposalWidget = __getGenericProposalListView__(1500)
+ # the clang code model does not change the . to -> before applying a proposal
+ # so, verify list of proposals roughly
+ if useClang:
+ expectProposal = testData.field(record, "clangProposal") == 'True'
+ test.compare(genericProposalWidget is not None, expectProposal,
+ 'Verifying whether proposal widget is displayed as expected.')
+
+ if genericProposalWidget is not None:
+ model = genericProposalWidget.model()
+ proposalToolTips = dumpItems(model, role=WhatsThisRole)
+ needCorrection = filter(lambda x: 'Requires changing "." to "->"' in x,
+ proposalToolTips)
+ correction = testData.field(record, "correction")
+ if correction == 'all':
+ test.compare(len(needCorrection), len(proposalToolTips),
+ "Verifying whether all proposal need correction.")
+ elif correction == 'mixed':
+ test.verify(len(proposalToolTips) > len(needCorrection) > 0,
+ "Verifying whether some of the proposals need correction.")
+ elif correction == 'none':
+ test.verify(len(needCorrection) == 0,
+ "Verifying whether no proposal needs a correction.")
+ else:
+ test.warning("Used tsv file seems to be broken - found '%s' in "
+ "correction column." % correction)
+ elif not expectProposal:
+ __verifyLineUnderCursor__(cppwindow, record)
+ else:
+ __verifyLineUnderCursor__(cppwindow, record)
invokeMenuItem("File", 'Revert "main.cpp" to Saved')
clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton"))
snooze(1)
diff --git a/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv b/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv
index 9d44b0431f..d9b3947394 100644
--- a/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv
+++ b/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv
@@ -1,30 +1,30 @@
-"include" "declaration" "usage" "operator" "expected"
-"" "" "syntaxError" "." "syntaxError."
-"" "" "argc" "." "argc."
-"" "" "argv[0]" "." "argv[0]."
-"" "" "2" "." "2."
-"" "" "float fl = 2" "." "float fl = 2."
-"" "QCoreApplication qa;" "qa" "." "qa."
-"" "QCoreApplication *p;" "p" "." "p->"
-"" "QCoreApplication &ref = a;" "ref" "." "ref."
-"<QPointer>" "QPointer<QCoreApplication> p;" "p" "." "p."
-"<QPointer>" "QPointer<QCoreApplication> *poi;" "poi" "." "poi->"
-"<QPointer>" "QPointer<QCoreApplication> &poi;" "poi" "." "poi."
-"<QPointer>" "QPointer<QCoreApplication> poi[5];" "poi[2]" "." "poi[2]."
-"<QPointer>" "QPointer<QCoreApplication> *poi[5];" "poi[2]" "." "poi[2]->"
-"<memory>" "std::auto_ptr<QCoreApplication> sap;" "sap" "." "sap."
-"<memory>" "std::auto_ptr<QCoreApplication> *sap;" "sap" "." "sap->"
-"<memory>" "std::auto_ptr<QCoreApplication> &sap;" "sap" "." "sap."
-"<memory>" "std::auto_ptr<QCoreApplication> sap[10];" "sap[2]" "." "sap[2]."
-"<memory>" "std::auto_ptr<QCoreApplication> *sap[10];" "sap[2]" "." "sap[2]->"
-"<QVector>" "QVector<QCoreApplication> vec;" "vec" "." "vec."
-"<QVector>" "QVector<QCoreApplication *> vec;" "vec" "." "vec."
-"<QVector>" "QVector<QCoreApplication> *vec;" "vec" "." "vec->"
-"<QVector>" "QVector<QCoreApplication *> *vec;" "vec" "." "vec->"
-"<QVector>" "QVector<QCoreApplication> vec;" "vec[0]" "." "vec[0]."
-"<QVector>" "QVector<QCoreApplication *> vec;" "vec[0]" "." "vec[0]->"
-"" "struct Foo { int foo; }; Foo *baz;" "baz" "." "baz->"
-"<QString>" "auto s = QString();" "s" "." "s."
-"<QString>" "auto *s = QString();" "s" "." "s."
-"<QString>" "auto s = new QString();" "s" "." "s->"
-"<QString>" "auto *s = new QString();" "s" "." "s->"
+"include" "declaration" "usage" "operator" "expected" "clangProposal" "correction"
+"" "" "syntaxError" "." "syntaxError." "False" ""
+"" "" "argc" "." "argc." "False" ""
+"" "" "argv[0]" "." "argv[0]." "False" ""
+"" "" "2" "." "2." "False" ""
+"" "" "float fl = 2" "." "float fl = 2." "False" ""
+"" "QCoreApplication qa;" "qa" "." "qa." "False" ""
+"" "QCoreApplication *p;" "p" "." "p->" "True" "all"
+"" "QCoreApplication &ref = a;" "ref" "." "ref." "True" "none"
+"<QPointer>" "QPointer<QCoreApplication> p;" "p" "." "p." "True" "mixed"
+"<QPointer>" "QPointer<QCoreApplication> *poi;" "poi" "." "poi->" "True" "all"
+"<QPointer>" "QPointer<QCoreApplication> &poi;" "poi" "." "poi." "False" ""
+"<QPointer>" "QPointer<QCoreApplication> poi[5];" "poi[2]" "." "poi[2]." "True" "mixed"
+"<QPointer>" "QPointer<QCoreApplication> *poi[5];" "poi[2]" "." "poi[2]->" "True" "all"
+"<memory>" "std::auto_ptr<QCoreApplication> sap;" "sap" "." "sap." "True" "mixed"
+"<memory>" "std::auto_ptr<QCoreApplication> *sap;" "sap" "." "sap->" "True" "all"
+"<memory>" "std::auto_ptr<QCoreApplication> &sap;" "sap" "." "sap." "False" ""
+"<memory>" "std::auto_ptr<QCoreApplication> sap[10];" "sap[2]" "." "sap[2]." "True" "mixed"
+"<memory>" "std::auto_ptr<QCoreApplication> *sap[10];" "sap[2]" "." "sap[2]->" "True" "all"
+"<QVector>" "QVector<QCoreApplication> vec;" "vec" "." "vec." "True" "none"
+"<QVector>" "QVector<QCoreApplication *> vec;" "vec" "." "vec." "True" "none"
+"<QVector>" "QVector<QCoreApplication> *vec;" "vec" "." "vec->" "True" "all"
+"<QVector>" "QVector<QCoreApplication *> *vec;" "vec" "." "vec->" "True" "all"
+"<QVector>" "QVector<QCoreApplication> vec;" "vec[0]" "." "vec[0]." "True" "none"
+"<QVector>" "QVector<QCoreApplication *> vec;" "vec[0]" "." "vec[0]->" "True" "all"
+"" "struct Foo { int foo; }; Foo *baz;" "baz" "." "baz->" "True" "all"
+"<QString>" "auto s = QString();" "s" "." "s." "True" "none"
+"<QString>" "auto *s = QString();" "s" "." "s." "False" ""
+"<QString>" "auto s = new QString();" "s" "." "s->" "True" "all"
+"<QString>" "auto *s = new QString();" "s" "." "s->" "True" "all"