diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result | 2 | ||||
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp | 23 | ||||
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result | 17 | ||||
-rw-r--r-- | tests/auto/mediaobject/qtesthelper.h | 1 | ||||
-rw-r--r-- | tests/auto/mediaobject/tst_mediaobject.cpp | 43 | ||||
-rw-r--r-- | tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 82 | ||||
-rw-r--r-- | tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qscriptengine/translatable.js | 2 | ||||
-rw-r--r-- | tests/auto/qscriptengine/translatable2.js | 9 | ||||
-rw-r--r-- | tests/auto/qscriptengine/translations/translatable_la.qm | bin | 241 -> 678 bytes | |||
-rw-r--r-- | tests/auto/qscriptengine/translations/translatable_la.ts | 38 | ||||
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 84 | ||||
-rw-r--r-- | tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp | 34 | ||||
-rw-r--r-- | tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp | 2 | ||||
-rw-r--r-- | tests/auto/uiloader/baseline/css_scroll.ui | 14 |
15 files changed, 299 insertions, 54 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result index 2f21de2..53d7a25 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result @@ -98,7 +98,7 @@ <location filename="main.cpp" line="238"/> <source></source> <comment>This is a comment to the translator.</comment> - <translation type="unfinished"></translation> + <translation></translation> </message> </context> <context> diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 6e73d6d..0765bfc 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -252,3 +252,26 @@ class YetAnotherTest : QObject { //: This is a message without a source string QString test = qtTrId("yet_another_id"); + + + +// QTBUG-9276: context in static initializers +class Bogus : QObject { + Q_OBJECT + + static const char * const s_strings[]; +}; + +const char * const Bogus::s_strings[] = { + QT_TR_NOOP("this should be in Bogus") +}; + +const char * const Bogus::s_strings[SIZE] = { + QT_TR_NOOP("this should be in Bogus") +}; + +void bogosity() +{ + // no spaces here. test collateral damage from ignoring equal sign + Class::member=QObject::tr("just QObject"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 6d50c21..208191d 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -26,6 +26,15 @@ backslashed \ stuff.</source> </message> </context> <context> + <name>Bogus</name> + <message> + <location filename="main.cpp" line="266"/> + <location filename="main.cpp" line="270"/> + <source>this should be in Bogus</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>Dialog2</name> <message numerus="yes"> <location filename="main.cpp" line="70"/> @@ -184,6 +193,14 @@ backslashed \ stuff.</source> </message> </context> <context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="276"/> + <source>just QObject</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>QTranslator</name> <message> <location filename="main.cpp" line="93"/> diff --git a/tests/auto/mediaobject/qtesthelper.h b/tests/auto/mediaobject/qtesthelper.h index f082296..39d5b91 100644 --- a/tests/auto/mediaobject/qtesthelper.h +++ b/tests/auto/mediaobject/qtesthelper.h @@ -215,7 +215,6 @@ namespace QTest default: return 0; } - return 0; } } // namespace QTest QT_END_NAMESPACE diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 5b0943e..994057b 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -193,31 +193,17 @@ static qint32 castQVariantToInt32(const QVariant &variant) return *reinterpret_cast<const qint32 *>(variant.constData()); } -static const char *const red = "\033[0;31m"; -static const char *const green = "\033[0;32m"; -static const char *const yellow = "\033[0;33m"; -static const char *const blue = "\033[0;34m"; -static const char *const purple = "\033[0;35m"; -static const char *const cyan = "\033[0;36m"; -static const char *const white = "\033[0;37m"; -static const char *const normal = "\033[0m"; - void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstate) { - if (newstate == Phonon::ErrorState) { - QWARN(QByteArray(QByteArray(red) + ".......................................................... ") + QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate)) + normal); - } else { - //qDebug() << ".........................................................." << cyan << QTest::toString(oldstate) << "to" << QTest::toString(newstate) << normal; - } + if (newstate == Phonon::ErrorState) + QWARN(QByteArray(QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate)))); } void tst_MediaObject::testPlayFromResource() { #ifdef Q_OS_SYMBIAN QSKIP("Not implemented yet.", SkipAll); - return; -#endif - +#else QFile file(MEDIA_FILEPATH); MediaObject media; media.setCurrentSource(&file); @@ -229,6 +215,7 @@ void tst_MediaObject::testPlayFromResource() if (media.state() != Phonon::PlayingState) QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); QCOMPARE(media.state(), Phonon::PlayingState); +#endif } void tst_MediaObject::testPlayIllegalFile() @@ -264,6 +251,13 @@ void tst_MediaObject::init() } m_stateChangedSignalSpy->clear(); } + + // Ensure that m_media is in StoppedState + if (m_media->state() != Phonon::StoppedState) { + m_media->stop(); + QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State))); + QCOMPARE(m_media->state(), Phonon::StoppedState); + } } void tst_MediaObject::cleanup() @@ -579,13 +573,18 @@ void tst_MediaObject::playSDP() if (m_media->state() != Phonon::StoppedState) QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); - // At this point we're in error state due to absent media, but it has now loaded the SDP: - QCOMPARE(m_media->errorString(), QString::fromLatin1("Buffering clip failed: Unknown error (-39)")); + // MediaObject should have loaded the SDP, but be in error state due to absent media + const bool stateMatch = (m_media->state() == Phonon::ErrorState); + const bool errorStringMatch = (m_media->errorString() == QString::fromLatin1("Loading clip failed: Unknown error (-39)")); - // We cannot play the SDP, we can neither attempt to play it, because we - // won't get a state change from ErrorState to ErrorState, and hence block - // on a never occuring signal. + // Ensure that m_media is back in ground state prior to starting next test step m_media->setCurrentSource(oldSource); + if (m_media->state() != Phonon::StoppedState) + QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State))); + QCOMPARE(m_media->state(), Phonon::StoppedState); + + QVERIFY(stateMatch); + QVERIFY(errorStringMatch); #else QSKIP("Unsupported on this platform.", SkipAll); diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index e46709b..d5f63d3 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <QtGui> #include "../../shared/util.h" +#include <private/qgraphicsproxywidget_p.h> #include <private/qlayoutengine_p.h> // qSmartMin functions... #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) #include <QMacStyle> @@ -2582,33 +2583,68 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() void tst_QGraphicsProxyWidget::tooltip_basic() { - // Confirm that mouse events are working properly by checking that - // when moving the mouse over a label with a tooptip the tooltip appears - QGraphicsScene scene; - QGraphicsView view(&scene); - view.show(); + QString toolTip = "Qt rocks!"; + QString toolTip2 = "Qt rocks even more!"; + + QPushButton *button = new QPushButton("button"); + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget; + QGraphicsProxyWidgetPrivate *proxyd = static_cast<QGraphicsProxyWidgetPrivate *>(QGraphicsItemPrivate::get(proxy)); + proxy->setWidget(button); + proxyd->lastWidgetUnderMouse = button; // force widget under mouse + + QVERIFY(button->toolTip().isEmpty()); + QVERIFY(proxy->toolTip().isEmpty()); + // Check that setting the tooltip on the proxy also set it on the widget + proxy->setToolTip(toolTip); + QCOMPARE(proxy->toolTip(), toolTip); + QCOMPARE(button->toolTip(), toolTip); + // Check that setting the tooltip on the widget also set it on the proxy + button->setToolTip(toolTip2); + QCOMPARE(proxy->toolTip(), toolTip2); + QCOMPARE(button->toolTip(), toolTip2); - QSKIP("Tooltips don't work yet", SkipAll); - - SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; - QLabel *widget = new QLabel; - widget->setText("If it ain't tested it's broken"); - widget->setToolTip("When in doubt, test"); - proxy->setWidget(widget); - widget->show(); + QGraphicsScene scene; scene.addItem(proxy); - QTest::qWait(125); - // in - QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); + QGraphicsView view(&scene); + view.setFixedSize(200, 200); + view.show(); + QTest::qWaitForWindowShown(&view); + { + QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), + view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); + QApplication::sendEvent(view.viewport(), &helpEvent); + QTest::qWait(350); + + bool foundView = false; + bool foundTipLabel = false; + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + if (widget == &view) + foundView = true; + if (widget->inherits("QTipLabel")) + foundTipLabel = true; + } + QVERIFY(foundView); + QVERIFY(!foundTipLabel); + } - QTRY_COMPARE(proxy->childItems().count(), 1); - QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0]; - QVERIFY(child->isWidget()); - QVERIFY(child->widget()); - QCOMPARE(child->widget()->parent(), static_cast<QObject*>(widget)); - QCOMPARE(child->widget()->x(), widget->x()); // ### ??? - QCOMPARE(child->widget()->y(), widget->y() + widget->height()); // ### ??? + { + QHelpEvent helpEvent(QEvent::ToolTip, view.mapFromScene(proxy->boundingRect().center()), + view.viewport()->mapToGlobal(view.mapFromScene(proxy->boundingRect().center()))); + QApplication::sendEvent(view.viewport(), &helpEvent); + QTest::qWait(350); + + bool foundView = false; + bool foundTipLabel = false; + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + if (widget == &view) + foundView = true; + if (widget->inherits("QTipLabel")) + foundTipLabel = true; + } + QVERIFY(foundView); + QVERIFY(foundTipLabel); + } } void tst_QGraphicsProxyWidget::childPos_data() diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 35ebbd9..0b55390 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -801,7 +801,7 @@ void tst_QHttpNetworkConnection::getMultiple_data() QTest::newRow("6 connections, no pipelining, 100 requests") << quint16(6) << false << 100; QTest::newRow("1 connection, no pipelining, 100 requests") << quint16(1) << false << 100; - QTest::newRow("6 connections, pipelining allowed, 100 requests") << quint16(2) << true << 100; + QTest::newRow("6 connections, pipelining allowed, 100 requests") << quint16(6) << true << 100; QTest::newRow("1 connection, pipelining allowed, 100 requests") << quint16(1) << true << 100; } diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js index 0c948e7..30e139a 100644 --- a/tests/auto/qscriptengine/translatable.js +++ b/tests/auto/qscriptengine/translatable.js @@ -5,3 +5,5 @@ var greeting_strings = [ QT_TR_NOOP("Hello"), QT_TRANSLATE_NOOP("FooContext", "Goodbye") ]; + +qsTr("One", "not the same one"); diff --git a/tests/auto/qscriptengine/translatable2.js b/tests/auto/qscriptengine/translatable2.js new file mode 100644 index 0000000..eee66f1 --- /dev/null +++ b/tests/auto/qscriptengine/translatable2.js @@ -0,0 +1,9 @@ +qsTr("Three"); +qsTranslate("BarContext", "Four"); + +var celebration_strings = [ + QT_TR_NOOP("Happy birthday!"), + QT_TRANSLATE_NOOP("BarContext", "Congratulations!") +]; + +qsTr("Three", "not the same three"); diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm Binary files differindex 03fcc52..703d0f1 100644 --- a/tests/auto/qscriptengine/translations/translatable_la.qm +++ b/tests/auto/qscriptengine/translations/translatable_la.qm diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts index 3f631de..1598f39 100644 --- a/tests/auto/qscriptengine/translations/translatable_la.ts +++ b/tests/auto/qscriptengine/translations/translatable_la.ts @@ -2,6 +2,19 @@ <!DOCTYPE TS> <TS version="2.0" language="nb_NO"> <context> + <name>BarContext</name> + <message> + <location filename="translatable2.js" line="2"/> + <source>Four</source> + <translation>Fire</translation> + </message> + <message> + <location filename="translatable2.js" line="6"/> + <source>Congratulations!</source> + <translation>Gratulerer!</translation> + </message> +</context> +<context> <name>FooContext</name> <message> <location filename="translatable.js" line="2"/> @@ -27,8 +40,33 @@ <translation>Hallo</translation> </message> <message> + <location filename="translatable.js" line="9"/> + <source>One</source> + <comment>not the same one</comment> + <translation>Enda en</translation> + </message> + <message> <source>Goodbye</source> <translation type="obsolete">Farvel</translation> </message> </context> +<context> + <name>translatable2</name> + <message> + <location filename="translatable2.js" line="1"/> + <source>Three</source> + <translation>Tre</translation> + </message> + <message> + <location filename="translatable2.js" line="5"/> + <source>Happy birthday!</source> + <translation>Gratulerer med dagen!</translation> + </message> + <message> + <location filename="translatable2.js" line="9"/> + <source>Three</source> + <comment>not the same three</comment> + <translation>Tre andre</translation> + </message> +</context> </TS> diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 96043f9..89ea1db 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -156,6 +156,8 @@ private slots: void installTranslatorFunctions_data(); void installTranslatorFunctions(); void translateScript(); + void translateWithInvalidArgs_data(); + void translateWithInvalidArgs(); void functionScopes(); void nativeFunctionScopes(); void evaluateProgram(); @@ -4336,6 +4338,11 @@ void tst_QScriptEngine::installTranslatorFunctions() } } +static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng) +{ + return eng->globalObject().property("qsTr").call(ctx->thisObject(), ctx->argumentsObject()); +} + void tst_QScriptEngine::translateScript() { QScriptEngine engine; @@ -4362,6 +4369,17 @@ void tst_QScriptEngine::translateScript() QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To")); 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("qsTr('One', 'not the same one')", fileName).toString(), QString::fromLatin1("Enda en")); + + 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")); + // 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")); @@ -4372,9 +4390,75 @@ void tst_QScriptEngine::translateScript() QCOMPARE(engine.globalObject().property("qsTr").call( QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One")); + // 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!")); + + // 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")); + + // 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!")); + + // 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); + QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Tre")); + QCOMPARE(engine.evaluate("bar('Three')", fileName).toString(), QString::fromLatin1("Tre")); + QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("One")); + + engine.evaluate("function foo(s) { return bar(s); }", fileName2); + engine.evaluate("function bar(s) { return qsTr(s); }", fileName); + 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")); + + // 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::translateWithInvalidArgs_data() +{ + QTest::addColumn<QString>("expression"); + QTest::addColumn<QString>("expectedError"); + + QTest::newRow("qsTr()") << "qsTr()" << "Error: qsTr() requires at least one argument"; + QTest::newRow("qsTr(123)") << "qsTr(123)" << "Error: qsTr(): first argument (text) must be a string"; + QTest::newRow("qsTr('foo', 123)") << "qsTr('foo', 123)" << "Error: qsTr(): second argument (comment) must be a string"; + QTest::newRow("qsTr('foo', 'bar', 'baz')") << "qsTr('foo', 'bar', 'baz')" << "Error: qsTr(): third argument (n) must be a number"; + QTest::newRow("qsTr('foo', 'bar', true)") << "qsTr('foo', 'bar', true)" << "Error: qsTr(): third argument (n) must be a number"; + + 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('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"; + QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')") << "qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')" << "Error: qsTranslate(): fifth argument (n) must be a number"; + QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 123)") << "qsTranslate('foo', 'bar', 'baz', 'zab', 123)" << "Error: qsTranslate(): invalid encoding 'zab'"; +} + +void tst_QScriptEngine::translateWithInvalidArgs() +{ + QFETCH(QString, expression); + QFETCH(QString, expectedError); + QScriptEngine engine; + engine.installTranslatorFunctions(); + QScriptValue result = engine.evaluate(expression); + QVERIFY(result.isError()); + QCOMPARE(result.toString(), expectedError); +} + void tst_QScriptEngine::functionScopes() { QScriptEngine eng; diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index c1496f7..09070e6 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -534,6 +534,7 @@ private slots: void connectToDestroyedSignal(); void emitAfterReceiverDeleted(); void inheritedSlots(); + void enumerateMetaObject(); private: QScriptEngine *m_engine; @@ -3130,5 +3131,38 @@ void tst_QScriptExtQObject::inheritedSlots() QCOMPARE(prototypeButtonClickedSpy.count(), 0); } +void tst_QScriptExtQObject::enumerateMetaObject() +{ + QScriptValue myClass = m_engine->newQMetaObject(m_myObject->metaObject(), m_engine->undefinedValue()); + + QStringList expectedNames; + expectedNames << "FooPolicy" << "BarPolicy" << "BazPolicy" + << "FooStrategy" << "BarStrategy" << "BazStrategy" + << "NoAbility" << "FooAbility" << "BarAbility" << "BazAbility" << "AllAbility"; + + for (int x = 0; x < 2; ++x) { + QSet<QString> actualNames; + if (x == 0) { + // From C++ + QScriptValueIterator it(myClass); + while (it.hasNext()) { + it.next(); + actualNames.insert(it.name()); + } + } else { + // From JS + m_engine->globalObject().setProperty("MyClass", myClass); + QScriptValue ret = m_engine->evaluate("a=[]; for (var p in MyClass) if (MyClass.hasOwnProperty(p)) a.push(p); a"); + QVERIFY(ret.isArray()); + QStringList strings = qscriptvalue_cast<QStringList>(ret); + for (int i = 0; i < strings.size(); ++i) + actualNames.insert(strings.at(i)); + } + QCOMPARE(actualNames.size(), expectedNames.size()); + for (int i = 0; i < expectedNames.size(); ++i) + QVERIFY(actualNames.contains(expectedNames.at(i))); + } +} + QTEST_MAIN(tst_QScriptExtQObject) #include "tst_qscriptextqobject.moc" diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 018c036..0a7458f 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -871,6 +871,8 @@ void tst_QTextScriptEngine::malayalam() { 0x3f8, 0x0 } }, { { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0x0 }, { 0x2ff, 0x0 } }, + { { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0x0 }, + { 0xf3, 0x350, 0x0 } }, { {0}, {0} } }; diff --git a/tests/auto/uiloader/baseline/css_scroll.ui b/tests/auto/uiloader/baseline/css_scroll.ui index 0537ab0..6ac6886 100644 --- a/tests/auto/uiloader/baseline/css_scroll.ui +++ b/tests/auto/uiloader/baseline/css_scroll.ui @@ -14,8 +14,10 @@ <string>Form</string> </property> <property name="styleSheet"> - <string notr="true">QScrollArea { background:red; } -QScrollArea .QWidget { background:transparent; } + <string notr="true">QScrollArea { background:red; + border: 5px dashed blue; } +QScrollArea .QWidget { background:transparent; + border: 5px dotted green;} QScrollArea::corner { background:yellow; } @@ -111,10 +113,10 @@ QScrollArea::corner { background:yellow; } <widget class="QWidget" name="scrollAreaWidgetContents"> <property name="geometry"> <rect> - <x>-60</x> - <y>-145</y> - <width>554</width> - <height>575</height> + <x>0</x> + <y>0</y> + <width>520</width> + <height>532</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_3"> |