2022-03-17 19:42:34 +01:00
|
|
|
# Copyright (C) 2022 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-05-15 13:17:33 +02:00
|
|
|
|
2012-03-21 14:48:31 +01:00
|
|
|
source("../../shared/qtcreator.py")
|
|
|
|
|
|
|
|
|
|
# test search in help mode and advanced search
|
2022-03-17 19:42:34 +01:00
|
|
|
searchKeywordDictionary = { "compass":True, "deplmint":False, "QODBC":True, "bldx":False }
|
|
|
|
|
urlDictionary = {"compass":"qthelp://org.qt-project.qtdoc.5141/qtdoc/mobiledevelopment.html",
|
|
|
|
|
"QODBC":"qthelp://org.qt-project.qtsql.5141/qtsql/sql-driver.html" }
|
2012-03-21 14:48:31 +01:00
|
|
|
|
2013-11-22 12:40:46 +01:00
|
|
|
|
2012-03-21 14:48:31 +01:00
|
|
|
def __getSelectedText__():
|
|
|
|
|
try:
|
2020-10-12 21:19:44 +02:00
|
|
|
return str(getHelpViewer().selectedText())
|
2012-03-21 14:48:31 +01:00
|
|
|
except:
|
|
|
|
|
test.warning("Could not get highlighted text.")
|
2018-04-18 19:09:20 +02:00
|
|
|
return str("")
|
2012-03-21 14:48:31 +01:00
|
|
|
|
2013-11-22 12:40:46 +01:00
|
|
|
def __getUrl__():
|
|
|
|
|
try:
|
2020-10-12 21:19:44 +02:00
|
|
|
url = getHelpViewer().url()
|
2013-11-22 12:40:46 +01:00
|
|
|
except:
|
2020-10-12 21:19:44 +02:00
|
|
|
return ""
|
2013-11-22 12:40:46 +01:00
|
|
|
return str(url.scheme) + "://" + str(url.host) + str(url.path)
|
2012-03-21 14:48:31 +01:00
|
|
|
|
|
|
|
|
def getHighlightsInHtml(htmlCode):
|
|
|
|
|
pattern = re.compile('color:#ff0000;">(.*?)</span>')
|
|
|
|
|
res = ""
|
|
|
|
|
for curr in pattern.finditer(htmlCode):
|
|
|
|
|
if curr.group(1) in res:
|
|
|
|
|
continue
|
|
|
|
|
res += "%s " % curr.group(1)
|
|
|
|
|
return res
|
|
|
|
|
|
2014-10-30 14:08:26 +01:00
|
|
|
def verifySelection(expected):
|
2018-04-18 19:09:20 +02:00
|
|
|
selText = str(__getSelectedText__())
|
2014-10-31 14:20:03 +01:00
|
|
|
if test.verify(selText, "Verify that there is a selection"):
|
2014-10-30 14:08:26 +01:00
|
|
|
# verify if search keyword is found in results
|
|
|
|
|
test.verify(expected.lower() in selText.lower(),
|
|
|
|
|
"'%s' search result can be found" % expected)
|
|
|
|
|
|
2016-06-13 12:49:57 +02:00
|
|
|
def verifyUrl(expected):
|
|
|
|
|
return test.compare(expected, __getUrl__(), "Expected URL loaded?")
|
|
|
|
|
|
2012-03-21 14:48:31 +01:00
|
|
|
def main():
|
|
|
|
|
noMatch = "Your search did not match any documents."
|
2018-08-22 14:37:34 +02:00
|
|
|
startQC()
|
2013-02-22 14:31:39 +01:00
|
|
|
if not startedWithoutPluginError():
|
|
|
|
|
return
|
2022-03-17 19:42:34 +01:00
|
|
|
docFiles = ["qtdoc.qch", "qtsql.qch"]
|
|
|
|
|
docFiles = [os.path.join(Qt5Path.docsPath(Targets.DESKTOP_5_14_1_DEFAULT), file) for file in docFiles]
|
|
|
|
|
addHelpDocumentation(docFiles)
|
2012-03-21 14:48:31 +01:00
|
|
|
# switch to help mode
|
|
|
|
|
switchViewTo(ViewConstants.HELP)
|
|
|
|
|
# verify that search widget is accessible
|
2012-09-07 14:49:16 +02:00
|
|
|
mouseClick(waitForObjectItem(":Qt Creator_Core::Internal::CommandComboBox", "Search"))
|
2018-04-19 15:54:43 +02:00
|
|
|
snooze(1) # Looks like searching is still available for an instant
|
2012-09-07 14:49:16 +02:00
|
|
|
test.verify(checkIfObjectExists("{type='QHelpSearchQueryWidget' unnamed='1' visible='1' "
|
2018-04-19 15:54:43 +02:00
|
|
|
"window=':Qt Creator_Core::Internal::MainWindow'}",
|
|
|
|
|
timeout=600000),
|
2012-03-21 14:48:31 +01:00
|
|
|
"Verifying search widget visibility.")
|
|
|
|
|
# try to search empty string
|
2012-09-07 14:49:16 +02:00
|
|
|
clickButton(waitForObject("{text='Search' type='QPushButton' unnamed='1' visible='1' "
|
2018-04-19 15:54:43 +02:00
|
|
|
"window=':Qt Creator_Core::Internal::MainWindow'}"))
|
2018-04-19 18:07:52 +02:00
|
|
|
resultWidget = waitForObject(':Hits_QResultWidget', 5000)
|
2022-02-28 15:01:06 +01:00
|
|
|
test.verify(waitFor("noMatch in "
|
|
|
|
|
"str(resultWidget.plainText)", 2000),
|
|
|
|
|
"Verifying if search did not match anything.")
|
2012-03-21 14:48:31 +01:00
|
|
|
# try to search keyword from list
|
2014-06-03 12:58:01 +02:00
|
|
|
searchLineEdit = getChildByClass(waitForObject("{type='QHelpSearchQueryWidget' unnamed='1' visible='1' "
|
|
|
|
|
"window=':Qt Creator_Core::Internal::MainWindow'}"),
|
|
|
|
|
"QLineEdit")
|
2012-03-21 14:48:31 +01:00
|
|
|
for searchKeyword,shouldFind in searchKeywordDictionary.items():
|
2014-06-03 12:58:01 +02:00
|
|
|
mouseClick(searchLineEdit)
|
|
|
|
|
replaceEditorContent(searchLineEdit, searchKeyword)
|
|
|
|
|
type(searchLineEdit, "<Return>")
|
2013-07-08 12:24:22 +02:00
|
|
|
progressBarWait(warn=False)
|
2012-03-21 14:48:31 +01:00
|
|
|
if shouldFind:
|
|
|
|
|
test.verify(waitFor("re.match('[1-9]\d* - [1-9]\d* of [1-9]\d* Hits',"
|
|
|
|
|
"str(findObject(':Hits_QLabel').text))", 2000),
|
|
|
|
|
"Verifying if search results found with 1+ hits for: " + searchKeyword)
|
2018-04-18 19:09:20 +02:00
|
|
|
selText = __getSelectedText__()
|
2013-11-22 12:40:46 +01:00
|
|
|
url = __getUrl__()
|
2012-03-21 14:48:31 +01:00
|
|
|
# click in the widget, tab to first item and press enter
|
2018-04-18 20:36:06 +02:00
|
|
|
mouseClick(resultWidget)
|
|
|
|
|
type(resultWidget, "<Tab>")
|
|
|
|
|
type(resultWidget, "<Return>")
|
2018-04-18 19:09:20 +02:00
|
|
|
waitFor("__getUrl__() != url or selText != __getSelectedText__()", 20000)
|
2014-10-30 14:08:26 +01:00
|
|
|
verifySelection(searchKeyword)
|
2019-06-11 18:14:07 +02:00
|
|
|
if not (searchKeyword == "QODBC" and JIRA.isBugStillOpen(10331)):
|
|
|
|
|
verifyUrl(urlDictionary[searchKeyword])
|
2012-03-21 14:48:31 +01:00
|
|
|
else:
|
2022-02-28 15:01:06 +01:00
|
|
|
test.verify(waitFor("noMatch in "
|
|
|
|
|
"str(resultWidget.plainText)", 1000),
|
|
|
|
|
"Verifying if search did not match anything for: " + searchKeyword)
|
2012-03-21 14:48:31 +01:00
|
|
|
# exit
|
|
|
|
|
invokeMenuItem("File", "Exit")
|