Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit fe1325d6 authored by Albert Astals Cid's avatar Albert Astals Cid

Add a test that selects text with the mouse and checks it is what it should be

parent 99667e4c
......@@ -8,14 +8,18 @@
#include <qtest_kde.h>
#include <qtestmouse.h>
#include "../core/page.h"
#include "../part.h"
#include "../ui/toc.h"
#include "../ui/pageview.h"
#include <KConfigDialog>
#include <KStandardDirs>
#include <KTempDir>
#include <QClipboard>
#include <QTreeView>
namespace Okular
......@@ -32,6 +36,7 @@ class PartTest
void testFowardPDF();
void testFowardPDF_data();
void testGeneratorPreferences();
void testSelectText();
class PartThatHijacksQueryClose : public Okular::Part
......@@ -158,6 +163,34 @@ void PartTest::testGeneratorPreferences()
delete dialog;
void PartTest::testSelectText()
QVariantList dummyArgs;
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
part.openDocument(KDESRCDIR "data/file2.pdf");
const int width = part.m_pageView->width();
const int height = part.m_pageView->height();
// wait for pixmap
while (!part.m_document->page(0)->hasPixmap(part.m_pageView))
QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect");
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.12, height * 0.16));
QTest::mousePress(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.12, height * 0.16));
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.8, height * 0.16));
QTest::mouseRelease(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.8, height * 0.16));
QMetaObject::invokeMethod(part.m_pageView, "copyTextSelection");
QCOMPARE(QApplication::clipboard()->text(), QString("Hola que tal\n"));
int main(int argc, char *argv[])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment