1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[Qt5] Fixed failing FormCompleter tests.

This commit is contained in:
nowrep 2013-02-18 13:37:33 +01:00
parent 4f53179752
commit f3c7f5a3ba
4 changed files with 11 additions and 22 deletions

View File

@ -214,27 +214,17 @@ PageFormCompleter::QueryItem PageFormCompleter::findUsername(const QWebElement &
return QueryItem(); return QueryItem();
} }
PageFormCompleter::QueryItems PageFormCompleter::createQueryItems(const QByteArray &data) const PageFormCompleter::QueryItems PageFormCompleter::createQueryItems(QByteArray data) const
{ {
/* Why not to use encodedQueryItems = QByteArrays ? // QUrlQuery/QUrl never encodes/decodes + and spaces
* Because we need to filter "+" characters that must be spaces data.replace('+', ' ');
* (not real "+" characters "%2B")
*
* DO NOT TOUCH! It works now with both Qt 4 & Qt 5 ...
*/
#if QT_VERSION >= 0x050000
QueryItems arguments = QUrlQuery(QUrl::fromEncoded("http://foo.com/?" + data)).queryItems();
#else
QByteArray dataCopy = data;
dataCopy.replace('+', ' ');
QueryItems arguments = QUrl::fromEncoded("http://foo.com/?" + dataCopy).queryItems();
#endif
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
for (int i = 0; i < arguments.count(); i++) { QUrlQuery query;
arguments[i].first.replace(QLatin1Char('+'), QLatin1Char(' ')); query.setQuery(data);
arguments[i].second.replace(QLatin1Char('+'), QLatin1Char(' ')); QueryItems arguments = query.queryItems(QUrl::FullyDecoded);
} #else
QueryItems arguments = QUrl::fromEncoded("http://foo.com/?" + data).queryItems();
#endif #endif
return arguments; return arguments;

View File

@ -51,7 +51,7 @@ private:
const QString &attributeValue) const; const QString &attributeValue) const;
QByteArray convertWebKitFormBoundaryIfNecessary(const QByteArray &data) const; QByteArray convertWebKitFormBoundaryIfNecessary(const QByteArray &data) const;
QueryItem findUsername(const QWebElement &form) const; QueryItem findUsername(const QWebElement &form) const;
QueryItems createQueryItems(const QByteArray &data) const; QueryItems createQueryItems(QByteArray data) const;
QWebElementCollection getAllElementsFromPage(QWebPage* page, const QString &selector) const; QWebElementCollection getAllElementsFromPage(QWebPage* page, const QString &selector) const;
QWebPage* m_page; QWebPage* m_page;

View File

@ -111,7 +111,6 @@ WebPage::WebPage(QupZilla* mainClass)
this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*, quint64))); this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*, quint64)));
#endif #endif
s_livingPages.append(this); s_livingPages.append(this);
} }

View File

@ -1,11 +1,11 @@
isEqual(QT_MAJOR_VERSION, 5) { isEqual(QT_MAJOR_VERSION, 5) {
QT += webkitwidgets network widgets printsupport sql script gui-private QT += webkitwidgets network widgets printsupport sql script gui-private testlib
} else { } else {
QT += core gui webkit sql network script QT += core gui webkit sql network script
CONFIG += qtestlib
} }
TARGET = autotests TARGET = autotests
CONFIG += qtestlib
!unix|mac: LIBS += -L$$PWD/../../bin -lQupZilla !unix|mac: LIBS += -L$$PWD/../../bin -lQupZilla
!mac:unix: LIBS += $$PWD/../../bin/libQupZilla.so !mac:unix: LIBS += $$PWD/../../bin/libQupZilla.so