forked from qt-creator/qt-creator
Squish: Handle empty selection in QWebEngineView
Change-Id: I7e4d53483f3168e78024dcf87125b44f96453fa2 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -28,14 +28,17 @@ import re
|
|||||||
|
|
||||||
# test search in help mode and advanced search
|
# test search in help mode and advanced search
|
||||||
searchKeywordDictionary={ "deployment":True, "deplmint":False, "build":True, "bld":False }
|
searchKeywordDictionary={ "deployment":True, "deplmint":False, "build":True, "bld":False }
|
||||||
|
urlDictionary = { "deployment":"qthelp://com.trolltech.qt.481/qdoc/gettingstarted-develop.html",
|
||||||
|
"build":"qthelp://com.trolltech.qt.481/qdoc/sql-driver.html" }
|
||||||
|
|
||||||
|
|
||||||
def __getSelectedText__():
|
def __getSelectedText__():
|
||||||
hv = getHelpViewer()
|
hv = getHelpViewer()
|
||||||
|
isWebEngineView = className(hv) == "QWebEngineView"
|
||||||
try:
|
try:
|
||||||
selText = hv.selectedText
|
selText = hv.selectedText
|
||||||
if className(selText) != 'instancemethod':
|
if className(selText) != 'instancemethod':
|
||||||
return str(selText)
|
return str(selText), isWebEngineView
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
@@ -43,7 +46,7 @@ def __getSelectedText__():
|
|||||||
except:
|
except:
|
||||||
test.warning("Could not get highlighted text.")
|
test.warning("Could not get highlighted text.")
|
||||||
selText = ''
|
selText = ''
|
||||||
return str(selText)
|
return str(selText), isWebEngineView
|
||||||
|
|
||||||
def __getUrl__():
|
def __getUrl__():
|
||||||
helpViewer = getHelpViewer()
|
helpViewer = getHelpViewer()
|
||||||
@@ -66,12 +69,20 @@ def getHighlightsInHtml(htmlCode):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def verifySelection(expected):
|
def verifySelection(expected):
|
||||||
selText = str(__getSelectedText__())
|
selText, isWebEngineView = __getSelectedText__()
|
||||||
|
if isWebEngineView:
|
||||||
|
test.log("The search results are not a selection in a QWebEngineView",
|
||||||
|
"Searched strings should still be highlighted")
|
||||||
|
return
|
||||||
|
selText = str(selText)
|
||||||
if test.verify(selText, "Verify that there is a selection"):
|
if test.verify(selText, "Verify that there is a selection"):
|
||||||
# verify if search keyword is found in results
|
# verify if search keyword is found in results
|
||||||
test.verify(expected.lower() in selText.lower(),
|
test.verify(expected.lower() in selText.lower(),
|
||||||
"'%s' search result can be found" % expected)
|
"'%s' search result can be found" % expected)
|
||||||
|
|
||||||
|
def verifyUrl(expected):
|
||||||
|
return test.compare(expected, __getUrl__(), "Expected URL loaded?")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global sdkPath
|
global sdkPath
|
||||||
noMatch = "Your search did not match any documents."
|
noMatch = "Your search did not match any documents."
|
||||||
@@ -109,14 +120,15 @@ def main():
|
|||||||
test.verify(waitFor("re.match('[1-9]\d* - [1-9]\d* of [1-9]\d* Hits',"
|
test.verify(waitFor("re.match('[1-9]\d* - [1-9]\d* of [1-9]\d* Hits',"
|
||||||
"str(findObject(':Hits_QLabel').text))", 2000),
|
"str(findObject(':Hits_QLabel').text))", 2000),
|
||||||
"Verifying if search results found with 1+ hits for: " + searchKeyword)
|
"Verifying if search results found with 1+ hits for: " + searchKeyword)
|
||||||
selText = __getSelectedText__()
|
selText = __getSelectedText__()[0]
|
||||||
url = __getUrl__()
|
url = __getUrl__()
|
||||||
# click in the widget, tab to first item and press enter
|
# click in the widget, tab to first item and press enter
|
||||||
mouseClick(waitForObject(":Hits_QCLuceneResultWidget"), 1, 1, 0, Qt.LeftButton)
|
mouseClick(waitForObject(":Hits_QCLuceneResultWidget"), 1, 1, 0, Qt.LeftButton)
|
||||||
type(waitForObject(":Hits_QCLuceneResultWidget"), "<Tab>")
|
type(waitForObject(":Hits_QCLuceneResultWidget"), "<Tab>")
|
||||||
type(waitForObject(":Hits_QCLuceneResultWidget"), "<Return>")
|
type(waitForObject(":Hits_QCLuceneResultWidget"), "<Return>")
|
||||||
waitFor("__getUrl__() != url or selText != __getSelectedText__()", 20000)
|
waitFor("__getUrl__() != url or selText != __getSelectedText__()[0]", 20000)
|
||||||
verifySelection(searchKeyword)
|
verifySelection(searchKeyword)
|
||||||
|
verifyUrl(urlDictionary[searchKeyword])
|
||||||
else:
|
else:
|
||||||
test.verify(waitFor("noMatch in "
|
test.verify(waitFor("noMatch in "
|
||||||
"str(waitForObject(':Hits_QCLuceneResultWidget').plainText)", 1000),
|
"str(waitForObject(':Hits_QCLuceneResultWidget').plainText)", 1000),
|
||||||
@@ -148,10 +160,12 @@ def main():
|
|||||||
type(resultsView, "<Tab>")
|
type(resultsView, "<Tab>")
|
||||||
type(resultsView, "<Return>")
|
type(resultsView, "<Return>")
|
||||||
verifySelection("printing")
|
verifySelection("printing")
|
||||||
|
verifyUrl("qthelp://com.trolltech.qt.481/qdoc/overviews.html")
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
type(resultsView, "<Tab>")
|
type(resultsView, "<Tab>")
|
||||||
type(resultsView, "<Return>")
|
type(resultsView, "<Return>")
|
||||||
verifySelection("sql")
|
verifySelection("sql")
|
||||||
|
verifyUrl("qthelp://com.trolltech.qt.481/qdoc/best-practices.html")
|
||||||
# verify if simple search is properly disabled
|
# verify if simple search is properly disabled
|
||||||
test.verify(not searchLineEdit.enabled,
|
test.verify(not searchLineEdit.enabled,
|
||||||
"Verifying if simple search is not active in advanced mode.")
|
"Verifying if simple search is not active in advanced mode.")
|
||||||
|
Reference in New Issue
Block a user