summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qobject/tst_qobject.cpp78
-rw-r--r--tests/auto/qscriptable/tst_qscriptable.cpp4
-rw-r--r--tests/auto/qscriptclass/tst_qscriptclass.cpp40
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp38
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp148
-rw-r--r--tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro3
-rw-r--r--tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.cpp79
-rw-r--r--tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.pro10
-rw-r--r--tests/auto/qscriptextensionplugin/staticplugin/__init__.js6
-rw-r--r--tests/auto/qscriptextensionplugin/staticplugin/staticplugin.cpp75
-rw-r--r--tests/auto/qscriptextensionplugin/staticplugin/staticplugin.pro7
-rw-r--r--tests/auto/qscriptextensionplugin/staticplugin/staticplugin.qrc6
-rw-r--r--tests/auto/qscriptextensionplugin/test/test.pro18
-rw-r--r--tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp167
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp100
-rw-r--r--tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp21
-rw-r--r--tests/auto/qthread/tst_qthread.cpp14
-rw-r--r--tests/auto/script.pro1
-rw-r--r--tests/benchmarks/benchmarks.pro3
-rw-r--r--tests/benchmarks/corelib/corelib.pro10
-rw-r--r--tests/benchmarks/declarative/declarative.pro2
-rw-r--r--tests/benchmarks/gui/gui.pro7
-rw-r--r--tests/benchmarks/network/network.pro7
-rw-r--r--tests/benchmarks/opengl/opengl.pro2
-rw-r--r--tests/benchmarks/script/script.pro7
-rw-r--r--tests/benchmarks/svg/svg.pro2
-rw-r--r--tests/benchmarks/trusted-benchmarks.pri8
27 files changed, 849 insertions, 14 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 24cd5a3..a09f109 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -134,6 +134,7 @@ private slots:
void connectConstructorByMetaMethod();
void disconnectByMetaMethod();
void disconnectNotSignalMetaMethod();
+ void autoConnectionBehavior();
protected:
};
@@ -3847,5 +3848,82 @@ void tst_QObject::disconnectNotSignalMetaMethod()
QVERIFY(!QObject::disconnect(&s, slot, &r, QMetaMethod()));
}
+class ThreadAffinityThread : public QThread
+{
+public:
+ SenderObject *sender;
+
+ ThreadAffinityThread(SenderObject *sender)
+ : sender(sender)
+ { }
+ void run()
+ {
+ sender->emitSignal1();
+ }
+};
+
+void tst_QObject::autoConnectionBehavior()
+{
+ SenderObject *sender = new SenderObject;
+ ReceiverObject *receiver = new ReceiverObject;
+ connect(sender, SIGNAL(signal1()), receiver, SLOT(slot1()));
+
+ // at emit, currentThread == sender->thread(), currentThread == receiver->thread(), sender->thread() == receiver->thread()
+ QVERIFY(!receiver->called(1));
+ sender->emitSignal1();
+ QVERIFY(receiver->called(1));
+ receiver->reset();
+
+ // at emit, currentThread != sender->thread(), currentThread != receiver->thread(), sender->thread() == receiver->thread()
+ ThreadAffinityThread emitThread1(sender);
+ QVERIFY(!receiver->called(1));
+ emitThread1.start();
+ QVERIFY(emitThread1.wait(30000));
+ QVERIFY(!receiver->called(1));
+ QCoreApplication::sendPostedEvents(receiver, QEvent::MetaCall);
+ QVERIFY(receiver->called(1));
+ receiver->reset();
+
+ // at emit, currentThread == sender->thread(), currentThread != receiver->thread(), sender->thread() != receiver->thread()
+ sender->moveToThread(&emitThread1);
+ QVERIFY(!receiver->called(1));
+ emitThread1.start();
+ QVERIFY(emitThread1.wait(30000));
+ QVERIFY(!receiver->called(1));
+ QCoreApplication::sendPostedEvents(receiver, QEvent::MetaCall);
+ QVERIFY(receiver->called(1));
+ receiver->reset();
+
+ // at emit, currentThread != sender->thread(), currentThread == receiver->thread(), sender->thread() != receiver->thread()
+ QVERIFY(!receiver->called(1));
+ sender->emitSignal1();
+ QVERIFY(receiver->called(1));
+ receiver->reset();
+
+ // at emit, currentThread != sender->thread(), currentThread != receiver->thread(), sender->thread() != receiver->thread()
+ ThreadAffinityThread emitThread2(sender);
+ QThread receiverThread;
+ QTimer *timer = new QTimer;
+ timer->setSingleShot(true);
+ timer->setInterval(100);
+ connect(&receiverThread, SIGNAL(started()), timer, SLOT(start()));
+ connect(timer, SIGNAL(timeout()), &receiverThread, SLOT(quit()), Qt::DirectConnection);
+ connect(&receiverThread, SIGNAL(finished()), timer, SLOT(deleteLater()));
+ timer->moveToThread(&receiverThread);
+
+ receiver->moveToThread(&receiverThread);
+ QVERIFY(!receiver->called(1));
+ emitThread2.start();
+ QVERIFY(emitThread2.wait(30000));
+ QVERIFY(!receiver->called(1));
+ receiverThread.start();
+ QVERIFY(receiverThread.wait(30000));
+ QVERIFY(receiver->called(1));
+ receiver->reset();
+
+ delete sender;
+ delete receiver;
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp
index 3c781b1..86dd80e 100644
--- a/tests/auto/qscriptable/tst_qscriptable.cpp
+++ b/tests/auto/qscriptable/tst_qscriptable.cpp
@@ -131,7 +131,7 @@ QScriptValue MyScriptable::getArguments()
int MyScriptable::getArgumentCount()
{
- return context()->argumentCount();
+ return argumentCount();
}
void MyScriptable::foo()
@@ -283,6 +283,8 @@ void tst_QScriptable::engine()
void tst_QScriptable::thisObject()
{
+ QVERIFY(!m_scriptable.thisObject().isValid());
+
m_engine.evaluate("o = { }");
{
QScriptValue ret = m_engine.evaluate("o.__proto__ = scriptable;"
diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp
index b4dbe73..2c669f3 100644
--- a/tests/auto/qscriptclass/tst_qscriptclass.cpp
+++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp
@@ -68,6 +68,7 @@ private slots:
void getAndSetProperty();
void enumerate();
void extension();
+ void defaultImplementations();
};
tst_QScriptClass::tst_QScriptClass()
@@ -603,6 +604,8 @@ void tst_QScriptClass::newInstance()
QVERIFY(obj2.data().strictlyEquals(num));
QVERIFY(obj2.prototype().strictlyEquals(cls.prototype()));
QCOMPARE(obj2.scriptClass(), (QScriptClass*)&cls);
+ QVERIFY(!obj2.equals(obj1));
+ QVERIFY(!obj2.strictlyEquals(obj1));
QScriptValue obj3 = eng.newObject();
QCOMPARE(obj3.scriptClass(), (QScriptClass*)0);
@@ -730,6 +733,14 @@ void tst_QScriptClass::getAndSetProperty()
QCOMPARE(cls.lastPropertyId(), foo2Id);
}
+ // attempt to delete custom property
+ obj1.setProperty(foo2, QScriptValue());
+ // delete real property
+ obj1.setProperty(foo, QScriptValue());
+ QVERIFY(!obj1.property(foo).isValid());
+ obj1.setProperty(foo, num);
+ QVERIFY(obj1.property(foo).equals(num));
+
// remove script class; normal properties should remain
obj1.setScriptClass(0);
QCOMPARE(obj1.scriptClass(), (QScriptClass*)0);
@@ -805,6 +816,7 @@ void tst_QScriptClass::extension()
QCOMPARE((int)cls.lastExtensionType(), -1);
QVERIFY(!obj.instanceOf(obj));
QCOMPARE((int)cls.lastExtensionType(), -1);
+ QVERIFY(!obj.construct().isValid());
}
// Callable
{
@@ -1017,5 +1029,33 @@ void tst_QScriptClass::extension()
}
}
+void tst_QScriptClass::defaultImplementations()
+{
+ QScriptEngine eng;
+
+ QScriptClass defaultClass(&eng);
+ QCOMPARE(defaultClass.engine(), &eng);
+ QVERIFY(!defaultClass.prototype().isValid());
+ QCOMPARE(defaultClass.name(), QString());
+
+ QScriptValue obj = eng.newObject(&defaultClass);
+ QCOMPARE(obj.scriptClass(), &defaultClass);
+
+ QScriptString name = eng.toStringHandle("foo");
+ uint id = -1;
+ QCOMPARE(defaultClass.queryProperty(obj, name, QScriptClass::HandlesReadAccess, &id), QScriptClass::QueryFlags(0));
+ QVERIFY(!defaultClass.property(obj, name, id).isValid());
+ QCOMPARE(defaultClass.propertyFlags(obj, name, id), QScriptValue::PropertyFlags(0));
+ defaultClass.setProperty(obj, name, id, 123);
+ QVERIFY(!obj.property(name).isValid());
+
+ QCOMPARE(defaultClass.newIterator(obj), (QScriptClassPropertyIterator*)0);
+
+ QVERIFY(!defaultClass.supportsExtension(QScriptClass::Callable));
+ QVERIFY(!defaultClass.supportsExtension(QScriptClass::HasInstance));
+ QVERIFY(!defaultClass.extension(QScriptClass::Callable).isValid());
+ QVERIFY(!defaultClass.extension(QScriptClass::HasInstance).isValid());
+}
+
QTEST_MAIN(tst_QScriptClass)
#include "tst_qscriptclass.moc"
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 617c183..99558eb 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -44,6 +44,7 @@
#include <QtScript/qscriptcontext.h>
#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptvalueiterator.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -77,6 +78,7 @@ private slots:
void scopeChain();
void pushAndPopScope();
void getSetActivationObject();
+ void getSetActivationObject_customContext();
void inheritActivationAndThisObject();
void toString();
void calledAsConstructor();
@@ -513,8 +515,30 @@ void tst_QScriptContext::pushAndPopContext()
QScriptContext *ctx3 = eng.pushContext();
ctx3->activationObject().setProperty("foo", QScriptValue(&eng, 123));
QVERIFY(eng.evaluate("foo").strictlyEquals(QScriptValue(&eng, 123)));
+ QCOMPARE(ctx3->activationObject().propertyFlags("foo"), QScriptValue::PropertyFlags(0));
+
+ ctx3->activationObject().setProperty(4, 456);
+ QVERIFY(ctx3->activationObject().property(4, QScriptValue::ResolveLocal).equals(456));
+
eng.evaluate("var bar = 'ciao'");
QVERIFY(ctx3->activationObject().property("bar", QScriptValue::ResolveLocal).strictlyEquals(QScriptValue(&eng, "ciao")));
+
+ ctx3->activationObject().setProperty("baz", 789, QScriptValue::ReadOnly);
+ QVERIFY(eng.evaluate("baz").equals(789));
+ QCOMPARE(ctx3->activationObject().propertyFlags("baz"), QScriptValue::ReadOnly);
+
+ QSet<QString> activationPropertyNames;
+ QScriptValueIterator it(ctx3->activationObject());
+ while (it.hasNext()) {
+ it.next();
+ activationPropertyNames.insert(it.name());
+ }
+ QCOMPARE(activationPropertyNames.size(), 4);
+ QVERIFY(activationPropertyNames.contains("foo"));
+ QVERIFY(activationPropertyNames.contains("4"));
+ QVERIFY(activationPropertyNames.contains("bar"));
+ QVERIFY(activationPropertyNames.contains("baz"));
+
eng.popContext();
}
@@ -1054,6 +1078,20 @@ void tst_QScriptContext::getSetActivationObject()
}
}
+void tst_QScriptContext::getSetActivationObject_customContext()
+{
+ QScriptEngine eng;
+ QScriptContext *ctx = eng.pushContext();
+ QVERIFY(ctx->activationObject().isObject());
+ QScriptValue act = eng.newObject();
+ ctx->setActivationObject(act);
+ QVERIFY(ctx->activationObject().equals(act));
+ eng.evaluate("var foo = 123");
+ QCOMPARE(act.property("foo").toInt32(), 123);
+ eng.popContext();
+ QCOMPARE(act.property("foo").toInt32(), 123);
+}
+
static QScriptValue myEval(QScriptContext *ctx, QScriptEngine *eng)
{
QString code = ctx->argument(0).toString();
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 7133a6c..034512f 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -120,6 +120,7 @@ private slots:
void uncaughtException();
void errorMessage_QT679();
void valueConversion();
+ void qScriptValueFromValue_noEngine();
void importExtension();
void infiniteRecursion();
void castWithPrototypeChain();
@@ -129,6 +130,7 @@ private slots:
void gcWithNestedDataStructure();
void processEventsWhileRunning();
void throwErrorFromProcessEvents();
+ void disableProcessEventsInterval();
void stacktrace();
void numberParsing_data();
void numberParsing();
@@ -169,6 +171,7 @@ private slots:
void evaluateProgram();
void collectGarbageAfterConnect();
void promoteThisObjectToQObjectInConstructor();
+ void scriptValueFromQMetaObject();
void qRegExpInport_data();
void qRegExpInport();
@@ -456,11 +459,13 @@ void tst_QScriptEngine::newVariant()
// replace value of existing object
{
QScriptValue object = eng.newVariant(QVariant(123));
- QScriptValue ret = eng.newVariant(object, QVariant(456));
- QVERIFY(ret.isValid());
- QVERIFY(ret.strictlyEquals(object));
- QVERIFY(ret.isVariant());
- QCOMPARE(ret.toVariant(), QVariant(456));
+ for (int x = 0; x < 2; ++x) {
+ QScriptValue ret = eng.newVariant(object, QVariant(456));
+ QVERIFY(ret.isValid());
+ QVERIFY(ret.strictlyEquals(object));
+ QVERIFY(ret.isVariant());
+ QCOMPARE(ret.toVariant(), QVariant(456));
+ }
}
// valueOf() and toString()
@@ -495,6 +500,19 @@ void tst_QScriptEngine::newVariant()
QVERIFY(value.strictlyEquals(object));
QCOMPARE(object.toString(), QString::fromLatin1("QVariant(QPoint)"));
}
+
+ {
+ QVariant var(456);
+ QScriptValue ret = eng.newVariant(123, var);
+ QVERIFY(ret.isVariant());
+ QCOMPARE(ret.toVariant(), var);
+ }
+
+ {
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::newVariant(): changing class of non-QScriptObject not supported");
+ QScriptValue ret = eng.newVariant(eng.newArray(), 123);
+ QVERIFY(!ret.isValid());
+ }
}
void tst_QScriptEngine::newRegExp()
@@ -733,12 +751,14 @@ void tst_QScriptEngine::newQObject()
QScriptValue object = eng.newVariant(123);
QScriptValue originalProto = object.prototype();
QObject otherQObject;
- QScriptValue ret = eng.newQObject(object, &otherQObject);
- QVERIFY(ret.isValid());
- QVERIFY(ret.isQObject());
- QVERIFY(ret.strictlyEquals(object));
- QCOMPARE(ret.toQObject(), (QObject *)&otherQObject);
- QVERIFY(ret.prototype().strictlyEquals(originalProto));
+ for (int x = 0; x < 2; ++x) {
+ QScriptValue ret = eng.newQObject(object, &otherQObject);
+ QVERIFY(ret.isValid());
+ QVERIFY(ret.isQObject());
+ QVERIFY(ret.strictlyEquals(object));
+ QCOMPARE(ret.toQObject(), (QObject *)&otherQObject);
+ QVERIFY(ret.prototype().strictlyEquals(originalProto));
+ }
}
// calling newQObject() several times with same object
@@ -793,6 +813,18 @@ void tst_QScriptEngine::newQObject()
eng.setDefaultPrototype(qMetaTypeId<QObject*>(), oldQObjectProto);
eng.setDefaultPrototype(typeId, QScriptValue());
}
+
+ {
+ QScriptValue ret = eng.newQObject(123, this);
+ QVERIFY(ret.isQObject());
+ QCOMPARE(ret.toQObject(), this);
+ }
+
+ {
+ QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::newQObject(): changing class of non-QScriptObject not supported");
+ QScriptValue ret = eng.newQObject(eng.newArray(), this);
+ QVERIFY(!ret.isValid());
+ }
}
QT_BEGIN_NAMESPACE
@@ -981,6 +1013,11 @@ void tst_QScriptEngine::getSetGlobalObject()
QCOMPARE(glob.prototype().isObject(), true);
QCOMPARE(glob.prototype().strictlyEquals(eng.evaluate("Object.prototype")), true);
+ eng.setGlobalObject(glob);
+ QVERIFY(eng.globalObject().equals(glob));
+ eng.setGlobalObject(123);
+ QVERIFY(eng.globalObject().equals(glob));
+
QScriptValue obj = eng.newObject();
eng.setGlobalObject(obj);
QVERIFY(eng.globalObject().strictlyEquals(obj));
@@ -1030,6 +1067,28 @@ void tst_QScriptEngine::getSetGlobalObject()
QScriptValue ret = eng.evaluate("(function() { return this; })()");
QVERIFY(ret.strictlyEquals(obj));
}
+
+ // Delete property.
+ {
+ QScriptValue ret = eng.evaluate("delete foo");
+ QVERIFY(ret.isBool());
+ QVERIFY(ret.toBool());
+ QVERIFY(!obj.property("foo").isValid());
+ }
+
+ // Getter/setter property.
+ QVERIFY(eng.evaluate("this.__defineGetter__('oof', function() { return this.bar; })").isUndefined());
+ QVERIFY(eng.evaluate("this.__defineSetter__('oof', function(v) { this.bar = v; })").isUndefined());
+ QVERIFY(eng.evaluate("this.__lookupGetter__('oof')").isFunction());
+ QVERIFY(eng.evaluate("this.__lookupSetter__('oof')").isFunction());
+ eng.evaluate("oof = 123");
+ QVERIFY(eng.evaluate("oof").equals(obj.property("bar")));
+
+ // Enumeration.
+ {
+ QScriptValue ret = eng.evaluate("a = []; for (var p in this) a.push(p); a");
+ QCOMPARE(ret.toString(), QString::fromLatin1("bar,baz,oof,p,a"));
+ }
}
static QScriptValue getSetFoo(QScriptContext *ctx, QScriptEngine *)
@@ -2256,6 +2315,14 @@ void tst_QScriptEngine::valueConversion()
QEXPECT_FAIL("", "QTBUG-6136: JSC-based back-end doesn't preserve QRegExp::minimal (always false)", Continue);
QCOMPARE(val.toRegExp().isMinimal(), in.isMinimal());
}
+
+ QCOMPARE(qscriptvalue_cast<QVariant>(QScriptValue(123)), QVariant(123));
+}
+
+void tst_QScriptEngine::qScriptValueFromValue_noEngine()
+{
+ QVERIFY(!qScriptValueFromValue(0, 123).isValid());
+ QVERIFY(!qScriptValueFromValue(0, QVariant(123)).isValid());
}
static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng)
@@ -2694,6 +2761,19 @@ void tst_QScriptEngine::throwErrorFromProcessEvents()
QCOMPARE(ret.toString(), QString::fromLatin1("Error: Killed"));
}
+void tst_QScriptEngine::disableProcessEventsInterval()
+{
+ QScriptEngine eng;
+ eng.setProcessEventsInterval(100);
+ QCOMPARE(eng.processEventsInterval(), 100);
+ eng.setProcessEventsInterval(0);
+ QCOMPARE(eng.processEventsInterval(), 0);
+ eng.setProcessEventsInterval(-1);
+ QCOMPARE(eng.processEventsInterval(), -1);
+ eng.setProcessEventsInterval(-100);
+ QCOMPARE(eng.processEventsInterval(), -100);
+}
+
void tst_QScriptEngine::stacktrace()
{
QString script = QString::fromLatin1(
@@ -4522,6 +4602,17 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), QString::fromLatin1("foobar"));
}
+ {
+ QScriptValue ret = eng.evaluate("'foo%0'.arg(123)");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo123"));
+ }
+ {
+ // Maybe this should throw an error?
+ QScriptValue ret = eng.evaluate("'foo%0'.arg()");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString());
+ }
{
QScriptValue ret = eng.evaluate("qsTrId('foo')");
@@ -4533,6 +4624,7 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), QString::fromLatin1("foo"));
}
+ QVERIFY(eng.evaluate("QT_TRID_NOOP()").isUndefined());
}
static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng)
@@ -4567,9 +4659,14 @@ void tst_QScriptEngine::translateScript()
QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel"));
QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')", fileName).toString(), QString::fromLatin1("Farvel"));
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')", fileName).toString(), QString::fromLatin1("Farvel"));
+
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)", fileName).toString(), QString::fromLatin1("Goodbye"));
QCOMPARE(engine.evaluate("qsTr('One', 'not the same one')", fileName).toString(), QString::fromLatin1("Enda en"));
+ QCOMPARE(engine.evaluate("qsTr('One', 'not the same one', 42)", fileName).toString(), QString::fromLatin1("One"));
+
QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined());
QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One"));
@@ -4638,6 +4735,7 @@ void tst_QScriptEngine::translateWithInvalidArgs_data()
QTest::newRow("qsTranslate()") << "qsTranslate()" << "Error: qsTranslate() requires at least two arguments";
QTest::newRow("qsTranslate('foo')") << "qsTranslate('foo')" << "Error: qsTranslate() requires at least two arguments";
+ QTest::newRow("qsTranslate(123, 'foo')") << "qsTranslate(123, 'foo')" << "Error: qsTranslate(): first argument (context) must be a string";
QTest::newRow("qsTranslate('foo', 123)") << "qsTranslate('foo', 123)" << "Error: qsTranslate(): second argument (text) must be a string";
QTest::newRow("qsTranslate('foo', 'bar', 123)") << "qsTranslate('foo', 'bar', 123)" << "Error: qsTranslate(): third argument (comment) must be a string";
QTest::newRow("qsTranslate('foo', 'bar', 'baz', 123)") << "qsTranslate('foo', 'bar', 'baz', 123)" << "Error: qsTranslate(): fourth argument (encoding) must be a string";
@@ -5101,6 +5199,10 @@ void tst_QScriptEngine::qRegExpInport_data()
QTest::newRow("aaa") << QRegExp("a{2,5}") << "aAaAaaaaaAa";
QTest::newRow("aaa minimal") << minimal(QRegExp("a{2,5}")) << "aAaAaaaaaAa";
QTest::newRow("minimal") << minimal(QRegExp(".*\\} [*8]")) << "}?} ?} *";
+ QTest::newRow(".? minimal") << minimal(QRegExp(".?")) << ".?";
+ QTest::newRow(".+ minimal") << minimal(QRegExp(".+")) << ".+";
+ QTest::newRow("[.?] minimal") << minimal(QRegExp("[.?]")) << ".?";
+ QTest::newRow("[.+] minimal") << minimal(QRegExp("[.+]")) << ".+";
}
void tst_QScriptEngine::qRegExpInport()
@@ -5445,5 +5547,29 @@ void tst_QScriptEngine::newGrowingStaticScopeObject()
eng.popContext();
}
+Q_SCRIPT_DECLARE_QMETAOBJECT(QStandardItemModel, QObject*)
+
+void tst_QScriptEngine::scriptValueFromQMetaObject()
+{
+ QScriptEngine eng;
+ {
+ QScriptValue meta = eng.scriptValueFromQMetaObject<QScriptEngine>();
+ QVERIFY(meta.isQMetaObject());
+ QCOMPARE(meta.toQMetaObject(), &QScriptEngine::staticMetaObject);
+ // Because of missing Q_SCRIPT_DECLARE_QMETAOBJECT() for QScriptEngine.
+ QVERIFY(!meta.construct().isValid());
+ }
+ {
+ QScriptValue meta = eng.scriptValueFromQMetaObject<QStandardItemModel>();
+ QVERIFY(meta.isQMetaObject());
+ QCOMPARE(meta.toQMetaObject(), &QStandardItemModel::staticMetaObject);
+ QScriptValue obj = meta.construct(QScriptValueList() << eng.newQObject(&eng));
+ QVERIFY(obj.isQObject());
+ QStandardItemModel *model = qobject_cast<QStandardItemModel*>(obj.toQObject());
+ QVERIFY(model != 0);
+ QCOMPARE(model->parent(), (QObject*)&eng);
+ }
+}
+
QTEST_MAIN(tst_QScriptEngine)
#include "tst_qscriptengine.moc"
diff --git a/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro b/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro
new file mode 100644
index 0000000..d4671c8
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+CONFIG -= app_bundle
+SUBDIRS = simpleplugin staticplugin test
diff --git a/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.cpp b/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.cpp
new file mode 100644
index 0000000..1679512
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** 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.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtScript/qscriptextensionplugin.h>
+#include <QtScript/qscriptengine.h>
+#include <qdebug.h>
+
+class SimplePlugin : public QScriptExtensionPlugin
+{
+public:
+ SimplePlugin(QObject *parent = 0);
+ ~SimplePlugin();
+
+ virtual QStringList keys() const;
+ virtual void initialize(const QString &key, QScriptEngine *engine);
+};
+
+SimplePlugin::SimplePlugin(QObject *parent)
+ : QScriptExtensionPlugin(parent)
+{
+}
+
+SimplePlugin::~SimplePlugin()
+{
+}
+
+QStringList SimplePlugin::keys() const
+{
+ return QStringList() << "simple"
+ << "simple.foo"
+ << "simple.foo.bar";
+}
+
+void SimplePlugin::initialize(const QString &key, QScriptEngine *engine)
+{
+ engine->globalObject().setProperty("pluginKey", key);
+ QScriptValue package = setupPackage(key, engine);
+ engine->globalObject().setProperty("package", package);
+}
+
+Q_EXPORT_PLUGIN2(simpleplugin, SimplePlugin)
diff --git a/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.pro b/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.pro
new file mode 100644
index 0000000..e184ca4
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = simpleplugin.cpp
+QT = core script
+TARGET = simpleplugin
+DESTDIR = ../plugins/script
+
+symbian {
+ TARGET.EPOCALLOWDLLDATA=1
+}
diff --git a/tests/auto/qscriptextensionplugin/staticplugin/__init__.js b/tests/auto/qscriptextensionplugin/staticplugin/__init__.js
new file mode 100644
index 0000000..4e462ae
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/staticplugin/__init__.js
@@ -0,0 +1,6 @@
+spy = {
+ extension: __extension__,
+ setupPackage: __setupPackage__,
+ postInit: __postInit__
+};
+__postInit__ = function() { postInitWasCalled = true; };
diff --git a/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.cpp b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.cpp
new file mode 100644
index 0000000..b13f723
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** 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.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtScript/qscriptextensionplugin.h>
+#include <QtScript/qscriptengine.h>
+#include <qdebug.h>
+
+class StaticPlugin : public QScriptExtensionPlugin
+{
+public:
+ StaticPlugin(QObject *parent = 0);
+ ~StaticPlugin();
+
+ virtual QStringList keys() const;
+ virtual void initialize(const QString &key, QScriptEngine *engine);
+};
+
+StaticPlugin::StaticPlugin(QObject *parent)
+ : QScriptExtensionPlugin(parent)
+{
+}
+
+StaticPlugin::~StaticPlugin()
+{
+}
+
+QStringList StaticPlugin::keys() const
+{
+ return QStringList() << "static";
+}
+
+void StaticPlugin::initialize(const QString &key, QScriptEngine *engine)
+{
+ engine->globalObject().setProperty("pluginKey", key);
+}
+
+Q_EXPORT_PLUGIN2(staticplugin, StaticPlugin)
diff --git a/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.pro b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.pro
new file mode 100644
index 0000000..a003338
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += static plugin
+SOURCES = staticplugin.cpp
+RESOURCES = staticplugin.qrc
+QT = core script
+TARGET = staticplugin
+DESTDIR = ../plugins/script
diff --git a/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.qrc b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.qrc
new file mode 100644
index 0000000..293bf0e
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/qtscriptextension/static/">
+<file>__init__.js</file>
+</qresource>
+</RCC>
+
diff --git a/tests/auto/qscriptextensionplugin/test/test.pro b/tests/auto/qscriptextensionplugin/test/test.pro
new file mode 100644
index 0000000..549bac2
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/test/test.pro
@@ -0,0 +1,18 @@
+load(qttest_p4)
+
+QT = core script
+SOURCES = ../tst_qscriptextensionplugin.cpp
+CONFIG -= app_bundle
+LIBS += -L../plugins/script -lstaticplugin
+
+TARGET = tst_qscriptextensionplugin
+CONFIG(debug_and_release) {
+ CONFIG(debug, debug|release) {
+ DESTDIR = ../debug
+ } else {
+ DESTDIR = ../release
+ }
+} else {
+ DESTDIR = ..
+}
+
diff --git a/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp b/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp
new file mode 100644
index 0000000..e8b5e0a
--- /dev/null
+++ b/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** 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.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QtScript/qscriptengine.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QScriptExtensionPlugin : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QScriptExtensionPlugin();
+ virtual ~tst_QScriptExtensionPlugin();
+
+private slots:
+ void importSimplePlugin();
+ void importStaticPlugin();
+};
+
+tst_QScriptExtensionPlugin::tst_QScriptExtensionPlugin()
+{
+}
+
+tst_QScriptExtensionPlugin::~tst_QScriptExtensionPlugin()
+{
+}
+
+void tst_QScriptExtensionPlugin::importSimplePlugin()
+{
+ QScriptEngine eng;
+ QCoreApplication::addLibraryPath("plugins");
+
+ QVERIFY(eng.importedExtensions().isEmpty());
+
+ QStringList available = eng.availableExtensions();
+ QVERIFY(available.contains("simple"));
+ QVERIFY(available.contains("simple.foo"));
+ QVERIFY(available.contains("simple.foo.bar"));
+
+ QScriptValue extensionObject;
+ {
+ QVERIFY(eng.importExtension("simple").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 1);
+ QCOMPARE(eng.importedExtensions().at(0), QString::fromLatin1("simple"));
+ QVERIFY(eng.availableExtensions().contains("simple"));
+ QVERIFY(eng.globalObject().property("pluginKey").equals("simple"));
+ QVERIFY(eng.globalObject().property("package").isObject());
+ extensionObject = eng.globalObject().property("simple");
+ QVERIFY(extensionObject.isObject());
+ QVERIFY(extensionObject.equals(eng.globalObject().property("package")));
+ }
+
+ {
+ QVERIFY(eng.importExtension("simple.foo").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 2);
+ QCOMPARE(eng.importedExtensions().at(1), QString::fromLatin1("simple.foo"));
+ QVERIFY(eng.availableExtensions().contains("simple.foo"));
+ QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo"));
+ QVERIFY(eng.globalObject().property("package").isObject());
+ QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
+ QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
+ QVERIFY(extensionObject.property("foo").isObject());
+ QVERIFY(extensionObject.property("foo").equals(eng.globalObject().property("package")));
+ }
+
+ {
+ QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 3);
+ QCOMPARE(eng.importedExtensions().at(2), QString::fromLatin1("simple.foo.bar"));
+ QVERIFY(eng.availableExtensions().contains("simple.foo.bar"));
+ QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo.bar"));
+ QVERIFY(eng.globalObject().property("package").isObject());
+ QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
+ QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
+ QVERIFY(extensionObject.property("foo").property("bar").isObject());
+ QVERIFY(extensionObject.property("foo").property("bar").equals(eng.globalObject().property("package")));
+ }
+
+ // Extensions can't be imported multiple times.
+ eng.globalObject().setProperty("pluginKey", QScriptValue());
+ QVERIFY(eng.importExtension("simple").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 3);
+ QVERIFY(!eng.globalObject().property("pluginKey").isValid());
+
+ QVERIFY(eng.importExtension("simple.foo").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 3);
+ QVERIFY(!eng.globalObject().property("pluginKey").isValid());
+
+ QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 3);
+ QVERIFY(!eng.globalObject().property("pluginKey").isValid());
+}
+
+void tst_QScriptExtensionPlugin::importStaticPlugin()
+{
+ Q_INIT_RESOURCE(staticplugin);
+ QScriptEngine eng;
+ QVERIFY(eng.availableExtensions().contains("static"));
+ QVERIFY(eng.importExtension("static").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 1);
+ QCOMPARE(eng.importedExtensions().at(0), QString::fromLatin1("static"));
+ QVERIFY(eng.availableExtensions().contains("static"));
+ QVERIFY(eng.globalObject().property("pluginKey").equals("static"));
+
+ // Verify that :/qtscriptextension/static/__init__.js was evaluated.
+ QVERIFY(eng.evaluate("spy").isObject());
+ QVERIFY(eng.evaluate("spy.extension").equals("static"));
+ QVERIFY(eng.evaluate("spy.setupPackage").isFunction());
+ QVERIFY(eng.evaluate("spy.postInit").isUndefined());
+
+ QVERIFY(eng.evaluate("postInitWasCalled").isBool());
+ QVERIFY(eng.evaluate("postInitWasCalled").toBool());
+
+ // Extensions can't be imported multiple times.
+ eng.globalObject().setProperty("pluginKey", QScriptValue());
+ QVERIFY(eng.importExtension("static").isUndefined());
+ QCOMPARE(eng.importedExtensions().size(), 1);
+ QVERIFY(!eng.globalObject().property("pluginKey").isValid());
+}
+
+Q_IMPORT_PLUGIN(staticplugin)
+
+QTEST_MAIN(tst_QScriptExtensionPlugin)
+#include "tst_qscriptextensionplugin.moc"
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 0d57f0c..1562118 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -329,6 +329,18 @@ public:
{ m_qtFunctionInvoked = 58; m_actuals << int(arg); return arg; }
Q_INVOKABLE MyQObject::Ability myInvokableWithQualifiedFlagsArg(MyQObject::Ability arg)
{ m_qtFunctionInvoked = 59; m_actuals << int(arg); return arg; }
+ Q_INVOKABLE QWidget *myInvokableWithQWidgetStarArg(QWidget *arg)
+ { m_qtFunctionInvoked = 63; m_actuals << qVariantFromValue((QWidget*)arg); return arg; }
+ Q_INVOKABLE short myInvokableWithShortArg(short arg)
+ { m_qtFunctionInvoked = 64; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE unsigned short myInvokableWithUShortArg(unsigned short arg)
+ { m_qtFunctionInvoked = 65; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE char myInvokableWithCharArg(char arg)
+ { m_qtFunctionInvoked = 66; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE unsigned char myInvokableWithUCharArg(unsigned char arg)
+ { m_qtFunctionInvoked = 67; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE qulonglong myInvokableWithULonglongArg(qulonglong arg)
+ { m_qtFunctionInvoked = 68; m_actuals << qVariantFromValue(arg); return arg; }
Q_INVOKABLE QObjectList findObjects() const
{ return findChildren<QObject *>(); }
@@ -394,6 +406,8 @@ public Q_SLOTS:
{ m_qtFunctionInvoked = 32; m_actuals << arg; }
void myOverloadedSlot(const QDate &arg)
{ m_qtFunctionInvoked = 33; m_actuals << arg; }
+ void myOverloadedSlot(const QTime &arg)
+ { m_qtFunctionInvoked = 69; m_actuals << arg; }
void myOverloadedSlot(const QRegExp &arg)
{ m_qtFunctionInvoked = 34; m_actuals << arg; }
void myOverloadedSlot(const QVariant &arg)
@@ -519,6 +533,7 @@ private slots:
void callQtInvokable();
void connectAndDisconnect();
void connectAndDisconnectWithBadArgs();
+ void connectAndDisconnect_senderDeleted();
void cppConnectAndDisconnect();
void classEnums();
void classConstructor();
@@ -1361,6 +1376,17 @@ void tst_QScriptExtQObject::callQtInvokable()
m_myObject->resetQtFunctionInvoked();
{
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQWidgetStarArg(null)");
+ QVERIFY(ret.isNull());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 63);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::QWidgetStar));
+ QCOMPARE(qvariant_cast<QWidget*>(v), (QObject *)0);
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
// no implicit conversion from integer to QObject*
QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithQObjectStarArg(123)");
QCOMPARE(ret.isError(), true);
@@ -1368,6 +1394,61 @@ void tst_QScriptExtQObject::callQtInvokable()
m_myObject->resetQtFunctionInvoked();
{
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithShortArg(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 64);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::Short));
+ QCOMPARE(qvariant_cast<short>(v), short(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithUShortArg(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 65);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::UShort));
+ QCOMPARE(qvariant_cast<ushort>(v), ushort(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithCharArg(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 66);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::Char));
+ QCOMPARE(qvariant_cast<char>(v), char(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithUCharArg(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 67);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::UChar));
+ QCOMPARE(qvariant_cast<uchar>(v), uchar(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithULonglongArg(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 68);
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::ULongLong));
+ QCOMPARE(qvariant_cast<qulonglong>(v), qulonglong(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
QScriptValue fun = m_engine->evaluate("myObject.myInvokableWithQBrushArg");
QVERIFY(fun.isFunction());
QColor color(10, 20, 30, 40);
@@ -1916,6 +1997,25 @@ void tst_QScriptExtQObject::connectAndDisconnectWithBadArgs()
}
}
+void tst_QScriptExtQObject::connectAndDisconnect_senderDeleted()
+{
+ QScriptEngine eng;
+ QObject *obj = new QObject;
+ eng.globalObject().setProperty("obj", eng.newQObject(obj));
+ eng.evaluate("signal = obj.destroyed");
+ delete obj;
+ {
+ QScriptValue ret = eng.evaluate("signal.connect(function(){})");
+ QVERIFY(ret.isError());
+ QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Function.prototype.connect: cannot connect to deleted QObject"));
+ }
+ {
+ QScriptValue ret = eng.evaluate("signal.disconnect(function(){})");
+ QVERIFY(ret.isError());
+ QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Function.prototype.discconnect: cannot disconnect from deleted QObject"));
+ }
+}
+
void tst_QScriptExtQObject::cppConnectAndDisconnect()
{
QScriptEngine eng;
diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
index 55773f0..df11537 100644
--- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
+++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
@@ -71,6 +71,7 @@ private slots:
void iterateString();
void iterateGetterSetter();
void assignObjectToIterator();
+ void iterateNonObject();
};
tst_QScriptValueIterator::tst_QScriptValueIterator()
@@ -583,5 +584,25 @@ void tst_QScriptValueIterator::assignObjectToIterator()
QCOMPARE(it.name(), QString::fromLatin1("bar"));
}
+void tst_QScriptValueIterator::iterateNonObject()
+{
+ QScriptValueIterator it(123);
+ QVERIFY(!it.hasNext());
+ it.next();
+ QVERIFY(!it.hasPrevious());
+ it.previous();
+ it.toFront();
+ it.toBack();
+ it.name();
+ it.scriptName();
+ it.flags();
+ it.value();
+ it.setValue(1);
+ it.remove();
+ QScriptValue num(5);
+ it = num;
+ QVERIFY(!it.hasNext());
+}
+
QTEST_MAIN(tst_QScriptValueIterator)
#include "tst_qscriptvalueiterator.moc"
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 843749a..f290a2b 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -106,6 +106,7 @@ private slots:
void adoptMultipleThreads();
void QTBUG13810_exitAndStart();
+ void connectThreadFinishedSignalToObjectDeleteLaterSlot();
void stressTest();
};
@@ -975,6 +976,19 @@ void tst_QThread::QTBUG13810_exitAndStart()
QCOMPARE(sync1.m_prop, 89);
}
+void tst_QThread::connectThreadFinishedSignalToObjectDeleteLaterSlot()
+{
+ QThread thread;
+ QObject *object = new QObject;
+ QWeakPointer<QObject> p = object;
+ QVERIFY(!p.isNull());
+ connect(&thread, SIGNAL(started()), &thread, SLOT(quit()), Qt::DirectConnection);
+ connect(&thread, SIGNAL(finished()), object, SLOT(deleteLater()));
+ object->moveToThread(&thread);
+ thread.start();
+ QVERIFY(thread.wait(30000));
+ QVERIFY(p.isNull());
+}
QTEST_MAIN(tst_QThread)
#include "tst_qthread.moc"
diff --git a/tests/auto/script.pro b/tests/auto/script.pro
index 06f51b5..420bd74 100644
--- a/tests/auto/script.pro
+++ b/tests/auto/script.pro
@@ -7,6 +7,7 @@ SUBDIRS=\
qscriptengine \
qscriptengineagent \
qscriptenginedebugger \
+ qscriptextensionplugin \
qscriptextqobject \
qscriptjstestsuite \
qscriptstring \
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 01d5cd5..00a1b37 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -7,3 +7,6 @@ SUBDIRS = \
svg
contains(QT_CONFIG, opengl): SUBDIRS += opengl
contains(QT_CONFIG, declarative): SUBDIRS += declarative
+
+check-trusted.CONFIG += recursive
+QMAKE_EXTRA_TARGETS += check-trusted
diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro
index 8a6941b..335280e 100644
--- a/tests/benchmarks/corelib/corelib.pro
+++ b/tests/benchmarks/corelib/corelib.pro
@@ -4,5 +4,13 @@ SUBDIRS = \
kernel \
thread \
tools \
- codecs \
+ codecs \
plugin
+
+TRUSTED_BENCHMARKS += \
+ kernel/qmetaobject \
+ kernel/qmetatype \
+ kernel/qobject \
+ thread/qthreadstorage
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro
index 5dd31f3..cb02a35 100644
--- a/tests/benchmarks/declarative/declarative.pro
+++ b/tests/benchmarks/declarative/declarative.pro
@@ -12,4 +12,4 @@ SUBDIRS += \
contains(QT_CONFIG, opengl): SUBDIRS += painting
-
+include(../trusted-benchmarks.pri)
diff --git a/tests/benchmarks/gui/gui.pro b/tests/benchmarks/gui/gui.pro
index 946f184..d825458 100644
--- a/tests/benchmarks/gui/gui.pro
+++ b/tests/benchmarks/gui/gui.pro
@@ -9,3 +9,10 @@ SUBDIRS = \
painting \
styles \
text
+
+TRUSTED_BENCHMARKS += \
+ graphicsview/functional/GraphicsViewBenchmark \
+ graphicsview/qgraphicsview \
+ painting/qtracebench
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/network/network.pro b/tests/benchmarks/network/network.pro
index 73de556..692a0a1 100644
--- a/tests/benchmarks/network/network.pro
+++ b/tests/benchmarks/network/network.pro
@@ -4,3 +4,10 @@ SUBDIRS = \
kernel \
ssl \
socket
+
+TRUSTED_BENCHMARKS += \
+ kernel/qhostinfo \
+ socket/qtcpserver \
+ ssl/qsslsocket
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/opengl/opengl.pro b/tests/benchmarks/opengl/opengl.pro
index 5c58751..b510c2b 100644
--- a/tests/benchmarks/opengl/opengl.pro
+++ b/tests/benchmarks/opengl/opengl.pro
@@ -8,3 +8,5 @@ QT += opengl
# Input
SOURCES += main.cpp
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/script/script.pro b/tests/benchmarks/script/script.pro
index 8d689b6..34910f7 100644
--- a/tests/benchmarks/script/script.pro
+++ b/tests/benchmarks/script/script.pro
@@ -3,3 +3,10 @@ SUBDIRS = \
qscriptclass \
qscriptengine \
qscriptvalue
+
+TRUSTED_BENCHMARKS += \
+ qscriptclass \
+ qscriptvalue \
+ qscriptengine
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/svg/svg.pro b/tests/benchmarks/svg/svg.pro
index cdc2ca5..d84eb71 100644
--- a/tests/benchmarks/svg/svg.pro
+++ b/tests/benchmarks/svg/svg.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = \
qsvgrenderer
+
+include(../trusted-benchmarks.pri) \ No newline at end of file
diff --git a/tests/benchmarks/trusted-benchmarks.pri b/tests/benchmarks/trusted-benchmarks.pri
new file mode 100644
index 0000000..632dcff
--- /dev/null
+++ b/tests/benchmarks/trusted-benchmarks.pri
@@ -0,0 +1,8 @@
+# Edit the list of trusted benchmarks in each of the sub-targets
+
+check-trusted.depends = qmake
+for(benchmark, TRUSTED_BENCHMARKS) {
+ check-trusted.commands += (cd $$benchmark && $(MAKE) -f $(MAKEFILE) check);
+}
+
+QMAKE_EXTRA_TARGETS += check-trusted