summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-10-27 08:32:25 (GMT)
committeraxis <qt-info@nokia.com>2009-10-27 08:32:25 (GMT)
commit51bfafed59d77b791f0266fa1bfc36634597c5c4 (patch)
tree630d9fbc5aad375950b03d80cf775c228f31a741 /tests
parentcb3a2633bb9d8a0e949c403d0f0631caef254599 (diff)
parent5a4909d9f87b9abf471908a085c0e9f31b7e0a50 (diff)
downloadQt-51bfafed59d77b791f0266fa1bfc36634597c5c4.zip
Qt-51bfafed59d77b791f0266fa1bfc36634597c5c4.tar.gz
Qt-51bfafed59d77b791f0266fa1bfc36634597c5c4.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp69
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp21
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp56
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp14
4 files changed, 151 insertions, 9 deletions
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index eb5c099..d8ab06e 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -59,6 +59,8 @@ private slots:
void rotation();
void rotation3d_data();
void rotation3d();
+ void rotation3dArbitraryAxis_data();
+ void rotation3dArbitraryAxis();
};
@@ -88,7 +90,7 @@ static QTransform transform2D(const QGraphicsTransform& t)
{
QMatrix4x4 m;
t.applyTo(&m);
- return m.toTransform(0);
+ return m.toTransform();
}
void tst_QGraphicsTransform::scale()
@@ -255,6 +257,19 @@ void tst_QGraphicsTransform::rotation3d()
QVERIFY(fuzzyCompare(transform2D(rotation), expected));
+ // Check that "rotation" produces the 4x4 form of the 3x3 matrix.
+ // i.e. third row and column are 0 0 1 0.
+ t.setIdentity();
+ rotation.applyTo(&t);
+ QMatrix4x4 r(expected);
+ if (sizeof(qreal) == sizeof(float) && angle == 268) {
+ // This test fails, on only this angle, when qreal == float
+ // because the deg2rad value in QTransform is not accurate
+ // enough to match what QMatrix4x4 is doing.
+ } else {
+ QVERIFY(qFuzzyCompare(t, r));
+ }
+
//now let's check that a null vector will not change the transform
rotation.setAxis(QVector3D(0, 0, 0));
rotation.setOrigin(QVector3D(10, 10, 0));
@@ -276,6 +291,58 @@ void tst_QGraphicsTransform::rotation3d()
QVERIFY(transform2D(rotation).isIdentity());
}
+void tst_QGraphicsTransform::rotation3dArbitraryAxis_data()
+{
+ QTest::addColumn<QVector3D>("axis");
+ QTest::addColumn<qreal>("angle");
+
+ QVector3D axis1 = QVector3D(1.0f, 1.0f, 1.0f);
+ QVector3D axis2 = QVector3D(2.0f, -3.0f, 0.5f);
+ QVector3D axis3 = QVector3D(-2.0f, 0.0f, -0.5f);
+ QVector3D axis4 = QVector3D(0.0001f, 0.0001f, 0.0001f);
+ QVector3D axis5 = QVector3D(0.01f, 0.01f, 0.01f);
+
+ for (int angle = 0; angle <= 360; angle++) {
+ QTest::newRow("test rotation on (1, 1, 1)") << axis1 << qreal(angle);
+ QTest::newRow("test rotation on (2, -3, .5)") << axis2 << qreal(angle);
+ QTest::newRow("test rotation on (-2, 0, -.5)") << axis3 << qreal(angle);
+ QTest::newRow("test rotation on (.0001, .0001, .0001)") << axis4 << qreal(angle);
+ QTest::newRow("test rotation on (.01, .01, .01)") << axis5 << qreal(angle);
+ }
+}
+
+void tst_QGraphicsTransform::rotation3dArbitraryAxis()
+{
+ QFETCH(QVector3D, axis);
+ QFETCH(qreal, angle);
+
+ QGraphicsRotation rotation;
+ rotation.setAxis(axis);
+
+ QMatrix4x4 t;
+ rotation.applyTo(&t);
+
+ QVERIFY(t.isIdentity());
+ QVERIFY(transform2D(rotation).isIdentity());
+
+ rotation.setAngle(angle);
+
+ // Compute the expected answer using QMatrix4x4 and a projection.
+ // These two steps are performed in one hit by QGraphicsRotation.
+ QMatrix4x4 exp;
+ exp.rotate(angle, axis);
+ QTransform expected = exp.toTransform(1024.0f);
+
+ QVERIFY(fuzzyCompare(transform2D(rotation), expected));
+
+ // Check that "rotation" produces the 4x4 form of the 3x3 matrix.
+ // i.e. third row and column are 0 0 1 0.
+ t.setIdentity();
+ rotation.applyTo(&t);
+ QMatrix4x4 r(expected);
+ QVERIFY(qFuzzyCompare(t, r));
+}
+
QTEST_MAIN(tst_QGraphicsTransform)
#include "tst_qgraphicstransform.moc"
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 9f5aee2..53b6230 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -166,6 +166,7 @@ private slots:
void fromImage_crash();
void fromData();
+ void loadFromDataNullValues();
void preserveDepth();
};
@@ -1436,6 +1437,26 @@ void tst_QPixmap::fromData()
QCOMPARE(img.pixel(0, 1), QRgb(0xff000000));
}
+void tst_QPixmap::loadFromDataNullValues()
+{
+ {
+ QPixmap pixmap;
+ pixmap.loadFromData(QByteArray());
+ QVERIFY(pixmap.isNull());
+ }
+ {
+ QPixmap pixmap;
+ pixmap.loadFromData(0, 123);
+ QVERIFY(pixmap.isNull());
+ }
+ {
+ QPixmap pixmap;
+ const uchar bla[] = "bla";
+ pixmap.loadFromData(bla, 0);
+ QVERIFY(pixmap.isNull());
+ }
+}
+
void tst_QPixmap::task_246446()
{
// This crashed without the bugfix in 246446
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 8fe6f2e..4d9e50f 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -193,6 +193,8 @@ private slots:
void sqlServerReturn0_data() { generic_data(); }
void sqlServerReturn0();
+ void QTBUG_551_data() { generic_data("QOCI"); }
+ void QTBUG_551();
private:
// returns all database connections
@@ -322,6 +324,11 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
tablenames << qTableName("test141895");
tst_Databases::safeDropTables( db, tablenames );
+
+ if ( db.driverName().startsWith( "QOCI" ) ) {
+ QSqlQuery q( db );
+ q.exec( "DROP PACKAGE " + qTableName("pkg") );
+ }
}
void tst_QSqlQuery::createTestTables( QSqlDatabase db )
@@ -396,7 +403,7 @@ void tst_QSqlQuery::char1SelectUnicode()
QSKIP("Needs someone with more Unicode knowledge than I have to fix", SkipSingle);
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
- QString uniStr( QChar( 'का' ) );
+ QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA
QSqlQuery q( db );
if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
@@ -2847,5 +2854,52 @@ void tst_QSqlQuery::sqlServerReturn0()
QVERIFY_SQL(q, next());
}
+void tst_QSqlQuery::QTBUG_551()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+ QSqlQuery q(db);
+ QString pkgname=qTableName("pkg");
+ QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\
+ \n\
+ TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\
+ TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\
+ PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\
+ END "+pkgname+";"));
+
+ QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\
+ PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\
+ IS\n\
+ BEGIN\n\
+ Outp(1) := '1. Value is ' ||TO_CHAR(Inp(1));\n\
+ Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\
+ Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\
+ END p;\n\
+ END "+pkgname+";"));
+
+ QVariantList inLst, outLst, res_outLst;
+
+ q.prepare("begin "+pkgname+".p(:inp, :outp); end;");
+
+ QString StVal;
+ StVal.reserve(60);
+
+ // loading arrays
+ for (int Cnt=0; Cnt < 3; Cnt++) {
+ inLst << Cnt;
+ outLst << StVal;
+ }
+
+ q.bindValue(":inp", inLst);
+ q.bindValue(":outp", outLst, QSql::Out);
+
+ QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) );
+ res_outLst = qVariantValue<QVariantList>(q.boundValues()[":outp"]);
+ QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0"));
+ QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1"));
+ QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2"));
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 8ea137e..5577903 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -2096,7 +2096,7 @@ void tst_QTcpSocket::connectToMultiIP()
stopWatch.restart();
socket->connectToHost("multi.dev.troll.no", 81);
- QVERIFY(!socket->waitForConnected(1000));
+ QVERIFY(!socket->waitForConnected(2000));
QVERIFY(stopWatch.elapsed() < 2000);
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
@@ -2116,7 +2116,7 @@ void tst_QTcpSocket::moveToThread0()
QTcpSocket *socket = newSocket();;
socket->connectToHost(QtNetworkSettings::serverName(), 143);
socket->moveToThread(0);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(socket->waitForDisconnected());
@@ -2127,7 +2127,7 @@ void tst_QTcpSocket::moveToThread0()
QTcpSocket *socket = newSocket();
socket->moveToThread(0);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(socket->waitForDisconnected());
@@ -2137,7 +2137,7 @@ void tst_QTcpSocket::moveToThread0()
// Case 3: Moved after writing, while waiting for bytes to be written.
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
socket->moveToThread(0);
QVERIFY(socket->waitForBytesWritten(5000));
@@ -2148,7 +2148,7 @@ void tst_QTcpSocket::moveToThread0()
// Case 4: Moved after writing, while waiting for response.
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(socket->waitForConnected(1000));
+ QVERIFY(socket->waitForConnected(2000));
socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000));
socket->moveToThread(0);
@@ -2263,7 +2263,7 @@ void tst_QTcpSocket::invalidProxy()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
} else {
QCOMPARE(socket->state(), QAbstractSocket::ConnectingState);
- QVERIFY(!socket->waitForConnected(1000));
+ QVERIFY(!socket->waitForConnected(2000));
}
QVERIFY(!socket->errorString().isEmpty());
@@ -2382,7 +2382,7 @@ void tst_QTcpSocket::proxyFactory()
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
} else {
QCOMPARE(socket->state(), QAbstractSocket::ConnectingState);
- QVERIFY(socket->waitForConnected(10000));
+ QVERIFY(socket->waitForConnected(2000));
QCOMPARE(proxyAuthCalled, 1);
}
QVERIFY(!socket->errorString().isEmpty());