summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2016-10-30 22:18:24 (GMT)
committerAlbert Astals Cid <aacid@kde.org>2016-10-30 22:19:14 (GMT)
commit5db87d4d6fd4f02ffa6514639b95ac950432804d (patch)
tree5f40c5dd313559d056c8db96803294f70bc4055f
parentc8742b3f378e665a0c4e7a5baf7ccd22c236838e (diff)
Fix autotest
Make the click/select location depend on the content size, not on the window size
-rw-r--r--autotests/parttest.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp
index 82607c0..d55e3cf 100644
--- a/autotests/parttest.cpp
+++ b/autotests/parttest.cpp
@@ -17,6 +17,7 @@
#include <KConfigDialog>
#include <QClipboard>
+#include <QScrollBar>
#include <QTemporaryDir>
#include <QTreeView>
@@ -194,8 +195,10 @@ void PartTest::testSelectText()
part.widget()->show();
QTest::qWaitForWindowExposed(part.widget());
- const int width = part.m_pageView->width();
- const int height = part.m_pageView->height();
+ 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);
@@ -204,13 +207,13 @@ void PartTest::testSelectText()
QVERIFY(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::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.12, height * 0.055));
+ QTest::mousePress(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.12, height * 0.055));
+ QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.8, height * 0.055));
// without this wait the test fails. 100ms were enough on my local system, but when running under valgrind
// or on the CI server we need to wait longer.
QTest::qWait(1000);
- QTest::mouseRelease(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.8, height * 0.16));
+ QTest::mouseRelease(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.8, height * 0.055));
QApplication::clipboard()->clear();
QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "copyTextSelection"));
@@ -226,8 +229,10 @@ void PartTest::testClickInternalLink()
part.widget()->show();
QTest::qWaitForWindowExposed(part.widget());
- const int width = part.m_pageView->width();
- const int height = part.m_pageView->height();
+ 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);
@@ -238,7 +243,7 @@ void PartTest::testClickInternalLink()
QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseNormal");
QCOMPARE(part.m_document->currentPage(), 0u);
- QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.17, height * 0.15));
+ QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.17, height * 0.05));
QCOMPARE(part.m_document->currentPage(), 1u);
}