File indexing completed on 2024-12-22 04:12:54

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_stabilized_events_sampler_test.h"
0008 
0009 #include "kis_stabilized_events_sampler.h"
0010 #include "kis_paint_information.h"
0011 
0012 void KisStabilizedEventsSamplerTest::test()
0013 {
0014     KisStabilizedEventsSampler sampler(20);
0015 
0016     KisPaintInformation pi1(QPoint(10,10));
0017     KisPaintInformation pi2(QPoint(20,20));
0018 
0019     sampler.addEvent(pi1);
0020 
0021     QTest::qSleep(50);
0022 
0023     sampler.addEvent(pi2);
0024 
0025     QTest::qSleep(70);
0026 
0027     KisStabilizedEventsSampler::iterator it;
0028     KisStabilizedEventsSampler::iterator end;
0029     std::tie(it, end) = sampler.range();
0030 
0031 
0032     int numTotal = 0;
0033     int num1 = 0;
0034     int num2 = 0;
0035 
0036     for (; it != end; ++it) {
0037         numTotal++;
0038         if (it->pos().x() == 10) {
0039             num1++;
0040         } else if (it->pos().x() == 20) {
0041             num2++;
0042         }
0043 
0044         qDebug() << ppVar(it->pos());
0045     }
0046 
0047     QVERIFY(numTotal >= 6);
0048     QVERIFY(num1 >= 3);
0049     QVERIFY(num2 >= 3);
0050 }
0051 
0052 SIMPLE_TEST_MAIN(KisStabilizedEventsSamplerTest)