142 SubQFontComboBox box; |
142 SubQFontComboBox box; |
143 QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); |
143 QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); |
144 QFont oldCurrentFont = box.currentFont(); |
144 QFont oldCurrentFont = box.currentFont(); |
145 |
145 |
146 box.setCurrentFont(currentFont); |
146 box.setCurrentFont(currentFont); |
147 QCOMPARE(box.currentFont(), currentFont); |
147 QRegExp foundry(" \\[.*\\]"); |
|
148 if (!box.currentFont().family().contains(foundry)) { |
|
149 QCOMPARE(box.currentFont(), currentFont); |
|
150 } |
148 QString boxFontFamily = QFontInfo(box.currentFont()).family(); |
151 QString boxFontFamily = QFontInfo(box.currentFont()).family(); |
149 QRegExp foundry(" \\[.*\\]"); |
|
150 if (!currentFont.family().contains(foundry)) |
152 if (!currentFont.family().contains(foundry)) |
151 boxFontFamily.remove(foundry); |
153 boxFontFamily.remove(foundry); |
152 QCOMPARE(boxFontFamily, currentFont.family()); |
154 QCOMPARE(boxFontFamily, currentFont.family()); |
153 |
155 |
154 if (oldCurrentFont != box.currentFont()) { |
156 if (oldCurrentFont != box.currentFont()) { |
155 //the signal may be emit twice if there is a foundry into brackets |
157 //the signal may be emit twice if there is a foundry into brackets |
156 QVERIFY(spy0.count() >= 1); |
158 QCOMPARE(spy0.count(),1); |
157 } |
159 } |
158 } |
160 } |
159 |
161 |
160 Q_DECLARE_METATYPE(QFontComboBox::FontFilters) |
162 Q_DECLARE_METATYPE(QFontComboBox::FontFilters) |
161 void tst_QFontComboBox::fontFilters_data() |
163 void tst_QFontComboBox::fontFilters_data() |
284 QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); |
286 QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&))); |
285 |
287 |
286 if (box.model()->rowCount() > 2) { |
288 if (box.model()->rowCount() > 2) { |
287 QTest::keyPress(&box, Qt::Key_Down); |
289 QTest::keyPress(&box, Qt::Key_Down); |
288 QCOMPARE(spy0.count(), 1); |
290 QCOMPARE(spy0.count(), 1); |
|
291 |
|
292 QFont f( "Sans Serif" ); |
|
293 box.setCurrentFont(f); |
|
294 QCOMPARE(spy0.count(), 2); |
289 } else |
295 } else |
290 qWarning("Not enough fonts installed on test system. Consider adding some"); |
296 qWarning("Not enough fonts installed on test system. Consider adding some"); |
291 } |
297 } |
292 |
298 |
293 QTEST_MAIN(tst_QFontComboBox) |
299 QTEST_MAIN(tst_QFontComboBox) |