diff options
Diffstat (limited to 'tests/auto')
20 files changed, 224 insertions, 21 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index e16eb75..80d540f 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -8,7 +8,7 @@ TEMPLATE = subdirs SUBDIRS += \ bic \ collections \ - compile \ + compiler \ compilerwarnings \ exceptionsafety \ linguist \ diff --git a/tests/auto/compile/.gitignore b/tests/auto/compiler/.gitignore index bdcee46..bdcee46 100644 --- a/tests/auto/compile/.gitignore +++ b/tests/auto/compiler/.gitignore diff --git a/tests/auto/compile/baseclass.cpp b/tests/auto/compiler/baseclass.cpp index 5479532..5479532 100644 --- a/tests/auto/compile/baseclass.cpp +++ b/tests/auto/compiler/baseclass.cpp diff --git a/tests/auto/compile/baseclass.h b/tests/auto/compiler/baseclass.h index 25abbfe..25abbfe 100644 --- a/tests/auto/compile/baseclass.h +++ b/tests/auto/compiler/baseclass.h diff --git a/tests/auto/compile/compile.pro b/tests/auto/compiler/compiler.pro index 6c38078..c444c63 100644 --- a/tests/auto/compile/compile.pro +++ b/tests/auto/compiler/compiler.pro @@ -1,5 +1,5 @@ load(qttest_p4) -SOURCES += tst_compile.cpp baseclass.cpp derivedclass.cpp +SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp HEADERS += baseclass.h derivedclass.h QT = core diff --git a/tests/auto/compile/derivedclass.cpp b/tests/auto/compiler/derivedclass.cpp index 3b71861..3b71861 100644 --- a/tests/auto/compile/derivedclass.cpp +++ b/tests/auto/compiler/derivedclass.cpp diff --git a/tests/auto/compile/derivedclass.h b/tests/auto/compiler/derivedclass.h index 9396ff9..9396ff9 100644 --- a/tests/auto/compile/derivedclass.h +++ b/tests/auto/compiler/derivedclass.h diff --git a/tests/auto/compile/tst_compile.cpp b/tests/auto/compiler/tst_compiler.cpp index cef798a..78c1a56 100644 --- a/tests/auto/compile/tst_compile.cpp +++ b/tests/auto/compiler/tst_compiler.cpp @@ -653,4 +653,4 @@ void tst_Compiler::staticConstUnionWithInitializerList() const } QTEST_MAIN(tst_Compiler) -#include "tst_compile.moc" +#include "tst_compiler.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 6adcdfe..effa876 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -156,6 +156,7 @@ private slots: void windowFlags(); void shortcutsDeletion(); void painterStateProtectionOnWindowFrame(); + void ensureClipping(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2459,6 +2460,87 @@ void tst_QGraphicsWidget::task250119_shortcutContext() scene.removeItem(&w_signal); } +class ClippingAndTransformsScene : public QGraphicsScene +{ +public: + QList<QGraphicsItem *> drawnItems; +protected: + void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], + const QStyleOptionGraphicsItem options[], QWidget *widget = 0) + { + drawnItems.clear(); + for (int i = 0; i < numItems; ++i) + drawnItems << items[i]; + QGraphicsScene::drawItems(painter, numItems, items, options, widget); + } +}; + +class RectWidget : public QGraphicsWidget +{ +public: + + RectWidget(Qt::GlobalColor color, QGraphicsItem *parent=0) : QGraphicsWidget(parent), mColor(color) {} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(QBrush(mColor)); + painter->drawRect(boundingRect()); + } + + Qt::GlobalColor mColor; +}; + +class RectItem : public QGraphicsItem +{ +public: + + RectItem(Qt::GlobalColor color, QGraphicsItem *parent=0) : QGraphicsItem(parent), mColor(color) {} + + QRectF boundingRect() const + {return QRectF(10,10,50,50);} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(QBrush(mColor)); + painter->drawRect(boundingRect()); + } + + Qt::GlobalColor mColor; +}; + +void tst_QGraphicsWidget::ensureClipping() +{ + ClippingAndTransformsScene scene; + scene.setSceneRect(-50, -50, 200, 200); + + //A root that clip children + RectWidget *clipWidget = new RectWidget(Qt::black); + scene.addItem(clipWidget); + + clipWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + //a child + RectWidget *childWidget = new RectWidget(Qt::red, clipWidget); + clipWidget->setGeometry(QRectF(10, 10, 100, 100)); + childWidget->setGeometry(QRectF(25, 25, 50, 50)); + + //We put a QGraphicsItem to be sure this one is also paint + RectItem *childitem = new RectItem(Qt::blue, clipWidget); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + + QList<QGraphicsItem *> expected; + expected << clipWidget << childWidget << childitem; + QVERIFY(scene.drawnItems.contains(clipWidget)); + QVERIFY(scene.drawnItems.contains(childWidget)); + QVERIFY(scene.drawnItems.contains(childitem)); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 13aa2b8..8590eac 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -266,6 +266,9 @@ tst_QMenu::addActionsAndClear() void tst_QMenu::mouseActivation() { +#ifdef Q_OS_WINCE_WM + QSKIP("We have a separate mouseActivation test for Windows mobile.", SkipAll); +#endif QMenu menu; menu.addAction("Menu Action"); menu.show(); diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index a0c56ed..ef609e0 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -559,6 +559,11 @@ static QScriptValue custom_eval(QScriptContext *ctx, QScriptEngine *eng) return eng->evaluate(ctx->argumentsObject().property(0).toString(), ctx->argumentsObject().property(1).toString()); } +static QScriptValue custom_call(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->argumentsObject().property(0).call(QScriptValue(), QScriptValueList() << ctx->argumentsObject().property(1)); +} + void tst_QScriptContext::backtrace_data() { QTest::addColumn<QString>("code"); @@ -681,7 +686,36 @@ void tst_QScriptContext::backtrace_data() QTest::newRow("two function") << source << expected; } + { + QString func("function foo(a, b) {\n" + " return bt(a);\n" + "}"); + + QString source = func + QString::fromLatin1("\n" + "custom_call(foo, 'hello');\n" + "var a = 1\n"); + + QStringList expected; + expected << "<native>('hello') at -1" + << "foo(a = 'hello') at testfile:2" + << QString("<native>(%1, 'hello') at -1").arg(func) + << "<global>() at testfile:4"; + QTest::newRow("call") << source << expected; + } + + { + QString source = QString::fromLatin1("\n" + "custom_call(bt, 'hello_world');\n" + "var a = 1\n"); + + QStringList expected; + expected << "<native>('hello_world') at -1" + << "<native>(function () {\n [native code]\n}, 'hello_world') at -1" + << "<global>() at testfile:2"; + + QTest::newRow("call native") << source << expected; + } } @@ -693,6 +727,7 @@ void tst_QScriptContext::backtrace() QScriptEngine eng; eng.globalObject().setProperty("bt", eng.newFunction(getBacktrace)); eng.globalObject().setProperty("custom_eval", eng.newFunction(custom_eval)); + eng.globalObject().setProperty("custom_call", eng.newFunction(custom_call)); QString fileName = "testfile"; QScriptValue ret = eng.evaluate(code, fileName); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 85cee28..0c67987 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1518,15 +1518,29 @@ static QScriptValue eval_nested(QScriptContext *ctx, QScriptEngine *eng) void tst_QScriptEngine::nestedEvaluate() { QScriptEngine eng; - eng.globalObject().setProperty("fun", eng.newFunction(eval_nested)); - QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()"); - QCOMPARE(result.property("local_bar").toString(), QString("local")); - QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); - QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); - QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); - QScriptValue bar = eng.evaluate("bar"); - QVERIFY(bar.isError()); - QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar")); + QScriptValue fun = eng.newFunction(eval_nested); + eng.globalObject().setProperty("fun", fun); + { + QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()"); + QCOMPARE(result.property("local_bar").toString(), QString("local")); + QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); + QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); + QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); + QScriptValue bar = eng.evaluate("bar"); + QVERIFY(bar.isError()); + QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar")); + } + + { + QScriptValue result = fun.call(eng.evaluate("p = { id:'foo' }") , QScriptValueList() ); + QCOMPARE(result.property("local_bar").toString(), QString("local")); + QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); + QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); + QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); + QScriptValue bar = eng.evaluate("bar"); + QVERIFY(bar.isError()); + QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar")); + } } void tst_QScriptEngine::uncaughtException() diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp index 70a198d..5cf27d3 100644 --- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp +++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp @@ -745,6 +745,9 @@ private: void tst_QScriptEngineDebugger::multithreadedDebugging() { +#ifdef Q_OS_WINCE + QSKIP("This tests uses too much memory for Windows CE", SkipAll); +#endif ScriptEvaluator eval; QThread thread; eval.moveToThread(&thread); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 16a9e87..3f231f2 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2504,6 +2504,13 @@ void tst_QScriptValue::call() QScriptValue ret5 = fun.call(QScriptValue(), QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); } + + // calling things that are not functions + QVERIFY(!QScriptValue(false).call().isValid()); + QVERIFY(!QScriptValue(123).call().isValid()); + QVERIFY(!QScriptValue(QString::fromLatin1("ciao")).call().isValid()); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).call().isValid()); + QVERIFY(!QScriptValue(QScriptValue::NullValue).call().isValid()); } static QScriptValue ctorReturningUndefined(QScriptContext *ctx, QScriptEngine *) @@ -2629,6 +2636,13 @@ void tst_QScriptValue::construct() QScriptValue ret5 = fun.construct(QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); } + + // construct on things that are not functions + QVERIFY(!QScriptValue(false).construct().isValid()); + QVERIFY(!QScriptValue(123).construct().isValid()); + QVERIFY(!QScriptValue(QString::fromLatin1("ciao")).construct().isValid()); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).construct().isValid()); + QVERIFY(!QScriptValue(QScriptValue::NullValue).construct().isValid()); } void tst_QScriptValue::lessThan() diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index ba5ef70..85ecf6b 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -181,6 +181,7 @@ private slots: void ignoreSslErrorsList(); void ignoreSslErrorsListWithSlot_data(); void ignoreSslErrorsListWithSlot(); + void readFromClosedSocket(); static void exitLoop() { @@ -1668,6 +1669,34 @@ void tst_QSslSocket::ignoreSslErrorsListWithSlot() QCOMPARE(socket.waitForEncrypted(10000), expectEncryptionSuccess); } +// make sure a closed socket has no bytesAvailable() +// related to https://bugs.webkit.org/show_bug.cgi?id=28016 +void tst_QSslSocket::readFromClosedSocket() +{ + QSslSocketPtr socket = newSocket(); + socket->ignoreSslErrors(); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->ignoreSslErrors(); + socket->waitForConnected(); + socket->waitForEncrypted(); + // provoke a response by sending a request + socket->write("GET /gif/fluke.gif HTTP/1.1\n"); + socket->write("Host: "); + socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write("\n"); + socket->write("\n"); + socket->waitForBytesWritten(); + socket->waitForReadyRead(); + QVERIFY(socket->state() == QAbstractSocket::ConnectedState); + QVERIFY(socket->bytesAvailable()); + socket->close(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); + socket->waitForDisconnected(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp index d8c4f51..dbba9ef 100644 --- a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +++ b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp @@ -71,6 +71,7 @@ private slots: void wrapAtWordBoundaryOrAnywhere(); void inlineImage(); void clippedTableCell(); + void floatingTablePageBreak(); private: QTextDocument *doc; @@ -250,5 +251,25 @@ void tst_QTextDocumentLayout::clippedTableCell() QCOMPARE(img, expected); } +void tst_QTextDocumentLayout::floatingTablePageBreak() +{ + doc->clear(); + + QTextCursor cursor(doc); + + QTextTableFormat tableFormat; + tableFormat.setPosition(QTextFrameFormat::FloatLeft); + QTextTable *table = cursor.insertTable(50, 1, tableFormat); + + // Make height of document 2/3 of the table, fitting the table into two pages + QSizeF documentSize = doc->size(); + documentSize.rheight() *= 2.0 / 3.0; + + doc->setPageSize(documentSize); + + QCOMPARE(doc->pageCount(), 2); +} + + QTEST_MAIN(tst_QTextDocumentLayout) #include "tst_qtextdocumentlayout.moc" diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp index 0ccc0aa..9473648 100644 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ b/tests/auto/qtwidgets/tst_qtwidgets.cpp @@ -86,9 +86,9 @@ void tst_QtWidgets::snapshot() QString filename = "qtwidgets_" + QHostInfo::localHostName() + "_" + QDateTime::currentDateTime().toString("yyyy.MM.dd_hh.mm.ss") + ".png"; QFtp ftp; - ftp.connectToHost("kramer.troll.no"); - ftp.login("anonymous"); - ftp.cd("pics"); + ftp.connectToHost("qt-test-server.qt-test-net"); + ftp.login("ftptest", "password"); + ftp.cd("qtest/pics"); ftp.put(buf.data(), filename, QFtp::Binary); ftp.close(); diff --git a/tests/auto/windowsmobile/test/testSimpleWidget_current.png b/tests/auto/windowsmobile/test/testSimpleWidget_current.png Binary files differindex 5cbc2bb..09a10a3 100644 --- a/tests/auto/windowsmobile/test/testSimpleWidget_current.png +++ b/tests/auto/windowsmobile/test/testSimpleWidget_current.png diff --git a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp index 73ea0a6..091504c 100644 --- a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp +++ b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp @@ -62,14 +62,14 @@ public: #endif } -#ifdef Q_OS_WINCE_WM +#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 private slots: void testMainWindowAndMenuBar(); void testSimpleWidget(); #endif }; -#ifdef Q_OS_WINCE_WM +#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 bool qt_wince_is_platform(const QString &platformString) { wchar_t tszPlatform[64]; @@ -120,8 +120,6 @@ void openMenu() void compareScreenshots(const QString &image1, const QString &image2) { - if (qt_wince_is_smartphone()) - QSKIP("This test is only for Windows Mobile", SkipAll); QImage screenShot(image1); QImage original(image2); @@ -145,6 +143,9 @@ void takeScreenShot(const QString filename) void tst_WindowsMobile::testMainWindowAndMenuBar() { + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QProcess process; process.start("testQMenuBar.exe"); QCOMPARE(process.state(), QProcess::Running); @@ -158,6 +159,9 @@ void tst_WindowsMobile::testMainWindowAndMenuBar() void tst_WindowsMobile::testSimpleWidget() { + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QMenuBar menubar; menubar.show(); QWidget maximized; diff --git a/tests/auto/windowsmobile/testQMenuBar/main.cpp b/tests/auto/windowsmobile/testQMenuBar/main.cpp index 4949dbb..f615c48 100644 --- a/tests/auto/windowsmobile/testQMenuBar/main.cpp +++ b/tests/auto/windowsmobile/testQMenuBar/main.cpp @@ -48,8 +48,6 @@ int main(int argc, char * argv[]) { - int widgetNum = 20; - QList<QWidget*> widgets; QApplication app(argc, argv); |