summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
authorLeonard Lee <leonard.lee@digia.com>2014-03-25 10:47:29 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-28 22:52:19 +0100
commit685f8fe550b2360546af8dc7fe4c3f747631645b (patch)
tree8722706a86a1b63d20128722b3e4bc56315a759c /tests/auto/widgets/dialogs
parentc4d8734c504cf0f313245befa34501e7314b4cd1 (diff)
Do not rely on the list of standard font sizes for QFontDialog.
QFontDialog should always show the correct size, even if the size is not available in the list of standard font sizes. Native font dialogs across common platforms show the correct size at all times. Inside init() function, the size list requires proper initialization since the initial value of size is zero. Task-number: QTBUG-10317 Change-Id: Idc9e922ac95f797ac98bbf6c885e52828c4c48fd Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 6eb36115cb..c5717a808c 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -66,6 +66,7 @@ public slots:
void postKeyReturn();
void testGetFont();
void testSetFont();
+ void testNonStandardFontSize();
public slots:
void initTestCase();
@@ -76,6 +77,7 @@ private slots:
void defaultOkButton();
void setFont();
void task256466_wrongStyle();
+ void setNonStandardFontSize();
private:
void runSlotWithFailsafeTimer(const char *member);
@@ -203,8 +205,38 @@ void tst_QFontDialog::task256466_wrongStyle()
}
}
+void tst_QFontDialog::setNonStandardFontSize()
+{
+ runSlotWithFailsafeTimer(SLOT(testNonStandardFontSize()));
+}
+void tst_QFontDialog::testNonStandardFontSize()
+{
+ QList<int> standardSizesList = QFontDatabase::standardSizes();
+ int nonStandardFontSize;
+ if (!standardSizesList.isEmpty()) {
+ nonStandardFontSize = standardSizesList.at(standardSizesList.count()-1); // get the maximum standard size.
+ nonStandardFontSize += 1; // the increment of 1 to mock a non-standard font size.
+ } else {
+ QSKIP("QFontDatabase::standardSizes() is empty.");
+ }
+ QFont testFont;
+ testFont.setPointSize(nonStandardFontSize);
+
+ bool accepted = false;
+ QTimer::singleShot(2000, this, SLOT(postKeyReturn()));
+ QFont resultFont = QFontDialog::getFont(&accepted, testFont,
+ QApplication::activeWindow(),
+ QLatin1String("QFontDialog - NonStandardFontSize Test"),
+ QFontDialog::DontUseNativeDialog);
+ QVERIFY(accepted);
+
+ if (accepted)
+ QCOMPARE(testFont.pointSize(), resultFont.pointSize());
+ else
+ QWARN("Fail using a non-standard font size.");
+}
QTEST_MAIN(tst_QFontDialog)
#include "tst_qfontdialog.moc"