void LccnTest::testFormalization() { QFETCH(QString, string); QFETCH(QString, result); QCOMPARE(Tellico::LCCNValidator::formalize(string), result); }
void tst_QColor::specConstructor() { QFETCH(QColor::Spec, spec); QColor color = spec; QCOMPARE(color.spec(), spec); }
void tst_QColor::name() { QFETCH(QColor, color); QFETCH(QString, name); QCOMPARE(color.name(), name); }
void WirelessSecuritySetting::testSetting() { QFETCH(QString, keyMgmt); QFETCH(quint32, wepTxKeyidx); QFETCH(QString, authAlg); QFETCH(QStringList, proto); QFETCH(QStringList, pairwise); QFETCH(QStringList, group); QFETCH(QString, leapUsername); QFETCH(QString, wepKey0); QFETCH(QString, wepKey1); QFETCH(QString, wepKey2); QFETCH(QString, wepKey3); QFETCH(quint32, wepKeyFlags); QFETCH(quint32, wepKeyType); QFETCH(QString, psk); QFETCH(quint32, pskFlags); QFETCH(QString, leapPassword); QFETCH(quint32, leapPasswordFlags); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), keyMgmt); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), wepTxKeyidx); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), authAlg); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PROTO), proto); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PAIRWISE), pairwise); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_GROUP), group); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), leapUsername); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), wepKey0); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), wepKey1); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), wepKey2); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), wepKey3); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), wepKeyFlags); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), wepKeyType); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK), psk); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), pskFlags); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), leapPassword); map.insert(QLatin1String(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), leapPasswordFlags); NetworkManager::WirelessSecuritySetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } }
void tst_QVideoFrame::assign() { QFETCH(QAbstractVideoBuffer::HandleType, handleType); QFETCH(QSize, size); QFETCH(QVideoFrame::PixelFormat, pixelFormat); QFETCH(QVideoFrame::FieldType, fieldType); QFETCH(qint64, startTime); QFETCH(qint64, endTime); QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); QVideoFrame frame; { QVideoFrame otherFrame(buffer, size, pixelFormat); otherFrame.setFieldType(fieldType); otherFrame.setStartTime(startTime); otherFrame.setEndTime(endTime); frame = otherFrame; QVERIFY(!buffer.isNull()); QVERIFY(otherFrame.isValid()); QCOMPARE(otherFrame.handleType(), handleType); QCOMPARE(otherFrame.pixelFormat(), pixelFormat); QCOMPARE(otherFrame.size(), size); QCOMPARE(otherFrame.width(), size.width()); QCOMPARE(otherFrame.height(), size.height()); QCOMPARE(otherFrame.fieldType(), fieldType); QCOMPARE(otherFrame.startTime(), startTime); QCOMPARE(otherFrame.endTime(), endTime); otherFrame.setStartTime(-1); QVERIFY(!buffer.isNull()); QVERIFY(otherFrame.isValid()); QCOMPARE(otherFrame.handleType(), handleType); QCOMPARE(otherFrame.pixelFormat(), pixelFormat); QCOMPARE(otherFrame.size(), size); QCOMPARE(otherFrame.width(), size.width()); QCOMPARE(otherFrame.height(), size.height()); QCOMPARE(otherFrame.fieldType(), fieldType); QCOMPARE(otherFrame.startTime(), qint64(-1)); QCOMPARE(otherFrame.endTime(), endTime); } QVERIFY(!buffer.isNull()); QVERIFY(frame.isValid()); QCOMPARE(frame.handleType(), handleType); QCOMPARE(frame.pixelFormat(), pixelFormat); QCOMPARE(frame.size(), size); QCOMPARE(frame.width(), size.width()); QCOMPARE(frame.height(), size.height()); QCOMPARE(frame.fieldType(), fieldType); QCOMPARE(frame.startTime(), qint64(-1)); QCOMPARE(frame.endTime(), endTime); frame = QVideoFrame(); QVERIFY(buffer.isNull()); QVERIFY(!frame.isValid()); QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); QCOMPARE(frame.size(), QSize()); QCOMPARE(frame.width(), -1); QCOMPARE(frame.height(), -1); QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); QCOMPARE(frame.startTime(), qint64(-1)); QCOMPARE(frame.endTime(), qint64(-1)); }
void tst_QRawFont::detach() { QFETCH(QFont::HintingPreference, hintingPreference); { QString rawFontFamilyName; qreal rawFontPixelSize; qreal rawFontAscent; qreal rawFontDescent; int rawFontTableSize; QRawFont outerRawFont; { QRawFont rawFont(QString::fromLatin1(SRCDIR "testfont.ttf"), 11, hintingPreference); QVERIFY(rawFont.isValid()); rawFontFamilyName = rawFont.familyName(); rawFontPixelSize = rawFont.pixelSize(); rawFontAscent = rawFont.ascent(); rawFontDescent = rawFont.descent(); rawFontTableSize = rawFont.fontTable("glyf").size(); QVERIFY(rawFontTableSize > 0); { QRawFont otherRawFont(rawFont); otherRawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"), rawFontPixelSize, hintingPreference); QVERIFY(otherRawFont.isValid()); QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize); QCOMPARE(otherRawFont.familyName(), rawFontFamilyName); QCOMPARE(otherRawFont.hintingPreference(), hintingPreference); QCOMPARE(otherRawFont.ascent(), rawFontAscent); QCOMPARE(otherRawFont.descent(), rawFontDescent); QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize); } { QRawFont otherRawFont = rawFont; otherRawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"), rawFontPixelSize, hintingPreference); QVERIFY(otherRawFont.isValid()); QCOMPARE(otherRawFont.pixelSize(), rawFontPixelSize); QCOMPARE(otherRawFont.familyName(), rawFontFamilyName); QCOMPARE(otherRawFont.hintingPreference(), hintingPreference); QCOMPARE(otherRawFont.ascent(), rawFontAscent); QCOMPARE(otherRawFont.descent(), rawFontDescent); QCOMPARE(otherRawFont.fontTable("glyf").size(), rawFontTableSize); } outerRawFont = rawFont; rawFont.loadFromFile(QLatin1String(SRCDIR "testfont.ttf"), rawFontPixelSize, hintingPreference); } QVERIFY(outerRawFont.isValid()); QCOMPARE(outerRawFont.pixelSize(), rawFontPixelSize); QCOMPARE(outerRawFont.familyName(), rawFontFamilyName); QCOMPARE(outerRawFont.hintingPreference(), hintingPreference); QCOMPARE(outerRawFont.ascent(), rawFontAscent); QCOMPARE(outerRawFont.descent(), rawFontDescent); QCOMPARE(outerRawFont.fontTable("glyf").size(), rawFontTableSize); } }
void KisFixedPaintDeviceTest::testMirroring() { QFETCH(QRect, rc); QFETCH(bool, mirrorHorizontally); QFETCH(bool, mirrorVertically); const KoColorSpace *cs = KoColorSpaceRegistry::instance()->rgb8(); KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs); dev->setRect(rc); dev->initialize(); KoColor c(Qt::black, cs); qsrand(1); int value = 0; for (int i = rc.x(); i < rc.x() + rc.width(); i++) { for (int j = rc.y(); j < rc.y() + rc.height(); j++) { setPixel(dev, i, j, value); value = qrand() % 255; } value = qrand() % 255; } //dev->convertToQImage(0).save("0_a.png"); dev->mirror(mirrorHorizontally, mirrorVertically); //dev->convertToQImage(0).save("0_b.png"); int startX; int endX; int incX; int startY; int endY; int incY; if (mirrorHorizontally) { startX = rc.x() + rc.width() - 1; endX = rc.x() - 1; incX = -1; } else { startX = rc.x(); endX = rc.x() + rc.width(); incX = 1; } if (mirrorVertically) { startY = rc.y() + rc.height() - 1; endY = rc.y() - 1; incY = -1; } else { startY = rc.y(); endY = rc.y() + rc.height(); incY = 1; } qsrand(1); value = 0; for (int i = startX; i != endX ; i += incX) { for (int j = startY; j != endY; j += incY) { QCOMPARE(pixel(dev, i, j), (quint8)value); value = qrand() % 255; } value = qrand() % 255; } }
// public QIcon icon(QFileIconProvider::IconType const& type) const void tst_QFileIconProvider::iconType() { QFETCH(QFileIconProvider::IconType, type); SubQFileIconProvider provider; QVERIFY(!provider.icon(type).isNull()); }
// public QString type(QFileInfo const& info) const void tst_QFileIconProvider::type() { QFETCH(QFileInfo, info); SubQFileIconProvider provider; QVERIFY(!provider.type(info).isEmpty()); }
void tst_QRegion::operator_plus() { QFETCH(QRegion, r1); QFETCH(QRegion, r2); QFETCH(QRegion, expected); if (r1 + r2 != expected) { qDebug() << "r1 + r2" << (r1 + r2); qDebug() << "expected" << expected; } QCOMPARE(r1 + r2, expected); if (r2.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r1 + QRect(r2)" << (r1 + r2.boundingRect()); qDebug() << "expected" << expected; } QCOMPARE(r1 + r2.boundingRect(), expected); } if (r2 + r1 != expected) { qDebug() << "r2 + r1" << (r2 + r1); qDebug() << "expected" << expected; } QCOMPARE(r2 + r1, expected); if (r1.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r2 + QRect(r1)" << (r2 + r1.boundingRect()); qDebug() << "expected" << expected; } QCOMPARE(r2 + r1.boundingRect(), expected); } QRegion result1 = r1; result1 += r2; if (result1 != expected) { qDebug() << "r1 += r2" << result1; qDebug() << "expected" << expected; } QCOMPARE(result1, expected); if (r2.rectCount() == 1) { result1 = r1; result1 += r2.boundingRect(); if (result1 != expected) { qDebug() << "r1 += QRect(r2)" << result1; qDebug() << "expected" << expected; } QCOMPARE(result1, expected); } QRegion result2 = r2; result2 += r1; if (result2 != expected) { qDebug() << "r2 += r1" << result2; qDebug() << "expected" << expected; } QCOMPARE(result2, expected); if (r1.rectCount() == 1) { result2 = r2; result2 += r1.boundingRect(); if (result2 != expected) { qDebug() << "r2 += QRect(r1)" << result2; qDebug() << "expected" << expected; } QCOMPARE(result2, expected); } }
void tst_QPdfWriter::testPageMetrics() { QFETCH(int, pageSize); QFETCH(qreal, widthMMf); QFETCH(qreal, heightMMf); QFETCH(bool, setMargins); QFETCH(qreal, leftMMf); QFETCH(qreal, rightMMf); QFETCH(qreal, topMMf); QFETCH(qreal, bottomMMf); QSizeF sizeMMf = QSizeF(widthMMf, heightMMf); QTemporaryFile file; if (!file.open()) QSKIP("Couldn't open temp file!"); QPdfWriter writer(file.fileName()); QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait); if (setMargins) { // Setup the given margins QPdfWriter::Margins margins; margins.left = leftMMf; margins.right = rightMMf; margins.top = topMMf; margins.bottom = bottomMMf; writer.setMargins(margins); QCOMPARE(writer.margins().left, leftMMf); QCOMPARE(writer.margins().right, rightMMf); QCOMPARE(writer.margins().top, topMMf); QCOMPARE(writer.margins().bottom, bottomMMf); } // Set the given size, in Portrait mode if (pageSize < 0) { writer.setPageSizeMM(sizeMMf); QCOMPARE(writer.pageSize(), QPdfWriter::Custom); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom); } else { writer.setPageSize(QPdfWriter::PageSize(pageSize)); QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize)); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize)); } QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait); QCOMPARE(writer.margins().left, leftMMf); QCOMPARE(writer.margins().right, rightMMf); QCOMPARE(writer.margins().top, topMMf); QCOMPARE(writer.margins().bottom, bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation QCOMPARE(writer.widthMM(), qRound(widthMMf - leftMMf - rightMMf)); QCOMPARE(writer.heightMM(), qRound(heightMMf - topMMf - bottomMMf)); // Now switch to Landscape mode, size should be unchanged, but rect and metrics should change writer.setPageOrientation(QPageLayout::Landscape); if (pageSize < 0) { QCOMPARE(writer.pageSize(), QPdfWriter::Custom); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom); } else { QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize)); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize)); } QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape); QCOMPARE(writer.margins().left, leftMMf); QCOMPARE(writer.margins().right, rightMMf); QCOMPARE(writer.margins().top, topMMf); QCOMPARE(writer.margins().bottom, bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf)); QCOMPARE(writer.heightMM(), qRound(widthMMf - topMMf - bottomMMf)); // QPdfWriter::fullRect() always returns set orientation QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, heightMMf, widthMMf)); // QPdfWriter::paintRect() always returns set orientation QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf)); // Now while in Landscape mode, set the size again, results should be the same if (pageSize < 0) { writer.setPageSizeMM(sizeMMf); QCOMPARE(writer.pageSize(), QPdfWriter::Custom); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom); } else { writer.setPageSize(QPdfWriter::PageSize(pageSize)); QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize)); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize)); } QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape); QCOMPARE(writer.margins().left, leftMMf); QCOMPARE(writer.margins().right, rightMMf); QCOMPARE(writer.margins().top, topMMf); QCOMPARE(writer.margins().bottom, bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf)); QCOMPARE(writer.heightMM(), qRound(widthMMf - topMMf - bottomMMf)); // QPdfWriter::fullRect() always returns set orientation QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, heightMMf, widthMMf)); // QPdfWriter::paintRect() always returns set orientation QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf)); }
void TestGudermannian::testGudermannian() { QFETCH( qreal, angle ); QFUZZYCOMPARE( atan( sinh ( angle * DEG2RAD ) ) * RAD2DEG, gd( angle * DEG2RAD ) * RAD2DEG, 0.1 ); }
void tst_qdesktopservices::storageLocation() { QFETCH(QDesktopServices::StandardLocation, location); #ifdef Q_OS_SYMBIAN QString storageLocation = QDesktopServices::storageLocation(location); QString displayName = QDesktopServices::displayName(location); //qDebug( "displayName: %s", displayName ); storageLocation = storageLocation.toLower(); displayName = displayName.toLower(); QString drive = QDir::currentPath().left(2).toLower(); if( drive == "z:" ) drive = "c:"; switch(location) { case QDesktopServices::DesktopLocation: QCOMPARE( storageLocation, drive + QString("/data") ); break; case QDesktopServices::DocumentsLocation: QCOMPARE( storageLocation, drive + QString("/data") ); break; case QDesktopServices::FontsLocation: // Currently point always to ROM QCOMPARE( storageLocation, QString("z:/resource/fonts") ); break; case QDesktopServices::ApplicationsLocation: #ifdef Q_CC_NOKIAX86 QCOMPARE( storageLocation, QString("z:/sys/bin") ); #else QCOMPARE( storageLocation, drive + QString("/sys/bin") ); #endif break; case QDesktopServices::MusicLocation: QCOMPARE( storageLocation, drive + QString("/data/sounds") ); break; case QDesktopServices::MoviesLocation: QCOMPARE( storageLocation, drive + QString("/data/videos") ); break; case QDesktopServices::PicturesLocation: QCOMPARE( storageLocation, drive + QString("/data/images") ); break; case QDesktopServices::TempLocation: QCOMPARE( storageLocation, QDir::tempPath().toLower()); break; case QDesktopServices::HomeLocation: QCOMPARE( storageLocation, QDir::homePath().toLower()); break; case QDesktopServices::DataLocation: // Just check the folder not the drive QCOMPARE( storageLocation.mid(2), QDir::currentPath().mid(2).toLower()); break; default: QCOMPARE( storageLocation, QString() ); break; } #else QDesktopServices::storageLocation(location); QDesktopServices::displayName(location); #endif }
void tst_QScriptValueGenerated::testHelper(TestFunction fun) { QFETCH(QString, __expression__); QScriptValue value = m_values.value(__expression__); (this->*fun)(__expression__.toLatin1(), value); }
void tst_Q3CString::length() { QFETCH( Q3CString, s1 ); QTEST( (int)s1.length(), "res" ); }
void TestPluginEffectLoader::testLoadPluginEffect() { QFETCH(QString, name); QFETCH(bool, expected); QFETCH(KWin::CompositingType, type); QFETCH(KWin::LoadEffectFlags, loadFlags); QFETCH(bool, enabledByDefault); MockEffectsHandler mockHandler(type); mockHandler.setProperty("testEnabledByDefault", enabledByDefault); KWin::PluginEffectLoader loader; loader.setPluginSubDirectory(QString()); KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); loader.setConfig(config); const auto plugins = KPluginLoader::findPlugins(QString(), [name] (const KPluginMetaData &data) { return data.pluginId().compare(name, Qt::CaseInsensitive) == 0 && data.serviceTypes().contains(QStringLiteral("KWin/Effect")); } ); QCOMPARE(plugins.size(), 1); qRegisterMetaType<KWin::Effect*>(); QSignalSpy spy(&loader, SIGNAL(effectLoaded(KWin::Effect*,QString))); // connect to signal to ensure that we delete the Effect again as the Effect doesn't have a parent connect(&loader, &KWin::PluginEffectLoader::effectLoaded, [&name](KWin::Effect *effect, const QString &effectName) { QCOMPARE(effectName, name); effect->deleteLater(); } ); // try to load the Effect QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected); // loading again should fail QVERIFY(!loader.loadEffect(plugins.first(), loadFlags)); // signal spy should have got the signal if it was expected QCOMPARE(spy.isEmpty(), !expected); if (!spy.isEmpty()) { QCOMPARE(spy.count(), 1); // if we caught a signal it should have the effect name we passed in QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.count(), 2); QCOMPARE(arguments.at(1).toString(), name); } spy.clear(); QVERIFY(spy.isEmpty()); // now if we wait for the events being processed, the effect will get deleted and it should load again QTest::qWait(1); QCOMPARE(loader.loadEffect(plugins.first(), loadFlags), expected); // signal spy should have got the signal if it was expected QCOMPARE(spy.isEmpty(), !expected); if (!spy.isEmpty()) { QCOMPARE(spy.count(), 1); // if we caught a signal it should have the effect name we passed in QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.count(), 2); QCOMPARE(arguments.at(1).toString(), name); } }
void valid() { QFETCH(QGeoCoordinate, c); QCOMPARE(c.isValid(), c.type() != QGeoCoordinate::InvalidCoordinate); }
void ECMAscriptTest::runAllTests() { static const QByteArray include = "$INCLUDE(\""; QFETCH(QString, filename); QByteArray expectedError; QFile input( filename ); foreach ( const QByteArray &skip, skips.keys() ) { if ( skip == QTest::currentDataTag() ) QSKIP( skips[ skip ], SkipSingle ); } QVERIFY( input.open( QIODevice::ReadOnly ) ); const QByteArray testdata = input.readAll(); QVERIFY( ! testdata.isEmpty() ); RefPtr<KJS::Interpreter> interp = new KJS::Interpreter(global); KJS::Interpreter::setShouldPrintExceptions(true); QByteArray testscript; // test is expected to fail if ( testdata.indexOf( "@negative" ) >= 0 ) { expectedError = getTextProperty( "@negative", testdata ); if ( expectedError.isEmpty() ) expectedError = "."; } int from = 0; while ( ( from = testdata.indexOf( include, from ) ) >= 0 ) { int endq = testdata.indexOf( "\"", from + include.length() ); QVERIFY( endq >= 0 ); const QByteArray includeFile = testdata.mid( from + include.length(), endq - from - include.length() ); if ( ! includes.contains( includeFile ) ) QVERIFY( loadInclude( includeFile ) ); testscript += includes[ includeFile ]; from = endq; } testscript += testrunner; testscript += testdata; const QFileInfo info( input ); const QString scriptutf = QString::fromUtf8( testscript.constData() ); KJS::Completion completion = interp->evaluate(info.fileName().toAscii().constData(), 0, scriptutf); const bool knownBroken = expectedBroken.contains( QString::fromAscii( QTest::currentDataTag() ) ); if ( expectedError.isEmpty() ) { ECMATEST_VERIFY( completion.complType() != KJS::Throw ); } else { if ( knownBroken && completion.complType() != KJS::Throw ) { QEXPECT_FAIL(QTest::currentDataTag(), "It is known that KJS doesn't pass this test", Abort); m_failed++; } QCOMPARE( completion.complType(), KJS::Throw ); QVERIFY( completion.value() != NULL ); const QString eMsg = exceptionToString( interp->execState(), completion.value() ); if ( expectedError == "^((?!NotEarlyError).)*$" ) { ECMATEST_VERIFY( eMsg.indexOf( "NotEarlyError" ) == -1 ); } else if ( expectedError == "." ) { // means "every exception passes } else { ECMATEST_VERIFY( eMsg.indexOf( expectedError ) >= 0 ); } } }
void Pt_MButton::toggledPaintPerformance() { QFETCH(qint32, width); QFETCH(qint32, height); QFETCH(QString, view); QFETCH(QString, icon1); QFETCH(QString, icon2); QFETCH(QString, text); QPixmap pixmap(width, height); QPainter painter(&pixmap); painter.fillRect(QRect(0, 0, width, height), QColor(0, 0, 0)); MWidgetView *buttonView = MClassFactory::instance()->createView(view.toStdString().c_str(), m_subject); m_subject->setView(buttonView); m_subject->setGeometry(QRectF(0, 0, width, height)); if (!text.isEmpty()) { m_subject->setText(text); m_subject->setTextVisible(true); } else m_subject->setTextVisible(false); if (!icon1.isEmpty()) { m_subject->setIconID(icon1); m_subject->setIconVisible(true); } else m_subject->setIconVisible(false); if (!icon2.isEmpty()) { m_subject->setToggledIconID(icon2); m_subject->setIconVisible(true); } //else // button->setIconVisible(false); while (MTheme::hasPendingRequests()) { usleep(10000); QCoreApplication::processEvents(); } m_subject->setDown(true); m_subject->setDown(false); while (MTheme::hasPendingRequests()) { usleep(10000); QCoreApplication::processEvents(); } // actual benchmark QBENCHMARK { painter.save(); m_subject->paint(&painter, NULL); painter.restore(); } // save a shot (for debugging) //#define SCREENSHOT #ifdef SCREENSHOT QString kuva; QTextStream(&kuva) << view << "_toggled" << "\"" << icon1 << "\"" << "_" << "\"" << icon2 << "\"" << "_" << "\"" << text << "\"" << "_" << width << "x" << height << ".png"; pixmap.save(kuva, "png", -1); #endif }
void TestChordsParser::validChords() { QFETCH(QString, chordText); QVERIFY(ChatChordsProgressionParser::isValidChord(chordText)); }
void evaluation() { QFETCH( QString, string ); QFETCH( bool, evalError ); QFETCH( QVariant, result ); QgsExpression exp( string ); QCOMPARE( exp.hasParserError(), false ); if ( exp.hasParserError() ) qDebug() << exp.parserErrorString(); QVariant res = exp.evaluate(); if ( exp.hasEvalError() ) qDebug() << exp.evalErrorString(); if ( res.type() != result.type() ) { qDebug() << "got " << res.typeName() << " instead of " << result.typeName(); } //qDebug() << res.type() << " " << result.type(); //qDebug() << "type " << res.typeName(); QCOMPARE( exp.hasEvalError(), evalError ); QCOMPARE( res.type(), result.type() ); switch ( res.type() ) { case QVariant::Invalid: break; // nothing more to check case QVariant::Int: QCOMPARE( res.toInt(), result.toInt() ); break; case QVariant::Double: QCOMPARE( res.toDouble(), result.toDouble() ); break; case QVariant::String: QCOMPARE( res.toString(), result.toString() ); break; case QVariant::Date: QCOMPARE( res.toDate(), result.toDate() ); break; case QVariant::DateTime: QCOMPARE( res.toDateTime(), result.toDateTime() ); break; case QVariant::Time: QCOMPARE( res.toTime(), result.toTime() ); break; case QVariant::UserType: { if ( res.userType() == qMetaTypeId<QgsExpression::Interval>() ) { QgsExpression::Interval inter = res.value<QgsExpression::Interval>(); QgsExpression::Interval gotinter = result.value<QgsExpression::Interval>(); QCOMPARE( inter.seconds(), gotinter.seconds() ); } else { QFAIL( "unexpected user type" ); } break; } default: Q_ASSERT( false ); // should never happen } }
void WirelessSettingTest::testSetting() { QFETCH(QByteArray, ssid); QFETCH(QString, mode); QFETCH(QString, band); QFETCH(quint32, channel); QFETCH(QByteArray, bssid); QFETCH(quint32, rate); QFETCH(quint32, txPower); QFETCH(QByteArray, macAddress); QFETCH(QByteArray, clonedMacAddress); QFETCH(QStringList, macAddressBlacklist); QFETCH(quint32, mtu); QFETCH(QStringList, seenBssids); QFETCH(QString, security); QFETCH(bool, hidden); QVariantMap map; map.insert(QLatin1String(NM_SETTING_WIRELESS_SSID), ssid); map.insert(QLatin1String(NM_SETTING_WIRELESS_MODE), mode); map.insert(QLatin1String(NM_SETTING_WIRELESS_BAND), band); map.insert(QLatin1String(NM_SETTING_WIRELESS_CHANNEL), channel); map.insert(QLatin1String(NM_SETTING_WIRELESS_BSSID), bssid); map.insert(QLatin1String(NM_SETTING_WIRELESS_RATE), rate); map.insert(QLatin1String(NM_SETTING_WIRELESS_TX_POWER), txPower); map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS), macAddress); map.insert(QLatin1String(NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), clonedMacAddress); map.insert(QLatin1String(NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), macAddressBlacklist); map.insert(QLatin1String(NM_SETTING_WIRELESS_MTU), mtu); map.insert(QLatin1String(NM_SETTING_WIRELESS_SEEN_BSSIDS), seenBssids); #if NM_CHECK_VERSION(1, 0, 0) map.insert(QLatin1String("security"), security); #else map.insert(QLatin1String(NM_SETTING_WIRELESS_SEC), security); #endif map.insert(QLatin1String(NM_SETTING_WIRELESS_HIDDEN), hidden); NetworkManager::WirelessSetting setting; setting.fromMap(map); QVariantMap map1 = setting.toMap(); // Will fail if set some default values, because they are skipped in toMap() method QVariantMap::const_iterator it = map.constBegin(); while (it != map.constEnd()) { QCOMPARE(it.value(), map1.value(it.key())); ++it; } }
void tst_QVideoFrame::copy() { QFETCH(QAbstractVideoBuffer::HandleType, handleType); QFETCH(QSize, size); QFETCH(QVideoFrame::PixelFormat, pixelFormat); QFETCH(QVideoFrame::FieldType, fieldType); QFETCH(qint64, startTime); QFETCH(qint64, endTime); QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); { QVideoFrame frame(buffer, size, pixelFormat); frame.setFieldType(QVideoFrame::FieldType(fieldType)); frame.setStartTime(startTime); frame.setEndTime(endTime); QVERIFY(frame.isValid()); QCOMPARE(frame.handleType(), handleType); QCOMPARE(frame.pixelFormat(), pixelFormat); QCOMPARE(frame.size(), size); QCOMPARE(frame.width(), size.width()); QCOMPARE(frame.height(), size.height()); QCOMPARE(frame.fieldType(), fieldType); QCOMPARE(frame.startTime(), startTime); QCOMPARE(frame.endTime(), endTime); { QVideoFrame otherFrame(frame); QVERIFY(!buffer.isNull()); QVERIFY(otherFrame.isValid()); QCOMPARE(otherFrame.handleType(), handleType); QCOMPARE(otherFrame.pixelFormat(), pixelFormat); QCOMPARE(otherFrame.size(), size); QCOMPARE(otherFrame.width(), size.width()); QCOMPARE(otherFrame.height(), size.height()); QCOMPARE(otherFrame.fieldType(), fieldType); QCOMPARE(otherFrame.startTime(), startTime); QCOMPARE(otherFrame.endTime(), endTime); otherFrame.setEndTime(-1); QVERIFY(!buffer.isNull()); QVERIFY(otherFrame.isValid()); QCOMPARE(otherFrame.handleType(), handleType); QCOMPARE(otherFrame.pixelFormat(), pixelFormat); QCOMPARE(otherFrame.size(), size); QCOMPARE(otherFrame.width(), size.width()); QCOMPARE(otherFrame.height(), size.height()); QCOMPARE(otherFrame.fieldType(), fieldType); QCOMPARE(otherFrame.startTime(), startTime); QCOMPARE(otherFrame.endTime(), qint64(-1)); } QVERIFY(!buffer.isNull()); QVERIFY(frame.isValid()); QCOMPARE(frame.handleType(), handleType); QCOMPARE(frame.pixelFormat(), pixelFormat); QCOMPARE(frame.size(), size); QCOMPARE(frame.width(), size.width()); QCOMPARE(frame.height(), size.height()); QCOMPARE(frame.fieldType(), fieldType); QCOMPARE(frame.startTime(), startTime); QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared. } QVERIFY(buffer.isNull()); }
void tst_QQuaternion::add() { QFETCH(qreal, x1); QFETCH(qreal, y1); QFETCH(qreal, z1); QFETCH(qreal, w1); QFETCH(qreal, x2); QFETCH(qreal, y2); QFETCH(qreal, z2); QFETCH(qreal, w2); QFETCH(qreal, x3); QFETCH(qreal, y3); QFETCH(qreal, z3); QFETCH(qreal, w3); QQuaternion v1(w1, x1, y1, z1); QQuaternion v2(w2, x2, y2, z2); QQuaternion v3(w3, x3, y3, z3); QVERIFY((v1 + v2) == v3); QQuaternion v4(v1); v4 += v2; QVERIFY(v4 == v3); QCOMPARE(v4.x(), v1.x() + v2.x()); QCOMPARE(v4.y(), v1.y() + v2.y()); QCOMPARE(v4.z(), v1.z() + v2.z()); QCOMPARE(v4.scalar(), v1.scalar() + v2.scalar()); }
void tst_ToJson::metaData() { QFETCH(QByteArray, data); QFETCH(QString, expected); compareMetaData(data, expected); }
void tst_QQuaternion::subtract() { QFETCH(qreal, x1); QFETCH(qreal, y1); QFETCH(qreal, z1); QFETCH(qreal, w1); QFETCH(qreal, x2); QFETCH(qreal, y2); QFETCH(qreal, z2); QFETCH(qreal, w2); QFETCH(qreal, x3); QFETCH(qreal, y3); QFETCH(qreal, z3); QFETCH(qreal, w3); QQuaternion v1(w1, x1, y1, z1); QQuaternion v2(w2, x2, y2, z2); QQuaternion v3(w3, x3, y3, z3); QVERIFY((v3 - v1) == v2); QVERIFY((v3 - v2) == v1); QQuaternion v4(v3); v4 -= v1; QVERIFY(v4 == v2); QCOMPARE(v4.x(), v3.x() - v1.x()); QCOMPARE(v4.y(), v3.y() - v1.y()); QCOMPARE(v4.z(), v3.z() - v1.z()); QCOMPARE(v4.scalar(), v3.scalar() - v1.scalar()); QQuaternion v5(v3); v5 -= v2; QVERIFY(v5 == v1); QCOMPARE(v5.x(), v3.x() - v2.x()); QCOMPARE(v5.y(), v3.y() - v2.y()); QCOMPARE(v5.z(), v3.z() - v2.z()); QCOMPARE(v5.scalar(), v3.scalar() - v2.scalar()); }
void tst_QColor::isValid() { QFETCH(QColor, color); QFETCH(bool, isValid); QVERIFY(color.isValid() == isValid); }
void tst_QQuaternion::slerp() { QFETCH(qreal, x1); QFETCH(qreal, y1); QFETCH(qreal, z1); QFETCH(qreal, angle1); QFETCH(qreal, x2); QFETCH(qreal, y2); QFETCH(qreal, z2); QFETCH(qreal, angle2); QFETCH(qreal, t); QFETCH(qreal, x3); QFETCH(qreal, y3); QFETCH(qreal, z3); QFETCH(qreal, angle3); QQuaternion q1 = QQuaternion::fromAxisAndAngle(x1, y1, z1, angle1); QQuaternion q2 = QQuaternion::fromAxisAndAngle(x2, y2, z2, angle2); QQuaternion q3 = QQuaternion::fromAxisAndAngle(x3, y3, z3, angle3); QQuaternion result = QQuaternion::slerp(q1, q2, t); QVERIFY(fuzzyCompare(result.x(), q3.x())); QVERIFY(fuzzyCompare(result.y(), q3.y())); QVERIFY(fuzzyCompare(result.z(), q3.z())); QVERIFY(fuzzyCompare(result.scalar(), q3.scalar())); }
void tst_QColor::globalColors() { QFETCH(QColor, color); QFETCH(uint, argb); QCOMPARE(color.rgba(), argb); }
void tst_QQmlMetaObject::property() { QFETCH(QString, testFile); QFETCH(QByteArray, cppTypeName); QFETCH(int, cppType); QFETCH(bool, isDefault); QFETCH(QVariant, expectedValue); QFETCH(bool, isWritable); QFETCH(QVariant, newValue); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl(testFile)); QObject *object = component.create(); QVERIFY(object != 0); const QMetaObject *mo = object->metaObject(); QVERIFY(mo->superClass() != 0); QVERIFY(QByteArray(mo->className()).contains("_QML_")); QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount()); QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1); QMetaProperty prop = mo->property(mo->propertyOffset()); QCOMPARE(prop.name(), "test"); QCOMPARE(QByteArray(prop.typeName()), cppTypeName); if (prop.userType() < QMetaType::User) QCOMPARE(prop.type(), QVariant::Type(cppType)); else QCOMPARE(prop.type(), QVariant::UserType); QCOMPARE(prop.userType(), cppType); QVERIFY(!prop.isConstant()); QVERIFY(!prop.isDesignable()); QVERIFY(!prop.isEnumType()); QVERIFY(!prop.isFinal()); QVERIFY(!prop.isFlagType()); QVERIFY(prop.isReadable()); QVERIFY(!prop.isResettable()); QVERIFY(prop.isScriptable()); QVERIFY(!prop.isStored()); QVERIFY(!prop.isUser()); QVERIFY(prop.isValid()); QCOMPARE(prop.isWritable(), isWritable); QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount()); QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0)); if (isDefault) { QMetaClassInfo info = mo->classInfo(mo->classInfoOffset()); QCOMPARE(info.name(), "DefaultProperty"); QCOMPARE(info.value(), "test"); } QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal QVERIFY(prop.notifySignalIndex() != -1); QMetaMethod signal = prop.notifySignal(); QCOMPARE(signal.methodType(), QMetaMethod::Signal); QCOMPARE(signal.name(), QByteArray("testChanged")); QCOMPARE(signal.methodSignature(), QByteArray("testChanged()")); QCOMPARE(signal.access(), QMetaMethod::Public); QCOMPARE(signal.parameterCount(), 0); QCOMPARE(signal.parameterTypes(), QList<QByteArray>()); QCOMPARE(signal.parameterNames(), QList<QByteArray>()); QCOMPARE(signal.tag(), ""); QCOMPARE(signal.typeName(), "void"); QCOMPARE(signal.returnType(), int(QMetaType::Void)); QSignalSpy changedSpy(object, SIGNAL(testChanged())); QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater())); if (expectedValue.isValid()) QCOMPARE(prop.read(object), expectedValue); else QVERIFY(prop.read(object).isValid()); QCOMPARE(changedSpy.count(), 0); if (isWritable) { QVERIFY(prop.write(object, newValue)); QCOMPARE(changedSpy.count(), 1); QCOMPARE(prop.read(object), newValue); } else { QVERIFY(!prop.write(object, prop.read(object))); QCOMPARE(changedSpy.count(), 0); } delete object; }