summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp7
-rw-r--r--tests/auto/network-settings.h3
-rw-r--r--tests/auto/qgl/tst_qgl.cpp12
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp1
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp2
-rw-r--r--tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp125
-rw-r--r--tests/auto/qquaternion/tst_qquaternion.cpp29
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp27
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp9
-rw-r--r--tests/auto/qvectornd/tst_qvectornd.cpp55
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp10
11 files changed, 160 insertions, 120 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp
index 925a776..462fcbb 100644
--- a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp
+++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp
@@ -1,6 +1,10 @@
+/****************************************************************************
+**
** 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.
@@ -32,6 +36,9 @@
**
**
** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "finddialog.h"
#include "mainwindow.h"
#include "tabbedbrowser.h"
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index 84f1241..d1c179e 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -1,4 +1,6 @@
/****************************************************************************
+**
+** 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.
@@ -36,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
#include <QString>
#ifdef QT_NETWORK_LIB
#include <QtNetwork/QHostInfo>
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index d87a29c..77e32ef 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -725,7 +725,8 @@ void tst_QGL::glFBORendering()
glw.makeCurrent();
// No multisample with combined depth/stencil attachment:
- QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
// Don't complicate things by using NPOT:
QGLFramebufferObject *fbo = new QGLFramebufferObject(256, 128, fboFormat);
@@ -785,7 +786,8 @@ void tst_QGL::multipleFBOInterleavedRendering()
glw.makeCurrent();
// No multisample with combined depth/stencil attachment:
- QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
QGLFramebufferObject *fbo1 = new QGLFramebufferObject(256, 128, fboFormat);
QGLFramebufferObject *fbo2 = new QGLFramebufferObject(256, 128, fboFormat);
@@ -890,7 +892,8 @@ protected:
{
QPainter widgetPainter;
widgetPainterBeginOk = widgetPainter.begin(this);
- QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat);
QPainter fboPainter;
@@ -1018,7 +1021,8 @@ void tst_QGL::stackedFBOs()
glw.makeCurrent();
// No multisample with combined depth/stencil attachment:
- QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
// Don't complicate things by using NPOT:
QGLFramebufferObject *fbo1 = new QGLFramebufferObject(128, 128, fboFormat);
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 65e6e56..03054f9 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -2529,6 +2529,7 @@ void tst_QGraphicsWidget::ensureClipping()
RectItem *childitem = new RectItem(Qt::blue, clipWidget);
QGraphicsView view(&scene);
+ view.setOptimizationFlag(QGraphicsView::IndirectPainting);
view.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index a325a33..65ca6e8 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -1249,7 +1249,7 @@ void tst_QImageReader::readCorruptImage()
void tst_QImageReader::readCorruptBmp()
{
- QCOMPARE(QImage("tst7.bmp").convertToFormat(QImage::Format_ARGB32_Premultiplied), QImage("images/tst7.png").convertToFormat(QImage::Format_ARGB32_Premultiplied));
+ QCOMPARE(QImage(prefix + "tst7.bmp").convertToFormat(QImage::Format_ARGB32_Premultiplied), QImage(prefix + "tst7.png").convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
void tst_QImageReader::supportsOption_data()
diff --git a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
index fd5ef3e..6a7e625 100644
--- a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -328,7 +328,7 @@ void tst_QMatrixNxN::setMatrix(QMatrix4x3& m, const qreal *values)
// the internal data() array.
void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values)
{
- float *data = m.data();
+ qreal *data = m.data();
for (int row = 0; row < 2; ++row) {
for (int col = 0; col < 2; ++col) {
data[row + col * 2] = values[row * 2 + col];
@@ -337,7 +337,7 @@ void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values)
}
void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values)
{
- float *data = m.data();
+ qreal *data = m.data();
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 3; ++col) {
data[row + col * 3] = values[row * 3 + col];
@@ -346,7 +346,7 @@ void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values)
}
void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values)
{
- float *data = m.data();
+ qreal *data = m.data();
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 4; ++col) {
data[row + col * 4] = values[row * 4 + col];
@@ -355,7 +355,7 @@ void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values)
}
void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values)
{
- float *data = m.data();
+ qreal *data = m.data();
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 4; ++col) {
data[row + col * 3] = values[row * 4 + col];
@@ -363,55 +363,42 @@ void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values)
}
}
-// qFuzzyCompare isn't always "fuzzy" enough to handle conversion
-// between float, double, and qreal. So create "fuzzier" compares.
-static bool fuzzyCompare(float x, float y, qreal epsilon = 0.001)
+// QVector2/3/4D use float internally, which can sometimes lead
+// to precision issues when converting to and from qreal during
+// operations involving QMatrix4x4. This fuzzy compare is slightly
+// "fuzzier" than the default qFuzzyCompare for qreal to compensate.
+static bool fuzzyCompare(qreal x, qreal y)
{
- float diff = x - y;
- if (diff < 0.0f)
- diff = -diff;
- return (diff < epsilon);
+ return qFuzzyIsNull((float)(x - y));
}
-static bool fuzzyCompare(const QVector3D &v1, const QVector3D &v2, qreal epsilon = 0.001)
+static bool fuzzyCompare(const QVector3D &v1, const QVector3D &v2)
{
- if (!fuzzyCompare(v1.x(), v2.x(), epsilon))
+ if (!fuzzyCompare(v1.x(), v2.x()))
return false;
- if (!fuzzyCompare(v1.y(), v2.y(), epsilon))
+ if (!fuzzyCompare(v1.y(), v2.y()))
return false;
- if (!fuzzyCompare(v1.z(), v2.z(), epsilon))
+ if (!fuzzyCompare(v1.z(), v2.z()))
return false;
return true;
}
-static bool matrixFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2)
-{
- bool ret = true;
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- ret = ret && fuzzyCompare(m1(i, j), m2(i, j));
- }
- }
-
- return ret;
-}
-
// Determine if a matrix is the same as a specified array of values.
// The values are assumed to be specified in row-major order.
bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values)
{
- const float *mv = m.constData();
+ const qreal *mv = m.constData();
for (int row = 0; row < 2; ++row) {
for (int col = 0; col < 2; ++col) {
// Check the values using the operator() function.
- if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 2 + col]))) {
+ if (!fuzzyCompare(m(row, col), values[row * 2 + col])) {
qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 2 + col];
return false;
}
// Check the values using direct access, which verifies that the values
// are stored internally in column-major order.
- if (!fuzzyCompare((float)(mv[col * 2 + row]), (float)(values[row * 2 + col]))) {
+ if (!fuzzyCompare(mv[col * 2 + row], values[row * 2 + col])) {
qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 2 + row] << "expected =" << values[row * 2 + col];
return false;
}
@@ -421,18 +408,18 @@ bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values)
}
bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values)
{
- const float *mv = m.constData();
+ const qreal *mv = m.constData();
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 3; ++col) {
// Check the values using the operator() access function.
- if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 3 + col]))) {
+ if (!fuzzyCompare(m(row, col), values[row * 3 + col])) {
qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 3 + col];
return false;
}
// Check the values using direct access, which verifies that the values
// are stored internally in column-major order.
- if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 3 + col]))) {
+ if (!fuzzyCompare(mv[col * 3 + row], values[row * 3 + col])) {
qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 3 + col];
return false;
}
@@ -442,18 +429,18 @@ bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values)
}
bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values)
{
- const float *mv = m.constData();
+ const qreal *mv = m.constData();
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 4; ++col) {
// Check the values using the operator() access function.
- if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) {
+ if (!fuzzyCompare(m(row, col), values[row * 4 + col])) {
qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col];
return false;
}
// Check the values using direct access, which verifies that the values
// are stored internally in column-major order.
- if (!fuzzyCompare((float)(mv[col * 4 + row]), (float)(values[row * 4 + col]))) {
+ if (!fuzzyCompare(mv[col * 4 + row], values[row * 4 + col])) {
qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 4 + row] << "expected =" << values[row * 4 + col];
return false;
}
@@ -463,18 +450,18 @@ bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values)
}
bool tst_QMatrixNxN::isSame(const QMatrix4x3& m, const qreal *values)
{
- const float *mv = m.constData();
+ const qreal *mv = m.constData();
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 4; ++col) {
// Check the values using the operator() access function.
- if (!fuzzyCompare((float)(m(row, col)), (float)(values[row * 4 + col]))) {
+ if (!fuzzyCompare(m(row, col), values[row * 4 + col])) {
qDebug() << "floating-point failure at" << row << col << "actual =" << m(row, col) << "expected =" << values[row * 4 + col];
return false;
}
// Check the values using direct access, which verifies that the values
// are stored internally in column-major order.
- if (!fuzzyCompare((float)(mv[col * 3 + row]), (float)(values[row * 4 + col]))) {
+ if (!fuzzyCompare(mv[col * 3 + row], values[row * 4 + col])) {
qDebug() << "column floating-point failure at" << row << col << "actual =" << mv[col * 3 + row] << "expected =" << values[row * 4 + col];
return false;
}
@@ -533,7 +520,7 @@ void tst_QMatrixNxN::create2x2()
qreal vals[4];
m6.toValueArray(vals);
for (int index = 0; index < 4; ++index)
- QCOMPARE((float)(vals[index]), (float)(uniqueValues2[index]));
+ QCOMPARE(vals[index], uniqueValues2[index]);
}
// Test the creation of QMatrix3x3 objects in various ways:
@@ -568,7 +555,7 @@ void tst_QMatrixNxN::create3x3()
qreal vals[9];
m6.toValueArray(vals);
for (int index = 0; index < 9; ++index)
- QCOMPARE((float)(vals[index]), (float)(uniqueValues3[index]));
+ QCOMPARE(vals[index], uniqueValues3[index]);
}
// Test the creation of QMatrix4x4 objects in various ways:
@@ -603,7 +590,7 @@ void tst_QMatrixNxN::create4x4()
qreal vals[16];
m6.toValueArray(vals);
for (int index = 0; index < 16; ++index)
- QCOMPARE((float)(vals[index]), (float)(uniqueValues4[index]));
+ QCOMPARE(vals[index], uniqueValues4[index]);
QMatrix4x4 m8
(uniqueValues4[0], uniqueValues4[1], uniqueValues4[2], uniqueValues4[3],
@@ -645,7 +632,7 @@ void tst_QMatrixNxN::create4x3()
qreal vals[12];
m6.toValueArray(vals);
for (int index = 0; index < 12; ++index)
- QCOMPARE((float)(vals[index]), (float)(uniqueValues4x3[index]));
+ QCOMPARE(vals[index], uniqueValues4x3[index]);
}
// Test isIdentity() for 2x2 matrices.
@@ -1303,7 +1290,7 @@ void tst_QMatrixNxN::multiply4x3()
QMatrix4x3 m1((const qreal *)m1Values);
QMatrix3x4 m2((const qreal *)m2Values);
- QGenericMatrix<3, 3, qreal, float> m4;
+ QGenericMatrix<3, 3, qreal> m4;
m4 = m1 * m2;
qreal values[9];
m4.toValueArray(values);
@@ -1882,7 +1869,7 @@ void tst_QMatrixNxN::inverted4x4()
Matrix4 m1alt;
memcpy(m1alt.v, (const qreal *)m1Values, sizeof(m1alt.v));
- QCOMPARE((float)(m1.determinant()), (float)(m4Determinant(m1alt)));
+ QCOMPARE(m1.determinant(), m4Determinant(m1alt));
QMatrix4x4 m2;
bool inv;
@@ -1917,7 +1904,7 @@ void tst_QMatrixNxN::inverted4x4()
void tst_QMatrixNxN::orthonormalInverse4x4()
{
QMatrix4x4 m1;
- QVERIFY(matrixFuzzyCompare(m1.inverted(), m1));
+ QVERIFY(qFuzzyCompare(m1.inverted(), m1));
QMatrix4x4 m2;
m2.rotate(45.0, 1.0, 0.0, 0.0);
@@ -1930,14 +1917,14 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
QMatrix4x4 m3 = m2;
m3.inferSpecialType();
bool invertible;
- QVERIFY(matrixFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
+ QVERIFY(qFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
QVERIFY(invertible);
QMatrix4x4 m4;
m4.rotate(45.0, 0.0, 1.0, 0.0);
QMatrix4x4 m5 = m4;
m5.inferSpecialType();
- QVERIFY(matrixFuzzyCompare(m4.inverted(), m5.inverted()));
+ QVERIFY(qFuzzyCompare(m4.inverted(), m5.inverted()));
QMatrix4x4 m6;
m1.rotate(88, 0.0, 0.0, 1.0);
@@ -1945,7 +1932,7 @@ void tst_QMatrixNxN::orthonormalInverse4x4()
m1.rotate(25, 1.0, 0.0, 0.0);
QMatrix4x4 m7 = m6;
m7.inferSpecialType();
- QVERIFY(matrixFuzzyCompare(m6.inverted(), m7.inverted()));
+ QVERIFY(qFuzzyCompare(m6.inverted(), m7.inverted()));
}
// Test the generation and use of 4x4 scale matrices.
@@ -2345,7 +2332,7 @@ void tst_QMatrixNxN::rotate4x4()
QMatrix4x4 m3(uniqueValues4);
QMatrix4x4 m4(m3);
m4.rotate(angle, x, y, z);
- QVERIFY(matrixFuzzyCompare(m4, m3 * m1));
+ QVERIFY(qFuzzyCompare(m4, m3 * m1));
// Null vectors don't make sense for quaternion rotations.
if (x != 0 || y != 0 || z != 0) {
@@ -2417,8 +2404,8 @@ void tst_QMatrixNxN::rotate4x4()
QPointF p3(2.0f, 3.0f);
QPointF p4 = m1 * p3;
- QVERIFY(fuzzyCompare((float)(p4.x()), p1x));
- QVERIFY(fuzzyCompare((float)(p4.y()), p1y));
+ QVERIFY(fuzzyCompare(p4.x(), p1x));
+ QVERIFY(fuzzyCompare(p4.y(), p1y));
if (x != 0 || y != 0 || z != 0) {
QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle);
@@ -2911,14 +2898,12 @@ void tst_QMatrixNxN::extractAxisRotation()
m.extractAxisRotation(extractedAngle, extractedAxis);
- qreal epsilon = 0.001;
-
if (angle > 180) {
- QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle, epsilon));
- QVERIFY(fuzzyCompare(extractedAxis, -origAxis, epsilon));
+ QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle));
+ QVERIFY(fuzzyCompare(extractedAxis, -origAxis));
} else {
- QVERIFY(fuzzyCompare(angle, extractedAngle, epsilon));
- QVERIFY(fuzzyCompare(extractedAxis, origAxis, epsilon));
+ QVERIFY(fuzzyCompare(angle, extractedAngle));
+ QVERIFY(fuzzyCompare(extractedAxis, origAxis));
}
}
@@ -2959,11 +2944,9 @@ void tst_QMatrixNxN::extractTranslation()
QVector3D vec = rotation.extractTranslation();
- qreal epsilon = 0.001;
-
- QVERIFY(fuzzyCompare(vec.x(), x, epsilon));
- QVERIFY(fuzzyCompare(vec.y(), y, epsilon));
- QVERIFY(fuzzyCompare(vec.z(), z, epsilon));
+ QVERIFY(fuzzyCompare(vec.x(), x));
+ QVERIFY(fuzzyCompare(vec.y(), y));
+ QVERIFY(fuzzyCompare(vec.z(), z));
QMatrix4x4 lookAt;
QVector3D eye(1.5f, -2.5f, 2.5f);
@@ -2973,9 +2956,9 @@ void tst_QMatrixNxN::extractTranslation()
QVector3D extEye = lookAt.extractTranslation();
- QVERIFY(fuzzyCompare(eye.x(), -extEye.x(), epsilon));
- QVERIFY(fuzzyCompare(eye.y(), -extEye.y(), epsilon));
- QVERIFY(fuzzyCompare(eye.z(), -extEye.z(), epsilon));
+ QVERIFY(fuzzyCompare(eye.x(), -extEye.x()));
+ QVERIFY(fuzzyCompare(eye.y(), -extEye.y()));
+ QVERIFY(fuzzyCompare(eye.z(), -extEye.z()));
}
// Copy of "flagBits" in qmatrix4x4.h.
@@ -2990,7 +2973,7 @@ enum {
// Structure that allows direct access to "flagBits" for testing.
struct Matrix4x4
{
- float m[4][4];
+ qreal m[4][4];
int flagBits;
};
@@ -3134,8 +3117,8 @@ void tst_QMatrixNxN::convertQMatrix()
QMatrix4x4 m6(m5);
QPointF p6 = m6 * QPointF(100.0, 150.0);
- QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005));
- QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005));
+ QVERIFY(fuzzyCompare(p5.x(), p6.x()));
+ QVERIFY(fuzzyCompare(p5.y(), p6.y()));
QMatrix m7 = m6.toAffine();
QVERIFY(fuzzyCompare(m5.m11(), m7.m11()));
@@ -3181,8 +3164,8 @@ void tst_QMatrixNxN::convertQTransform()
QMatrix4x4 m6(m5);
QPointF p6 = m6 * QPointF(100.0, 150.0);
- QVERIFY(fuzzyCompare(p5.x(), p6.x(), 0.005));
- QVERIFY(fuzzyCompare(p5.y(), p6.y(), 0.005));
+ QVERIFY(fuzzyCompare(p5.x(), p6.x()));
+ QVERIFY(fuzzyCompare(p5.y(), p6.y()));
QTransform m7 = m6.toTransform();
QVERIFY(fuzzyCompare(m5.m11(), m7.m11()));
diff --git a/tests/auto/qquaternion/tst_qquaternion.cpp b/tests/auto/qquaternion/tst_qquaternion.cpp
index 24427c3..e3c4cd6 100644
--- a/tests/auto/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/qquaternion/tst_qquaternion.cpp
@@ -98,14 +98,11 @@ private slots:
void metaTypes();
};
-// qFuzzyCompare isn't always "fuzzy" enough to handle conversion
-// between float, double, and qreal. So create "fuzzier" compares.
-static bool fuzzyCompare(float x, float y)
-{
- float diff = x - y;
- if (diff < 0.0f)
- diff = -diff;
- return (diff < 0.001);
+// QVector3D uses float internally, which can lead to some precision
+// issues when using it with the qreal-based QQuaternion.
+static bool fuzzyCompare(qreal x, qreal y)
+{
+ return qFuzzyIsNull(float(x - y));
}
// Test the creation of QQuaternion objects in various ways:
@@ -250,8 +247,8 @@ void tst_QQuaternion::length()
QFETCH(qreal, len);
QQuaternion v(w, x, y, z);
- QCOMPARE((float)(v.length()), (float)len);
- QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w));
+ QCOMPARE(v.length(), len);
+ QCOMPARE(v.lengthSquared(), x * x + y * y + z * z + w * w);
}
// Test the unit vector conversion for quaternions.
@@ -273,11 +270,11 @@ void tst_QQuaternion::normalized()
if (v.isNull())
QVERIFY(u.isNull());
else
- QCOMPARE((float)(u.length()), (float)1.0f);
- QCOMPARE((float)(u.x() * len), (float)(v.x()));
- QCOMPARE((float)(u.y() * len), (float)(v.y()));
- QCOMPARE((float)(u.z() * len), (float)(v.z()));
- QCOMPARE((float)(u.scalar() * len), (float)(v.scalar()));
+ QCOMPARE(u.length(), qreal(1.0f));
+ QCOMPARE(u.x() * len, v.x());
+ QCOMPARE(u.y() * len, v.y());
+ QCOMPARE(u.z() * len, v.z());
+ QCOMPARE(u.scalar() * len, v.scalar());
}
// Test the unit vector conversion for quaternions.
@@ -299,7 +296,7 @@ void tst_QQuaternion::normalize()
if (isNull)
QVERIFY(v.isNull());
else
- QCOMPARE((float)(v.length()), (float)1.0f);
+ QCOMPARE(v.length(), qreal(1.0f));
}
// Test the comparison operators for quaternions.
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 4c8f689..55b6e96 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -845,6 +845,7 @@ void tst_QStyleSheetStyle::hoverColors()
#endif
QApplication::setActiveWindow(&frame);
QTest::qWait(60);
+ //move the mouse inside the widget, it should be colored
QTest::mouseMove ( widget, QPoint(5,5));
QTest::qWait(60);
@@ -857,6 +858,32 @@ void tst_QStyleSheetStyle::hoverColors()
QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain text color #ff0084").toLocal8Bit().constData());
+
+ //move the mouse outside the widget, it should NOT be colored
+ QTest::mouseMove ( dummy, QPoint(5,5));
+ QTest::qWait(60);
+
+ frame.render(&image);
+
+ QVERIFY2(!testForColors(image, QColor(0xe8, 0xff, 0x66)),
+ (QString::fromLatin1(widget->metaObject()->className())
+ + " did contain background color #e8ff66").toLocal8Bit().constData());
+ QVERIFY2(!testForColors(image, QColor(0xff, 0x00, 0x84)),
+ (QString::fromLatin1(widget->metaObject()->className())
+ + " did contain text color #ff0084").toLocal8Bit().constData());
+
+ //move the mouse again inside the widget, it should be colored
+ QTest::mouseMove (widget, QPoint(5,5));
+ QTest::qWait(60);
+
+ frame.render(&image);
+
+ QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
+ (QString::fromLatin1(widget->metaObject()->className())
+ + " did not contain background color #e8ff66").toLocal8Bit().constData());
+ QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
+ (QString::fromLatin1(widget->metaObject()->className())
+ + " did not contain text color #ff0084").toLocal8Bit().constData());
}
}
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 39ab4c6..6fe2963 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -2487,6 +2487,11 @@ void tst_QTableView::indexAt()
QtTestTableView view;
view.show();
+
+ //some styles change the scroll mode in their polish
+ view.setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
+ view.setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
+
view.setModel(&model);
view.setSpan(row, column, rowSpan, columnSpan);
view.hideRow(hiddenRow);
@@ -3143,6 +3148,10 @@ void tst_QTableView::task240266_veryBigColumn()
table.show();
QTest::qWait(100);
+ //some styles change the scroll mode in their polish
+ table.setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
+ table.setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
+
QScrollBar *scroll = table.horizontalScrollBar();
QCOMPARE(scroll->minimum(), 0);
QCOMPARE(scroll->maximum(), model.columnCount() - 1);
diff --git a/tests/auto/qvectornd/tst_qvectornd.cpp b/tests/auto/qvectornd/tst_qvectornd.cpp
index 243b172..75c2eb5 100644
--- a/tests/auto/qvectornd/tst_qvectornd.cpp
+++ b/tests/auto/qvectornd/tst_qvectornd.cpp
@@ -144,14 +144,13 @@ private slots:
void metaTypes();
};
-// qFuzzyCompare isn't always "fuzzy" enough to handle conversion
-// between float, double, and qreal. So create "fuzzier" compares.
-static bool fuzzyCompare(float x, float y)
+// QVector2/3/4D use float internally, which can sometimes lead
+// to precision issues when converting to and from qreal.
+// This fuzzy compare is slightly "fuzzier" than the default
+// qFuzzyCompare for qreal to compensate.
+static bool fuzzyCompare(qreal x, qreal y)
{
- float diff = x - y;
- if (diff < 0.0f)
- diff = -diff;
- return (diff < 0.001);
+ return qFuzzyIsNull((float)(x - y));
}
// Test the creation of QVector2D objects in various ways:
@@ -577,8 +576,8 @@ void tst_QVector::length2()
QFETCH(qreal, len);
QVector2D v(x, y);
- QCOMPARE((float)(v.length()), (float)len);
- QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y));
+ QCOMPARE(v.length(), len);
+ QCOMPARE(v.lengthSquared(), x * x + y * y);
}
// Test vector length computation for 3D vectors.
@@ -606,8 +605,8 @@ void tst_QVector::length3()
QFETCH(qreal, len);
QVector3D v(x, y, z);
- QCOMPARE((float)(v.length()), (float)len);
- QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z));
+ QCOMPARE(v.length(), len);
+ QCOMPARE(v.lengthSquared(), x * x + y * y + z * z);
}
// Test vector length computation for 4D vectors.
@@ -639,8 +638,8 @@ void tst_QVector::length4()
QFETCH(qreal, len);
QVector4D v(x, y, z, w);
- QCOMPARE((float)(v.length()), (float)len);
- QCOMPARE((float)(v.lengthSquared()), (float)(x * x + y * y + z * z + w * w));
+ QCOMPARE(v.length(), len);
+ QCOMPARE(v.lengthSquared(), x * x + y * y + z * z + w * w);
}
// Test the unit vector conversion for 2D vectors.
@@ -660,9 +659,9 @@ void tst_QVector::normalized2()
if (v.isNull())
QVERIFY(u.isNull());
else
- QCOMPARE((float)(u.length()), (float)1.0f);
- QCOMPARE((float)(u.x() * len), (float)(v.x()));
- QCOMPARE((float)(u.y() * len), (float)(v.y()));
+ QVERIFY(fuzzyCompare(u.length(), qreal(1.0f)));
+ QVERIFY(fuzzyCompare(u.x() * len, v.x()));
+ QVERIFY(fuzzyCompare(u.y() * len, v.y()));
}
// Test the unit vector conversion for 3D vectors.
@@ -683,10 +682,10 @@ void tst_QVector::normalized3()
if (v.isNull())
QVERIFY(u.isNull());
else
- QCOMPARE((float)(u.length()), (float)1.0f);
- QCOMPARE((float)(u.x() * len), (float)(v.x()));
- QCOMPARE((float)(u.y() * len), (float)(v.y()));
- QCOMPARE((float)(u.z() * len), (float)(v.z()));
+ QVERIFY(fuzzyCompare(u.length(), qreal(1.0f)));
+ QVERIFY(fuzzyCompare(u.x() * len, v.x()));
+ QVERIFY(fuzzyCompare(u.y() * len, v.y()));
+ QVERIFY(fuzzyCompare(u.z() * len, v.z()));
}
// Test the unit vector conversion for 4D vectors.
@@ -708,11 +707,11 @@ void tst_QVector::normalized4()
if (v.isNull())
QVERIFY(u.isNull());
else
- QCOMPARE((float)(u.length()), (float)1.0f);
- QCOMPARE((float)(u.x() * len), (float)(v.x()));
- QCOMPARE((float)(u.y() * len), (float)(v.y()));
- QCOMPARE((float)(u.z() * len), (float)(v.z()));
- QCOMPARE((float)(u.w() * len), (float)(v.w()));
+ QVERIFY(fuzzyCompare(u.length(), qreal(1.0f)));
+ QVERIFY(fuzzyCompare(u.x() * len, v.x()));
+ QVERIFY(fuzzyCompare(u.y() * len, v.y()));
+ QVERIFY(fuzzyCompare(u.z() * len, v.z()));
+ QVERIFY(fuzzyCompare(u.w() * len, v.w()));
}
// Test the unit vector conversion for 2D vectors.
@@ -732,7 +731,7 @@ void tst_QVector::normalize2()
if (isNull)
QVERIFY(v.isNull());
else
- QCOMPARE((float)(v.length()), (float)1.0f);
+ QVERIFY(fuzzyCompare(v.length(), qreal(1.0f)));
}
// Test the unit vector conversion for 3D vectors.
@@ -753,7 +752,7 @@ void tst_QVector::normalize3()
if (isNull)
QVERIFY(v.isNull());
else
- QCOMPARE((float)(v.length()), (float)1.0f);
+ QVERIFY(fuzzyCompare(v.length(), qreal(1.0f)));
}
// Test the unit vector conversion for 4D vectors.
@@ -775,7 +774,7 @@ void tst_QVector::normalize4()
if (isNull)
QVERIFY(v.isNull());
else
- QCOMPARE((float)(v.length()), (float)1.0f);
+ QVERIFY(fuzzyCompare(v.length(), qreal(1.0f)));
}
// Test the comparison operators for 2D vectors.
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index f638efd..b3df69d 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -5347,6 +5347,8 @@ void tst_QWidget::moveChild()
QFETCH(QPoint, offset);
ColorWidget parent;
+ // prevent custom styles
+ parent.setStyle(new QWindowsStyle);
ColorWidget child(&parent, Qt::blue);
#ifndef Q_OS_WINCE
@@ -5397,6 +5399,8 @@ void tst_QWidget::moveChild()
void tst_QWidget::showAndMoveChild()
{
QWidget parent(0, Qt::FramelessWindowHint);
+ // prevent custom styles
+ parent.setStyle(new QWindowsStyle);
parent.resize(300, 300);
parent.setPalette(Qt::red);
parent.show();
@@ -6467,6 +6471,8 @@ void tst_QWidget::render()
{
QWidget window;
window.resize(100, 100);
+ // prevent custom styles
+ window.setStyle(new QWindowsStyle);
window.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&window);
@@ -6484,6 +6490,8 @@ void tst_QWidget::render()
widget.resize(200, 200);
widget.setAutoFillBackground(true);
widget.setPalette(Qt::red);
+ // prevent custom styles
+ widget.setStyle(new QWindowsStyle);
widget.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&widget);
@@ -6739,6 +6747,8 @@ void tst_QWidget::renderInvisible()
void tst_QWidget::renderWithPainter()
{
QWidget widget;
+ // prevent custom styles
+ widget.setStyle(new QWindowsStyle);
widget.show();
widget.resize(70, 50);
widget.setAutoFillBackground(true);