|
|
|
|
@ -56,6 +56,12 @@ public: |
|
|
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Close a modal dialog, which may not be associated to any other widget
|
|
|
|
|
CloseDialogHelper(QDialogButtonBox::StandardButton b) : m_widget(nullptr), m_button(b), m_clicked(false) |
|
|
|
|
{ |
|
|
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
~CloseDialogHelper() |
|
|
|
|
{ |
|
|
|
|
QVERIFY(m_clicked); |
|
|
|
|
@ -64,7 +70,7 @@ public: |
|
|
|
|
private slots: |
|
|
|
|
void closeDialog() |
|
|
|
|
{ |
|
|
|
|
QDialog *dialog = m_widget->findChild<QDialog*>(); |
|
|
|
|
QWidget *dialog = ( m_widget ) ? m_widget->findChild<QDialog*>() : qApp->activeModalWidget(); |
|
|
|
|
if (!dialog) { |
|
|
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog); |
|
|
|
|
return; |
|
|
|
|
@ -128,6 +134,7 @@ class PartTest |
|
|
|
|
void testCrashTextEditDestroy(); |
|
|
|
|
void testAnnotWindow(); |
|
|
|
|
void testAdditionalActionTriggers(); |
|
|
|
|
void testTypewriterAnnotTool(); |
|
|
|
|
void testJumpToPage(); |
|
|
|
|
void testTabletProximityBehavior(); |
|
|
|
|
|
|
|
|
|
@ -1794,6 +1801,50 @@ void PartTest::testAdditionalActionTriggers() |
|
|
|
|
verifyTargetStates( QStringLiteral( "pb" ), fields, false, false, false, __LINE__ ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PartTest::testTypewriterAnnotTool() |
|
|
|
|
{ |
|
|
|
|
Okular::Part part(nullptr, nullptr, QVariantList()); |
|
|
|
|
|
|
|
|
|
part.openUrl(QUrl::fromLocalFile(QStringLiteral(KDESRCDIR "data/file1.pdf"))); |
|
|
|
|
|
|
|
|
|
part.widget()->show(); |
|
|
|
|
QVERIFY(QTest::qWaitForWindowExposed(part.widget())); |
|
|
|
|
|
|
|
|
|
const int width = part.m_pageView->horizontalScrollBar()->maximum() + |
|
|
|
|
part.m_pageView->viewport()->width(); |
|
|
|
|
const int height = part.m_pageView->verticalScrollBar()->maximum() + |
|
|
|
|
part.m_pageView->viewport()->height(); |
|
|
|
|
|
|
|
|
|
part.m_document->setViewportPage(0); |
|
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(part.m_pageView, "slotToggleAnnotator", Q_ARG( bool, true )); |
|
|
|
|
|
|
|
|
|
// Find the button for the TypeWriter annotation
|
|
|
|
|
QList<QToolButton *> toolbuttonList = part.m_pageView->findChildren<QToolButton *>(); |
|
|
|
|
auto it = std::find_if( toolbuttonList.begin(), |
|
|
|
|
toolbuttonList.end(), |
|
|
|
|
[](const QToolButton * x) { return x->toolTip().contains("Typewriter"); } ); |
|
|
|
|
|
|
|
|
|
QVERIFY(it != toolbuttonList.end()); |
|
|
|
|
QToolButton* typewriterButton = *it; |
|
|
|
|
|
|
|
|
|
typewriterButton->click(); |
|
|
|
|
|
|
|
|
|
QTest::qWait(1000); // Wait for the "add new note" dialog to appear
|
|
|
|
|
CloseDialogHelper closeDialogHelper( QDialogButtonBox::Ok ); |
|
|
|
|
|
|
|
|
|
QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.5, height * 0.2)); |
|
|
|
|
|
|
|
|
|
Annotation* annot = part.m_document->page(0)->annotations().first(); |
|
|
|
|
TextAnnotation* ta = static_cast<TextAnnotation*>( annot ); |
|
|
|
|
QVERIFY( annot ); |
|
|
|
|
QVERIFY( ta ); |
|
|
|
|
QCOMPARE( annot->subType(), Okular::Annotation::AText ); |
|
|
|
|
QCOMPARE( annot->style().color(), QColor(255,255,255,0) ); |
|
|
|
|
QCOMPARE( ta->textType(), Okular::TextAnnotation::InPlace ); |
|
|
|
|
QCOMPARE( ta->inplaceIntent(), Okular::TextAnnotation::TypeWriter ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PartTest::testJumpToPage() { |
|
|
|
|
const QString testFile = QStringLiteral( KDESRCDIR "data/simple-multipage.pdf" ); |
|
|
|
|
const int targetPage = 25; |
|
|
|
|
|