diff options
author | Robert Loehning <robert.loehning@qt.io> | 2018-04-18 20:36:06 +0200 |
---|---|---|
committer | Robert Loehning <robert.loehning@qt.io> | 2018-04-19 14:06:34 +0000 |
commit | 356a2fd8553e382f65830659582d64ac98d9c477 (patch) | |
tree | 3fa87189cc31b6a07fdd8df9056dee33439ee2ae | |
parent | 0e216fda3e05b5ca16f6c231291cbda6b7140563 (diff) |
Squish: Update tst_HELP04 for current Qt versions
Change-Id: I944f824807d47bcfaf9cabd2b15b678d858db15f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | tests/system/objects.map | 1 | ||||
-rwxr-xr-x | tests/system/suite_HELP/tst_HELP04/test.py | 112 |
2 files changed, 65 insertions, 48 deletions
diff --git a/tests/system/objects.map b/tests/system/objects.map index 7805817f51..6f04a58926 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 8985de2d27..ed90010e3b 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"), "<Tab>") - type(waitForObject(":Hits_QCLuceneResultWidget"), "<Return>") + mouseClick(resultWidget) + type(resultWidget, "<Tab>") + type(resultWidget, "<Return>") 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 <B>similar</B> to:":"deploy", - "<B>without</B> the words:":"bookmark", - "with <B>exact phrase</B>:":"sql in qt", - "with <B>all</B> of the words:":"designer sql", - "with <B>at least one</B> 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, "<Tab>") - type(resultsView, "<Return>") - 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 <B>similar</B> to:":"deploy", + "<B>without</B> the words:":"bookmark", + "with <B>exact phrase</B>:":"sql in qt", + "with <B>all</B> of the words:":"designer sql", + "with <B>at least one</B> 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, "<Tab>") - type(resultsView, "<Return>") - 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, "<Return>") + verifySelection("printing") + verifyUrl("qthelp://com.trolltech.qt.487/qdoc/overviews.html") + for i in range(2): + type(resultsView, "<Tab>") + type(resultsView, "<Return>") + 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") |