diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2011-06-06 10:25:17 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2011-06-06 10:25:17 (GMT) |
commit | 71cd7dfea1b8f0e287eb1616c0cda5493508c3c4 (patch) | |
tree | 9b0aedf6a235000164c4cb43eb3a99939611e545 /tests/auto/qscriptable/tst_qscriptable.cpp | |
parent | 278c2b360aba87db2d1e5a2d3e14de7260d8a16e (diff) | |
parent | 408a522ffa25106334c3b29a4799e0d0a1719291 (diff) | |
download | Qt-71cd7dfea1b8f0e287eb1616c0cda5493508c3c4.zip Qt-71cd7dfea1b8f0e287eb1616c0cda5493508c3c4.tar.gz Qt-71cd7dfea1b8f0e287eb1616c0cda5493508c3c4.tar.bz2 |
Merge remote branch 'qt/4.8' into fire-master
Conflicts:
src/plugins/platforms/wayland/qwaylandclipboard.cpp
src/plugins/platforms/wayland/qwaylandclipboard.h
src/plugins/platforms/wayland/qwaylanddisplay.cpp
src/s60installs/eabi/QtOpenGLu.def
Diffstat (limited to 'tests/auto/qscriptable/tst_qscriptable.cpp')
-rw-r--r-- | tests/auto/qscriptable/tst_qscriptable.cpp | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index f5d36ea..54ffbe9 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -7,29 +7,29 @@ ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** @@ -137,8 +137,8 @@ int MyScriptable::getArgumentCount() void MyScriptable::foo() { m_lastEngine = engine(); - QVERIFY(engine() != 0); - context()->throwError("MyScriptable.foo"); + if (engine()) + context()->throwError("MyScriptable.foo"); } void MyScriptable::evalIsBar() @@ -164,15 +164,15 @@ void MyScriptable::setOtherEngine() void MyScriptable::setX(int x) { m_lastEngine = engine(); - Q_ASSERT(engine()); - thisObject().setProperty("x", QScriptValue(engine(), x)); + if (engine()) + thisObject().setProperty("x", QScriptValue(engine(), x)); } void MyScriptable::setX(const QString &x) { m_lastEngine = engine(); - Q_ASSERT(engine()); - thisObject().setProperty("x", QScriptValue(engine(), x)); + if (engine()) + thisObject().setProperty("x", QScriptValue(engine(), x)); } void MyScriptable::setX2(int) @@ -291,6 +291,7 @@ void tst_QScriptable::thisObject() "o.setX(123);" "o.__proto__ = Object.prototype;" "o.x"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 123)), true); } { @@ -298,46 +299,55 @@ void tst_QScriptable::thisObject() "o.setX2(456);" "o.__proto__ = Object.prototype;" "o.x"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 456)), true); } m_engine.evaluate("o.__proto__ = scriptable"); { QScriptValue ret = m_engine.evaluate("o.isBar()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, false)), true); } { QScriptValue ret = m_engine.evaluate("o.toString = function() { return 'foo@bar'; }; o.isBar()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, true)), true); } // property getter { QScriptValue ret = m_engine.evaluate("scriptable.zab"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QScriptValue ret = m_engine.evaluate("scriptable[1]"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QScriptValue ret = m_engine.evaluate("o.zab"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.toQObject(), (QObject *)0); } // property setter { QScriptValue ret = m_engine.evaluate("scriptable.setZab(null)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QVERIFY(!m_scriptable.oofThisObject().isValid()); m_engine.evaluate("o.oof = 123"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o"))); } { m_engine.evaluate("scriptable.oof = 123"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("scriptable"))); } @@ -345,13 +355,17 @@ void tst_QScriptable::thisObject() { { QScriptValue ret = m_engine.evaluate("scriptable.sig.connect(o, scriptable.setX)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(ret.isUndefined()); } QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 456))); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); m_scriptable.emitSig(654321); QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 654321))); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); { QScriptValue ret = m_engine.evaluate("scriptable.sig.disconnect(o, scriptable.setX)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(ret.isUndefined()); } } @@ -383,6 +397,7 @@ void tst_QScriptable::arguments() void tst_QScriptable::throwError() { QScriptValue ret = m_engine.evaluate("scriptable.foo()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isError(), true); QCOMPARE(ret.toString(), QString("Error: MyScriptable.foo")); } |