void Ut_PagedPanning::testCurrentPageRemainsSameWhenPageCountChanges() { fillDefaultIntegrationParameters(m_subject, DEFAULT_NUM_PAGES, 0, 1000); m_subject->setPage(4); QSignalSpy spy(m_subject, SIGNAL(pageChanged(int))); // Change the page count and set the range accordingly m_subject->setPageCount(21); m_subject->setRange(QRectF(0, 0, 2000, 0)); performIntegration(m_subject); // Neither the position or the page should have changed QCOMPARE(m_subject->position().x(), 400.0); QCOMPARE(spy.count(), 0); // Set the count to be less than the current page and reduce the range m_subject->setPageCount(3); m_subject->setRange(QRectF(0, 0, 200, 0)); performIntegration(m_subject); // Now we should have ended on the last page QCOMPARE(m_subject->position().x(), 200.0); QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toInt(), 2); }
QcepIntegratedDataPtr QxrdIntegrator::performIntegration(QcepDoubleImageDataPtr dimg, QcepMaskDataPtr mask) { QcepIntegratedDataPtr res = QcepAllocator::newIntegratedData(QcepAllocator::AlwaysAllocate, dimg); if (res) { return performIntegration(res, dimg, mask); } else { return res; } }
void Ut_PagedPanning::testAutoPanning() { QSignalSpy spy(m_subject, SIGNAL(pageChanged(int))); m_subject->setPage(3); m_subject->panToPage(0); performIntegration(m_subject); QCOMPARE(m_subject->position().x(), 0.0); QList<QVariant> arguments = spy.takeLast(); QCOMPARE(arguments.at(0).toInt(), 0); spy.clear(); m_subject->panToPage(2); performIntegration(m_subject); QCOMPARE(m_subject->position().x(), 200.0); arguments = spy.takeLast(); QCOMPARE(arguments.at(0).toInt(), 2); }
void Ut_PagedPanning::testWhenPhysicsDisabledWhileActivelyPanningThenPositionIsPannedToNearestPage() { Ut_MPhysics2DPanning physicsDriver(m_subject); // Start panning m_subject->pointerPress(QPointF(0.0, 0.0)); for (int i = 0; i < DEFAULT_PAGE_WIDTH; i++) { m_subject->pointerMove(QPointF(-i * 2.2, 0)); physicsDriver.advancePhysicsCalculation(); } int currentPage = m_subject->currentPage; // Disable while being panned m_subject->setEnabled(false); QSignalSpy panningStoppedSpy(m_subject, SIGNAL(panningStopped())); performIntegration(m_subject); QCOMPARE(m_subject->position().x(), currentPage * DEFAULT_PAGE_WIDTH); QCOMPARE(panningStoppedSpy.count(), 2); }
void QxrdIntegrator::appendIntegration(QcepDoubleImageDataPtr res, QcepDoubleImageDataPtr dimg, QcepMaskDataPtr mask) { QcepIntegratedDataPtr integ = performIntegration(dimg, mask); appendIntegration(res, integ); }