Changeset View
Changeset View
Standalone View
Standalone View
autotests/parttest.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 86 | private slots: | |||
---|---|---|---|---|---|
113 | void testRClickOverLinkWhileLinkTextIsSelected(); | 113 | void testRClickOverLinkWhileLinkTextIsSelected(); | ||
114 | void testRClickOnSelectionModeShoulShowFollowTheLinkMenu(); | 114 | void testRClickOnSelectionModeShoulShowFollowTheLinkMenu(); | ||
115 | void testClickAnywhereAfterSelectionShouldUnselect(); | 115 | void testClickAnywhereAfterSelectionShouldUnselect(); | ||
116 | void testeRectSelectionStartingOnLinks(); | 116 | void testeRectSelectionStartingOnLinks(); | ||
117 | void testCheckBoxReadOnly(); | 117 | void testCheckBoxReadOnly(); | ||
118 | void testCrashTextEditDestroy(); | 118 | void testCrashTextEditDestroy(); | ||
119 | void testAnnotWindow(); | 119 | void testAnnotWindow(); | ||
120 | void testAdditionalActionTriggers(); | 120 | void testAdditionalActionTriggers(); | ||
121 | void testJumpToPage(); | ||||
121 | 122 | | |||
122 | private: | 123 | private: | ||
123 | void simulateMouseSelection(double startX, double startY, double endX, double endY, QWidget *target); | 124 | void simulateMouseSelection(double startX, double startY, double endX, double endY, QWidget *target); | ||
124 | }; | 125 | }; | ||
125 | 126 | | |||
126 | class PartThatHijacksQueryClose : public Okular::Part | 127 | class PartThatHijacksQueryClose : public Okular::Part | ||
127 | { | 128 | { | ||
128 | public: | 129 | public: | ||
▲ Show 20 Lines • Show All 1617 Lines • ▼ Show 20 Line(s) | 1646 | #endif | |||
1746 | 1747 | | |||
1747 | // Confirm that a mouse release outside does not trigger the show action. | 1748 | // Confirm that a mouse release outside does not trigger the show action. | ||
1748 | QTest::mousePress( widget, Qt::LeftButton, Qt::NoModifier, QPoint( 5, 5 ) ); | 1749 | QTest::mousePress( widget, Qt::LeftButton, Qt::NoModifier, QPoint( 5, 5 ) ); | ||
1749 | verifyTargetStates( QStringLiteral( "pb" ), fields, false, false, false, __LINE__ ); | 1750 | verifyTargetStates( QStringLiteral( "pb" ), fields, false, false, false, __LINE__ ); | ||
1750 | QTest::mouseRelease( part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, tfPos ); | 1751 | QTest::mouseRelease( part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, tfPos ); | ||
1751 | verifyTargetStates( QStringLiteral( "pb" ), fields, false, false, false, __LINE__ ); | 1752 | verifyTargetStates( QStringLiteral( "pb" ), fields, false, false, false, __LINE__ ); | ||
1752 | } | 1753 | } | ||
1753 | 1754 | | |||
1755 | void PartTest::testJumpToPage() { | ||||
1756 | const QString testFile = QStringLiteral( KDESRCDIR "data/simple-multipage.pdf" ); | ||||
1757 | const int targetPage = 25; | ||||
1758 | Okular::Part part( nullptr, nullptr, QVariantList() ); | ||||
1759 | part.openDocument( testFile ); | ||||
1760 | part.widget()->resize(800, 600); | ||||
1761 | part.widget()->show(); | ||||
1762 | QVERIFY( QTest::qWaitForWindowExposed( part.widget() ) ); | ||||
1763 | | ||||
1764 | part.m_document->pages(); | ||||
1765 | part.m_document->setViewportPage( targetPage ); | ||||
1766 | | ||||
1767 | /* Document::setViewportPage triggers pixmap rendering in another thread. | ||||
1768 | * We want to test how things look AFTER finished signal arrives back, | ||||
1769 | * because PageView::slotRelayoutPages may displace the viewport again. | ||||
1770 | */ | ||||
1771 | QTRY_VERIFY( part.m_document->page( targetPage )->hasPixmap( part.m_pageView ) ); | ||||
1772 | | ||||
1773 | const int contentAreaHeight = part.m_pageView->verticalScrollBar()->maximum() + part.m_pageView->viewport()->height(); | ||||
1774 | const int pageWithSpaceTop = contentAreaHeight / part.m_document->pages() * targetPage; | ||||
1775 | | ||||
1776 | /* | ||||
1777 | * This is a test for a "known by trial" displacement. | ||||
1778 | * We'd need access to part.m_pageView->d->items[targetPage]->croppedGeometry().top(), | ||||
1779 | * to determine the expected viewport position, but we don't have access. | ||||
1780 | */ | ||||
1781 | QCOMPARE(part.m_pageView->verticalScrollBar()->value(), pageWithSpaceTop - 4); | ||||
1782 | } | ||||
1783 | | ||||
1754 | } // namespace Okular | 1784 | } // namespace Okular | ||
1755 | 1785 | | |||
1756 | int main(int argc, char *argv[]) | 1786 | int main(int argc, char *argv[]) | ||
1757 | { | 1787 | { | ||
1758 | // Force consistent locale | 1788 | // Force consistent locale | ||
1759 | QLocale locale(QStringLiteral("en_US.UTF-8")); | 1789 | QLocale locale(QStringLiteral("en_US.UTF-8")); | ||
1760 | if (locale == QLocale::c()) { // This is the way to check if the above worked | 1790 | if (locale == QLocale::c()) { // This is the way to check if the above worked | ||
1761 | locale = QLocale(QLocale::English, QLocale::UnitedStates); | 1791 | locale = QLocale(QLocale::English, QLocale::UnitedStates); | ||
Show All 32 Lines |