void QtQuickSampleApplicationTest::myCalculatorViewModelOperationTest()
{
    // Setup the test
    MyCalculatorViewModelTest model;

    QCOMPARE( model.getOperation(), 0 ); //Expect the operation to be 'None' by default
    MyCalculatorViewModel::MyCalculator_Operation expect( MyCalculatorViewModel::MyCalculator_Operation::MyCalculator_Operation_Addition );
    model.injectOperation( expect );

    // Test - we're actually testing both the set and get method here, not as isolated as I would like but ok for what it is.
    int actual = model.getOperation();

    QVERIFY2( actual == (int)expect,
              QString("Expect the result value to be [%1] but actually got [%2] instead.").arg(expect).arg(actual).toStdString().c_str());
}
void ctkMTAttrPasswordTestSuite::testAttributeTypePassword1()
{
  ctkMetaTypeInformationPtr mti = mts->getMetaTypeInformation(plugin);
  ctkObjectClassDefinitionPtr ocd = mti->getObjectClassDefinition("org.commontk.metatype.tests.attrpwd");
  QVERIFY(ocd);
  QList<ctkAttributeDefinitionPtr> ads = ocd->getAttributeDefinitions(ctkObjectClassDefinition::ALL);
  for (int i = 0; i < ads.size(); i++)
  {
    if (ads[i]->getID() == "password1")
    {
      QVERIFY2(ctkAttributeDefinition::PASSWORD == ads[i]->getType(),
               "Attribute type is not PASSWORD");
    }
  }
}
示例#3
0
void tst_QDirModel::unreadable()
{
#ifndef Q_OS_UNIX
    QSKIP("Test not implemented on non-Unixes");
#else
    // Create an empty file which has no read permissions (file will be removed by cleanup()).
    QFile unreadableFile(QDir::currentPath() + "qtest_unreadable");
    QVERIFY2(unreadableFile.open(QIODevice::WriteOnly | QIODevice::Text), qPrintable(unreadableFile.errorString()));
    unreadableFile.close();
    QVERIFY(unreadableFile.exists());
    QVERIFY2(unreadableFile.setPermissions(QFile::WriteOwner), qPrintable(unreadableFile.errorString()));

    // Check that we can't make a valid model index from an unreadable file.
    QDirModel model;
    QModelIndex index = model.index(QDir::currentPath() + "/qtest_unreadable");
    QVERIFY(!index.isValid());

    // Check that unreadable files are not treated like hidden files.
    QDirModel model2;
    model2.setFilter(model2.filter() | QDir::Hidden);
    index = model2.index(QDir::currentPath() + "/qtest_unreadable");
    QVERIFY(!index.isValid());
#endif
}
void ctkEAScenario3EventConsumer::runTest()
{
  asynchMessages = 0;
  synchMessages = 0;
  /* create the hashtable to put properties in */
  ctkDictionary props;

  /* put service.pid property in hashtable */
  props.insert(ctkEventConstants::EVENT_TOPIC, topicsToConsume);

  /* register the service */
  serviceRegistration = context->registerService<ctkEventHandler>(this, props);

  QVERIFY2(serviceRegistration, "service registration should not be null");
}
void ZippedBufferTests::basictTest()
{
    QString name("toto.txt");
    QByteArray data;
    data.reserve(2);
    data[0] = 'a';
    data[1] = 'b';
    ZippedBuffer zbw(name, data);
    QTemporaryFile file;
    QVERIFY2(file.open(), "Cannot create file");
    QDataStream stream(&file);
    zbw.write(stream);
    file.close();
    {
        QFile read_file(file.fileName());
        QDataStream read_stream(&read_file);
        ZippedBuffer zbr;
        QVERIFY2(read_file.open(QIODevice::ReadOnly), "Cannot read file");
        zbr.read(read_stream);
        QVERIFY2(zbw.get_filename() == zbr.get_filename(), "Filename not equal");
        QVERIFY2(zbw.get_data() == zbr.get_data(), "Data not equal");
    }

}
示例#6
0
void tst_QLibrary::fileName()
{
    QFETCH( QString, libName);
    QFETCH( QString, expectedFilename);

    QLibrary lib(libName);
    bool ok = lib.load();
    QVERIFY2(ok, qPrintable(lib.errorString()));
#if defined(Q_OS_WIN)
    QCOMPARE(lib.fileName().toLower(), expectedFilename.toLower());
#else
    QCOMPARE(lib.fileName(), expectedFilename);
#endif
    QVERIFY(lib.unload());
}
void tst_QPauseAnimationJob::pauseResume()
{
    TestablePauseAnimation animation;
    animation.setDuration(400);
    animation.start();
    QCOMPARE(animation.state(), QAbstractAnimationJob::Running);
    QTest::qWait(200);
    animation.pause();
    QCOMPARE(animation.state(), QAbstractAnimationJob::Paused);
    animation.start();
    QTest::qWait(300);
    QTRY_VERIFY(animation.state() == QAbstractAnimationJob::Stopped);
    QVERIFY2(animation.m_updateCurrentTimeCount >= 3,
            QByteArrayLiteral("animation.m_updateCurrentTimeCount=") + QByteArray::number(animation.m_updateCurrentTimeCount));
}
示例#8
0
void ThreadedTestHTTPServer::run()
{
    TestHTTPServer server;
    {
        QMutexLocker locker(&m_mutex);
        QVERIFY2(server.listen(), qPrintable(server.errorString()));
        m_port = server.port();
        for (QHash<QString, TestHTTPServer::Mode>::ConstIterator i = m_dirs.constBegin();
                i != m_dirs.constEnd(); ++i) {
            server.serveDirectory(i.key(), i.value());
        }
        m_condition.wakeAll();
    }
    exec();
}
示例#9
0
void uiLoader::createBaseline()
{
    // can't use ftpUploadFile() here
    qDebug() << " ========== Uploading baseline of only the latest test values ";

    QFtp ftp;
    ftp.connectToHost( ftpHost );
    ftp.login( ftpUser, ftpPass );
    ftp.cd( ftpBaseDir );

    QDir dir( output );

    // Upload all the latest test results to the FTP server's baseline directory.
    QHashIterator<QString, QString> i(enginesToTest);
    while ( i.hasNext() ) {
        i.next();

        dir.cd( i.key() );
        ftp.cd( i.key() + ".baseline" );

        dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
        dir.setNameFilters( QStringList() << "*.png" );
        QFileInfoList list = dir.entryInfoList();

        dir.cd( ".." );

        for (int n = 0; n < list.size(); n++) {
            QFileInfo fileInfo = list.at( n );
            QFile file( QString( output ) + "/" + i.key() + "/" + fileInfo.fileName() );

            errorMsg = "could not open file " + fileInfo.fileName();
            QVERIFY2( file.open(QIODevice::ReadOnly), qPrintable(errorMsg));

            QByteArray fileData = file.readAll();
            file.close();

            ftp.put( fileData, fileInfo.fileName(), QFtp::Binary );
            qDebug() << "\t(I) Uploading:" << fileInfo.fileName() << "with file size" << fileData.size();
        }

        ftp.cd( ".." );
    }

    ftp.close();

    while ( ftp.hasPendingCommands() )
        QCoreApplication::instance()->processEvents();
}
示例#10
0
void tst_QWinJumpList::testRecent()
{
    if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10)
        QSKIP("QTBUG-48751: Recent items do not work on Windows 10", Continue);
    QScopedPointer<QWinJumpList> jumplist(new QWinJumpList);
    QWinJumpListCategory *recent1 = jumplist->recent();
    QVERIFY(recent1);
    QVERIFY(!recent1->isVisible());
    QVERIFY(recent1->title().isEmpty());

    recent1->clear();
    QVERIFY(recent1->isEmpty());

    recent1->addItem(0);
    QVERIFY(recent1->isEmpty());

    recent1->setVisible(true);
    QVERIFY(recent1->isVisible());
    recent1->addLink(QStringLiteral("tst_QWinJumpList"), QCoreApplication::applicationFilePath());

    QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support separators.");
    recent1->addSeparator();

    QTest::ignoreMessage(QtWarningMsg, "QWinJumpListCategory::addItem(): only tasks/custom categories support destinations.");
    recent1->addDestination(QCoreApplication::applicationDirPath());

    // cleanup the first jumplist instance and give the system a little time to update.
    // then test that another jumplist instance loads up the recent item(s) added above
    jumplist.reset();
    QTest::qWait(100);

    jumplist.reset(new QWinJumpList);
    QWinJumpListCategory *recent2 = jumplist->recent();
    QVERIFY(recent2);
    QCOMPARE(recent2->count(), 1);

    QWinJumpListItem* item = recent2->items().value(0);
    QVERIFY(item);
    const QString itemPath = item->filePath();
    const QString applicationFilePath = QCoreApplication::applicationFilePath();
    QVERIFY2(!itemPath.compare(applicationFilePath, Qt::CaseInsensitive),
             msgFileNameMismatch(itemPath, applicationFilePath));
    QEXPECT_FAIL("", "QWinJumpListItem::title not supported for recent items", Continue);
    QCOMPARE(item->title(), QStringLiteral("tst_QWinJumpList"));

    recent2->clear();
    QVERIFY(recent2->isEmpty());
}
示例#11
0
void Test_Bone::testResolveDirection()
{
    Bone bone;

    bone.setLength(2.0);
    bone.mPos[1]->setX(1.5f);

    int sanity = 0;

    while(!bone.resolve()) {
        QVERIFY2(sanity < 100, "Bone never resolved.");
        sanity++;
    }

   // QVERIFY2(bone.mPos[1]->x() > 1.99, "bone is facing wrong way");
}
示例#12
0
void KWalletExecuter::pamRead(const QString &value) const
{
    QDBusMessage msg =
        QDBusMessage::createMethodCall("org.kde.kwalletd", "/modules/kwalletd", "org.kde.KWallet", "readPassword");
    QVariantList args;
    args << m_handler
         << QLatin1String("Passwords")
         << QLatin1String("foo")
         << QLatin1String("buh");
    msg.setArguments(args);
    const QDBusMessage reply = QDBusConnection::sessionBus().call(msg);

    QVERIFY2(reply.type() != QDBusMessage::ErrorMessage, reply.errorMessage().toLocal8Bit());
    const QString password = reply.arguments().first().toString();
    QCOMPARE(password, value);
}
示例#13
0
void KWalletExecuter::pamOpen()
{
    QDBusMessage msg =
        QDBusMessage::createMethodCall("org.kde.kwalletd", "/modules/kwalletd", "org.kde.KWallet", "open");
    QVariantList args;
    qlonglong wid = 0;
    args << QLatin1String("kdewallet") << wid << QLatin1String("buh");
    msg.setArguments(args);
    const QDBusMessage reply = QDBusConnection::sessionBus().call(msg);

    QVERIFY2(reply.type() != QDBusMessage::ErrorMessage, reply.errorMessage().toLocal8Bit());
    m_handler = reply.arguments().first().toInt();
    if (m_handler <= 0) {
        qFatal("Couldn't open the wallet via dbus");//We don't want the test to continue
    }
}
示例#14
0
 void testForceThemeForTests()
 {
     auto forcedName = QStringLiteral("kitten");
     auto resolvedCurrent = KIconTheme::current();
     QVERIFY2(KIconTheme::current() != forcedName,
              "current theme initially expected to not be mangled");
     // Force a specific theme.
     KIconTheme::forceThemeForTests(forcedName);
     QCOMPARE(KIconTheme::current(), forcedName);
     // Reset override.
     KIconTheme::forceThemeForTests(QString());
     QCOMPARE(KIconTheme::current(), resolvedCurrent);
     // And then override again to make sure we still can.
     KIconTheme::forceThemeForTests(forcedName);
     QCOMPARE(KIconTheme::current(), forcedName);
 }
示例#15
0
void tst_QTimer::remainingTime()
{
    TimerHelper helper;
    QTimer timer;

    connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout()));
    timer.start(200);

    QCOMPARE(helper.count, 0);

    QTest::qWait(50);
    QCOMPARE(helper.count, 0);

    int remainingTime = timer.remainingTime();
    QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime)));
}
示例#16
0
void tst_MacNativeEvents::testMouseMoveLocation()
{
    QWidget w;
    w.setMouseTracking(true);
    w.show();
    QPoint p = w.geometry().center();

    NativeEventList native;
    native.append(new QNativeMouseMoveEvent(p, Qt::NoModifier));

    ExpectedEventList expected(&w);
    expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(p), p, Qt::NoButton, Qt::NoButton, Qt::NoModifier));

    native.play();
    QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!");
}
void tst_QLogSystem::loggerConstruction()
{
    FileLogger<> l_name1("NO-DIRECTORY/file-should-not-be-opened");
    QString err_msg;
    QVERIFY2(!l_name1.isReady(err_msg), "File logger is ready with invalid dir.");
    QVERIFY2(!err_msg.isEmpty(), "File logger has not obtained error message");

    err_msg = QString("");

    FileLogger<> l_name2("./LoggersTest.log");
    QVERIFY2(l_name2.isReady(err_msg), "File logger is not ready with local dir.");
    QVERIFY2(err_msg.isEmpty(), "File logger has obtained error message with local dir");
    QVERIFY2(QFile::remove("./LoggersTest.log"), "could not delete log file");

    FileLogger<> l_name3(stdout);
    QVERIFY2(l_name3.isReady(err_msg), "File logger is not ready with stdout.");
    QVERIFY2(err_msg.isEmpty(), "File logger has obtained error message with stdout.");

    FileLogger<> l_name4(stderr);
    QVERIFY2(l_name4.isReady(err_msg), "File logger is not ready with stderr.");
    QVERIFY2(err_msg.isEmpty(), "File logger has obtained error message with stderr.");
}
示例#18
0
void Physics_testTest::testCase1()
{
  Matrix3f matrix(Matrix3f::kZero);
  Matrix3f identity(Matrix3f::kIdentity);

  Matrix3f sum(identity + identity);
  Matrix3f sum2 = identity * 2.0f;

  QVERIFY2(sum2 - sum == Matrix3f::kZero, "Sum" );
  QVERIFY2(sum2.det() == 8.0f, "Det");

  Matrix3f inverse = sum2.inverse();
  QVERIFY2(inverse.det() - (1.0f/8.0f) < 0.01f, "Inverse");
  QVERIFY2(inverse*sum2 == Matrix3f::kIdentity, "Inverse2");

  Matrix3f rotX = Matrix3f::RotationX(0.1);
  Matrix3f rotY = Matrix3f::RotationY(0.5);
  Matrix3f rotZ = Matrix3f::RotationZ(2.0);

  Matrix3f total = rotX * rotY * rotZ;

  QVERIFY2(fabs(((total * total.inverse()) - Matrix3f::kIdentity).det()) < 0.00000001f, "Complex");

  Vector3f y_up = Vector3f(0.0f, 1.0f, 0.0f);
  Vector3f x_right = Vector3f(1.0f, 0.0f, 0.0f);

  Vector3f imageY = rotX * y_up;
  QVERIFY2(fabs(imageY.dot(y_up) - cosf(0.1f)) < 0.00001, "Rotation");

  Matrix3f rot_axis = Matrix3f::FromAxisAngle(y_up, 0.5);
  Vector3f imageX = rot_axis * y_up;
  QVERIFY2(fabs(imageX.dot(y_up) - y_up.lengthSquared()) < 0.00001, "Axis Angle");

  imageX = rot_axis * x_right;
  QVERIFY2(fabs(imageX.dot(x_right) - cosf(0.5)) < 0.00001, "Axis Angle");

  //Matrix3f identity = Matrix3f::kIdentity;
  QVERIFY2(true, "Failure");
}
示例#19
0
void ensureSerializesCorrectly(const QPicture &picture, QDataStream::Version version)
 {
    QDataStream stream;

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    stream.setDevice(&buffer);
    stream.setVersion(version);
    stream << picture;
    buffer.close();

    buffer.open(QIODevice::ReadOnly);
    QPicture readpicture;
    stream >> readpicture;
    QVERIFY2(memcmp(picture.data(), readpicture.data(), picture.size()) == 0,
        qPrintable(QString::fromLatin1("Picture data does not compare equal for QDataStream version %1").arg(version)));
}
示例#20
0
void uiLoader::clearDirectory(const QString& pathDir)
{
    qDebug() << "\t(I) Clearing directory local: " << pathDir;

    QDir dir(pathDir);
    dir.setFilter(QDir::Files);
    QStringList list = dir.entryList();

    for (int n = 0; n < list.size(); n++) {
        QString filePath = pathDir + "/" + list.at(n);
        QFile file(filePath);

        errorMsg = "could not remove file " + filePath;
        QVERIFY2( file.remove(), qPrintable(errorMsg));
    }

}
示例#21
0
void KArchiveTest::testTarRootDir() // bug 309463
{
    KTar tar(QFINDTESTDATA(QLatin1String("tar_rootdir.tar.gz")));
    QVERIFY2(tar.open(QIODevice::ReadOnly), qPrintable(tar.fileName()));

    const KArchiveDirectory *dir = tar.directory();
    QVERIFY(dir != nullptr);

    const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup);
    //qDebug() << listing.join("\n");

    QVERIFY(listing[0].contains("%{APPNAME}.cpp"));
    QVERIFY(listing[1].contains("%{APPNAME}.h"));
    QVERIFY(listing[5].contains("main.cpp"));

    QCOMPARE(listing.count(), 10);
}
示例#22
0
void KArchiveTest::testTarDirectoryForgotten()
{
    KTar tar(QFINDTESTDATA(QLatin1String("tar_directory_forgotten.tar.gz")));
    QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_directory_forgotten.tar.gz");

    const KArchiveDirectory *dir = tar.directory();
    QVERIFY(dir != nullptr);

    const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup);

    QVERIFY(listing[9].contains("trolltech/examples/generator"));
    QVERIFY(listing[10].contains("trolltech/examples/generator/GeneratorExample.html"));

    QCOMPARE(listing.count(), 11);

    QVERIFY(tar.close());
}
示例#23
0
void KArchiveTest::testTarGlobalHeader()
{
    KTar tar(QFINDTESTDATA(QLatin1String("global_header_test.tar.gz")));
    QVERIFY2(tar.open(QIODevice::ReadOnly), "global_header_test.tar.gz");

    const KArchiveDirectory *dir = tar.directory();
    QVERIFY(dir != nullptr);

    const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup);

    QCOMPARE(listing.count(), 2);

    QCOMPARE(listing[0], QString("mode=40775 user=root group=root path=Test type=dir"));
    QCOMPARE(listing[1], QString("mode=664 user=root group=root path=Test/test.txt type=file size=0"));

    QVERIFY(tar.close());
}
示例#24
0
 void testWLAN6X() {
     Keygen * keygen = matcher.getKeygen("WLAN123456", "11:22:33:44:55:66", 0, "");
     QVERIFY2(keygen != NULL, "An algorithm was not detected");
     QCOMPARE(typeid(*keygen),typeid(Wlan6Keygen) );
     QVector<QString> results = keygen->getResults();
     QCOMPARE( results.size(),10);
     QCOMPARE(results.at(0), QString("5630556304607"));
     QCOMPARE(results.at(1), QString("5730446305616"));
     QCOMPARE(results.at(2), QString("5430776306625"));
     QCOMPARE(results.at(3), QString("5530666307634"));
     QCOMPARE(results.at(4), QString("5230116300643"));
     QCOMPARE(results.at(5), QString("5330006301652"));
     QCOMPARE(results.at(6), QString("5030336302661"));
     QCOMPARE(results.at(7), QString("5130226303670"));
     QCOMPARE(results.at(8), QString("5E30DD630C68F"));
     QCOMPARE(results.at(9), QString("5F30CC630D69E"));
 }
示例#25
0
void tst_QUdpSocket::pendingDatagramSize()
{
    QUdpSocket server;
    QVERIFY2(server.bind(), server.errorString().toLatin1().constData());

    QHostAddress serverAddress = QHostAddress::LocalHost;
    if (!(server.localAddress() == QHostAddress::Any))
        serverAddress = server.localAddress();

    QUdpSocket client;
    QVERIFY(client.writeDatagram("this is", 7, serverAddress, server.localPort()) == 7);
    QVERIFY(client.writeDatagram(0, 0, serverAddress, server.localPort()) == 0);
    QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10);

    char c = 0;
    QVERIFY(server.waitForReadyRead());
    if (server.hasPendingDatagrams()) {
#if defined Q_OS_HPUX && defined __ia64
        QEXPECT_FAIL("", "HP-UX 11i v2 can't determine the datagram size correctly.", Abort);
#endif
        QCOMPARE(server.pendingDatagramSize(), qint64(7));
        c = '\0';
        QCOMPARE(server.readDatagram(&c, 1), qint64(1));
        QCOMPARE(c, 't');
        c = '\0';
    } else {
        QSKIP("does not have the 1st datagram", SkipSingle);
    }

    if (server.hasPendingDatagrams()) {
        QCOMPARE(server.pendingDatagramSize(), qint64(0));
        QCOMPARE(server.readDatagram(&c, 1), qint64(0));
        QCOMPARE(c, '\0'); // untouched
        c = '\0';
    } else {
        QSKIP("does not have the 2nd datagram", SkipSingle);
    }

    if (server.hasPendingDatagrams()) {
        QCOMPARE(server.pendingDatagramSize(), qint64(10));
        QCOMPARE(server.readDatagram(&c, 1), qint64(1));
        QCOMPARE(c, '3');
    } else {
        QSKIP("does not have the 3rd datagram", SkipSingle);
    }
}
示例#26
0
文件: chattest.cpp 项目: schuay/sepm
void ChatTests::testInviteNotLoggedIn()
{
    QVERIFY(chat);

    QSignalSpy spy(chat.data(), SIGNAL(inviteCompleted(bool, QString)));
    QVERIFY(spy.isValid());
    QVERIFY(spy.isEmpty());

    QSharedPointer<const User> u(new User(getUsername("registeredbutneverlogsin"),
                                          WORKING_DIR "public.pem"));
    chat->invite(u);
    waitForResult(spy);

    QCOMPARE(spy.count(), 1);
    QList<QVariant> arguments = spy.takeFirst();
    QVERIFY2(arguments.at(0) == false, arguments.at(1).toString().toStdString().c_str());
}
示例#27
0
文件: chattest.cpp 项目: schuay/sepm
void ChatTests::testInviteSelf()
{
    QVERIFY(chat);

    QSignalSpy spy(chat.data(), SIGNAL(inviteCompleted(bool, QString)));
    QVERIFY(spy.isValid());
    QVERIFY(spy.isEmpty());

    QSharedPointer<const User> u(new User(TEMP_SESSION_USER3,
                                      WORKING_DIR "public.pem"));
    chat->invite(u);
    waitForResult(spy);

    QCOMPARE(spy.count(), 1);
    QList<QVariant> arguments = spy.takeFirst();
    QVERIFY2(arguments.at(0) == false, arguments.at(1).toString().toStdString().c_str());
}
示例#28
0
void KMimeTypeTest::testFindByPathUsingFileName_data()
{
    QTest::addColumn<QString>("fileName");
    QTest::addColumn<QString>("expectedMimeType");
    // Maybe we could also add a expectedAccuracy column...

    QTest::newRow("text") << "textfile.txt" << "text/plain";
    QTest::newRow("case-insensitive search") << "textfile.TxT" << "text/plain";
    // With QMime, this needs shared-mime-info > 0.91. Earlier versions wrote .Z to the mime.cache file...
    if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 91, 0)) {
        QTest::newRow("case-insensitive match on a non-lowercase glob") << "foo.z" << "application/x-compress";
    }

    QTest::newRow("case-sensitive uppercase match") << "textfile.C" << "text/x-c++src";
    QTest::newRow("case-sensitive lowercase match") << "textfile.c" << "text/x-csrc";
    QTest::newRow("case-sensitive long-extension match") << "foo.PS.gz" << "application/x-gzpostscript";
    QTest::newRow("case-sensitive-only match") << "core" << "application/x-core";
    QTest::newRow("case-sensitive-only match") << "Core" << "application/octet-stream"; // #198477

    QTest::newRow("desktop file") << "foo.desktop" << "application/x-desktop";
    QTest::newRow("old kdelnk file is x-desktop too") << "foo.kdelnk" << "application/x-desktop";
    QTest::newRow("double-extension file") << "foo.tar.bz2" << "application/x-bzip-compressed-tar";
    QTest::newRow("single-extension file") << "foo.bz2" << "application/x-bzip";
    QTest::newRow(".doc should assume msword") << "somefile.doc" << "application/msword"; // #204139
    QTest::newRow("glob that uses [] syntax, 1") << "Makefile" << "text/x-makefile";
    QTest::newRow("glob that uses [] syntax, 2") << "makefile" << "text/x-makefile";
    QTest::newRow("glob that ends with *, no extension") << "README" << "text/x-readme";
    QTest::newRow("glob that ends with *, extension") << "README.foo" << "text/x-readme";
    QTest::newRow("glob that ends with *, also matches *.txt. Higher weight wins.") << "README.txt" << "text/plain";
    QTest::newRow("glob that ends with *, also matches *.nfo. Higher weight wins.") << "README.nfo" << "text/x-nfo";
    // fdo bug 15436, needs shared-mime-info >= 0.40 (and this tests the globs2-parsing code).
    QTest::newRow("glob that ends with *, also matches *.pdf. *.pdf has higher weight") << "README.pdf" << "application/pdf";
    QTest::newRow("directory") << "/" << "inode/directory";
    QTest::newRow("doesn't exist, no extension") << "IDontExist" << "application/octet-stream";
    QTest::newRow("doesn't exist but has known extension") << "IDontExist.txt" << "text/plain";
    QTest::newRow("png image") << QFINDTESTDATA("image.png") << "image/png";

    const QString exePath = QStandardPaths::findExecutable("cmake");
    QVERIFY2(!exePath.isEmpty(), "cmake not found. Isn't it in your $PATH?");
#ifdef Q_OS_WIN
    const QString executableType = QString::fromLatin1("application/x-ms-dos-executable");
#else
    const QString executableType = QString::fromLatin1("application/x-executable");
#endif
    QTest::newRow("executable") << exePath << executableType;
}
示例#29
0
void IndentTest::runTest(const ExpectedFailures& failures)
{
  if ( !QFile::exists(testDataPath) )
    QSKIP(qPrintable(QString(testDataPath + " does not exist")), SkipAll);

  QFETCH(QString, testcase);

  m_toplevel->resize( 800, 600); // restore size

  // load page
  KUrl url;
  url.setProtocol("file");
  url.setPath(testcase + "/origin");
  m_document->openUrl(url);

  // evaluate test-script
  QFile sourceFile(testcase + "/input.js");
  QVERIFY( sourceFile.open(QFile::ReadOnly) );

  QTextStream stream(&sourceFile);
  stream.setCodec("UTF8");
  QString code = stream.readAll();
  sourceFile.close();

  // Execute script
  QScriptValue result = m_env->engine()->evaluate(code, testcase + "/input.js", 1);
  QVERIFY2( !result.isError(), result.toString().toUtf8().constData() );

  url.setPath(testcase + "/actual");
  m_document->saveAs(url);

  // diff actual and expected
  QProcess diff;
  QStringList args;
  args << "-u" << (testcase + "/expected") << (testcase + "/actual");
  diff.start("diff", args);
  diff.waitForFinished();
  QByteArray out = diff.readAllStandardOutput();
  QByteArray err = diff.readAllStandardError();
  if ( !err.isEmpty() ) {
    qWarning() << err;
  }
  foreach( const Failure& failure, failures ) {
    QEXPECT_FAIL(failure.first, failure.second, Abort);
  }
示例#30
0
/*
    This tests whether the temporary dir really gets placed in QDir::tempPath
*/
void tst_QTemporaryDir::fileName()
{
    // Get QDir::tempPath and make an absolute path.
    QString tempPath = QDir::tempPath();
    QString absoluteTempPath = QDir(tempPath).absolutePath();
    QTemporaryDir dir;
    dir.setAutoRemove(true);
    QString fileName = dir.path();
    QVERIFY2(fileName.contains("/tst_qtemporarydir-"), qPrintable(fileName));
    QVERIFY(QDir(fileName).exists());
    // Get path to the temp dir, without the file name.
    QString absoluteFilePath = QFileInfo(fileName).absolutePath();
#if defined(Q_OS_WIN)
    absoluteFilePath = absoluteFilePath.toLower();
    absoluteTempPath = absoluteTempPath.toLower();
#endif
    QCOMPARE(absoluteFilePath, absoluteTempPath);
}