summaryrefslogtreecommitdiffstats
path: root/tests/auto/qrawfont
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-05-06 13:45:37 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-05-06 13:52:14 (GMT)
commit821b8b540af491ce60d35bd84d3c91399ecc0d16 (patch)
treec54ca4167c3cd3b0ee4940b09e82299633f74c86 /tests/auto/qrawfont
parenta423ff5474b89028eeca95b254f5184311c8223b (diff)
downloadQt-821b8b540af491ce60d35bd84d3c91399ecc0d16.zip
Qt-821b8b540af491ce60d35bd84d3c91399ecc0d16.tar.gz
Qt-821b8b540af491ce60d35bd84d3c91399ecc0d16.tar.bz2
Fix QRawFont::setPixelSize() on Mac
When refactoring the setPixelSize() code of QRawFont, it was broken on Mac. To avoid making the same mistake again, I've added a simple autotest to check that the pixel size is actually set. Reviewed-by: Jiang Jiang
Diffstat (limited to 'tests/auto/qrawfont')
-rw-r--r--tests/auto/qrawfont/tst_qrawfont.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp
index 4b42c74..ad16a9a 100644
--- a/tests/auto/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/qrawfont/tst_qrawfont.cpp
@@ -91,6 +91,9 @@ private slots:
void unsupportedWritingSystem_data();
void unsupportedWritingSystem();
+
+ void rawFontSetPixelSize_data();
+ void rawFontSetPixelSize();
#endif // QT_NO_RAWFONT
};
@@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem()
fontDatabase.removeApplicationFont(id);
}
+void tst_QRawFont::rawFontSetPixelSize_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::rawFontSetPixelSize()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QTextLayout layout("Foobar");
+
+ QFont font = layout.font();
+ font.setHintingPreference(hintingPreference);
+ font.setPixelSize(12);
+ layout.setFont(font);
+
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QGlyphs glyphs = layout.glyphs().at(0);
+ QRawFont rawFont = glyphs.font();
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ rawFont.setPixelSize(24);
+ QCOMPARE(rawFont.pixelSize(), 24.0);
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)