summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-10-29 12:02:51 (GMT)
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-11-01 07:57:58 (GMT)
commit121b7a47670f8a8e8e4c7ef6cf69a42865297158 (patch)
tree9b436e3eb646dd4b8df662ca567c6c71f78f0c80 /tests/auto
parent0540537b2841d3c9e367d84d0f89f6a5f5f487a7 (diff)
downloadQt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.zip
Qt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.tar.gz
Qt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.tar.bz2
Increase range of getSetScriptClass test.
Few bound QScriptValue instances were added to the test. Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp19
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.h10
2 files changed, 22 insertions, 7 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 4232aff..e5af792 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -56,7 +56,8 @@ tst_QScriptValue::tst_QScriptValue()
tst_QScriptValue::~tst_QScriptValue()
{
- delete engine;
+ if (engine)
+ delete engine;
}
void tst_QScriptValue::ctor_invalid()
@@ -2278,8 +2279,9 @@ public:
TestScriptClass(QScriptEngine *engine) : QScriptClass(engine) {}
};
-void tst_QScriptValue::getSetScriptClass_nonObjects_data()
+void tst_QScriptValue::getSetScriptClass_emptyClass_data()
{
+ newEngine();
QTest::addColumn<QScriptValue>("value");
QTest::newRow("invalid") << QScriptValue();
@@ -2288,9 +2290,18 @@ void tst_QScriptValue::getSetScriptClass_nonObjects_data()
QTest::newRow("bool") << QScriptValue(false);
QTest::newRow("null") << QScriptValue(QScriptValue::NullValue);
QTest::newRow("undefined") << QScriptValue(QScriptValue::UndefinedValue);
+
+ QTest::newRow("number") << QScriptValue(engine, 123);
+ QTest::newRow("string") << QScriptValue(engine, "pong");
+ QTest::newRow("bool") << QScriptValue(engine, true);
+ QTest::newRow("null") << QScriptValue(engine->nullValue());
+ QTest::newRow("undefined") << QScriptValue(engine->undefinedValue());
+ QTest::newRow("object") << QScriptValue(engine->newObject());
+ QTest::newRow("date") << QScriptValue(engine->evaluate("new Date()"));
+ QTest::newRow("qobject") << QScriptValue(engine->newQObject(this));
}
-void tst_QScriptValue::getSetScriptClass_nonObjects()
+void tst_QScriptValue::getSetScriptClass_emptyClass()
{
QFETCH(QScriptValue, value);
QCOMPARE(value.scriptClass(), (QScriptClass*)0);
@@ -2303,7 +2314,6 @@ void tst_QScriptValue::getSetScriptClass_JSObjectFromCpp()
// object created in C++ (newObject())
{
QScriptValue obj = eng.newObject();
- QCOMPARE(obj.scriptClass(), (QScriptClass*)0);
obj.setScriptClass(&testClass);
QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass);
obj.setScriptClass(0);
@@ -2355,7 +2365,6 @@ void tst_QScriptValue::getSetScriptClass_QObject()
{
QScriptValue obj = eng.newQObject(this);
QVERIFY(obj.isQObject());
- QCOMPARE(obj.scriptClass(), (QScriptClass*)0);
obj.setScriptClass(&testClass);
QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass);
QVERIFY(obj.isObject());
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h
index d196ea5..7eb4f04 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.h
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h
@@ -109,8 +109,8 @@ private slots:
void getSetProperty();
void arrayElementGetterSetter();
void getSetData();
- void getSetScriptClass_nonObjects_data();
- void getSetScriptClass_nonObjects();
+ void getSetScriptClass_emptyClass_data();
+ void getSetScriptClass_emptyClass();
void getSetScriptClass_JSObjectFromCpp();
void getSetScriptClass_JSObjectFromJS();
void getSetScriptClass_QVariant();
@@ -128,6 +128,12 @@ private slots:
void nestedObjectToVariant();
private:
+ void newEngine()
+ {
+ if (engine)
+ delete engine;
+ engine = new QScriptEngine();
+ }
QScriptEngine *engine;
};