// public QFontDatabase::WritingSystem writingSystem() const void tst_QFontComboBox::writingSystem() { QFETCH(QFontDatabase::WritingSystem, writingSystem); SubQFontComboBox box; QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont currentFont = box.currentFont(); box.setWritingSystem(writingSystem); QCOMPARE(box.writingSystem(), writingSystem); QFontDatabase db; QStringList list = db.families(writingSystem); int c = list.count(); for (int i = 0; i < list.count(); ++i) { if (db.isPrivateFamily(list[i])) c--; } QCOMPARE(box.model()->rowCount(), c); if (list.count() == 0) QCOMPARE(box.currentFont(), QFont()); QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0); }
// public void load() void tst_AdBlockManager::load() { SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); manager.load(); QCOMPARE(spy0.count(), 0); }
// public AdBlockDialog *showDialog() void tst_AdBlockManager::showDialog() { SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); AdBlockDialog *dialog = manager.showDialog(); QVERIFY(dialog); QTRY_VERIFY(dialog->isVisible()); }
void tst_AdBlockManager::rulesChanged() { SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); AdBlockSubscription *subscription = new AdBlockSubscription(QUrl(), &manager); manager.addSubscription(subscription); subscription->setEnabled(true); subscription->addRule(AdBlockRule()); QCOMPARE(spy0.count(), 3); }
// public void removeSubscription(AdBlockSubscription *subscription) void tst_AdBlockManager::removeSubscription() { SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); QList<AdBlockSubscription*> list = manager.subscriptions(); AdBlockSubscription *subscription = new AdBlockSubscription(QUrl(), &manager); manager.addSubscription(subscription); manager.removeSubscription(subscription); QCOMPARE(manager.subscriptions(), list); QCOMPARE(spy0.count(), 2); }
// protected void currentFontChanged(QFont const& f) void tst_QFontComboBox::currentFontChanged() { SubQFontComboBox box; QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); if (box.model()->rowCount() > 2) { QTest::keyPress(&box, Qt::Key_Down); QCOMPARE(spy0.count(), 1); QFont f( "Sans Serif" ); box.setCurrentFont(f); QCOMPARE(spy0.count(), 2); } else qWarning("Not enough fonts installed on test system. Consider adding some"); }
// public AdBlockSubscription *customRules() void tst_AdBlockManager::customRules() { SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); AdBlockSubscription *subscription = manager.customRules(); QVERIFY(subscription); QVERIFY(!subscription->title().isEmpty()); QVERIFY(subscription->allRules().isEmpty()); QCOMPARE(spy0.count(), 1); subscription = manager.customRules(); QCOMPARE(spy0.count(), 1); }
// public QFontComboBox::FontFilters fontFilters() const void tst_QFontComboBox::fontFilters() { QFETCH(QFontComboBox::FontFilters, fontFilters); SubQFontComboBox box; QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont currentFont = box.currentFont(); box.setFontFilters(fontFilters); QCOMPARE(box.fontFilters(), fontFilters); QFontDatabase db; QStringList list = db.families(); int c = 0; const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts); const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts); if((fontFilters & scalableMask) == scalableMask) fontFilters &= ~scalableMask; if((fontFilters & spacingMask) == spacingMask) fontFilters &= ~spacingMask; for (int i = 0; i < list.count(); ++i) { if (db.isPrivateFamily(list[i])) continue; if (fontFilters & QFontComboBox::ScalableFonts) { if (!db.isSmoothlyScalable(list[i])) continue; } else if (fontFilters & QFontComboBox::NonScalableFonts) { if (db.isSmoothlyScalable(list[i])) continue; } if (fontFilters & QFontComboBox::MonospacedFonts) { if (!db.isFixedPitch(list[i])) continue; } else if (fontFilters & QFontComboBox::ProportionalFonts) { if (db.isFixedPitch(list[i])) continue; } c++; } QCOMPARE(box.model()->rowCount(), c); if (c == 0) QCOMPARE(box.currentFont(), QFont()); QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0); }
// public bool isEnabled() const void tst_AdBlockManager::isEnabled() { QFETCH(bool, isEnabled); SubAdBlockManager manager; QSignalSpy spy0(&manager, SIGNAL(rulesChanged())); bool before = manager.isEnabled(); manager.setEnabled(isEnabled); manager.setEnabled(isEnabled); QCOMPARE(manager.isEnabled(), isEnabled); QCOMPARE(spy0.count(), before == isEnabled ? 0 : 1); }
void tst_QXYSeries::append_raw() { QFETCH(QList<QPointF>, points); QFETCH(QList<QPointF>, otherPoints); QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF))); QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); m_series->append(points); TRY_COMPARE(spy0.count(), 0); TRY_COMPARE(addedSpy.count(), points.count()); QCOMPARE(m_series->points(), points); QCOMPARE(m_series->pointsVector(), points.toVector()); // Process events between appends foreach (const QPointF &point, otherPoints) { m_series->append(point); QApplication::processEvents(); }
// public QFontDatabase::WritingSystem writingSystem() const void tst_QFontComboBox::writingSystem() { QFETCH(QFontDatabase::WritingSystem, writingSystem); SubQFontComboBox box; QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont currentFont = box.currentFont(); box.setWritingSystem(writingSystem); QCOMPARE(box.writingSystem(), writingSystem); QFontDatabase db; QStringList list = db.families(writingSystem); QCOMPARE(box.model()->rowCount(), list.count()); if (list.count() == 0) QCOMPARE(box.currentFont(), QFont()); QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0); }
// public QFont currentFont() const void tst_QFontComboBox::currentFont() { QFETCH(QFont, currentFont); SubQFontComboBox box; QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont))); QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); QRegExp foundry(" \\[.*\\]"); if (!box.currentFont().family().contains(foundry)) { QCOMPARE(box.currentFont(), currentFont); } QString boxFontFamily = QFontInfo(box.currentFont()).family(); if (!currentFont.family().contains(foundry)) boxFontFamily.remove(foundry); QCOMPARE(boxFontFamily, currentFont.family()); if (oldCurrentFont != box.currentFont()) { //the signal may be emit twice if there is a foundry into brackets QCOMPARE(spy0.count(),1); } }