Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Qt] Fix QObject bridge tests in Qt5 after (not so) recent QVariant c…
…hanges

https://bugs.webkit.org/show_bug.cgi?id=88127

Reviewed by Noam Rosenthal.

We were checking for invalid QVariants in a very odd way. Since in Qt5 the
userType of invalid changed to not be Void, this broke the tests for QtWebKit
with Qt5. Replace those checks with QVariant::isValid() calls.

* tests/qobjectbridge/tst_qobjectbridge.cpp:
(tst_QObjectBridge::evalJS):
(tst_QObjectBridge::evalJSV):

Canonical link: https://commits.webkit.org/105952@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Caio Marcelo de Oliveira Filho committed Jun 1, 2012
1 parent a41c032 commit 8037a20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 15 additions & 0 deletions Source/WebKit/qt/ChangeLog
@@ -1,3 +1,18 @@
2012-06-01 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>

[Qt] Fix QObject bridge tests in Qt5 after (not so) recent QVariant changes
https://bugs.webkit.org/show_bug.cgi?id=88127

Reviewed by Noam Rosenthal.

We were checking for invalid QVariants in a very odd way. Since in Qt5 the
userType of invalid changed to not be Void, this broke the tests for QtWebKit
with Qt5. Replace those checks with QVariant::isValid() calls.

* tests/qobjectbridge/tst_qobjectbridge.cpp:
(tst_QObjectBridge::evalJS):
(tst_QObjectBridge::evalJSV):

2012-06-01 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>

[Qt] Move QObject bridge related tests from tst_qwebframe to tst_qobjectbridge
Expand Down
6 changes: 2 additions & 4 deletions Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp
Expand Up @@ -656,9 +656,8 @@ private slots:
private:
QString evalJS(const QString& s)
{
// Convert an undefined return variant to the string "undefined"
QVariant ret = evalJSV(s);
if (ret.userType() == QMetaType::Void)
if (!ret.isValid())
return "undefined";
return ret.toString();
}
Expand All @@ -678,7 +677,6 @@ private slots:
// As a special measure, if we get an exception we set the type to 'error'
// (in ecma, an Error object has typeof object, but qtscript has a convenience function)
// Similarly, an array is an object, but we'd prefer to have a type of 'array'
// Also, consider a QMetaType::Void QVariant to be undefined
QString escaped = s;
escaped.replace('\'', "\\'"); // Don't preescape your single quotes!
QString code("var retvalue; "
Expand All @@ -695,7 +693,7 @@ private slots:
evalJS(code.arg(escaped));

QVariant ret = evalJSV("retvalue");
if (ret.userType() != QMetaType::Void)
if (ret.isValid())
type = evalJS("typevalue");
else {
ret = QString("undefined");
Expand Down

0 comments on commit 8037a20

Please sign in to comment.