diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-10-29 10:37:50 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-11-01 07:57:28 (GMT) |
commit | 3ecb6db4a3e71582e5249c3c2101f2f4ddf39510 (patch) | |
tree | 6ed981a6f3f5198d326ca4366e7c852282797dd4 /tests/auto/qscriptvalue | |
parent | 49c0770f875b81586bd1890e128534759e057705 (diff) | |
download | Qt-3ecb6db4a3e71582e5249c3c2101f2f4ddf39510.zip Qt-3ecb6db4a3e71582e5249c3c2101f2f4ddf39510.tar.gz Qt-3ecb6db4a3e71582e5249c3c2101f2f4ddf39510.tar.bz2 |
Split tst_QScriptValue::getSetScriptClass autotest.
The test was too big. More data was added to the part testing non Object
behaviour.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue')
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 43 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.h | 7 |
2 files changed, 43 insertions, 7 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 3184d7a..ce9e8d1 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2332,14 +2332,27 @@ public: TestScriptClass(QScriptEngine *engine) : QScriptClass(engine) {} }; -void tst_QScriptValue::getSetScriptClass() +void tst_QScriptValue::getSetScriptClass_nonObjects_data() { - QScriptEngine eng; - QScriptValue inv; - QCOMPARE(inv.scriptClass(), (QScriptClass*)0); - QScriptValue num(123); - QCOMPARE(num.scriptClass(), (QScriptClass*)0); + QTest::addColumn<QScriptValue>("value"); + + QTest::newRow("invalid") << QScriptValue(); + QTest::newRow("number") << QScriptValue(123); + QTest::newRow("string") << QScriptValue("pong"); + QTest::newRow("bool") << QScriptValue(false); + QTest::newRow("null") << QScriptValue(QScriptValue::NullValue); + QTest::newRow("undefined") << QScriptValue(QScriptValue::UndefinedValue); +} + +void tst_QScriptValue::getSetScriptClass_nonObjects() +{ + QFETCH(QScriptValue, value); + QCOMPARE(value.scriptClass(), (QScriptClass*)0); +} +void tst_QScriptValue::getSetScriptClass_JSObjectFromCpp() +{ + QScriptEngine eng; TestScriptClass testClass(&eng); // object created in C++ (newObject()) { @@ -2350,6 +2363,12 @@ void tst_QScriptValue::getSetScriptClass() obj.setScriptClass(0); QCOMPARE(obj.scriptClass(), (QScriptClass*)0); } +} + +void tst_QScriptValue::getSetScriptClass_JSObjectFromJS() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); // object created in JS { QScriptValue obj = eng.evaluate("new Object"); @@ -2364,6 +2383,12 @@ void tst_QScriptValue::getSetScriptClass() obj.setScriptClass(0); QCOMPARE(obj.scriptClass(), (QScriptClass*)0); } +} + +void tst_QScriptValue::getSetScriptClass_QVariant() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); // object that already has a(n internal) class { QScriptValue obj = eng.newVariant(QUrl("http://example.com")); @@ -2375,6 +2400,12 @@ void tst_QScriptValue::getSetScriptClass() QVERIFY(!obj.isVariant()); QCOMPARE(obj.toVariant(), QVariant(QVariantMap())); } +} + +void tst_QScriptValue::getSetScriptClass_QObject() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); { QScriptValue obj = eng.newQObject(this); QVERIFY(obj.isQObject()); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h index fe5f079..6274a69 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.h +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h @@ -234,7 +234,12 @@ private slots: void getSetProperty(); void arrayElementGetterSetter(); void getSetData(); - void getSetScriptClass(); + void getSetScriptClass_nonObjects_data(); + void getSetScriptClass_nonObjects(); + void getSetScriptClass_JSObjectFromCpp(); + void getSetScriptClass_JSObjectFromJS(); + void getSetScriptClass_QVariant(); + void getSetScriptClass_QObject(); void call(); void construct(); void construct_constructorThrowsPrimitive(); |