Make Help mode Squish-testable again

Change-Id: I09bcdb63c44c4728cce63d5a5c2b29bf9fc96ac1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Robert Loehning
2020-10-12 21:19:44 +02:00
parent c510cf79d8
commit 89d36b418a
3 changed files with 11 additions and 19 deletions

View File

@@ -41,10 +41,11 @@ public:
explicit QLiteHtmlWidget(QWidget *parent = nullptr);
~QLiteHtmlWidget() override;
// declaring the getters Q_INVOKABLE to make them Squish-testable
void setUrl(const QUrl &url);
QUrl url() const;
Q_INVOKABLE QUrl url() const;
void setHtml(const QString &content);
QString title() const;
Q_INVOKABLE QString title() const;
void setZoomFactor(qreal scale);
qreal zoomFactor() const;
@@ -62,7 +63,8 @@ public:
using ResourceHandler = std::function<QByteArray(QUrl)>;
void setResourceHandler(const ResourceHandler &handler);
QString selectedText() const;
// declaring this Q_INVOKABLE to make it Squish-testable
Q_INVOKABLE QString selectedText() const;
signals:
void linkClicked(const QUrl &url);

View File

@@ -670,9 +670,9 @@ def getChildByClass(parent, classToSearchFor, occurrence=1):
return children[occurrence - 1]
def getHelpViewer():
return waitForObject("{type='Help::Internal::TextBrowserHelpWidget' unnamed='1' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}",
return waitForObject("{type='QLiteHtmlWidget' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}",
1000)
def getHelpTitle():
return str(getHelpViewer().documentTitle)
return str(getHelpViewer().title())

View File

@@ -32,27 +32,17 @@ urlDictionary = { "abundance":"qthelp://com.trolltech.qt.487/qdoc/gettingstarted
def __getSelectedText__():
hv = getHelpViewer()
try:
return hv.textCursor().selectedText()
except:
pass
try:
test.log("Falling back to searching for selection in HTML.")
return getHighlightsInHtml(str(hv.toHtml()))
return str(getHelpViewer().selectedText())
except:
test.warning("Could not get highlighted text.")
return str("")
def __getUrl__():
helpViewer = getHelpViewer()
try:
url = helpViewer.url
url = getHelpViewer().url()
except:
try:
url = helpViewer.source
except:
return ""
return ""
return str(url.scheme) + "://" + str(url.host) + str(url.path)
def getHighlightsInHtml(htmlCode):