From b85183d966027bb724c36f3ded54e07058d55019 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 3 Nov 2022 15:46:41 +0100 Subject: [PATCH] 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: Reviewed-by: Christian Stenger --- .../suite_editors/tst_memberoperator/test.py | 46 ++++++++++++------- .../tst_memberoperator/testdata/usages.tsv | 4 +- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/tests/system/suite_editors/tst_memberoperator/test.py b/tests/system/suite_editors/tst_memberoperator/test.py index 14419e1fa46..18d5547f324 100644 --- a/tests/system/suite_editors/tst_memberoperator/test.py +++ b/tests/system/suite_editors/tst_memberoperator/test.py @@ -16,7 +16,22 @@ def __getGenericProposalListView__(timeout): def __verifyLineUnderCursor__(cppwindow, record): found = str(lineUnderCursor(cppwindow)).strip() 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(): @@ -38,7 +53,13 @@ def main(): placeCursorToLine(cppwindow, "return a.exec();") typeLines(cppwindow, ("", testData.field(record, "declaration"))) 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")) genericProposalWidget = __getGenericProposalListView__(1500) # 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.') 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': + if correction in ['all', 'none']: + type(genericProposalWidget, "") __verifyLineUnderCursor__(cppwindow, record) - test.compare(len(needCorrection), 0, - "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: + elif correction != 'mixed' and expectProposal: test.warning("Used tsv file seems to be broken - found '%s' in " "correction column." % correction) elif not expectProposal: @@ -73,5 +83,9 @@ def main(): __verifyLineUnderCursor__(cppwindow, record) invokeMenuItem("File", 'Revert "main.cpp" to Saved') 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") waitForCleanShutdown() diff --git a/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv b/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv index 89831a431bb..482903ad1bb 100644 --- a/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv +++ b/tests/system/suite_editors/tst_memberoperator/testdata/usages.tsv @@ -9,13 +9,13 @@ "" "QCoreApplication &ref = a;" "ref" "." "ref." "True" "none" "" "QPointer p;" "p" "." "p." "True" "mixed" "" "QPointer *poi;" "poi" "." "poi->" "True" "all" -"" "QPointer &poi;" "poi" "." "poi." "False" "" +"" "QPointer &poi;" "poi" "." "poi." "True" "mixed" "" "QPointer pa; QPointer &poi = pa;" "poi" "." "poi." "True" "mixed" "" "QPointer poi[5];" "poi[2]" "." "poi[2]." "True" "mixed" "" "QPointer *poi[5];" "poi[2]" "." "poi[2]->" "True" "all" "" "std::auto_ptr sap;" "sap" "." "sap." "True" "mixed" "" "std::auto_ptr *sap;" "sap" "." "sap->" "True" "all" -"" "std::auto_ptr &sap;" "sap" "." "sap." "False" "" +"" "std::auto_ptr &sap;" "sap" "." "sap." "True" "mixed" "" "std::auto_ptr sapqa; std::auto_ptr &sap = sapqa;" "sap" "." "sap." "True" "mixed" "" "std::auto_ptr sap[10];" "sap[2]" "." "sap[2]." "True" "mixed" "" "std::auto_ptr *sap[10];" "sap[2]" "." "sap[2]->" "True" "all"