diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-19 16:16:14 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-19 16:16:14 (GMT) |
commit | 54839932adbddf68c78fd79d1b824ff1ad3f83b8 (patch) | |
tree | b3a97c95635bb53cec30b755ae56babbdb478579 /tests | |
parent | 2969a34664430338875e9786935b865aec0252de (diff) | |
parent | 2c466e4a198f2a21d296eee77d321f548931a3b3 (diff) | |
download | Qt-54839932adbddf68c78fd79d1b824ff1ad3f83b8.zip Qt-54839932adbddf68c78fd79d1b824ff1ad3f83b8.tar.gz Qt-54839932adbddf68c78fd79d1b824ff1ad3f83b8.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
installTranslatorFunctions doesn't work for custom global object
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 8658240..cbc36a7 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -150,6 +150,7 @@ private slots: void getSetAgent(); void reentrancy(); void incDecNonObjectProperty(); + void installTranslatorFunctions_data(); void installTranslatorFunctions(); void functionScopes(); void nativeFunctionScopes(); @@ -4118,22 +4119,46 @@ void tst_QScriptEngine:: incDecNonObjectProperty() } } +void tst_QScriptEngine::installTranslatorFunctions_data() +{ + QTest::addColumn<bool>("useCustomGlobalObject"); + + QTest::newRow("Default global object") << false; + QTest::newRow("Custom global object") << true; +} + void tst_QScriptEngine::installTranslatorFunctions() { + QFETCH(bool, useCustomGlobalObject); + QScriptEngine eng; - QScriptValue global = eng.globalObject(); + QScriptValue globalOrig = eng.globalObject(); + QScriptValue global; + if (useCustomGlobalObject) { + global = eng.newObject(); + eng.setGlobalObject(global); + } else { + global = globalOrig; + } QVERIFY(!global.property("qsTranslate").isValid()); QVERIFY(!global.property("QT_TRANSLATE_NOOP").isValid()); QVERIFY(!global.property("qsTr").isValid()); QVERIFY(!global.property("QT_TR_NOOP").isValid()); - QVERIFY(!global.property("String").property("prototype").property("arg").isValid()); + QVERIFY(!globalOrig.property("String").property("prototype").property("arg").isValid()); eng.installTranslatorFunctions(); QVERIFY(global.property("qsTranslate").isFunction()); QVERIFY(global.property("QT_TRANSLATE_NOOP").isFunction()); QVERIFY(global.property("qsTr").isFunction()); QVERIFY(global.property("QT_TR_NOOP").isFunction()); - QVERIFY(global.property("String").property("prototype").property("arg").isFunction()); + QVERIFY(globalOrig.property("String").property("prototype").property("arg").isFunction()); + + if (useCustomGlobalObject) { + QVERIFY(!globalOrig.property("qsTranslate").isValid()); + QVERIFY(!globalOrig.property("QT_TRANSLATE_NOOP").isValid()); + QVERIFY(!globalOrig.property("qsTr").isValid()); + QVERIFY(!globalOrig.property("QT_TR_NOOP").isValid()); + } { QScriptValue ret = eng.evaluate("qsTr('foo')"); |