summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-11-19 20:28:48 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-11-19 20:28:48 (GMT)
commit04aefeb84dba892c677ca6f8b7b71781177389b2 (patch)
tree34410e8b3ff64a81a014b6fee03eeb9e0530e5d2
parent530c0a32bf58b382c32806bb6742b6029086c92e (diff)
parent2c3c8f63c36afaa47f94492215fa87989484a004 (diff)
downloadQt-04aefeb84dba892c677ca6f8b7b71781177389b2.zip
Qt-04aefeb84dba892c677ca6f8b7b71781177389b2.tar.gz
Qt-04aefeb84dba892c677ca6f8b7b71781177389b2.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Add script translation test data for plural forms Refactor script translation tests Resolve two save/restore geometry issues on X11. Split newQObject tests into smaller chunks. Compile fix Don't destroy Qt's internal pthread_key_t if it was not initialized
-rw-r--r--src/corelib/thread/qthread_unix.cpp15
-rw-r--r--src/gui/kernel/qwidget.cpp7
-rw-r--r--tests/auto/qscriptengine/translatable.js3
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.qmbin678 -> 975 bytes
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.ts16
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp214
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp90
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.h2
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp7
9 files changed, 219 insertions, 135 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index f508c0a..c578955 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -136,15 +136,16 @@ static void destroy_current_thread_data(void *p)
static void create_current_thread_data_key()
{
pthread_key_create(&current_thread_data_key, destroy_current_thread_data);
+ static class destroy_current_thread_data_key
+ {
+ public:
+ ~destroy_current_thread_data_key()
+ {
+ pthread_key_delete(current_thread_data_key);
+ }
+ } d;
}
-static void destroy_current_thread_data_key()
-{
- pthread_key_delete(current_thread_data_key);
-}
-Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
-
-
// Utility functions for getting, setting and clearing thread specific data.
// In Symbian, TLS access is significantly faster than pthread_getspecific.
// However Symbian does not have the thread destruction cleanup functionality
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index cd1c9f0..6bc699c 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -7066,13 +7066,8 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
setWindowState(ws);
d_func()->topData()->normalGeometry = restoredNormalGeometry;
} else {
- QPoint offset;
-#ifdef Q_WS_X11
- if (isFullScreen())
- offset = d_func()->topData()->fullScreenOffset;
-#endif
setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
- move(restoredFrameGeometry.topLeft() + offset);
+ move(restoredFrameGeometry.topLeft());
resize(restoredNormalGeometry.size());
}
return true;
diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js
index 30e139a..c0d7ed0 100644
--- a/tests/auto/qscriptengine/translatable.js
+++ b/tests/auto/qscriptengine/translatable.js
@@ -7,3 +7,6 @@ var greeting_strings = [
];
qsTr("One", "not the same one");
+
+qsTr("%n message(s) saved", "", 10);
+qsTranslate("FooContext", "%n fooish bar(s) found", "", "UnicodeUTF8", 10);
diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm
index 703d0f1..d76b1ca 100644
--- a/tests/auto/qscriptengine/translations/translatable_la.qm
+++ b/tests/auto/qscriptengine/translations/translatable_la.qm
Binary files differ
diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts
index 1598f39..36271c9 100644
--- a/tests/auto/qscriptengine/translations/translatable_la.ts
+++ b/tests/auto/qscriptengine/translations/translatable_la.ts
@@ -26,6 +26,14 @@
<source>Goodbye</source>
<translation>Farvel</translation>
</message>
+ <message numerus="yes">
+ <location filename="translatable.js" line="12"/>
+ <source>%n fooish bar(s) found</source>
+ <translation>
+ <numerusform>%n fooaktig bar funnet</numerusform>
+ <numerusform>%n fooaktige barer funnet</numerusform>
+ </translation>
+ </message>
</context>
<context>
<name>translatable</name>
@@ -45,6 +53,14 @@
<comment>not the same one</comment>
<translation>Enda en</translation>
</message>
+ <message numerus="yes">
+ <location filename="translatable.js" line="11"/>
+ <source>%n message(s) saved</source>
+ <translation>
+ <numerusform>%n melding lagret</numerusform>
+ <numerusform>%n meldinger lagret</numerusform>
+ </translation>
+ </message>
<message>
<source>Goodbye</source>
<translation type="obsolete">Farvel</translation>
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index d529b8b..2fe7a2d 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -180,7 +180,12 @@ private slots:
void incDecNonObjectProperty();
void installTranslatorFunctions_data();
void installTranslatorFunctions();
+ void translateScript_data();
void translateScript();
+ void translateScript_crossScript();
+ void translateScript_callQsTrFromNative();
+ void translateScript_trNoOp();
+ void translateScript_callQsTrFromCpp();
void translateWithInvalidArgs_data();
void translateWithInvalidArgs();
void translationContext_data();
@@ -4728,78 +4733,134 @@ void tst_QScriptEngine::installTranslatorFunctions()
QVERIFY(eng.evaluate("QT_TRID_NOOP()").isUndefined());
}
-static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng)
-{
- return eng->globalObject().property("qsTr").call(ctx->thisObject(), ctx->argumentsObject());
-}
-
-void tst_QScriptEngine::translateScript()
+class TranslationScope
{
- QScriptEngine engine;
+public:
+ TranslationScope(const QString &fileName)
+ {
+ translator.load(fileName);
+ QCoreApplication::instance()->installTranslator(&translator);
+ }
+ ~TranslationScope()
+ {
+ QCoreApplication::instance()->removeTranslator(&translator);
+ }
+private:
QTranslator translator;
- translator.load(":/translations/translatable_la");
- QCoreApplication::instance()->installTranslator(&translator);
- engine.installTranslatorFunctions();
+};
+
+void tst_QScriptEngine::translateScript_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("expectedTranslation");
QString fileName = QString::fromLatin1("translatable.js");
// Top-level
- QCOMPARE(engine.evaluate("qsTr('One')", fileName).toString(), QString::fromLatin1("En"));
- QCOMPARE(engine.evaluate("qsTr('Hello')", fileName).toString(), QString::fromLatin1("Hallo"));
+ QTest::newRow("qsTr('One')@translatable.js")
+ << QString::fromLatin1("qsTr('One')") << fileName << QString::fromLatin1("En");
+ QTest::newRow("qsTr('Hello')@translatable.js")
+ << QString::fromLatin1("qsTr('Hello')") << fileName << QString::fromLatin1("Hallo");
// From function
- QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName).toString(), QString::fromLatin1("En"));
- QCOMPARE(engine.evaluate("(function() { return qsTr('Hello'); })()", fileName).toString(), QString::fromLatin1("Hallo"));
+ QTest::newRow("(function() { return qsTr('One'); })()@translatable.js")
+ << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName << QString::fromLatin1("En");
+ QTest::newRow("(function() { return qsTr('Hello'); })()@translatable.js")
+ << QString::fromLatin1("(function() { return qsTr('Hello'); })()") << fileName << QString::fromLatin1("Hallo");
// From eval
- QCOMPARE(engine.evaluate("eval('qsTr(\\'One\\')')", fileName).toString(), QString::fromLatin1("En"));
- QCOMPARE(engine.evaluate("eval('qsTr(\\'Hello\\')')", fileName).toString(), QString::fromLatin1("Hallo"));
+ QTest::newRow("eval('qsTr(\\'One\\')')@translatable.js")
+ << QString::fromLatin1("eval('qsTr(\\'One\\')')") << fileName << QString::fromLatin1("En");
+ QTest::newRow("eval('qsTr(\\'Hello\\')')@translatable.js")
+ << QString::fromLatin1("eval('qsTr(\\'Hello\\')')") << fileName << QString::fromLatin1("Hallo");
+ // Plural
+ QTest::newRow("qsTr('%n message(s) saved', '', 1)@translatable.js")
+ << QString::fromLatin1("qsTr('%n message(s) saved', '', 1)") << fileName << QString::fromLatin1("1 melding lagret");
+ QTest::newRow("qsTr('%n message(s) saved', '', 3).arg@translatable.js")
+ << QString::fromLatin1("qsTr('%n message(s) saved', '', 3)") << fileName << QString::fromLatin1("3 meldinger lagret");
- QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName).toString(), QString::fromLatin1("To"));
- QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Farvel"));
+ // Top-level
+ QTest::newRow("qsTranslate('FooContext', 'Two')@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName << QString::fromLatin1("To");
+ QTest::newRow("qsTranslate('FooContext', 'Goodbye')@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye')") << fileName << QString::fromLatin1("Farvel");
// From eval
- QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To"));
- QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel"));
+ QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')@translatable.js")
+ << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')") << fileName << QString::fromLatin1("To");
+ QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')@translatable.js")
+ << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')") << fileName << 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"));
+ QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')") << fileName << QString::fromLatin1("Farvel");
+ QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')") << fileName << QString::fromLatin1("Farvel");
- QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)", fileName).toString(), QString::fromLatin1("Goodbye"));
+ QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)") << fileName << QString::fromLatin1("Goodbye");
- QCOMPARE(engine.evaluate("qsTr('One', 'not the same one')", fileName).toString(), QString::fromLatin1("Enda en"));
+ QTest::newRow("qsTr('One', 'not the same one')@translatable.js")
+ << QString::fromLatin1("qsTr('One', 'not the same one')") << fileName << QString::fromLatin1("Enda en");
- QCOMPARE(engine.evaluate("qsTr('One', 'not the same one', 42)", fileName).toString(), QString::fromLatin1("One"));
+ QTest::newRow("qsTr('One', 'not the same one', 42)@translatable.js")
+ << QString::fromLatin1("qsTr('One', 'not the same one', 42)") << fileName << QString::fromLatin1("One");
- QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined());
- QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One"));
-
- QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP()").isUndefined());
- QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP('FooContext')").isUndefined());
- QCOMPARE(engine.evaluate("QT_TRANSLATE_NOOP('FooContext', 'Two')").toString(), QString::fromLatin1("Two"));
+ // Plural
+ QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)") << fileName << QString::fromLatin1("1 fooaktig bar funnet");
+ QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)") << fileName << QString::fromLatin1("2 fooaktige barer funnet");
// Don't exist in translation
- QCOMPARE(engine.evaluate("qsTr('Three')", fileName).toString(), QString::fromLatin1("Three"));
- QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'So long')", fileName).toString(), QString::fromLatin1("So long"));
- QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Goodbye"));
-
- // From C++
- // There is no context, but it shouldn't crash
- QCOMPARE(engine.globalObject().property("qsTr").call(
- QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One"));
+ QTest::newRow("qsTr('Three')@translatable.js")
+ << QString::fromLatin1("qsTr('Three')") << fileName << QString::fromLatin1("Three");
+ QTest::newRow("qsTranslate('FooContext', 'So long')@translatable.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'So long')") << fileName << QString::fromLatin1("So long");
+ QTest::newRow("qsTranslate('BarContext', 'Goodbye')@translatable.js")
+ << QString::fromLatin1("qsTranslate('BarContext', 'Goodbye')") << fileName << QString::fromLatin1("Goodbye");
// Translate strings from the second script (translatable2.js)
QString fileName2 = QString::fromLatin1("translatable2.js");
-
- QCOMPARE(engine.evaluate("qsTr('Three')", fileName2).toString(), QString::fromLatin1("Tre"));
- QCOMPARE(engine.evaluate("qsTr('Happy birthday!')", fileName2).toString(), QString::fromLatin1("Gratulerer med dagen!"));
+ QTest::newRow("qsTr('Three')@translatable2.js")
+ << QString::fromLatin1("qsTr('Three')") << fileName2 << QString::fromLatin1("Tre");
+ QTest::newRow("qsTr('Happy birthday!')@translatable2.js")
+ << QString::fromLatin1("qsTr('Happy birthday!')") << fileName2 << QString::fromLatin1("Gratulerer med dagen!");
// Not translated because translation is only in translatable.js
- QCOMPARE(engine.evaluate("qsTr('One')", fileName2).toString(), QString::fromLatin1("One"));
- QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName2).toString(), QString::fromLatin1("One"));
+ QTest::newRow("qsTr('One')@translatable2.js")
+ << QString::fromLatin1("qsTr('One')") << fileName2 << QString::fromLatin1("One");
+ QTest::newRow("(function() { return qsTr('One'); })()@translatable2.js")
+ << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName2 << QString::fromLatin1("One");
// For qsTranslate() the filename shouldn't matter
- QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName2).toString(), QString::fromLatin1("To"));
- QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Congratulations!')", fileName).toString(), QString::fromLatin1("Gratulerer!"));
+ QTest::newRow("qsTranslate('FooContext', 'Two')@translatable2.js")
+ << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName2 << QString::fromLatin1("To");
+ QTest::newRow("qsTranslate('BarContext', 'Congratulations!')@translatable.js")
+ << QString::fromLatin1("qsTranslate('BarContext', 'Congratulations!')") << fileName << QString::fromLatin1("Gratulerer!");
+}
+
+void tst_QScriptEngine::translateScript()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, fileName);
+ QFETCH(QString, expectedTranslation);
+
+ QScriptEngine engine;
+
+ TranslationScope tranScope(":/translations/translatable_la");
+ engine.installTranslatorFunctions();
+
+ QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation);
+ QVERIFY(!engine.hasUncaughtException());
+}
+
+void tst_QScriptEngine::translateScript_crossScript()
+{
+ QScriptEngine engine;
+ TranslationScope tranScope(":/translations/translatable_la");
+ engine.installTranslatorFunctions();
+ QString fileName = QString::fromLatin1("translatable.js");
+ QString fileName2 = QString::fromLatin1("translatable2.js");
// qsTr() should use the innermost filename as context
engine.evaluate("function foo(s) { return bar(s); }", fileName);
engine.evaluate("function bar(s) { return qsTr(s); }", fileName2);
@@ -4812,15 +4873,52 @@ void tst_QScriptEngine::translateScript()
QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Three"));
QCOMPARE(engine.evaluate("bar('One')", fileName).toString(), QString::fromLatin1("En"));
QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("En"));
+}
+static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng)
+{
+ return eng->globalObject().property("qsTr").call(ctx->thisObject(), ctx->argumentsObject());
+}
+
+void tst_QScriptEngine::translateScript_callQsTrFromNative()
+{
+ QScriptEngine engine;
+ TranslationScope tranScope(":/translations/translatable_la");
+ engine.installTranslatorFunctions();
+
+ QString fileName = QString::fromLatin1("translatable.js");
+ QString fileName2 = QString::fromLatin1("translatable2.js");
// Calling qsTr() from a native function
engine.globalObject().setProperty("qsTrProxy", engine.newFunction(callQsTr));
QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName).toString(), QString::fromLatin1("En"));
QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName2).toString(), QString::fromLatin1("One"));
QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName).toString(), QString::fromLatin1("Three"));
QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName2).toString(), QString::fromLatin1("Tre"));
+}
- QCoreApplication::instance()->removeTranslator(&translator);
+void tst_QScriptEngine::translateScript_trNoOp()
+{
+ QScriptEngine engine;
+ TranslationScope tranScope(":/translations/translatable_la");
+ engine.installTranslatorFunctions();
+
+ QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined());
+ QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One"));
+
+ QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP()").isUndefined());
+ QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP('FooContext')").isUndefined());
+ QCOMPARE(engine.evaluate("QT_TRANSLATE_NOOP('FooContext', 'Two')").toString(), QString::fromLatin1("Two"));
+}
+
+void tst_QScriptEngine::translateScript_callQsTrFromCpp()
+{
+ QScriptEngine engine;
+ TranslationScope tranScope(":/translations/translatable_la");
+ engine.installTranslatorFunctions();
+
+ // There is no context, but it shouldn't crash
+ QCOMPARE(engine.globalObject().property("qsTr").call(
+ QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One"));
}
void tst_QScriptEngine::translateWithInvalidArgs_data()
@@ -4890,9 +4988,7 @@ void tst_QScriptEngine::translationContext_data()
void tst_QScriptEngine::translationContext()
{
- QTranslator translator;
- translator.load(":/translations/translatable_la");
- QCoreApplication::instance()->installTranslator(&translator);
+ TranslationScope tranScope(":/translations/translatable_la");
QScriptEngine engine;
engine.installTranslatorFunctions();
@@ -4903,17 +4999,13 @@ void tst_QScriptEngine::translationContext()
QScriptValue ret = engine.evaluate(QString::fromLatin1("qsTr('%0')").arg(text), path);
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), expectedTranslation);
-
- QCoreApplication::instance()->removeTranslator(&translator);
}
void tst_QScriptEngine::translateScriptIdBased()
{
QScriptEngine engine;
- QTranslator translator;
- translator.load(":/translations/idtranslatable_la");
- QCoreApplication::instance()->installTranslator(&translator);
+ TranslationScope tranScope(":/translations/idtranslatable_la");
engine.installTranslatorFunctions();
QString fileName = QString::fromLatin1("idtranslatable.js");
@@ -4995,15 +5087,11 @@ void tst_QScriptEngine::translateScriptUnicode()
QScriptEngine engine;
- QTranslator translator;
- QVERIFY(translator.load(":/translations/translatable-unicode"));
- QCoreApplication::instance()->installTranslator(&translator);
+ TranslationScope tranScope(":/translations/translatable-unicode");
engine.installTranslatorFunctions();
QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation);
QVERIFY(!engine.hasUncaughtException());
-
- QCoreApplication::instance()->removeTranslator(&translator);
}
void tst_QScriptEngine::translateScriptUnicodeIdBased_data()
@@ -5030,15 +5118,11 @@ void tst_QScriptEngine::translateScriptUnicodeIdBased()
QScriptEngine engine;
- QTranslator translator;
- QVERIFY(translator.load(":/translations/idtranslatable-unicode"));
- QCoreApplication::instance()->installTranslator(&translator);
+ TranslationScope tranScope(":/translations/idtranslatable-unicode");
engine.installTranslatorFunctions();
QCOMPARE(engine.evaluate(expression).toString(), expectedTranslation);
QVERIFY(!engine.hasUncaughtException());
-
- QCoreApplication::instance()->removeTranslator(&translator);
}
void tst_QScriptEngine::functionScopes()
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index de753d2..1343356 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1341,52 +1341,53 @@ void tst_QScriptValue::toVariant()
}
}
-// unfortunately, this is necessary in order to do qscriptvalue_cast<QPushButton*>(...)
-Q_DECLARE_METATYPE(QPushButton*)
-
-void tst_QScriptValue::toQObject()
+void tst_QScriptValue::toQObject_nonQObject_data()
{
- QScriptEngine eng;
-
- QScriptValue undefined = eng.undefinedValue();
- QCOMPARE(undefined.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(undefined), (QObject *)0);
+ newEngine();
+ QTest::addColumn<QScriptValue>("value");
- QScriptValue null = eng.nullValue();
- QCOMPARE(null.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(null), (QObject *)0);
+ QTest::newRow("invalid") << QScriptValue();
+ QTest::newRow("bool(false)") << QScriptValue(false);
+ QTest::newRow("bool(true)") << QScriptValue(true);
+ QTest::newRow("int") << QScriptValue(123);
+ QTest::newRow("string") << QScriptValue(QString::fromLatin1("ciao"));
+ QTest::newRow("undefined") << QScriptValue(QScriptValue::UndefinedValue);
+ QTest::newRow("null") << QScriptValue(QScriptValue::NullValue);
- {
- QScriptValue falskt = QScriptValue(&eng, false);
- QCOMPARE(falskt.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(falskt), (QObject *)0);
+ QTest::newRow("bool bound(false)") << QScriptValue(engine, false);
+ QTest::newRow("bool bound(true)") << QScriptValue(engine, true);
+ QTest::newRow("int bound") << QScriptValue(engine, 123);
+ QTest::newRow("string bound") << QScriptValue(engine, QString::fromLatin1("ciao"));
+ QTest::newRow("undefined bound") << engine->undefinedValue();
+ QTest::newRow("null bound") << engine->nullValue();
+ QTest::newRow("object") << engine->newObject();
+ QTest::newRow("array") << engine->newArray();
+ QTest::newRow("date") << engine->newDate(124);
+ QTest::newRow("variant(12345)") << engine->newVariant(12345);
+ QTest::newRow("variant((QObject*)0)") << engine->newVariant(qVariantFromValue((QObject*)0));
+ QTest::newRow("newQObject(0)") << engine->newQObject(0);
+}
- QScriptValue sant = QScriptValue(&eng, true);
- QCOMPARE(sant.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(sant), (QObject *)0);
- QScriptValue number = QScriptValue(&eng, 123.0);
- QCOMPARE(number.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(number), (QObject *)0);
+void tst_QScriptValue::toQObject_nonQObject()
+{
+ QFETCH(QScriptValue, value);
+ QCOMPARE(value.toQObject(), (QObject *)0);
+ QCOMPARE(qscriptvalue_cast<QObject*>(value), (QObject *)0);
+}
- QScriptValue str = QScriptValue(&eng, QString("ciao"));
- QCOMPARE(str.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(str), (QObject *)0);
- }
+// unfortunately, this is necessary in order to do qscriptvalue_cast<QPushButton*>(...)
+Q_DECLARE_METATYPE(QPushButton*);
- QScriptValue object = eng.newObject();
- QCOMPARE(object.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(object), (QObject *)0);
+void tst_QScriptValue::toQObject()
+{
+ QScriptEngine eng;
QScriptValue qobject = eng.newQObject(this);
QCOMPARE(qobject.toQObject(), (QObject *)this);
QCOMPARE(qscriptvalue_cast<QObject*>(qobject), (QObject *)this);
QCOMPARE(qscriptvalue_cast<QWidget*>(qobject), (QWidget *)0);
- QScriptValue qobject2 = eng.newQObject(0);
- QCOMPARE(qobject2.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(qobject2), (QObject *)0);
-
QWidget widget;
QScriptValue qwidget = eng.newQObject(&widget);
QCOMPARE(qwidget.toQObject(), (QObject *)&widget);
@@ -1400,25 +1401,6 @@ void tst_QScriptValue::toQObject()
QCOMPARE(qscriptvalue_cast<QWidget*>(qbutton), (QWidget *)&button);
QCOMPARE(qscriptvalue_cast<QPushButton*>(qbutton), &button);
- // V2 constructors
- {
- QScriptValue falskt = QScriptValue(false);
- QCOMPARE(falskt.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(falskt), (QObject *)0);
-
- QScriptValue sant = QScriptValue(true);
- QCOMPARE(sant.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(sant), (QObject *)0);
-
- QScriptValue number = QScriptValue(123.0);
- QCOMPARE(number.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(number), (QObject *)0);
-
- QScriptValue str = QScriptValue(QString("ciao"));
- QCOMPARE(str.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(str), (QObject *)0);
- }
-
// wrapping a QObject* as variant
QScriptValue variant = eng.newVariant(qVariantFromValue((QObject*)&button));
QCOMPARE(variant.toQObject(), (QObject*)&button);
@@ -1437,10 +1419,6 @@ void tst_QScriptValue::toQObject()
QCOMPARE(qscriptvalue_cast<QObject*>(variant3), (QObject*)0);
QCOMPARE(qscriptvalue_cast<QWidget*>(variant3), (QWidget*)0);
QCOMPARE(qscriptvalue_cast<QPushButton*>(variant3), &button);
-
- QScriptValue inv;
- QCOMPARE(inv.toQObject(), (QObject *)0);
- QCOMPARE(qscriptvalue_cast<QObject*>(inv), (QObject *)0);
}
void tst_QScriptValue::toObject()
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h
index 7bf0b66..98d83e4 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.h
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h
@@ -91,6 +91,8 @@ private slots:
void toUInt32();
void toUInt16();
void toVariant();
+ void toQObject_nonQObject_data();
+ void toQObject_nonQObject();
void toQObject();
void toDateTime();
void toRegExp();
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index d230f2c..ba6d8ba 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -3272,8 +3272,13 @@ void tst_QWidget::restoreVersion1Geometry()
QTest::qWait(10);
if (expectedWindowState != Qt::WindowNoState) {
- // restoring from maximized or fullscreen, we can only restore to the normal geometry
+#ifndef Q_WS_X11
+ // X11 fullscreen handling has changed. The window is positioned correctly
+ // on screen, but geometry() returns different values. Let this silently
+ // fail when restoring from version1 data.
QTRY_COMPARE(widget.geometry(), expectedNormalGeometry);
+#endif
+
} else {
QTRY_COMPARE(widget.pos(), expectedPosition);
QTRY_COMPARE(widget.size(), expectedSize);