forked from qt-creator/qt-creator
SquishTests: Improve tst_memberoperator
- Update expected behavior - Update to ClangCodeModel replacing "." with "->" only after selecting a completion - Update to ClangCodeModel no longer announcing needed substitution in proposal widget - Added test for unchanged lines - Stabilize by using proper wait conditions - Fix surplus warning Change-Id: Ia90e0102d44fbd8abb41acaa83509657ad11bf4d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
committed by
Christian Stenger
parent
b36cc91acb
commit
b85183d966
@@ -16,7 +16,22 @@ def __getGenericProposalListView__(timeout):
|
|||||||
def __verifyLineUnderCursor__(cppwindow, record):
|
def __verifyLineUnderCursor__(cppwindow, record):
|
||||||
found = str(lineUnderCursor(cppwindow)).strip()
|
found = str(lineUnderCursor(cppwindow)).strip()
|
||||||
exp = testData.field(record, "expected")
|
exp = testData.field(record, "expected")
|
||||||
test.compare(found, exp)
|
test.verify(found.startswith(exp),
|
||||||
|
"Completed line '%s' should start with '%s'" % (found, exp))
|
||||||
|
|
||||||
|
|
||||||
|
def __noBuildIssues__():
|
||||||
|
return len(getBuildIssues()) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def __syntaxErrorDetected__():
|
||||||
|
buildIssues = getBuildIssues()
|
||||||
|
for issue in buildIssues:
|
||||||
|
if issue[3] in ["Expected ';' after expression (fix available)",
|
||||||
|
"Expected ';' at end of declaration (fix available)",
|
||||||
|
"Use of undeclared identifier 'syntaxError'"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -38,7 +53,13 @@ def main():
|
|||||||
placeCursorToLine(cppwindow, "return a.exec();")
|
placeCursorToLine(cppwindow, "return a.exec();")
|
||||||
typeLines(cppwindow, ("<Up>", testData.field(record, "declaration")))
|
typeLines(cppwindow, ("<Up>", testData.field(record, "declaration")))
|
||||||
type(cppwindow, testData.field(record, "usage"))
|
type(cppwindow, testData.field(record, "usage"))
|
||||||
snooze(1) # maybe find something better
|
if useClang:
|
||||||
|
if not waitFor(__syntaxErrorDetected__, 5000):
|
||||||
|
test.warning("Waiting for code model to find a syntax error timed out",
|
||||||
|
"If the code model's messages didn't change, "
|
||||||
|
"consider raising the timeout.")
|
||||||
|
else:
|
||||||
|
snooze(1)
|
||||||
type(cppwindow, testData.field(record, "operator"))
|
type(cppwindow, testData.field(record, "operator"))
|
||||||
genericProposalWidget = __getGenericProposalListView__(1500)
|
genericProposalWidget = __getGenericProposalListView__(1500)
|
||||||
# the clang code model does not change the . to -> before applying a proposal
|
# the clang code model does not change the . to -> before applying a proposal
|
||||||
@@ -49,22 +70,11 @@ def main():
|
|||||||
'Verifying whether proposal widget is displayed as expected.')
|
'Verifying whether proposal widget is displayed as expected.')
|
||||||
|
|
||||||
if genericProposalWidget is not None:
|
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")
|
correction = testData.field(record, "correction")
|
||||||
if correction == 'all':
|
if correction in ['all', 'none']:
|
||||||
|
type(genericProposalWidget, "<Return>")
|
||||||
__verifyLineUnderCursor__(cppwindow, record)
|
__verifyLineUnderCursor__(cppwindow, record)
|
||||||
test.compare(len(needCorrection), 0,
|
elif correction != 'mixed' and expectProposal:
|
||||||
"Verifying whether operator has been already corrected.")
|
|
||||||
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 "
|
test.warning("Used tsv file seems to be broken - found '%s' in "
|
||||||
"correction column." % correction)
|
"correction column." % correction)
|
||||||
elif not expectProposal:
|
elif not expectProposal:
|
||||||
@@ -73,5 +83,9 @@ def main():
|
|||||||
__verifyLineUnderCursor__(cppwindow, record)
|
__verifyLineUnderCursor__(cppwindow, record)
|
||||||
invokeMenuItem("File", 'Revert "main.cpp" to Saved')
|
invokeMenuItem("File", 'Revert "main.cpp" to Saved')
|
||||||
clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton"))
|
clickButton(waitForObject(":Revert to Saved.Proceed_QPushButton"))
|
||||||
|
if useClang and not waitFor(__noBuildIssues__, 5000):
|
||||||
|
test.warning("Waiting for code model timed out",
|
||||||
|
"If there is no new issue detected in the code, "
|
||||||
|
"consider raising the timeout.")
|
||||||
invokeMenuItem("File", "Exit")
|
invokeMenuItem("File", "Exit")
|
||||||
waitForCleanShutdown()
|
waitForCleanShutdown()
|
||||||
|
@@ -9,13 +9,13 @@
|
|||||||
"" "QCoreApplication &ref = a;" "ref" "." "ref." "True" "none"
|
"" "QCoreApplication &ref = a;" "ref" "." "ref." "True" "none"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> p;" "p" "." "p." "True" "mixed"
|
"<QPointer>" "QPointer<QCoreApplication> p;" "p" "." "p." "True" "mixed"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> *poi;" "poi" "." "poi->" "True" "all"
|
"<QPointer>" "QPointer<QCoreApplication> *poi;" "poi" "." "poi->" "True" "all"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> &poi;" "poi" "." "poi." "False" ""
|
"<QPointer>" "QPointer<QCoreApplication> &poi;" "poi" "." "poi." "True" "mixed"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> pa; QPointer<QCoreApplication> &poi = pa;" "poi" "." "poi." "True" "mixed"
|
"<QPointer>" "QPointer<QCoreApplication> pa; QPointer<QCoreApplication> &poi = pa;" "poi" "." "poi." "True" "mixed"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> poi[5];" "poi[2]" "." "poi[2]." "True" "mixed"
|
"<QPointer>" "QPointer<QCoreApplication> poi[5];" "poi[2]" "." "poi[2]." "True" "mixed"
|
||||||
"<QPointer>" "QPointer<QCoreApplication> *poi[5];" "poi[2]" "." "poi[2]->" "True" "all"
|
"<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" "mixed"
|
||||||
"<memory>" "std::auto_ptr<QCoreApplication> *sap;" "sap" "." "sap->" "True" "all"
|
"<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;" "sap" "." "sap." "True" "mixed"
|
||||||
"<memory>" "std::auto_ptr<QCoreApplication> sapqa; std::auto_ptr<QCoreApplication> &sap = sapqa;" "sap" "." "sap." "True" "mixed"
|
"<memory>" "std::auto_ptr<QCoreApplication> sapqa; std::auto_ptr<QCoreApplication> &sap = sapqa;" "sap" "." "sap." "True" "mixed"
|
||||||
"<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" "mixed"
|
||||||
"<memory>" "std::auto_ptr<QCoreApplication> *sap[10];" "sap[2]" "." "sap[2]->" "True" "all"
|
"<memory>" "std::auto_ptr<QCoreApplication> *sap[10];" "sap[2]" "." "sap[2]->" "True" "all"
|
||||||
|
|
Reference in New Issue
Block a user