Changeset View
Changeset View
Standalone View
Standalone View
autotests/parttest.cpp
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | 201 | { | |||
---|---|---|---|---|---|
210 | workDir.mkpath(QStringLiteral(".")); | 210 | workDir.mkpath(QStringLiteral(".")); | ||
211 | 211 | | |||
212 | QFile f(QStringLiteral(KDESRCDIR "data/synctextest.tex")); | 212 | QFile f(QStringLiteral(KDESRCDIR "data/synctextest.tex")); | ||
213 | const QString texDestination = workDir.path() + QStringLiteral("/synctextest.tex"); | 213 | const QString texDestination = workDir.path() + QStringLiteral("/synctextest.tex"); | ||
214 | QVERIFY(f.copy(texDestination)); | 214 | QVERIFY(f.copy(texDestination)); | ||
215 | QProcess process; | 215 | QProcess process; | ||
216 | process.setWorkingDirectory(workDir.path()); | 216 | process.setWorkingDirectory(workDir.path()); | ||
217 | 217 | | |||
218 | const QString pdflatexPath(QStandardPaths::findExecutable("pdflatex")); | 218 | const QString pdflatexPath(QStandardPaths::findExecutable(QStringLiteral("pdflatex"))); | ||
219 | if (pdflatexPath.isEmpty()) { | 219 | if (pdflatexPath.isEmpty()) { | ||
220 | QFAIL("pdflatex executable not found, but needed for the test. Try installing the respective TeXLive packages."); | 220 | QFAIL("pdflatex executable not found, but needed for the test. Try installing the respective TeXLive packages."); | ||
221 | } | 221 | } | ||
222 | process.start(pdflatexPath, QStringList() << QStringLiteral("-synctex=1") << QStringLiteral("-interaction=nonstopmode") << texDestination); | 222 | process.start(pdflatexPath, QStringList() << QStringLiteral("-synctex=1") << QStringLiteral("-interaction=nonstopmode") << texDestination); | ||
223 | bool started = process.waitForStarted(); | 223 | bool started = process.waitForStarted(); | ||
224 | if (!started) { | 224 | if (!started) { | ||
225 | qDebug() << "start error:" << process.error(); | 225 | qDebug() << "start error:" << process.error(); | ||
226 | qDebug() << "start stdout:" << process.readAllStandardOutput(); | 226 | qDebug() << "start stdout:" << process.readAllStandardOutput(); | ||
Show All 22 Lines | |||||
249 | part.openUrl(u); | 249 | part.openUrl(u); | ||
250 | QCOMPARE(part.m_document->currentPage(), 1u); | 250 | QCOMPARE(part.m_document->currentPage(), 1u); | ||
251 | } | 251 | } | ||
252 | 252 | | |||
253 | void PartTest::testForwardPDF_data() | 253 | void PartTest::testForwardPDF_data() | ||
254 | { | 254 | { | ||
255 | QTest::addColumn<QString>("dir"); | 255 | QTest::addColumn<QString>("dir"); | ||
256 | 256 | | |||
257 | QTest::newRow("non-utf8") << QString::fromUtf8("synctextest"); | 257 | QTest::newRow("non-utf8") << QStringLiteral("synctextest"); | ||
258 | QTest::newRow("utf8") << QString::fromUtf8("ßðđđŋßðđŋ"); | 258 | QTest::newRow("utf8") << QStringLiteral("ßðđđŋßðđŋ"); | ||
aacid: QStringliteral is broken on windows with non ascii chars, please turn this back to QString… | |||||
nicolasfella: Might be worth a comment so the next person knows? | |||||
259 | } | 259 | } | ||
260 | 260 | | |||
261 | void PartTest::testGeneratorPreferences() | 261 | void PartTest::testGeneratorPreferences() | ||
262 | { | 262 | { | ||
263 | KConfigDialog * dialog; | 263 | KConfigDialog * dialog; | ||
264 | QVariantList dummyArgs; | 264 | QVariantList dummyArgs; | ||
265 | Okular::Part part(nullptr, nullptr, dummyArgs); | 265 | Okular::Part part(nullptr, nullptr, dummyArgs); | ||
266 | 266 | | |||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 370 | { | |||
385 | 385 | | |||
386 | // wait for pixmap | 386 | // wait for pixmap | ||
387 | QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView)); | 387 | QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView)); | ||
388 | 388 | | |||
389 | // enter text-selection mode | 389 | // enter text-selection mode | ||
390 | QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect")); | 390 | QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect")); | ||
391 | 391 | | |||
392 | // overwrite urlHandler for 'mailto' urls | 392 | // overwrite urlHandler for 'mailto' urls | ||
393 | QDesktopServices::setUrlHandler("mailto", this, "urlHandler"); | 393 | QDesktopServices::setUrlHandler(QStringLiteral("mailto"), this, "urlHandler"); | ||
394 | QSignalSpy openUrlSignalSpy(this, SIGNAL(urlHandler(QUrl))); | 394 | QSignalSpy openUrlSignalSpy(this, &PartTest::urlHandler); | ||
395 | 395 | | |||
396 | // click on url | 396 | // click on url | ||
397 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.250, height * 0.127)); | 397 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.250, height * 0.127)); | ||
398 | QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.250, height * 0.127)); | 398 | QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.250, height * 0.127)); | ||
399 | 399 | | |||
400 | // expect that the urlHandler signal was called | 400 | // expect that the urlHandler signal was called | ||
401 | QTRY_COMPARE(openUrlSignalSpy.count(), 1); | 401 | QTRY_COMPARE(openUrlSignalSpy.count(), 1); | ||
402 | QList<QVariant> arguments = openUrlSignalSpy.takeFirst(); | 402 | QList<QVariant> arguments = openUrlSignalSpy.takeFirst(); | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 462 | { | |||
483 | 483 | | |||
484 | const double mouseY = height * 0.127; | 484 | const double mouseY = height * 0.127; | ||
485 | const double mouseStartX = width * 0.13; | 485 | const double mouseStartX = width * 0.13; | ||
486 | const double mouseEndX = width * 0.40; | 486 | const double mouseEndX = width * 0.40; | ||
487 | 487 | | |||
488 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | 488 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | ||
489 | 489 | | |||
490 | // overwrite urlHandler for 'mailto' urls | 490 | // overwrite urlHandler for 'mailto' urls | ||
491 | QDesktopServices::setUrlHandler("mailto", this, "urlHandler"); | 491 | QDesktopServices::setUrlHandler(QStringLiteral("mailto"), this, "urlHandler"); | ||
492 | QSignalSpy openUrlSignalSpy(this, SIGNAL(urlHandler(QUrl))); | 492 | QSignalSpy openUrlSignalSpy(this, &PartTest::urlHandler); | ||
493 | 493 | | |||
494 | // click on url | 494 | // click on url | ||
495 | const double mouseClickX = width * 0.2997; | 495 | const double mouseClickX = width * 0.2997; | ||
496 | const double mouseClickY = height * 0.1293; | 496 | const double mouseClickY = height * 0.1293; | ||
497 | 497 | | |||
498 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(mouseClickX, mouseClickY)); | 498 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(mouseClickX, mouseClickY)); | ||
499 | QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(mouseClickX, mouseClickY), 1000); | 499 | QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(mouseClickX, mouseClickY), 1000); | ||
500 | 500 | | |||
Show All 34 Lines | 509 | { | |||
535 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | 535 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | ||
536 | 536 | | |||
537 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | 537 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | ||
538 | // the menu disappear | 538 | // the menu disappear | ||
539 | PageView *view = part.m_pageView; | 539 | PageView *view = part.m_pageView; | ||
540 | bool menuClosed = false; | 540 | bool menuClosed = false; | ||
541 | QTimer::singleShot(2000, [view, &menuClosed]() { | 541 | QTimer::singleShot(2000, [view, &menuClosed]() { | ||
542 | // check if popup menu is active and visible | 542 | // check if popup menu is active and visible | ||
543 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>("PopupMenu")); | 543 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>(QStringLiteral("PopupMenu"))); | ||
544 | QVERIFY(menu); | 544 | QVERIFY(menu); | ||
545 | QVERIFY(menu->isVisible()); | 545 | QVERIFY(menu->isVisible()); | ||
546 | 546 | | |||
547 | // check if the menu contains go-to link action | 547 | // check if the menu contains go-to link action | ||
548 | QAction *goToAction = qobject_cast<QAction*>(menu->findChild<QAction*>("GoToAction")); | 548 | QAction *goToAction = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("GoToAction"))); | ||
549 | QVERIFY(goToAction); | 549 | QVERIFY(goToAction); | ||
550 | 550 | | |||
551 | // check if the "follow this link" action is not visible | 551 | // check if the "follow this link" action is not visible | ||
552 | QAction *processLinkAction = qobject_cast<QAction*>(menu->findChild<QAction*>("ProcessLinkAction")); | 552 | QAction *processLinkAction = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("ProcessLinkAction"))); | ||
553 | QVERIFY(!processLinkAction); | 553 | QVERIFY(!processLinkAction); | ||
554 | 554 | | |||
555 | // check if the "copy link address" action is not visible | 555 | // check if the "copy link address" action is not visible | ||
556 | QAction *copyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>("CopyLinkLocationAction")); | 556 | QAction *copyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("CopyLinkLocationAction"))); | ||
557 | QVERIFY(!copyLinkLocation); | 557 | QVERIFY(!copyLinkLocation); | ||
558 | 558 | | |||
559 | // close menu to continue test | 559 | // close menu to continue test | ||
560 | menu->close(); | 560 | menu->close(); | ||
561 | menuClosed = true; | 561 | menuClosed = true; | ||
562 | }); | 562 | }); | ||
563 | 563 | | |||
564 | // click on url | 564 | // click on url | ||
Show All 39 Lines | 578 | { | |||
604 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | 604 | simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); | ||
605 | 605 | | |||
606 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | 606 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | ||
607 | // the menu disappear | 607 | // the menu disappear | ||
608 | PageView *view = part.m_pageView; | 608 | PageView *view = part.m_pageView; | ||
609 | bool menuClosed = false; | 609 | bool menuClosed = false; | ||
610 | QTimer::singleShot(2000, [view, &menuClosed]() { | 610 | QTimer::singleShot(2000, [view, &menuClosed]() { | ||
611 | // check if popup menu is active and visible | 611 | // check if popup menu is active and visible | ||
612 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>("PopupMenu")); | 612 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>(QStringLiteral("PopupMenu"))); | ||
613 | QVERIFY(menu); | 613 | QVERIFY(menu); | ||
614 | QVERIFY(menu->isVisible()); | 614 | QVERIFY(menu->isVisible()); | ||
615 | 615 | | |||
616 | // check if the menu contains "follow this link" action | 616 | // check if the menu contains "follow this link" action | ||
617 | QAction *processLinkAction = qobject_cast<QAction*>(menu->findChild<QAction*>("ProcessLinkAction")); | 617 | QAction *processLinkAction = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("ProcessLinkAction"))); | ||
618 | QVERIFY(processLinkAction); | 618 | QVERIFY(processLinkAction); | ||
619 | 619 | | |||
620 | // check if the menu contains "copy link address" action | 620 | // check if the menu contains "copy link address" action | ||
621 | QAction *copyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>("CopyLinkLocationAction")); | 621 | QAction *copyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("CopyLinkLocationAction"))); | ||
622 | QVERIFY(copyLinkLocation); | 622 | QVERIFY(copyLinkLocation); | ||
623 | 623 | | |||
624 | // close menu to continue test | 624 | // close menu to continue test | ||
625 | menu->close(); | 625 | menu->close(); | ||
626 | menuClosed = true; | 626 | menuClosed = true; | ||
627 | }); | 627 | }); | ||
628 | 628 | | |||
629 | // click on url | 629 | // click on url | ||
Show All 31 Lines | 641 | { | |||
661 | QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect")); | 661 | QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect")); | ||
662 | 662 | | |||
663 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | 663 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | ||
664 | // the menu disappear | 664 | // the menu disappear | ||
665 | PageView *view = part.m_pageView; | 665 | PageView *view = part.m_pageView; | ||
666 | bool menuClosed = false; | 666 | bool menuClosed = false; | ||
667 | QTimer::singleShot(2000, [view, &menuClosed]() { | 667 | QTimer::singleShot(2000, [view, &menuClosed]() { | ||
668 | // check if popup menu is active and visible | 668 | // check if popup menu is active and visible | ||
669 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>("PopupMenu")); | 669 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>(QStringLiteral("PopupMenu"))); | ||
670 | QVERIFY(menu); | 670 | QVERIFY(menu); | ||
671 | QVERIFY(menu->isVisible()); | 671 | QVERIFY(menu->isVisible()); | ||
672 | 672 | | |||
673 | // check if the menu contains "Follow this link" action | 673 | // check if the menu contains "Follow this link" action | ||
674 | QAction *processLink = qobject_cast<QAction*>(menu->findChild<QAction*>("ProcessLinkAction")); | 674 | QAction *processLink = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("ProcessLinkAction"))); | ||
675 | QVERIFY(processLink); | 675 | QVERIFY(processLink); | ||
676 | 676 | | |||
677 | // chek if the menu contains "Copy Link Address" action | 677 | // chek if the menu contains "Copy Link Address" action | ||
678 | QAction *actCopyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>("CopyLinkLocationAction")); | 678 | QAction *actCopyLinkLocation = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("CopyLinkLocationAction"))); | ||
679 | QVERIFY(actCopyLinkLocation); | 679 | QVERIFY(actCopyLinkLocation); | ||
680 | 680 | | |||
681 | // close menu to continue test | 681 | // close menu to continue test | ||
682 | menu->close(); | 682 | menu->close(); | ||
683 | menuClosed = true; | 683 | menuClosed = true; | ||
684 | }); | 684 | }); | ||
685 | 685 | | |||
686 | // r-click on url | 686 | // r-click on url | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 740 | { | |||
767 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | 767 | // Need to do this because the pop-menu will have his own mainloop and will block tests until | ||
768 | // the menu disappear | 768 | // the menu disappear | ||
769 | PageView *view = part.m_pageView; | 769 | PageView *view = part.m_pageView; | ||
770 | bool menuClosed = false; | 770 | bool menuClosed = false; | ||
771 | QTimer::singleShot(2000, [view, &menuClosed]() { | 771 | QTimer::singleShot(2000, [view, &menuClosed]() { | ||
772 | QApplication::clipboard()->clear(); | 772 | QApplication::clipboard()->clear(); | ||
773 | 773 | | |||
774 | // check if popup menu is active and visible | 774 | // check if popup menu is active and visible | ||
775 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>("PopupMenu")); | 775 | QMenu *menu = qobject_cast<QMenu*>(view->findChild<QMenu*>(QStringLiteral("PopupMenu"))); | ||
776 | QVERIFY(menu); | 776 | QVERIFY(menu); | ||
777 | QVERIFY(menu->isVisible()); | 777 | QVERIFY(menu->isVisible()); | ||
778 | 778 | | |||
779 | // check if the copy selected text to clipboard is present | 779 | // check if the copy selected text to clipboard is present | ||
780 | QAction *copyAct = qobject_cast<QAction*>(menu->findChild<QAction*>("CopyTextToClipboard")); | 780 | QAction *copyAct = qobject_cast<QAction*>(menu->findChild<QAction*>(QStringLiteral("CopyTextToClipboard"))); | ||
781 | QVERIFY(copyAct); | 781 | QVERIFY(copyAct); | ||
782 | 782 | | |||
783 | menu->close(); | 783 | menu->close(); | ||
784 | menuClosed = true; | 784 | menuClosed = true; | ||
785 | }); | 785 | }); | ||
786 | 786 | | |||
787 | simulateMouseSelection(mouseStartX, mouseStartY, mouseEndX, mouseEndY, part.m_pageView->viewport()); | 787 | simulateMouseSelection(mouseStartX, mouseStartY, mouseEndX, mouseEndY, part.m_pageView->viewport()); | ||
788 | 788 | | |||
Show All 26 Lines | |||||
815 | 815 | | |||
816 | void PartTest::testSaveAsToNonExistingPath() | 816 | void PartTest::testSaveAsToNonExistingPath() | ||
817 | { | 817 | { | ||
818 | Okular::Part part(nullptr, nullptr, QVariantList()); | 818 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
819 | part.openDocument( KDESRCDIR "data/file1.pdf" ); | 819 | part.openDocument( KDESRCDIR "data/file1.pdf" ); | ||
820 | 820 | | |||
821 | QString saveFilePath; | 821 | QString saveFilePath; | ||
822 | { | 822 | { | ||
823 | QTemporaryFile saveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 823 | QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
824 | saveFile.open(); | 824 | saveFile.open(); | ||
825 | saveFilePath = saveFile.fileName(); | 825 | saveFilePath = saveFile.fileName(); | ||
826 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | 826 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | ||
827 | } | 827 | } | ||
828 | 828 | | |||
829 | QVERIFY( !QFileInfo::exists( saveFilePath ) ); | 829 | QVERIFY( !QFileInfo::exists( saveFilePath ) ); | ||
830 | 830 | | |||
831 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFilePath ), Part::NoSaveAsFlags ) ); | 831 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFilePath ), Part::NoSaveAsFlags ) ); | ||
832 | 832 | | |||
833 | QFile::remove( saveFilePath ); | 833 | QFile::remove( saveFilePath ); | ||
834 | } | 834 | } | ||
835 | 835 | | |||
836 | void PartTest::testSaveAsToSymlink() | 836 | void PartTest::testSaveAsToSymlink() | ||
837 | { | 837 | { | ||
838 | #ifdef Q_OS_UNIX | 838 | #ifdef Q_OS_UNIX | ||
839 | Okular::Part part(nullptr, nullptr, QVariantList()); | 839 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
840 | part.openDocument( KDESRCDIR "data/file1.pdf" ); | 840 | part.openDocument( KDESRCDIR "data/file1.pdf" ); | ||
841 | 841 | | |||
842 | QTemporaryFile newFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 842 | QTemporaryFile newFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
843 | newFile.open(); | 843 | newFile.open(); | ||
844 | 844 | | |||
845 | QString linkFilePath; | 845 | QString linkFilePath; | ||
846 | { | 846 | { | ||
847 | QTemporaryFile linkFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 847 | QTemporaryFile linkFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
848 | linkFile.open(); | 848 | linkFile.open(); | ||
849 | linkFilePath = linkFile.fileName(); | 849 | linkFilePath = linkFile.fileName(); | ||
850 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | 850 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | ||
851 | } | 851 | } | ||
852 | 852 | | |||
853 | QFile::link( newFile.fileName(), linkFilePath ); | 853 | QFile::link( newFile.fileName(), linkFilePath ); | ||
854 | 854 | | |||
855 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | 855 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | ||
856 | 856 | | |||
857 | QVERIFY( part.saveAs( QUrl::fromLocalFile( linkFilePath ), Part::NoSaveAsFlags ) ); | 857 | QVERIFY( part.saveAs( QUrl::fromLocalFile( linkFilePath ), Part::NoSaveAsFlags ) ); | ||
858 | 858 | | |||
859 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | 859 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | ||
860 | 860 | | |||
861 | QFile::remove( linkFilePath ); | 861 | QFile::remove( linkFilePath ); | ||
862 | #endif | 862 | #endif | ||
863 | } | 863 | } | ||
864 | 864 | | |||
865 | void PartTest::testSaveIsSymlink() | 865 | void PartTest::testSaveIsSymlink() | ||
866 | { | 866 | { | ||
867 | #ifdef Q_OS_UNIX | 867 | #ifdef Q_OS_UNIX | ||
868 | Okular::Part part(nullptr, nullptr, QVariantList()); | 868 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
869 | 869 | | |||
870 | QString newFilePath; | 870 | QString newFilePath; | ||
871 | { | 871 | { | ||
872 | QTemporaryFile newFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 872 | QTemporaryFile newFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
873 | newFile.open(); | 873 | newFile.open(); | ||
874 | newFilePath = newFile.fileName(); | 874 | newFilePath = newFile.fileName(); | ||
875 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | 875 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | ||
876 | } | 876 | } | ||
877 | 877 | | |||
878 | QFile::copy( KDESRCDIR "data/file1.pdf", newFilePath ); | 878 | QFile::copy( KDESRCDIR "data/file1.pdf", newFilePath ); | ||
879 | 879 | | |||
880 | QString linkFilePath; | 880 | QString linkFilePath; | ||
881 | { | 881 | { | ||
882 | QTemporaryFile linkFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 882 | QTemporaryFile linkFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
883 | linkFile.open(); | 883 | linkFile.open(); | ||
884 | linkFilePath = linkFile.fileName(); | 884 | linkFilePath = linkFile.fileName(); | ||
885 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | 885 | // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares | ||
886 | } | 886 | } | ||
887 | 887 | | |||
888 | QFile::link( newFilePath, linkFilePath ); | 888 | QFile::link( newFilePath, linkFilePath ); | ||
889 | 889 | | |||
890 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | 890 | QVERIFY( QFileInfo( linkFilePath ).isSymLink() ); | ||
Show All 13 Lines | 903 | { | |||
904 | QFETCH(QString, file); | 904 | QFETCH(QString, file); | ||
905 | QFETCH(QString, extension); | 905 | QFETCH(QString, extension); | ||
906 | QFETCH(bool, nativelySupportsAnnotations); | 906 | QFETCH(bool, nativelySupportsAnnotations); | ||
907 | QFETCH(bool, canSwapBackingFile); | 907 | QFETCH(bool, canSwapBackingFile); | ||
908 | 908 | | |||
909 | QScopedPointer<CloseDialogHelper> closeDialogHelper; | 909 | QScopedPointer<CloseDialogHelper> closeDialogHelper; | ||
910 | 910 | | |||
911 | QString annotName; | 911 | QString annotName; | ||
912 | QTemporaryFile archiveSave( QString( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) ); | 912 | QTemporaryFile archiveSave( QStringLiteral( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) ); | ||
913 | QTemporaryFile nativeDirectSave( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | 913 | QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | ||
914 | QTemporaryFile nativeFromArchiveFile( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | 914 | QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | ||
915 | QVERIFY( archiveSave.open() ); | 915 | QVERIFY( archiveSave.open() ); | ||
916 | archiveSave.close(); | 916 | archiveSave.close(); | ||
917 | QVERIFY( nativeDirectSave.open() ); | 917 | QVERIFY( nativeDirectSave.open() ); | ||
918 | nativeDirectSave.close(); | 918 | nativeDirectSave.close(); | ||
919 | QVERIFY( nativeFromArchiveFile.open() ); | 919 | QVERIFY( nativeFromArchiveFile.open() ); | ||
920 | nativeFromArchiveFile.close(); | 920 | nativeFromArchiveFile.close(); | ||
921 | 921 | | |||
922 | qDebug() << "Open file, add annotation and save both natively and to .okular"; | 922 | qDebug() << "Open file, add annotation and save both natively and to .okular"; | ||
923 | { | 923 | { | ||
924 | Okular::Part part(nullptr, nullptr, QVariantList()); | 924 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
925 | part.openDocument( file ); | 925 | part.openDocument( file ); | ||
926 | part.m_document->documentInfo(); | 926 | part.m_document->documentInfo(); | ||
927 | 927 | | |||
928 | QCOMPARE(part.m_document->canSwapBackingFile(), canSwapBackingFile); | 928 | QCOMPARE(part.m_document->canSwapBackingFile(), canSwapBackingFile); | ||
929 | 929 | | |||
930 | Okular::Annotation *annot = new Okular::TextAnnotation(); | 930 | Okular::Annotation *annot = new Okular::TextAnnotation(); | ||
931 | annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); | 931 | annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); | ||
932 | annot->setContents( "annot contents" ); | 932 | annot->setContents( QStringLiteral("annot contents") ); | ||
933 | part.m_document->addPageAnnotation( 0, annot ); | 933 | part.m_document->addPageAnnotation( 0, annot ); | ||
934 | annotName = annot->uniqueName(); | 934 | annotName = annot->uniqueName(); | ||
935 | 935 | | |||
936 | if ( canSwapBackingFile ) | 936 | if ( canSwapBackingFile ) | ||
937 | { | 937 | { | ||
938 | if ( !nativelySupportsAnnotations ) | 938 | if ( !nativelySupportsAnnotations ) | ||
939 | { | 939 | { | ||
940 | closeDialogHelper.reset(new CloseDialogHelper( &part, QDialogButtonBox::No )); // this is the "you're going to lose the annotations" dialog | 940 | closeDialogHelper.reset(new CloseDialogHelper( &part, QDialogButtonBox::No )); // this is the "you're going to lose the annotations" dialog | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 1052 | { | |||
1059 | const Part::SaveAsFlag saveFlags = saveToArchive ? Part::SaveAsOkularArchive : Part::NoSaveAsFlags; | 1059 | const Part::SaveAsFlag saveFlags = saveToArchive ? Part::SaveAsOkularArchive : Part::NoSaveAsFlags; | ||
1060 | 1060 | | |||
1061 | QScopedPointer<CloseDialogHelper> closeDialogHelper; | 1061 | QScopedPointer<CloseDialogHelper> closeDialogHelper; | ||
1062 | 1062 | | |||
1063 | // closeDialogHelper relies on the availability of the "Continue" button to drop changes | 1063 | // closeDialogHelper relies on the availability of the "Continue" button to drop changes | ||
1064 | // when saving to a file format not supporting those. However, this button is only sensible | 1064 | // when saving to a file format not supporting those. However, this button is only sensible | ||
1065 | // and available for "Save As", but not for "Save". By alternately saving to saveFile1 and | 1065 | // and available for "Save As", but not for "Save". By alternately saving to saveFile1 and | ||
1066 | // saveFile2 we always force "Save As", so closeDialogHelper keeps working. | 1066 | // saveFile2 we always force "Save As", so closeDialogHelper keeps working. | ||
1067 | QTemporaryFile saveFile1( QString( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | 1067 | QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | ||
1068 | QVERIFY( saveFile1.open() ); | 1068 | QVERIFY( saveFile1.open() ); | ||
1069 | saveFile1.close(); | 1069 | saveFile1.close(); | ||
1070 | QTemporaryFile saveFile2( QString( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | 1070 | QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); | ||
1071 | QVERIFY( saveFile2.open() ); | 1071 | QVERIFY( saveFile2.open() ); | ||
1072 | saveFile2.close(); | 1072 | saveFile2.close(); | ||
1073 | 1073 | | |||
1074 | Okular::Part part(nullptr, nullptr, QVariantList()); | 1074 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
1075 | part.openDocument( file ); | 1075 | part.openDocument( file ); | ||
1076 | 1076 | | |||
1077 | QCOMPARE(part.m_document->canSwapBackingFile(), canSwapBackingFile); | 1077 | QCOMPARE(part.m_document->canSwapBackingFile(), canSwapBackingFile); | ||
1078 | 1078 | | |||
1079 | Okular::Annotation *annot = new Okular::TextAnnotation(); | 1079 | Okular::Annotation *annot = new Okular::TextAnnotation(); | ||
1080 | annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); | 1080 | annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); | ||
1081 | annot->setContents( "annot contents" ); | 1081 | annot->setContents( QStringLiteral("annot contents") ); | ||
1082 | part.m_document->addPageAnnotation( 0, annot ); | 1082 | part.m_document->addPageAnnotation( 0, annot ); | ||
1083 | QString annotName = annot->uniqueName(); | 1083 | QString annotName = annot->uniqueName(); | ||
1084 | 1084 | | |||
1085 | if ( !nativelySupportsAnnotations && !saveToArchive ) { | 1085 | if ( !nativelySupportsAnnotations && !saveToArchive ) { | ||
1086 | closeDialogHelper.reset(new CloseDialogHelper( &part, QDialogButtonBox::No )); // this is the "you're going to lose the annotations" dialog | 1086 | closeDialogHelper.reset(new CloseDialogHelper( &part, QDialogButtonBox::No )); // this is the "you're going to lose the annotations" dialog | ||
1087 | } | 1087 | } | ||
1088 | 1088 | | |||
1089 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile1.fileName() ), saveFlags ) ); | 1089 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile1.fileName() ), saveFlags ) ); | ||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | |||||
1245 | void PartTest::testSaveAsUndoStackForms() | 1245 | void PartTest::testSaveAsUndoStackForms() | ||
1246 | { | 1246 | { | ||
1247 | QFETCH(QString, file); | 1247 | QFETCH(QString, file); | ||
1248 | QFETCH(QString, extension); | 1248 | QFETCH(QString, extension); | ||
1249 | QFETCH(bool, saveToArchive); | 1249 | QFETCH(bool, saveToArchive); | ||
1250 | 1250 | | |||
1251 | const Part::SaveAsFlag saveFlags = saveToArchive ? Part::SaveAsOkularArchive : Part::NoSaveAsFlags; | 1251 | const Part::SaveAsFlag saveFlags = saveToArchive ? Part::SaveAsOkularArchive : Part::NoSaveAsFlags; | ||
1252 | 1252 | | |||
1253 | QTemporaryFile saveFile( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) ); | 1253 | QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) ); | ||
1254 | QVERIFY( saveFile.open() ); | 1254 | QVERIFY( saveFile.open() ); | ||
1255 | saveFile.close(); | 1255 | saveFile.close(); | ||
1256 | 1256 | | |||
1257 | Okular::Part part(nullptr, nullptr, QVariantList()); | 1257 | Okular::Part part(nullptr, nullptr, QVariantList()); | ||
1258 | part.openDocument( file ); | 1258 | part.openDocument( file ); | ||
1259 | 1259 | | |||
1260 | for ( FormField *ff : part.m_document->page( 0 )->formFields() ) | 1260 | for ( FormField *ff : part.m_document->page( 0 )->formFields() ) | ||
1261 | { | 1261 | { | ||
1262 | if ( ff->id() == 65537 ) | 1262 | if ( ff->id() == 65537 ) | ||
1263 | { | 1263 | { | ||
1264 | QCOMPARE( ff->type(), FormField::FormText ); | 1264 | QCOMPARE( ff->type(), FormField::FormText ); | ||
1265 | FormFieldText *fft = static_cast<FormFieldText *>( ff ); | 1265 | FormFieldText *fft = static_cast<FormFieldText *>( ff ); | ||
1266 | part.m_document->editFormText( 0, fft, "BlaBla", 6, 0, 0 ); | 1266 | part.m_document->editFormText( 0, fft, QStringLiteral("BlaBla"), 6, 0, 0 ); | ||
1267 | } | 1267 | } | ||
1268 | else if ( ff->id() == 65538 ) | 1268 | else if ( ff->id() == 65538 ) | ||
1269 | { | 1269 | { | ||
1270 | QCOMPARE( ff->type(), FormField::FormButton ); | 1270 | QCOMPARE( ff->type(), FormField::FormButton ); | ||
1271 | FormFieldButton *ffb = static_cast<FormFieldButton *>( ff ); | 1271 | FormFieldButton *ffb = static_cast<FormFieldButton *>( ff ); | ||
1272 | QCOMPARE( ffb->buttonType(), FormFieldButton::Radio ); | 1272 | QCOMPARE( ffb->buttonType(), FormFieldButton::Radio ); | ||
1273 | part.m_document->editFormButtons( 0, QList< FormFieldButton* >() << ffb, QList< bool >() << true ); | 1273 | part.m_document->editFormButtons( 0, QList< FormFieldButton* >() << ffb, QList< bool >() << true ); | ||
1274 | } | 1274 | } | ||
1275 | else if ( ff->id() == 65542 ) | 1275 | else if ( ff->id() == 65542 ) | ||
1276 | { | 1276 | { | ||
1277 | QCOMPARE( ff->type(), FormField::FormChoice ); | 1277 | QCOMPARE( ff->type(), FormField::FormChoice ); | ||
1278 | FormFieldChoice *ffc = static_cast<FormFieldChoice *>( ff ); | 1278 | FormFieldChoice *ffc = static_cast<FormFieldChoice *>( ff ); | ||
1279 | QCOMPARE( ffc->choiceType(), FormFieldChoice::ListBox ); | 1279 | QCOMPARE( ffc->choiceType(), FormFieldChoice::ListBox ); | ||
1280 | part.m_document->editFormList( 0, ffc, QList< int >() << 1 ); | 1280 | part.m_document->editFormList( 0, ffc, QList< int >() << 1 ); | ||
1281 | } | 1281 | } | ||
1282 | else if ( ff->id() == 65543 ) | 1282 | else if ( ff->id() == 65543 ) | ||
1283 | { | 1283 | { | ||
1284 | QCOMPARE( ff->type(), FormField::FormChoice ); | 1284 | QCOMPARE( ff->type(), FormField::FormChoice ); | ||
1285 | FormFieldChoice *ffc = static_cast<FormFieldChoice *>( ff ); | 1285 | FormFieldChoice *ffc = static_cast<FormFieldChoice *>( ff ); | ||
1286 | QCOMPARE( ffc->choiceType(), FormFieldChoice::ComboBox ); | 1286 | QCOMPARE( ffc->choiceType(), FormFieldChoice::ComboBox ); | ||
1287 | part.m_document->editFormCombo( 0, ffc, "combo2", 3, 0, 0); | 1287 | part.m_document->editFormCombo( 0, ffc, QStringLiteral("combo2"), 3, 0, 0); | ||
1288 | } | 1288 | } | ||
1289 | } | 1289 | } | ||
1290 | 1290 | | |||
1291 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), saveFlags ) ); | 1291 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), saveFlags ) ); | ||
1292 | 1292 | | |||
1293 | QVERIFY( part.m_document->canUndo() ); | 1293 | QVERIFY( part.m_document->canUndo() ); | ||
1294 | part.m_document->undo(); | 1294 | part.m_document->undo(); | ||
1295 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), saveFlags ) ); | 1295 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), saveFlags ) ); | ||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Line(s) | 1409 | #endif | |||
1479 | QVERIFY( targetDefaultRO->isReadOnly() ); | 1479 | QVERIFY( targetDefaultRO->isReadOnly() ); | ||
1480 | 1480 | | |||
1481 | // Now set both to checked again and confirm that | 1481 | // Now set both to checked again and confirm that | ||
1482 | // save / load works. | 1482 | // save / load works. | ||
1483 | btnStates.clear(); | 1483 | btnStates.clear(); | ||
1484 | btnStates << true << true; | 1484 | btnStates << true << true; | ||
1485 | part.m_document->editFormButtons( 0, btns, btnStates ); | 1485 | part.m_document->editFormButtons( 0, btns, btnStates ); | ||
1486 | 1486 | | |||
1487 | QTemporaryFile saveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | 1487 | QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); | ||
1488 | QVERIFY( saveFile.open() ); | 1488 | QVERIFY( saveFile.open() ); | ||
1489 | saveFile.close(); | 1489 | saveFile.close(); | ||
1490 | 1490 | | |||
1491 | // Save | 1491 | // Save | ||
1492 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), Part::NoSaveAsFlags ) ); | 1492 | QVERIFY( part.saveAs( QUrl::fromLocalFile( saveFile.fileName() ), Part::NoSaveAsFlags ) ); | ||
1493 | part.closeUrl(); | 1493 | part.closeUrl(); | ||
1494 | 1494 | | |||
1495 | // Load | 1495 | // Load | ||
Show All 24 Lines | |||||
1520 | void PartTest::testCrashTextEditDestroy() | 1520 | void PartTest::testCrashTextEditDestroy() | ||
1521 | { | 1521 | { | ||
1522 | const QString testFile = QStringLiteral( KDESRCDIR "data/formSamples.pdf" ); | 1522 | const QString testFile = QStringLiteral( KDESRCDIR "data/formSamples.pdf" ); | ||
1523 | Okular::Part part( nullptr, nullptr, QVariantList() ); | 1523 | Okular::Part part( nullptr, nullptr, QVariantList() ); | ||
1524 | part.openDocument( testFile ); | 1524 | part.openDocument( testFile ); | ||
1525 | part.widget()->show(); | 1525 | part.widget()->show(); | ||
1526 | QVERIFY(QTest::qWaitForWindowExposed(part.widget())); | 1526 | QVERIFY(QTest::qWaitForWindowExposed(part.widget())); | ||
1527 | 1527 | | |||
1528 | part.widget()->findChild<QTextEdit*>()->setText("HOLA"); | 1528 | part.widget()->findChild<QTextEdit*>()->setText(QStringLiteral("HOLA")); | ||
1529 | part.actionCollection()->action(QStringLiteral("view_toggle_forms"))->trigger(); | 1529 | part.actionCollection()->action(QStringLiteral("view_toggle_forms"))->trigger(); | ||
1530 | } | 1530 | } | ||
1531 | 1531 | | |||
1532 | void PartTest::testAnnotWindow() | 1532 | void PartTest::testAnnotWindow() | ||
1533 | { | 1533 | { | ||
1534 | QVariantList dummyArgs; | 1534 | QVariantList dummyArgs; | ||
1535 | Okular::Part part(nullptr, nullptr, dummyArgs); | 1535 | Okular::Part part(nullptr, nullptr, dummyArgs); | ||
1536 | QVERIFY(openDocument(&part, QStringLiteral(KDESRCDIR "data/file1.pdf"))); | 1536 | QVERIFY(openDocument(&part, QStringLiteral(KDESRCDIR "data/file1.pdf"))); | ||
Show All 32 Lines | |||||
1569 | QVERIFY( part.m_document->page( 0 )->annotations().size() == 2 ); | 1569 | QVERIFY( part.m_document->page( 0 )->annotations().size() == 2 ); | ||
1570 | 1570 | | |||
1571 | // Double click the first annotation to open its window (move mouse for visual feedback) | 1571 | // Double click the first annotation to open its window (move mouse for visual feedback) | ||
1572 | const NormalizedPoint annot1pt = annot1->boundingRectangle().center(); | 1572 | const NormalizedPoint annot1pt = annot1->boundingRectangle().center(); | ||
1573 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot1pt.x, height * annot1pt.y)); | 1573 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot1pt.x, height * annot1pt.y)); | ||
1574 | QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot1pt.x, height * annot1pt.y)); | 1574 | QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot1pt.x, height * annot1pt.y)); | ||
1575 | QTRY_COMPARE( part.m_pageView->findChildren<QFrame *>("AnnotWindow").size(), 1 ); | 1575 | QTRY_COMPARE( part.m_pageView->findChildren<QFrame *>("AnnotWindow").size(), 1 ); | ||
1576 | // Verify that the window is visible | 1576 | // Verify that the window is visible | ||
1577 | QFrame* win1 = part.m_pageView->findChild<QFrame *>("AnnotWindow"); | 1577 | QFrame* win1 = part.m_pageView->findChild<QFrame *>(QStringLiteral("AnnotWindow")); | ||
1578 | QVERIFY( !win1->visibleRegion().isEmpty() ); | 1578 | QVERIFY( !win1->visibleRegion().isEmpty() ); | ||
1579 | 1579 | | |||
1580 | // Double click the second annotation to open its window (move mouse for visual feedback) | 1580 | // Double click the second annotation to open its window (move mouse for visual feedback) | ||
1581 | const NormalizedPoint annot2pt = annot2->boundingRectangle().center(); | 1581 | const NormalizedPoint annot2pt = annot2->boundingRectangle().center(); | ||
1582 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot2pt.x, height * annot2pt.y)); | 1582 | QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot2pt.x, height * annot2pt.y)); | ||
1583 | QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot2pt.x, height * annot2pt.y)); | 1583 | QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot2pt.x, height * annot2pt.y)); | ||
1584 | QTRY_COMPARE( part.m_pageView->findChildren<QFrame *>("AnnotWindow").size(), 2 ); | 1584 | QTRY_COMPARE( part.m_pageView->findChildren<QFrame *>("AnnotWindow").size(), 2 ); | ||
1585 | // Verify that the first window is hidden covered by the second, which is visible | 1585 | // Verify that the first window is hidden covered by the second, which is visible | ||
1586 | QList<QFrame *> lstWin = part.m_pageView->findChildren<QFrame *>("AnnotWindow"); | 1586 | QList<QFrame *> lstWin = part.m_pageView->findChildren<QFrame *>(QStringLiteral("AnnotWindow")); | ||
1587 | QFrame * win2; | 1587 | QFrame * win2; | ||
1588 | if (lstWin[0] == win1) { | 1588 | if (lstWin[0] == win1) { | ||
1589 | win2 = lstWin[1]; | 1589 | win2 = lstWin[1]; | ||
1590 | } else { | 1590 | } else { | ||
1591 | win2 = lstWin[0]; | 1591 | win2 = lstWin[0]; | ||
1592 | } | 1592 | } | ||
1593 | QVERIFY( win1->visibleRegion().isEmpty() ); | 1593 | QVERIFY( win1->visibleRegion().isEmpty() ); | ||
1594 | QVERIFY( !win2->visibleRegion().isEmpty() ); | 1594 | QVERIFY( !win2->visibleRegion().isEmpty() ); | ||
▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Line(s) | 1787 | { | |||
1803 | qputenv("HOME", homePath); | 1803 | qputenv("HOME", homePath); | ||
1804 | qputenv("XDG_DATA_HOME", homePath + "/.local"); | 1804 | qputenv("XDG_DATA_HOME", homePath + "/.local"); | ||
1805 | qputenv("XDG_CONFIG_HOME", homePath + "/.kde-unit-test/xdg/config"); | 1805 | qputenv("XDG_CONFIG_HOME", homePath + "/.kde-unit-test/xdg/config"); | ||
1806 | 1806 | | |||
1807 | // Disable fancy debug output | 1807 | // Disable fancy debug output | ||
1808 | qunsetenv("QT_MESSAGE_PATTERN"); | 1808 | qunsetenv("QT_MESSAGE_PATTERN"); | ||
1809 | 1809 | | |||
1810 | QApplication app( argc, argv ); | 1810 | QApplication app( argc, argv ); | ||
1811 | app.setApplicationName(QLatin1String("okularparttest")); | 1811 | app.setApplicationName(QStringLiteral("okularparttest")); | ||
1812 | app.setOrganizationDomain(QLatin1String("kde.org")); | 1812 | app.setOrganizationDomain(QStringLiteral("kde.org")); | ||
1813 | app.setQuitOnLastWindowClosed(false); | 1813 | app.setQuitOnLastWindowClosed(false); | ||
1814 | 1814 | | |||
1815 | qRegisterMetaType<QUrl>(); /*as done by kapplication*/ | 1815 | qRegisterMetaType<QUrl>(); /*as done by kapplication*/ | ||
1816 | qRegisterMetaType<QList<QUrl>>(); | 1816 | qRegisterMetaType<QList<QUrl>>(); | ||
1817 | 1817 | | |||
1818 | Okular::PartTest test; | 1818 | Okular::PartTest test; | ||
1819 | 1819 | | |||
1820 | return QTest::qExec( &test, argc, argv ); | 1820 | return QTest::qExec( &test, argc, argv ); | ||
1821 | } | 1821 | } | ||
1822 | 1822 | | |||
1823 | #include "parttest.moc" | 1823 | #include "parttest.moc" |
QStringliteral is broken on windows with non ascii chars, please turn this back to QString::fromUtf8 so tests don't start failing.