summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-08 16:02:07 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-09 15:41:40 +0100
commitccf50893e8086ae15db10296655db23364e55674 (patch)
treebbead2c58a7de5898afbb579f407169011941eb3 /tests
parentd30c446d35ae404f5a67421ac59e6f0997123321 (diff)
Skip incompatible QTextLayout tests when dpi-scaling is used
On e.g. Android, the tabs will be scaled by DPI. This breaks the logic in the QTextLayout tests for tabs. It's not possible to just scale the expected sizes either, since the whole text layout will be affected by font sizes and scaling, and it's difficult to predict where characters will land on different platforms and resolutions. To avoid breaking this test on other platforms, we just skip them when we know they will break. Since the code tested is cross-platform, this will hopefully not have any significant impact on our coverage. Change-Id: I65d6c33c9c6724665983a17f99eadcf1baedcc20 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 4b2970cd17..4fa8575153 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -1280,6 +1280,13 @@ void tst_QTextLayout::smallTextLengthWrapAtWordBoundaryOrAnywhere()
void tst_QTextLayout::testDefaultTabs()
{
QTextLayout layout("Foo\tBar\ta slightly longer text\tend.", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
layout.beginLayout();
QTextLine line = layout.createLine();
@@ -1322,6 +1329,13 @@ void tst_QTextLayout::testDefaultTabs()
void tst_QTextLayout::testTabs()
{
QTextLayout layout("Foo\tBar.", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
QTextOption option = layout.textOption();
option.setTabStop(150);
@@ -1339,6 +1353,13 @@ void tst_QTextLayout::testTabs()
void tst_QTextLayout::testMultilineTab()
{
QTextLayout layout("Lorem ipsum dolor sit\tBar.", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
// test if this works on the second line.
layout.beginLayout();
@@ -1348,12 +1369,20 @@ void tst_QTextLayout::testMultilineTab()
line.setLineWidth(220.);
layout.endLayout();
+
QCOMPARE(line.cursorToX(22), 80.);
}
void tst_QTextLayout::testMultiTab()
{
QTextLayout layout("Foo\t\t\tBar.", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
layout.beginLayout();
QTextLine line = layout.createLine();
@@ -1367,6 +1396,13 @@ void tst_QTextLayout::testTabsInAlignedParag()
{
QTextLayout layout("Foo\tsome more words", testFont);
layout.setCacheEnabled(true);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
QTextOption option = layout.textOption();
// right
option.setAlignment(Qt::AlignRight);
@@ -1426,6 +1462,12 @@ void tst_QTextLayout::testRightTab()
*/
layout.setCacheEnabled(true);
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
QTextOption option = layout.textOption();
QList<QTextOption::Tab> tabs;
QTextOption::Tab tab;
@@ -1463,6 +1505,13 @@ void tst_QTextLayout::testRightTab()
void tst_QTextLayout::testCenteredTab()
{
QTextLayout layout("Foo\tBar", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
// test if centering the tab works. We expect the center of 'Bar.' to be at the tab point.
QTextOption option = layout.textOption();
@@ -1484,6 +1533,13 @@ void tst_QTextLayout::testCenteredTab()
void tst_QTextLayout::testDelimiterTab()
{
QTextLayout layout("Foo\tBar. Barrabas", testFont);
+
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
layout.setCacheEnabled(true);
// try the different delimiter characters to see if the alignment works there.
QTextOption option = layout.textOption();
@@ -1537,6 +1593,12 @@ void tst_QTextLayout::tabsForRtl()
*/
layout.setCacheEnabled(true);
+ QFont font = layout.font();
+ QFontPrivate *fd = QFontPrivate::get(font);
+ qreal dpiScale = qreal(fd->dpi) / qreal(qt_defaultDpiY());
+ if (!qFuzzyCompare(dpiScale, 1.0))
+ QSKIP("Test logic does not work when tabs are scaled by dpi");
+
QTextOption option = layout.textOption();
QList<QTextOption::Tab> tabs;
QTextOption::Tab tab;