1 #include "test_viewmanager.h"
2 #include "viewmanager.h"
5 TestViewManager::TestViewManager()
10 void TestViewManager::initTestCase()
16 mEditor->setObject(
object);
19 void TestViewManager::cleanupTestCase()
24 void TestViewManager::testTranslation10()
32 QCOMPARE( QPointF(10 ,10), v.mapCanvasToScreen(QPointF(0,0)) );
35 void TestViewManager::testTranslation2Times()
42 QCOMPARE( v.mapCanvasToScreen(QPointF(0, 0)), QPointF(0, 15));
45 QCOMPARE( v.mapCanvasToScreen(QPointF(0, 0)), QPointF(0, 30));
48 void TestViewManager::testTranslationQPointF()
54 v.translate(QPointF(10, 10));
55 QCOMPARE(QPointF(10, 10), v.mapCanvasToScreen(QPointF(0, 0)));
58 void TestViewManager::testRotation90()
65 QCOMPARE( v.mapCanvasToScreen(QPointF(1, 0)), QPointF(0, 1));
66 QCOMPARE(v.mapCanvasToScreen(QPointF(23.6, 0)), QPointF(0, 23.6));
69 void TestViewManager::testRotation180()
76 QCOMPARE(v.rotation(), 180.f);
77 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 0)), QPointF(-1, 0));
78 QCOMPARE(v.mapCanvasToScreen(QPointF(92.1, 0)), QPointF(-92.1, 0));
81 void TestViewManager::testRotationTwice()
88 QCOMPARE(v.rotation(), 45.f);
89 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 0)), QPointF(cos(M_PI/4), sin(M_PI /4)));
92 QCOMPARE(v.rotation(), 90.f);
93 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 0)), QPointF(0, 1));
96 void TestViewManager::testScaling2()
103 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 1)), QPointF(2, 2));
104 QCOMPARE(v.scaling(), 2.0f);
107 void TestViewManager::testScaling2Times()
110 v.setEditor(mEditor);
114 QCOMPARE(v.scaling(), 2.0f);
115 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 1)), QPointF(2, 2));
118 QCOMPARE(v.scaling(), 6.0f);
119 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 1)), QPointF(6, 6));
120 QCOMPARE(v.mapCanvasToScreen(QPointF(-1, 2)), QPointF(-6, 12));
123 void TestViewManager::testMaxScalingValue()
126 v.setEditor(mEditor);
132 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 1)), QPointF(100, 100));
135 void TestViewManager::testMinScalingValue()
138 v.setEditor(mEditor);
143 QPointF p1 = v.mapCanvasToScreen(QPointF(1, 1));
144 QPointF p2 = QPointF(0.01, 0.01);
146 QVERIFY(std::abs(p1.x() - p2.x()) < 0.000001);
147 QVERIFY(std::abs(p1.y() - p2.y()) < 0.000001);
150 void TestViewManager::testTranslateAndRotate()
153 v.setEditor(mEditor);
161 QCOMPARE(v.mapCanvasToScreen(QPointF(1, 1)), QPointF(-1, 11));