summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorNils Jeisecke <jeisecke@saltation.de>2016-09-01 14:26:18 +0200
committerNils Jeisecke <nils.jeisecke@saltation.com>2019-09-17 23:05:09 +0200
commit4a240bb67e72b34c80af448e0a74846609fa6975 (patch)
tree6ce38e4b7f44cc6dc260534fcc4df4525c2d817a /tests/auto/widgets
parent6cee284001adf9da42b347a074cbff3cb92621b2 (diff)
QTextDocument: Fix device scaling for QTextFrameFormat margins, padding and border
Those values must be scaled to device coordinates - otherwise borders, margins etc. will be too small when rendered on high dpi devices (printers etc.). This change will add the scaling to those values. QTextDocument::print applies 2cm margins to the root frame of a unpaginated QTextDocument. Those margins were previously scaled to device coordinates in order to give the correct result. But because scaling is now done inside QTextDocumentLayout that scaling must be removed and pixel values based on qt_defaultDpi are provided instead. Fixes: QTBUG-78318 Change-Id: I6fe6dcc25f846341f6a2fe5df2f54baea473fdfd Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index c2cf31bfa4..b31e230893 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -1978,8 +1978,23 @@ void tst_QTextEdit::fullWidthSelection_data()
#endif
#ifdef QT_BUILD_INTERNAL
+
+// With the fix for QTBUG-78318 scaling of documentMargin is added. The testing framework
+// forces qt_defaultDpi() to always return 96 DPI. For systems where the actual DPI differs
+// (typically 72 DPI) this would now cause scaling of the documentMargin when
+// drawing QTextEdit into QImage. In order to avoid the need of multiple reference PNGs
+// for comparison we disable the Qt::AA_Use96Dpi attribute for these tests.
+
+struct ForceSystemDpiHelper {
+ ForceSystemDpiHelper() { QCoreApplication::setAttribute(Qt::AA_Use96Dpi, false); }
+ ~ForceSystemDpiHelper() { QCoreApplication::setAttribute(Qt::AA_Use96Dpi, old); }
+ bool old = QCoreApplication::testAttribute(Qt::AA_Use96Dpi);
+};
+
void tst_QTextEdit::fullWidthSelection()
{
+ ForceSystemDpiHelper useSystemDpi;
+
QFETCH(int, cursorFrom);
QFETCH(int, cursorTo);
QFETCH(QString, imageFileName);
@@ -2048,6 +2063,8 @@ void tst_QTextEdit::fullWidthSelection()
#ifdef QT_BUILD_INTERNAL
void tst_QTextEdit::fullWidthSelection2()
{
+ ForceSystemDpiHelper useSystemDpi;
+
QPalette myPalette;
myPalette.setColor(QPalette::All, QPalette::HighlightedText, QColor(0,0,0,0));
myPalette.setColor(QPalette::All, QPalette::Highlight, QColor(239,221,85));