summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicstransform
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-08-10 14:47:13 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-08-10 14:50:11 +1000
commitbb97f90ef340d668f3dc04026aa034b33a997453 (patch)
tree675bb9c290a7dff576418667b57220eb3d2d0691 /tests/auto/qgraphicstransform
parente54e4f19ec2fd06f9d383b2cd83a565479e3cced (diff)
Set default QGraphicsTransform3D axis to (0, 0, 1)
The docs said that the default axis was (0, 0, 1), but the code and unit tests were using (0, 0, 0). Modify the code to match the docs because (0, 0, 0) is not very useful. Also optimize the calculation of sin/cos values for 90, 180, and 270 degrees. Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/qgraphicstransform')
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index 672b1f15a9..c9481da3b5 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -137,7 +137,10 @@ void tst_QGraphicsTransform::rotation()
void tst_QGraphicsTransform::rotation3d()
{
QGraphicsRotation3D rotation;
- rotation.setOrigin(QPointF(10, 10));
+ QCOMPARE(rotation.axis().x(), (qreal)0);
+ QCOMPARE(rotation.axis().y(), (qreal)0);
+ QCOMPARE(rotation.axis().z(), (qreal)1);
+ QCOMPARE(rotation.angle(), (qreal)0);
QTransform t;
rotation.applyTo(&t);
@@ -147,6 +150,23 @@ void tst_QGraphicsTransform::rotation3d()
rotation.setAngle(180);
+ QTransform t180;
+ t180.rotate(180.0f);
+
+ QCOMPARE(t, QTransform());
+ QVERIFY(qFuzzyCompare(rotation.transform(), t180));
+
+ rotation.setAxis(QVector3D(0, 0, 0));
+ rotation.setOrigin(QPointF(10, 10));
+
+ t = QTransform();
+ rotation.applyTo(&t);
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(rotation.transform(), QTransform());
+
+ rotation.setAngle(180);
+
QCOMPARE(t, QTransform());
QCOMPARE(rotation.transform(), QTransform());