1 /*
2 * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org
3 * Copyright (c) 2008 Cyrille Berger <cberger@cberger.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "kis_paint_information_test.h"
21
22 #include <QTest>
23 #include <brushengine/kis_paint_information.h>
24 #include "kis_debug.h"
25
26
27 #include <QDomDocument>
28 #include <Eigen/Core>
29
testCreation()30 void KisPaintInformationTest::testCreation()
31 {
32 KisPaintInformation test;
33 }
34
testSerialisation()35 void KisPaintInformationTest::testSerialisation()
36 {
37 KisPaintInformation test(QPointF(double(rand()) / RAND_MAX, double(rand()) / RAND_MAX), double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX, double(rand()) / RAND_MAX);
38
39 QDomDocument doc = QDomDocument("pi");
40 QDomElement root = doc.createElement("pi");
41 doc.appendChild(root);
42 test.toXML(doc, root);
43 KisPaintInformation testUnS = KisPaintInformation::fromXML(root);
44 QCOMPARE(test.pos().x() , testUnS.pos().x());
45 QCOMPARE(test.pos().y() , testUnS.pos().y());
46 QCOMPARE(test.pressure() , testUnS.pressure());
47 QCOMPARE(test.xTilt() , testUnS.xTilt());
48 QCOMPARE(test.yTilt() , testUnS.yTilt());
49 QCOMPARE(test.rotation() , testUnS.rotation());
50 QCOMPARE(test.tangentialPressure() , testUnS.tangentialPressure());
51 /**
52 * drawingAngle(), velocity() and distance() are calculated basing
53 * on the KisDistanceInformation data and are not available without
54 * it
55 */
56 }
57
58 #include <boost/random/taus88.hpp>
59 #include <boost/random/uniform_smallint.hpp>
60
benchmarkTausRandomGeneration()61 void KisPaintInformationTest::benchmarkTausRandomGeneration()
62 {
63 boost::taus88 rnd;
64
65 QBENCHMARK {
66 // make a copy
67 boost::taus88 rnd2(rnd);
68
69 // use smallint shaper
70 boost::uniform_smallint<int> smallint(0,10);
71
72 // generate
73 int value = smallint(rnd2);
74 Q_UNUSED(value);
75 }
76 }
77
78
79 QTEST_MAIN(KisPaintInformationTest)
80