diff --git a/tests/system/objects.map b/tests/system/objects.map index 7805817f513..6f04a58926f 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -88,6 +88,7 @@ :Help Widget_Help::Internal::HelpWidget {type='Help::Internal::HelpWidget' unnamed='1' visible='1' windowTitle?='Help -*'} :Hits_QCLuceneResultWidget {aboveWidget=':Hits_QLabel' type='QCLuceneResultWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Hits_QLabel {text~='\\\\d+ - \\\\d+ of \\\\d+ Hits' type='QLabel' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} +:Hits_QResultWidget {aboveWidget=':Hits_QLabel' type='QResultWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} :Kits_QtVersion_QComboBox {container=':qt_tabwidget_stackedwidget_QWidget' leftWidget=':QtVersionLabel_KitPage' type='QComboBox' unnamed='1' visible='1'} :Locals and Expressions_Debugger::Internal::WatchTreeView {container=':Debugger.Docks.LocalsAndWatchersDockWidget.Inspector_QFrame' name='WatchWindow' type='Debugger::Internal::WatchTreeView' visible='1'} :Minimal required Qt version:_QLabel {text='Minimal required Qt version:' type='QLabel' unnamed='1' visible='1' window=':New Text File_ProjectExplorer::JsonWizard'} diff --git a/tests/system/suite_HELP/tst_HELP04/test.py b/tests/system/suite_HELP/tst_HELP04/test.py index 8985de2d275..ed90010e3bb 100755 --- a/tests/system/suite_HELP/tst_HELP04/test.py +++ b/tests/system/suite_HELP/tst_HELP04/test.py @@ -27,14 +27,20 @@ source("../../shared/qtcreator.py") import re # test search in help mode and advanced search -searchKeywordDictionary={ "deployment":True, "deplmint":False, "build":True, "bld":False } -urlDictionary = { "deployment":"qthelp://com.trolltech.qt.487/qdoc/gettingstarted-develop.html", - "build":"qthelp://com.trolltech.qt.487/qdoc/sql-driver.html" } +searchKeywordDictionary={ "abundance":True, "deplmint":False, "QODBC":True, "bld":False } +urlDictionary = { "abundance":"qthelp://com.trolltech.qt.487/qdoc/gettingstarted-develop.html", + "QODBC":"qthelp://com.trolltech.qt.487/qdoc/sql-driver.html" } def __getSelectedText__(): + hv = getHelpViewer() try: - return getHighlightsInHtml(str(getHelpViewer().toHtml())) + return hv.textCursor().selectedText() + except: + pass + try: + test.log("Falling back to searching for selection in HTML.") + return getHighlightsInHtml(str(hv.toHtml())) except: test.warning("Could not get highlighted text.") return str("") @@ -85,9 +91,18 @@ def main(): # try to search empty string clickButton(waitForObject("{text='Search' type='QPushButton' unnamed='1' visible='1' " "window=':Qt Creator_Core::Internal::MainWindow'}", 600000)) - test.verify(waitFor("noMatch in " - "str(waitForObject(':Hits_QCLuceneResultWidget').plainText)", 2000), - "Verifying if search did not match anything.") + try: + # Creator built with Qt <= 5.8.0 + resultWidget = waitForObject(':Hits_QCLuceneResultWidget', 5000) + olderThan59 = False + except: + # Creator built with Qt >= 5.9.0 + resultWidget = waitForObject(':Hits_QResultWidget', 5000) + olderThan59 = True + if not olderThan59 or not JIRA.isBugStillOpen(67737, JIRA.Bug.QT): + test.verify(waitFor("noMatch in " + "str(resultWidget.plainText)", 2000), + "Verifying if search did not match anything.") # workaround for "endless waiting cursor" mouseClick(waitForObject("{column='0' container=':Qt Creator_QHelpContentWidget' " "text='Qt Reference Documentation' type='QModelIndex'}")) @@ -107,51 +122,52 @@ def main(): selText = __getSelectedText__() url = __getUrl__() # click in the widget, tab to first item and press enter - mouseClick(waitForObject(":Hits_QCLuceneResultWidget"), 1, 1, 0, Qt.LeftButton) - type(waitForObject(":Hits_QCLuceneResultWidget"), "") - type(waitForObject(":Hits_QCLuceneResultWidget"), "") + mouseClick(resultWidget) + type(resultWidget, "") + type(resultWidget, "") waitFor("__getUrl__() != url or selText != __getSelectedText__()", 20000) verifySelection(searchKeyword) verifyUrl(urlDictionary[searchKeyword]) else: - test.verify(waitFor("noMatch in " - "str(waitForObject(':Hits_QCLuceneResultWidget').plainText)", 1000), - "Verifying if search did not match anything for: " + searchKeyword) - # advanced search - setup - clickButton(waitForObject("{text='+' type='QToolButton' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}")) - label = ("{text='%s' type='QLabel' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}") - lineEdit = ("{leftWidget=%s type='QLineEdit' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}") - labelTextsToSearchStr = {"words similar to:":"deploy", - "without the words:":"bookmark", - "with exact phrase:":"sql in qt", - "with all of the words:":"designer sql", - "with at least one of the words:":"printing"} - for labelText,searchStr in labelTextsToSearchStr.items(): - type(waitForObject(lineEdit % (label % labelText)), searchStr) - # advanced search - do search - clickButton(waitForObject("{text='Search' type='QPushButton' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}")) - progressBarWait(warn=False) - # verify that advanced search results found - test.verify(waitFor("re.search('1 - 2 of 2 Hits'," - "str(findObject(':Hits_QLabel').text))", 3000), - "Verifying if 2 search results found") - resultsView = waitForObject(":Hits_QCLuceneResultWidget") - mouseClick(resultsView, 1, 1, 0, Qt.LeftButton) - type(resultsView, "") - type(resultsView, "") - verifySelection("printing") - verifyUrl("qthelp://com.trolltech.qt.487/qdoc/overviews.html") - for i in range(2): + if not olderThan59 or not JIRA.isBugStillOpen(67737, JIRA.Bug.QT): + test.verify(waitFor("noMatch in " + "str(resultWidget.plainText)", 1000), + "Verifying if search did not match anything for: " + searchKeyword) + if not olderThan59: + # advanced search - setup + clickButton(waitForObject("{text='+' type='QToolButton' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}")) + label = ("{text='%s' type='QLabel' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}") + lineEdit = ("{leftWidget=%s type='QLineEdit' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}") + labelTextsToSearchStr = {"words similar to:":"deploy", + "without the words:":"bookmark", + "with exact phrase:":"sql in qt", + "with all of the words:":"designer sql", + "with at least one of the words:":"printing"} + for labelText,searchStr in labelTextsToSearchStr.items(): + type(waitForObject(lineEdit % (label % labelText)), searchStr) + # advanced search - do search + clickButton(waitForObject("{text='Search' type='QPushButton' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow'}")) + progressBarWait(warn=False) + # verify that advanced search results found + test.verify(waitFor("re.search('1 - 2 of 2 Hits'," + "str(findObject(':Hits_QLabel').text))", 3000), + "Verifying if 2 search results found") + resultsView = waitForObject(":Hits_QCLuceneResultWidget") + mouseClick(resultsView, 1, 1, 0, Qt.LeftButton) type(resultsView, "") - type(resultsView, "") - verifySelection("sql") - verifyUrl("qthelp://com.trolltech.qt.487/qdoc/best-practices.html") - # verify if simple search is properly disabled - test.verify(not searchLineEdit.enabled, - "Verifying if simple search is not active in advanced mode.") + type(resultsView, "") + verifySelection("printing") + verifyUrl("qthelp://com.trolltech.qt.487/qdoc/overviews.html") + for i in range(2): + type(resultsView, "") + type(resultsView, "") + verifyUrl("qthelp://com.trolltech.qt.487/qdoc/best-practices.html") + # verify if simple search is properly disabled + test.verify(not searchLineEdit.enabled, + "Verifying if simple search is not active in advanced mode.") # exit invokeMenuItem("File", "Exit")