1 /*
2  *  Copyright (c) 2016 Dmitry Kazakov <dimula73@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "kis_stabilized_events_sampler_test.h"
20 
21 #include "kis_stabilized_events_sampler.h"
22 #include "kis_paint_information.h"
23 
test()24 void KisStabilizedEventsSamplerTest::test()
25 {
26     KisStabilizedEventsSampler sampler(20);
27 
28     KisPaintInformation pi1(QPoint(10,10));
29     KisPaintInformation pi2(QPoint(20,20));
30 
31     sampler.addEvent(pi1);
32 
33     QTest::qSleep(50);
34 
35     sampler.addEvent(pi2);
36 
37     QTest::qSleep(70);
38 
39     KisStabilizedEventsSampler::iterator it;
40     KisStabilizedEventsSampler::iterator end;
41     std::tie(it, end) = sampler.range();
42 
43 
44     int numTotal = 0;
45     int num1 = 0;
46     int num2 = 0;
47 
48     for (; it != end; ++it) {
49         numTotal++;
50         if (it->pos().x() == 10) {
51             num1++;
52         } else if (it->pos().x() == 20) {
53             num2++;
54         }
55 
56         qDebug() << ppVar(it->pos());
57     }
58 
59     QVERIFY(numTotal >= 6);
60     QVERIFY(num1 >= 3);
61     QVERIFY(num2 >= 3);
62 }
63 
64 QTEST_MAIN(KisStabilizedEventsSamplerTest)
65