diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-07-30 13:28:49 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-07-30 13:28:49 (GMT) |
commit | a08b3f5336e5c819b33d922d3a809b5203d728f3 (patch) | |
tree | 952f42304d50f28ed6651bace587ab7935b29cd0 /tests | |
parent | 813fc3574a006cb2687715ccf7bdb984a485b173 (diff) | |
parent | 188ac02e2fb6cc6437b776f8c5b69a508728fbdb (diff) | |
download | Qt-a08b3f5336e5c819b33d922d3a809b5203d728f3.zip Qt-a08b3f5336e5c819b33d922d3a809b5203d728f3.tar.gz Qt-a08b3f5336e5c819b33d922d3a809b5203d728f3.tar.bz2 |
Merge commit 'qt/master-stable'
Conflicts:
demos/demos.pro
src/gui/graphicsview/qgraphicsitem_p.h
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 158 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 69 | ||||
-rw-r--r-- | tests/auto/qgraphicstransform/qgraphicstransform.pro | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp | 162 | ||||
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qsqldatabase/tst_databases.h | 10 | ||||
-rw-r--r-- | tests/auto/qxml/tst_qxml.cpp | 26 | ||||
-rw-r--r-- | tests/auto/selftests/cmptest/tst_cmptest.cpp | 46 | ||||
-rw-r--r-- | tests/auto/selftests/expected_cmptest.txt | 20 |
10 files changed, 382 insertions, 126 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 9f1693d..7f6f322 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -44,6 +44,7 @@ #include <private/qtextcontrol_p.h> #include <private/qgraphicsitem_p.h> +#include <private/qgraphicsview_p.h> #include <QStyleOptionGraphicsItem> #include <QAbstractTextDocumentLayout> #include <QBitmap> @@ -6884,44 +6885,21 @@ void tst_QGraphicsItem::update() void tst_QGraphicsItem::setTransformProperties_data() { QTest::addColumn<QPointF>("origin"); - QTest::addColumn<qreal>("rotationX"); - QTest::addColumn<qreal>("rotationY"); - QTest::addColumn<qreal>("rotationZ"); - QTest::addColumn<qreal>("scaleX"); - QTest::addColumn<qreal>("scaleY"); - QTest::addColumn<qreal>("shearX"); - QTest::addColumn<qreal>("shearY"); + QTest::addColumn<qreal>("rotation"); + QTest::addColumn<qreal>("scale"); - QTest::newRow("nothing") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0) - << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0); + QTest::newRow("nothing") << QPointF() << qreal(0.0) << qreal(1.0); - QTest::newRow("rotationZ") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(42.2) - << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0); + QTest::newRow("rotation") << QPointF() << qreal(42.2) << qreal(1.0); - QTest::newRow("rotationXY") << QPointF() << qreal(12.5) << qreal(53.6) << qreal(0.0) - << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0); + QTest::newRow("rotation dicentred") << QPointF(qreal(22.3), qreal(-56.2)) + << qreal(-2578.2) + << qreal(1.0); - QTest::newRow("rotationXYZ") << QPointF() << qreal(-25) << qreal(12) << qreal(556) - << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0); + QTest::newRow("Scale") << QPointF() << qreal(0.0) + << qreal(6); - QTest::newRow("rotationXYZ dicentred") << QPointF(-53, 25.2) - << qreal(-2578.2) << qreal(4565.2) << qreal(56) - << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0); - - QTest::newRow("Scale") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0) - << qreal(6) << qreal(0.5) << qreal(0.0) << qreal(0.0); - - QTest::newRow("Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0) - << qreal(1.0) << qreal(1.0) << qreal(2.2) << qreal(0.5); - - QTest::newRow("Scale and Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0) - << qreal(5.2) << qreal(2.1) << qreal(5.2) << qreal(5.5); - - QTest::newRow("Everything") << QPointF() << qreal(41) << qreal(-23) << qreal(0.56) - << qreal(8.2) << qreal(-0.2) << qreal(-12) << qreal(-0.8); - - QTest::newRow("Everything dicentred") << QPointF(qreal(22.3), qreal(-56.2)) << qreal(-175) << qreal(196) << qreal(-1260) - << qreal(4) << qreal(2) << qreal(2.56) << qreal(0.8); + QTest::newRow("Everything dicentred") << QPointF(qreal(22.3), qreal(-56.2)) << qreal(-175) << qreal(196); } /** @@ -6932,92 +6910,61 @@ void tst_QGraphicsItem::setTransformProperties_data() void tst_QGraphicsItem::setTransformProperties() { QFETCH(QPointF,origin); - QFETCH(qreal,rotationX); - QFETCH(qreal,rotationY); - QFETCH(qreal,rotationZ); - QFETCH(qreal,scaleX); - QFETCH(qreal,scaleY); - QFETCH(qreal,shearX); - QFETCH(qreal,shearY); + QFETCH(qreal,rotation); + QFETCH(qreal,scale); QTransform result; result.translate(origin.x(), origin.y()); - result.rotate(rotationX, Qt::XAxis); - result.rotate(rotationY, Qt::YAxis); - result.rotate(rotationZ, Qt::ZAxis); - result.shear(shearX, shearY); - result.scale(scaleX, scaleY); + result.rotate(rotation, Qt::ZAxis); + result.scale(scale, scale); result.translate(-origin.x(), -origin.y()); QGraphicsScene scene; QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100)); scene.addItem(item); - item->setRotation(rotationX, rotationY, rotationZ); - item->setScale(scaleX, scaleY); - item->setShear(shearX, shearY); - item->setTransformOrigin(origin); + item->setRotation(rotation); + item->setScale(scale); + item->setTransformOriginPoint(origin); - QCOMPARE(item->xRotation(), rotationX); - QCOMPARE(item->yRotation(), rotationY); - QCOMPARE(item->zRotation(), rotationZ); - QCOMPARE(item->xScale(), scaleX); - QCOMPARE(item->yScale(), scaleY); - QCOMPARE(item->horizontalShear(), shearX); - QCOMPARE(item->verticalShear(), shearY); - QCOMPARE(item->transformOrigin(), origin); + QCOMPARE(item->rotation(), rotation); + QCOMPARE(item->scale(), scale); + QCOMPARE(item->transformOriginPoint(), origin); QCOMPARE(QTransform(), item->transform()); QCOMPARE(result, item->sceneTransform()); //----------------------------------------------------------------- //Change the rotation Z - item->setZRotation(45); + item->setRotation(45); QTransform result2; result2.translate(origin.x(), origin.y()); - result2.rotate(rotationX, Qt::XAxis); - result2.rotate(rotationY, Qt::YAxis); - result2.rotate(45, Qt::ZAxis); - result2.shear(shearX, shearY); - result2.scale(scaleX, scaleY); + result2.rotate(45); + result2.scale(scale, scale); result2.translate(-origin.x(), -origin.y()); - QCOMPARE(item->xRotation(), rotationX); - QCOMPARE(item->yRotation(), rotationY); - QCOMPARE(item->zRotation(), 45.0); - QCOMPARE(item->xScale(), scaleX); - QCOMPARE(item->yScale(), scaleY); - QCOMPARE(item->horizontalShear(), shearX); - QCOMPARE(item->verticalShear(), shearY); - QCOMPARE(item->transformOrigin(), origin); + QCOMPARE(item->rotation(), 45.); + QCOMPARE(item->scale(), scale); + QCOMPARE(item->transformOriginPoint(), origin); QCOMPARE(QTransform(), item->transform()); QCOMPARE(result2, item->sceneTransform()); //----------------------------------------------------------------- - // calling setTransform() and setPos shoukld change the sceneTransform + // calling setTransform() and setPos should change the sceneTransform item->setTransform(result); item->setPos(100, -150.5); - QCOMPARE(item->xRotation(), rotationX); - QCOMPARE(item->yRotation(), rotationY); - QCOMPARE(item->zRotation(), 45.0); - QCOMPARE(item->xScale(), scaleX); - QCOMPARE(item->yScale(), scaleY); - QCOMPARE(item->horizontalShear(), shearX); - QCOMPARE(item->verticalShear(), shearY); - QCOMPARE(item->transformOrigin(), origin); + QCOMPARE(item->rotation(), 45.); + QCOMPARE(item->scale(), scale); + QCOMPARE(item->transformOriginPoint(), origin); QCOMPARE(result, item->transform()); - QTransform result3; + QTransform result3(result); result3.translate(origin.x(), origin.y()); - result3 = result * result3; - result3.rotate(rotationX, Qt::XAxis); - result3.rotate(rotationY, Qt::YAxis); - result3.rotate(45, Qt::ZAxis); - result3.shear(shearX, shearY); - result3.scale(scaleX, scaleY); + result3.rotate(45); + result3.scale(scale, scale); result3.translate(-origin.x(), -origin.y()); result3 *= QTransform::fromTranslate(100, -150.5); //the pos; @@ -7034,10 +6981,9 @@ void tst_QGraphicsItem::setTransformProperties() item1->setPos(12.3, -5); item2->setPos(12.3, -5); - item1->setRotation(rotationX, rotationY, rotationZ); - item1->setScale(scaleX, scaleY); - item1->setShear(shearX, shearY); - item1->setTransformOrigin(origin); + item1->setRotation(rotation); + item1->setScale(scale); + item1->setTransformOriginPoint(origin); item2->setTransform(result); @@ -7046,36 +6992,6 @@ void tst_QGraphicsItem::setTransformProperties() QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform()); QCOMPARE_TRANSFORM(item2->itemTransform(item1), QTransform()); } - - {//with center origin on the item - QGraphicsRectItem *item1 = new QGraphicsRectItem(QRectF(50.2, -150, 230.5, 119)); - scene.addItem(item1); - QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(50.2, -150, 230.5, 119)); - scene.addItem(item2); - - item1->setPos(12.3, -5); - item2->setPos(12.3, -5); - item1->setTransformOrigin(origin); - item2->setTransformOrigin(origin); - - item1->setRotation(rotationX, rotationY, rotationZ); - item1->setScale(scaleX, scaleY); - item1->setShear(shearX, shearY); - - QTransform tr; - tr.rotate(rotationX, Qt::XAxis); - tr.rotate(rotationY, Qt::YAxis); - tr.rotate(rotationZ, Qt::ZAxis); - tr.shear(shearX, shearY); - tr.scale(scaleX, scaleY); - - item2->setTransform(tr); - - QCOMPARE_TRANSFORM(item1->sceneTransform(), item2->sceneTransform()); - - QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform()); - QCOMPARE_TRANSFORM(item2->itemTransform(item1), QTransform()); - } } class MyStyleOptionTester : public QGraphicsRectItem diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 27b1da6..d3b8883 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -263,6 +263,7 @@ private slots: void sendEvent(); void inputMethod_data(); void inputMethod(); + void dispatchHoverOnPress(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3729,5 +3730,73 @@ void tst_QGraphicsScene::inputMethod() QCOMPARE(item->queryCalls, 0); } +void tst_QGraphicsScene::dispatchHoverOnPress() +{ + QGraphicsScene scene; + EventTester *tester1 = new EventTester; + tester1->setAcceptHoverEvents(true); + EventTester *tester2 = new EventTester; + tester2->setAcceptHoverEvents(true); + tester2->setPos(30, 30); + scene.addItem(tester1); + scene.addItem(tester2); + + tester1->eventTypes.clear(); + tester2->eventTypes.clear(); + + { + QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress); + me.setButton(Qt::LeftButton); + me.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); + me2.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + << QEvent::GraphicsSceneHoverEnter + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + tester1->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + } + { + QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress); + me.setScenePos(QPointF(30, 30)); + me.setButton(Qt::LeftButton); + me.setButtons(Qt::LeftButton); + QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); + me2.setScenePos(QPointF(30, 30)); + me2.setButton(Qt::LeftButton); + tester1->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + qDebug() << tester1->eventTypes; + QCOMPARE(tester1->eventTypes, QList<QEvent::Type>() + << QEvent::GraphicsSceneHoverLeave); + QCOMPARE(tester2->eventTypes, QList<QEvent::Type>() + << QEvent::GraphicsSceneHoverEnter + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + tester2->eventTypes.clear(); + qApp->sendEvent(&scene, &me); + qApp->sendEvent(&scene, &me2); + QCOMPARE(tester2->eventTypes, QList<QEvent::Type>() + << QEvent::GraphicsSceneHoverMove + << QEvent::GrabMouse + << QEvent::GraphicsSceneMousePress + << QEvent::UngrabMouse); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicstransform/qgraphicstransform.pro b/tests/auto/qgraphicstransform/qgraphicstransform.pro new file mode 100644 index 0000000..709cff6 --- /dev/null +++ b/tests/auto/qgraphicstransform/qgraphicstransform.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qgraphicstransform.cpp diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp new file mode 100644 index 0000000..672b1f1 --- /dev/null +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> +#include <qgraphicsitem.h> +#include <qgraphicstransform.h> +#include "../../shared/util.h" + +class tst_QGraphicsTransform : public QObject { + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void scale(); + void rotation(); + void rotation3d(); +}; + + +// This will be called before the first test function is executed. +// It is only called once. +void tst_QGraphicsTransform::initTestCase() +{ +} + +// This will be called after the last test function is executed. +// It is only called once. +void tst_QGraphicsTransform::cleanupTestCase() +{ +} + +// This will be called before each test function is executed. +void tst_QGraphicsTransform::init() +{ +} + +// This will be called after every test function. +void tst_QGraphicsTransform::cleanup() +{ +} + + +void tst_QGraphicsTransform::scale() +{ + QGraphicsScale scale; + scale.setOrigin(QPointF(10, 10)); + + QTransform t; + scale.applyTo(&t); + + QCOMPARE(t, QTransform()); + QCOMPARE(scale.transform(), QTransform()); + + scale.setXScale(10); + scale.setOrigin(QPointF(0, 0)); + + QTransform res; + res.scale(10, 1); + + QCOMPARE(scale.transform(), res); + QCOMPARE(scale.transform().map(QPointF(10, 10)), QPointF(100, 10)); + + scale.setOrigin(QPointF(10, 10)); + QCOMPARE(scale.transform().map(QPointF(10, 10)), QPointF(10, 10)); + QCOMPARE(scale.transform().map(QPointF(11, 10)), QPointF(20, 10)); +} + +void tst_QGraphicsTransform::rotation() +{ + QGraphicsRotation rotation; + rotation.setOrigin(QPointF(10, 10)); + + QTransform t; + rotation.applyTo(&t); + + QCOMPARE(t, QTransform()); + QCOMPARE(rotation.transform(), QTransform()); + + rotation.setAngle(40); + rotation.setOrigin(QPointF(0, 0)); + + QTransform res; + res.rotate(40); + + QCOMPARE(rotation.transform(), res); + + rotation.setOrigin(QPointF(10, 10)); + rotation.setAngle(90); + QCOMPARE(rotation.transform().map(QPointF(10, 10)), QPointF(10, 10)); + QCOMPARE(rotation.transform().map(QPointF(20, 10)), QPointF(10, 20)); +} + +void tst_QGraphicsTransform::rotation3d() +{ + QGraphicsRotation3D rotation; + rotation.setOrigin(QPointF(10, 10)); + + QTransform t; + rotation.applyTo(&t); + + QCOMPARE(t, QTransform()); + QCOMPARE(rotation.transform(), QTransform()); + + rotation.setAngle(180); + + QCOMPARE(t, QTransform()); + QCOMPARE(rotation.transform(), QTransform()); + + rotation.setOrigin(QPointF(0, 0)); + + QCOMPARE(t, QTransform()); + QCOMPARE(rotation.transform(), QTransform()); +} + + +QTEST_MAIN(tst_QGraphicsTransform) +#include "tst_qgraphicstransform.moc" + diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 78d13d3..2cfedb1 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1315,6 +1315,12 @@ void tst_QGraphicsWidget::focusNextPrevChild() void tst_QGraphicsWidget::verifyFocusChain() { QGraphicsScene scene; + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); { // parent/child focus SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window); @@ -1448,6 +1454,11 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + // delete item in focus chain with no focus and verify chain SubQGraphicsWidget *parent = new SubQGraphicsWidget(0, Qt::Window); SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window); diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 4991549..65be4fe 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -235,6 +235,9 @@ extern int forwardDeclaredDestructorRunCount; void tst_QSharedPointer::forwardDeclaration1() { +#if defined(Q_CC_SUN) + QSKIP("This type of forward declaration is not valid with this compiler", SkipAll); +#else externalForwardDeclaration(); struct Wrapper { QSharedPointer<ForwardDeclared> pointer; }; @@ -246,6 +249,7 @@ void tst_QSharedPointer::forwardDeclaration1() QVERIFY(!w.pointer.isNull()); } QCOMPARE(forwardDeclaredDestructorRunCount, 1); +#endif } #include "forwarddeclared.h" diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 9c8c313..8253541 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -335,7 +335,7 @@ public: if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) { table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName); wasDropped = q.exec( "drop table " + table); - dbtables.removeAll(table); + dbtables.removeAll(table2); } } } @@ -430,8 +430,8 @@ public: return "IDENTITY"; /* if ( db.driverName().startsWith( "QPSQL" ) ) return "SERIAL";*/ - if ( db.driverName().startsWith( "QDB2" ) ) - return "GENERATED BY DEFAULT AS IDENTITY"; +// if ( db.driverName().startsWith( "QDB2" ) ) +// return "GENERATED BY DEFAULT AS IDENTITY"; return QString(); } @@ -483,6 +483,10 @@ public: { return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); } + static bool isDB2( QSqlDatabase db ) + { + return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") ); + } // -1 on fail, else Oracle version static int getOraVersion( QSqlDatabase db ) diff --git a/tests/auto/qxml/tst_qxml.cpp b/tests/auto/qxml/tst_qxml.cpp index 13de82f..1bc5ef5 100644 --- a/tests/auto/qxml/tst_qxml.cpp +++ b/tests/auto/qxml/tst_qxml.cpp @@ -57,6 +57,7 @@ Q_OBJECT private slots: void getSetCheck(); void interpretedAs0D() const; + void exception(); }; class MyXmlEntityResolver : public QXmlEntityResolver @@ -213,5 +214,30 @@ void tst_QXml::interpretedAs0D() const QCOMPARE(myHandler.attrName, QChar(0x010D) + QString::fromLatin1("reated-by")); } +void tst_QXml::exception() +{ +#ifndef QT_NO_EXCEPTIONS + QString message = QString::fromLatin1("message"); + int column = 3; + int line = 2; + QString publicId = QString::fromLatin1("publicId"); + QString systemId = QString::fromLatin1("systemId"); + + try { + QXmlParseException e(message, column, line, publicId, systemId); + throw e; + } + catch (QXmlParseException e) { + QCOMPARE(e.message(), message); + QCOMPARE(e.columnNumber(), column); + QCOMPARE(e.lineNumber(), line); + QCOMPARE(e.publicId(), publicId); + QCOMPARE(e.systemId(), systemId); + } +#else + QSKIP("Exceptions not available", SkipAll); +#endif +} + QTEST_MAIN(tst_QXml) #include "tst_qxml.moc" diff --git a/tests/auto/selftests/cmptest/tst_cmptest.cpp b/tests/auto/selftests/cmptest/tst_cmptest.cpp index 59dd678..7395210 100644 --- a/tests/auto/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/selftests/cmptest/tst_cmptest.cpp @@ -50,6 +50,8 @@ class tst_Cmptest: public QObject private slots: void compare_boolfuncs(); void compare_pointerfuncs(); + void compare_tostring(); + void compare_tostring_data(); }; static bool boolfunc() { return true; } @@ -76,6 +78,50 @@ void tst_Cmptest::compare_pointerfuncs() QCOMPARE(&i, intptr()); } +Q_DECLARE_METATYPE(QVariant) + +class PhonyClass +{}; + +void tst_Cmptest::compare_tostring_data() +{ + QTest::addColumn<QVariant>("actual"); + QTest::addColumn<QVariant>("expected"); + + QTest::newRow("int, string") + << QVariant::fromValue(123) + << QVariant::fromValue(QString("hi")) + ; + + QTest::newRow("both invalid") + << QVariant() + << QVariant() + ; + + QTest::newRow("null hash, invalid") + << QVariant(QVariant::Hash) + << QVariant() + ; + + QTest::newRow("string, null user type") + << QVariant::fromValue(QString::fromLatin1("A simple string")) + << QVariant(QVariant::Type(qRegisterMetaType<PhonyClass>("PhonyClass"))) + ; + + QTest::newRow("both non-null user type") + << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0) + << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0) + ; +} + +void tst_Cmptest::compare_tostring() +{ + QFETCH(QVariant, actual); + QFETCH(QVariant, expected); + + QCOMPARE(actual, expected); +} + QTEST_MAIN(tst_Cmptest) #include "tst_cmptest.moc" diff --git a/tests/auto/selftests/expected_cmptest.txt b/tests/auto/selftests/expected_cmptest.txt index dc89d9d..f70eba5 100644 --- a/tests/auto/selftests/expected_cmptest.txt +++ b/tests/auto/selftests/expected_cmptest.txt @@ -1,8 +1,24 @@ ********* Start testing of tst_Cmptest ********* -Config: Using QTest library 4.1.0, Qt 4.1.0 +Config: Using QTest library 4.6.0, Qt 4.6.0 PASS : tst_Cmptest::initTestCase() PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() +FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same + Actual (actual): QVariant(int,123) + Expected (expected): QVariant(QString,hi) + Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)] +FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same + Actual (actual): QVariant(QVariantHash) + Expected (expected): QVariant() + Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)] +FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same + Actual (actual): QVariant(QString,A simple string) + Expected (expected): QVariant(PhonyClass) + Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)] +FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same + Actual (actual): QVariant(PhonyClass,<value not representable as string>) + Expected (expected): QVariant(PhonyClass,<value not representable as string>) + Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)] PASS : tst_Cmptest::cleanupTestCase() -Totals: 4 passed, 0 failed, 0 skipped +Totals: 4 passed, 4 failed, 0 skipped ********* Finished testing of tst_Cmptest ********* |