diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/guiapplauncher/tst_guiapplauncher.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 138 | ||||
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 27 | ||||
-rw-r--r-- | tests/auto/qimage/tst_qimage.cpp | 22 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 29 | ||||
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp | 134 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/gui/image/image.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro | 10 | ||||
-rw-r--r-- | tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp | 108 |
11 files changed, 484 insertions, 21 deletions
diff --git a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp index 048ea35..4b3ce18 100644 --- a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp +++ b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp @@ -128,10 +128,10 @@ const struct Example examples[] = { {"mainwindows/menus Example", "mainwindows/menus", "menus", 10, -1}, {"mainwindows/recentfiles Example", "mainwindows/recentfiles", "recentfiles", 10, -1}, {"mainwindows/sdi Example", "mainwindows/sdi", "sdi", 10, -1}, - {"multitouch/dials Example", "multitouch/dials", "dials", 10, -1}, - {"multitouch/fingerpaint Example", "multitouch/fingerpaint", "fingerpaint", 10, -1}, - {"multitouch/knobs Example", "multitouch/knobs", "knobs", 10, -1}, - {"multitouch/pinchzoom Example", "multitouch/pinchzoom", "pinchzoom", 10, -1}, + {"touch/dials Example", "touch/dials", "dials", 10, -1}, + {"touch/fingerpaint Example", "touch/fingerpaint", "fingerpaint", 10, -1}, + {"touch/knobs Example", "touch/knobs", "knobs", 10, -1}, + {"touch/pinchzoom Example", "touch/pinchzoom", "pinchzoom", 10, -1}, {"opengl/2dpainting Example", "opengl/2dpainting", "2dpainting", 10, -1}, {"opengl/grabber Example", "opengl/grabber", "grabber", 10, -1}, {"opengl/hellogl Example", "opengl/hellogl", "hellogl", 10, -1}, diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index d8ff2d3..a870e47 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -70,18 +70,34 @@ class MyObject: public QObject " <arg direction=\"in\" type=\"v\" name=\"ping\" />\n" " <arg direction=\"out\" type=\"v\" name=\"ping\" />\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"v\" name=\"ping_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"ping_invokable\" />\n" +" </method>\n" " <method name=\"ping\" >\n" " <arg direction=\"in\" type=\"v\" name=\"ping1\" />\n" " <arg direction=\"in\" type=\"v\" name=\"ping2\" />\n" " <arg direction=\"out\" type=\"v\" name=\"pong1\" />\n" " <arg direction=\"out\" type=\"v\" name=\"pong2\" />\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"v\" name=\"ping1_invokable\" />\n" +" <arg direction=\"in\" type=\"v\" name=\"ping2_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"pong1_invokable\" />\n" +" <arg direction=\"out\" type=\"v\" name=\"pong2_invokable\" />\n" +" </method>\n" " <method name=\"ping\" >\n" " <arg direction=\"in\" type=\"ai\" name=\"ping\" />\n" " <arg direction=\"out\" type=\"ai\" name=\"ping\" />\n" " <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList<int>\"/>\n" " <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList<int>\"/>\n" " </method>\n" +" <method name=\"ping_invokable\" >\n" +" <arg direction=\"in\" type=\"ai\" name=\"ping_invokable\" />\n" +" <arg direction=\"out\" type=\"ai\" name=\"ping_invokable\" />\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList<int>\"/>\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList<int>\"/>\n" +" </method>\n" " </interface>\n" "") Q_PROPERTY(int prop1 READ prop1 WRITE setProp1) @@ -120,6 +136,20 @@ public: m_complexProp = value; } + Q_INVOKABLE void ping_invokable(QDBusMessage msg) + { + QDBusConnection sender = QDBusConnection::sender(); + if (!sender.isConnected()) + exit(1); + + ++callCount; + callArgs = msg.arguments(); + + msg.setDelayedReply(true); + if (!sender.send(msg.createReply(callArgs))) + exit(1); + } + public slots: void ping(QDBusMessage msg) @@ -220,6 +250,7 @@ void tst_QDBusInterface::initTestCase() con.registerObject("/", &obj, QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSlots + | QDBusConnection::ExportAllInvokables | QDBusConnection::ExportChildObjects); } @@ -283,7 +314,7 @@ void tst_QDBusInterface::introspect() const QMetaObject *mo = iface.metaObject(); - QCOMPARE(mo->methodCount() - mo->methodOffset(), 4); + QCOMPARE(mo->methodCount() - mo->methodOffset(), 7); QVERIFY(mo->indexOfSignal(TEST_SIGNAL_NAME "(QString)") != -1); QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 2); @@ -298,6 +329,8 @@ void tst_QDBusInterface::callMethod() TEST_INTERFACE_NAME); MyObject::callCount = 0; + + // call a SLOT method QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -315,6 +348,25 @@ void tst_QDBusInterface::callMethod() dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().type(), QVariant::String); QCOMPARE(dv.variant().toString(), QString("foo")); + + // call an INVOKABLE method + reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + QCOMPARE(MyObject::callCount, 2); + QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); + + // verify reply + QCOMPARE(reply.arguments().count(), 1); + v = reply.arguments().at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); } void tst_QDBusInterface::invokeMethod() @@ -323,8 +375,9 @@ void tst_QDBusInterface::invokeMethod() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; + + // make the SLOT call without a return type QDBusVariant arg("foo"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_ARG(QDBusVariant, arg))); QCOMPARE(MyObject::callCount, 1); @@ -335,6 +388,18 @@ void tst_QDBusInterface::invokeMethod() QDBusVariant dv = qdbus_cast<QDBusVariant>(v); QCOMPARE(dv.variant().type(), QVariant::String); QCOMPARE(dv.variant().toString(), QString("foo")); + + // make the INVOKABLE call without a return type + QDBusVariant arg2("bar"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_ARG(QDBusVariant, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), QString("bar")); } void tst_QDBusInterface::invokeMethodWithReturn() @@ -343,10 +408,11 @@ void tst_QDBusInterface::invokeMethodWithReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QDBusVariant arg("foo"); QDBusVariant retArg; + + // make the SLOT call without a return type + QDBusVariant arg("foo"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg))); QCOMPARE(MyObject::callCount, 1); @@ -359,6 +425,21 @@ void tst_QDBusInterface::invokeMethodWithReturn() // verify that we got the reply as expected QCOMPARE(retArg.variant(), arg.variant()); + + // make the INVOKABLE call without a return type + QDBusVariant arg2("bar"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg2.variant().toString()); + + // verify that we got the reply as expected + QCOMPARE(retArg.variant(), arg2.variant()); } void tst_QDBusInterface::invokeMethodWithMultiReturn() @@ -367,10 +448,11 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QDBusVariant arg("foo"), arg2("bar"); QDBusVariant retArg, retArg2; + + // make the SLOT call without a return type + QDBusVariant arg("foo"), arg2("bar"); QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg), @@ -393,6 +475,31 @@ void tst_QDBusInterface::invokeMethodWithMultiReturn() // verify that we got the replies as expected QCOMPARE(retArg.variant(), arg.variant()); QCOMPARE(retArg2.variant(), arg2.variant()); + + // make the INVOKABLE call without a return type + QDBusVariant arg3("hello"), arg4("world"); + QVERIFY(QMetaObject::invokeMethod(&iface, "ping_invokable", + Q_RETURN_ARG(QDBusVariant, retArg), + Q_ARG(QDBusVariant, arg3), + Q_ARG(QDBusVariant, arg4), + Q_ARG(QDBusVariant&, retArg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 2); + v = MyObject::callArgs.at(0); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg3.variant().toString()); + + v = MyObject::callArgs.at(1); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg4.variant().toString()); + + // verify that we got the replies as expected + QCOMPARE(retArg.variant(), arg3.variant()); + QCOMPARE(retArg2.variant(), arg4.variant()); } void tst_QDBusInterface::invokeMethodWithComplexReturn() @@ -401,10 +508,11 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); - // make the call without a return type MyObject::callCount = 0; - QList<int> arg = QList<int>() << 42 << -47; QList<int> retArg; + + // make the SLOT call without a return type + QList<int> arg = QList<int>() << 42 << -47; QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg))); QCOMPARE(MyObject::callCount, 1); @@ -416,6 +524,20 @@ void tst_QDBusInterface::invokeMethodWithComplexReturn() // verify that we got the reply as expected QCOMPARE(retArg, arg); + + // make the INVOKABLE call without a return type + QList<int> arg2 = QList<int>() << 24 << -74; + QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg2))); + QCOMPARE(MyObject::callCount, 2); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + v = MyObject::callArgs.at(0); + QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); + QCOMPARE(qdbus_cast<QList<int> >(v), arg2); + + // verify that we got the reply as expected + QCOMPARE(retArg, arg2); } void tst_QDBusInterface::signal() diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 8ee494f..7fe461c 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -2252,5 +2252,30 @@ void tst_QGL::textureCleanup() #endif } -QTEST_MAIN(tst_QGL) +class tst_QGLDummy : public QObject +{ +Q_OBJECT + +public: + tst_QGLDummy() {} + +private slots: + void qglSkipTests() { + QSKIP("QGL not supported on this system.", SkipAll); + } +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QTEST_DISABLE_KEYPAD_NAVIGATION \ + QGLWidget glWidget; + if (!glWidget.isValid()) { + tst_QGLDummy tc; + return QTest::qExec(&tc, argc, argv); + } + tst_QGL tc; + return QTest::qExec(&tc, argc, argv); +} + #include "tst_qgl.moc" diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 5052114..1330d96 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -83,6 +83,8 @@ private slots: void convertToFormat_data(); void convertToFormat(); + void convertToFormatRgb888ToRGB32(); + void createAlphaMask_data(); void createAlphaMask(); #ifndef QT_NO_IMAGE_HEURISTIC_MASK @@ -799,6 +801,26 @@ void tst_QImage::convertToFormat() QFile::remove(QLatin1String("expected2.xpm")); } +void tst_QImage::convertToFormatRgb888ToRGB32() +{ + // 545 so width % 4 != 0. This ensure there is padding at the end of the scanlines + const int height = 545; + const int width = 545; + QImage source(width, height, QImage::Format_RGB888); + for (int y = 0; y < height; ++y) { + uchar *srcPixels = source.scanLine(y); + for (int x = 0; x < width * 3; ++x) + srcPixels[x] = x; + } + + QImage rgb32Image = source.convertToFormat(QImage::Format_RGB888); + QCOMPARE(rgb32Image.format(), QImage::Format_RGB888); + for (int x = 0; x < width; ++x) { + for (int y = 0; y < height; ++y) + QCOMPARE(rgb32Image.pixel(x, y), source.pixel(x, y)); + } +} + void tst_QImage::createAlphaMask_data() { QTest::addColumn<int>("x"); diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index b34e559..717b32d 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -66,7 +66,6 @@ #include <qspinbox.h> #include <qdebug.h> - //TESTED_CLASS= //TESTED_FILES= @@ -275,6 +274,7 @@ private slots: void taskQTBUG_7902_contextMenuCrash(); #endif void taskQTBUG_7395_readOnlyShortcut(); + void QTBUG697_paletteCurrentColorGroup(); #ifdef QT3_SUPPORT void validateAndSet_data(); @@ -3714,5 +3714,32 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() QCOMPARE(spy.count(), 1); } +void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() +{ +#ifndef Q_WS_X11 + QSKIP("Only tested on X11", SkipAll); +#endif + QLineEdit le; + le.setText(" "); + QPalette p = le.palette(); + p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green); + p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red); + le.setPalette(p); + + le.show(); + QApplication::setActiveWindow(&le); + QTest::qWaitForWindowShown(&le); + le.setFocus(); + QTRY_VERIFY(le.hasFocus()); + le.selectAll(); + + QImage img(le.size(),QImage::Format_ARGB32 ); + le.render(&img); + QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::green).rgb()); + QApplication::setActiveWindow(0); + le.render(&img); + QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb()); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 27ee6e7..f358681 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -4176,14 +4176,18 @@ void tst_QPainter::inactivePainter() p.setWorldTransform(QTransform().scale(0.5, 0.5), true); } -bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMode op) +bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMode op, qreal opacity = 1.0) { - QImage actual(1, 1, QImage::Format_ARGB32_Premultiplied); + // The test image needs to be large enough to test SIMD code + const QSize imageSize(100, 100); + + QImage actual(imageSize, QImage::Format_ARGB32_Premultiplied); actual.fill(QColor(dst, dst, dst).rgb()); QPainter p(&actual); p.setCompositionMode(op); - p.fillRect(0, 0, 1, 1, QColor(src, src, src)); + p.setOpacity(opacity); + p.fillRect(QRect(QPoint(), imageSize), QColor(src, src, src)); p.end(); if (qRed(actual.pixel(0, 0)) != expected) { @@ -4191,7 +4195,9 @@ bool testCompositionMode(int src, int dst, int expected, QPainter::CompositionMo src, dst, qRed(actual.pixel(0, 0)), expected); return false; } else { - return true; + QImage refImage(imageSize, QImage::Format_ARGB32_Premultiplied); + refImage.fill(QColor(expected, expected, expected).rgb()); + return actual == refImage; } } @@ -4206,6 +4212,16 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus)); QVERIFY(testCompositionMode(128, 128, 255, QPainter::CompositionMode_Plus)); + QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(127, 128, 165, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(127, 0, 37, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 127, 127, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(255, 0, 75, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(128, 128, 166, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(186, 200, 255, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Multiply)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Multiply)); QVERIFY(testCompositionMode(127, 255, 127, QPainter::CompositionMode_Multiply)); diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index a0f10dd..c30a636 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -97,6 +97,7 @@ private slots: void functionEntryAndExit_objectCall(); void positionChange_1(); void positionChange_2(); + void positionChange_3(); void exceptionThrowAndCatch(); void eventOrder_assigment(); void eventOrder_functionDefinition(); @@ -116,6 +117,8 @@ private slots: void evaluateProgram_SyntaxError(); void evaluateNullProgram(); void QTBUG6108(); + void backtraces_data(); + void backtraces(); private: double m_testProperty; @@ -1623,6 +1626,56 @@ void tst_QScriptEngineAgent::positionChange_2() delete spy; } +void tst_QScriptEngineAgent::positionChange_3() +{ + QScriptEngine eng; + eng.evaluate("function some_function1(a) {\n a++; \n return a + 12; } \n some_function1(42);", "function1.qs", 12); + QScriptValue some_function2 = eng.evaluate("(function (b) {\n b--; \n return b + 11; })", "function2.qs", 21); + some_function2.call(QScriptValue(), QScriptValueList() << 2 ); + + // Test that the agent work, even if installed after the function has been evaluated. + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnorePositionChange)); + { + spy->clear(); + QScriptValue v = eng.evaluate("some_function1(15)"); + QCOMPARE(v.toInt32(), (15+1+12)); + QCOMPARE(spy->count(), 3); + + // some_function1() + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(0).scriptId != -1); + QCOMPARE(spy->at(0).lineNumber, 1); + + // a++ + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(1).scriptId != spy->at(0).scriptId); + QCOMPARE(spy->at(1).lineNumber, 13); + // return a + 12 + QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(2).scriptId == spy->at(1).scriptId); + QCOMPARE(spy->at(2).lineNumber, 14); + } + + { + spy->clear(); + QScriptValue v = some_function2.call(QScriptValue(), QScriptValueList() << 89 ); + QCOMPARE(v.toInt32(), (89-1+11)); + QCOMPARE(spy->count(), 2); + + // b-- + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(0).scriptId != -1); + QCOMPARE(spy->at(0).lineNumber, 22); + // return b + 11 + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(1).scriptId == spy->at(0).scriptId); + QCOMPARE(spy->at(1).lineNumber, 23); + } + + QVERIFY(!eng.hasUncaughtException()); +} + + void tst_QScriptEngineAgent::exceptionThrowAndCatch() { QScriptEngine eng; @@ -2379,5 +2432,86 @@ void tst_QScriptEngineAgent::QTBUG6108() QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); } +class BacktraceSpy : public QScriptEngineAgent +{ +public: + BacktraceSpy(QScriptEngine *engine, const QStringList &expectedbacktrace, int breakpoint) + : QScriptEngineAgent(engine), expectedbacktrace(expectedbacktrace), breakpoint(breakpoint), ok(false) {} + + QStringList expectedbacktrace; + int breakpoint; + bool ok; + +protected: + + void exceptionThrow(qint64 , const QScriptValue &, bool) + { check(); } + + void positionChange(qint64 , int lineNumber, int ) + { + if (lineNumber == breakpoint) + check(); + } + +private: + void check() + { + QCOMPARE(engine()->currentContext()->backtrace(), expectedbacktrace); + ok = true; + } +}; + + +void tst_QScriptEngineAgent::backtraces_data() +{ + QTest::addColumn<QString>("code"); + QTest::addColumn<int>("breakpoint"); + QTest::addColumn<QStringList>("expectedbacktrace"); + + { + QString source( + "function foo() {\n" + " var a = 5\n" + "}\n" + "foo('hello', { })\n" + "var r = 0;"); + + QStringList expected; + expected + << "foo('hello', [object Object]) at filename.js:2" + << "<global>() at filename.js:4"; + QTest::newRow("simple breakpoint") << source << 2 << expected; + } + + { + QString source( + "function foo() {\n" + " error = err\n" //this must throw + "}\n" + "foo('hello', { })\n" + "var r = 0;"); + + QStringList expected; + expected + << "foo('hello', [object Object]) at filename.js:2" + << "<global>() at filename.js:4"; + QTest::newRow("throw because of error") << source << -100 << expected; + } +} + +void tst_QScriptEngineAgent::backtraces() +{ + QFETCH(QString, code); + QFETCH(int, breakpoint); + QFETCH(QStringList, expectedbacktrace); + + QScriptEngine eng; + BacktraceSpy *spy = new BacktraceSpy(&eng, expectedbacktrace, breakpoint); + eng.setAgent(spy); + QLatin1String filename("filename.js"); + eng.evaluate(code, filename); + QVERIFY(spy->ok); +} + QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f20d27a..f722f89 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9694,7 +9694,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden() // Native child widget should once again share parent's backing store QVERIFY(0 != backingStore(parent)); - QEXPECT_FAIL("", "QTBUG-10643", Continue); QVERIFY(0 == backingStore(child)); } @@ -9743,7 +9742,7 @@ void tst_QWidget::destroyBackingStoreWhenHidden() QVERIFY(0 != backingStore(child)); // Parent is obscured, therefore its backing store should be destroyed - QEXPECT_FAIL("", "QTBUG-10643", Continue); + QEXPECT_FAIL("", "QTBUG-12406", Continue); QVERIFY(0 == backingStore(parent)); // Disable full screen @@ -9757,7 +9756,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden() // Native child widget should once again share parent's backing store QVERIFY(0 != backingStore(parent)); - QEXPECT_FAIL("", "QTBUG-10643", Continue); QVERIFY(0 == backingStore(child)); } } diff --git a/tests/benchmarks/gui/image/image.pro b/tests/benchmarks/gui/image/image.pro index 3094e72..a8c6732 100644 --- a/tests/benchmarks/gui/image/image.pro +++ b/tests/benchmarks/gui/image/image.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = \ blendbench \ + qimageconversion \ qimagereader \ qpixmap \ qpixmapcache diff --git a/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro b/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro new file mode 100644 index 0000000..ec50d98 --- /dev/null +++ b/tests/benchmarks/gui/image/qimageconversion/qimageconversion.pro @@ -0,0 +1,10 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_imageConversion + +SOURCES += tst_qimageconversion.cpp + +!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF +!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG +!contains(QT_CONFIG, no-mng):DEFINES += QTEST_HAVE_MNG +!contains(QT_CONFIG, no-tiff):DEFINES += QTEST_HAVE_TIFF diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp new file mode 100644 index 0000000..1c76d46 --- /dev/null +++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QImage> + +Q_DECLARE_METATYPE(QImage) + +class tst_QImageConversion : public QObject +{ + Q_OBJECT +private slots: + void convertRgb888ToRGB32_data(); + void convertRgb888ToRGB32(); + +private: + QImage generateImageRgb888(int width, int height); +}; + +void tst_QImageConversion::convertRgb888ToRGB32_data() +{ + QTest::addColumn<QImage>("inputImage"); + // height = 5000 to get interesting timing. + + // 3 pixels wide -> smaller than regular vector of 128bits + QTest::newRow("width: 3px; height: 5000px;") << generateImageRgb888(3, 5000); + + // 8 pixels wide -> potential for 2 vectors + QTest::newRow("width: 8px; height: 5000px;") << generateImageRgb888(3, 5000); + + // 16 pixels, minimum for the SSSE3 implementation + QTest::newRow("width: 16px; height: 5000px;") << generateImageRgb888(16, 5000); + + // 50 pixels, more realistic use case + QTest::newRow("width: 50px; height: 5000px;") << generateImageRgb888(50, 5000); + + // 2000 pixels -> typical values for pictures + QTest::newRow("width: 2000px; height: 5000px;") << generateImageRgb888(2000, 5000); +} + +void tst_QImageConversion::convertRgb888ToRGB32() +{ + QFETCH(QImage, inputImage); + + QBENCHMARK { + volatile QImage output = inputImage.convertToFormat(QImage::Format_RGB32); + // we need the volatile and the following to make sure the compiler does not do + // anything stupid :) + (void)output; + } +} + +/* + Fill a RGB888 image with "random" pixel values. + */ +QImage tst_QImageConversion::generateImageRgb888(int width, int height) +{ + QImage image(width, height, QImage::Format_RGB888); + const int byteWidth = width * 3; + + for (int y = 0; y < image.height(); ++y) { + uchar *scanline = image.scanLine(y); + for (int x = 0; x < byteWidth; ++x) + scanline[x] = x ^ y; + } + return image; +} + +QTEST_MAIN(tst_QImageConversion) +#include "tst_qimageconversion.moc" |