void TestAnalysisTab::testAddVideo() {
	QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
	tabWidget->setCurrentIndex(1);
	qApp->processEvents();
	QTest::qSleep(500);
	loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
	//we skip pressing the "Add video" button and use the UndoStack instead
	GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
	QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
	UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
	UndoRedo::UndoStack::getUndoStack().push(addVideo);
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QCoreApplication::processEvents();
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 1,"Could not add video");
	//test UndoRedo
	TestMainWindow::triggerAction("Undo");
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 0,"Could not undo the adding of a video");
	TestMainWindow::triggerAction("Redo");
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 1,"Could not redo the adding of a video");
}
Beispiel #2
0
void KConfigCompiler_Test::testBaselineComparison()
{
    QFETCH(QString, testName);

    QFile file(QFINDTESTDATA(testName));
    QFile fileRef(QFINDTESTDATA(testName + QLatin1String(".ref")));

    if (!file.open(QIODevice::ReadOnly)) {
        qWarning() << "Failed to open" << file.fileName() << "(" << testName << ")";
        QFAIL("Can't open file for comparison");
    }
    if (!fileRef.open(QIODevice::ReadOnly)) {
        qWarning() << "Failed to open" << fileRef.fileName() << "(" << testName << ".ref )";
        QFAIL("Can't open file for comparison");
    }
    QString content = file.readAll();
    QString contentRef = fileRef.readAll();

    if (content != contentRef)  {
        appendFileDiff(fileRef.fileName(), file.fileName());
    }
    // use split('\n') to avoid
    // the whole output shown inline
    QCOMPARE(content.split('\n'), contentRef.split('\n'));
    QVERIFY(content == contentRef);
}
Beispiel #3
0
void tst_QPluginLoader::loadCorruptElf()
{
#if defined (__ELF__)
    if (sizeof(void*) == 8) {
        QVERIFY(QFile::exists(QFINDTESTDATA("elftest/corrupt1.elf64.so")));

        QPluginLoader lib1(QFINDTESTDATA("elftest/corrupt1.elf64.so"));
        QCOMPARE(lib1.load(), false);
        QVERIFY2(lib1.errorString().contains("not an ELF object"), qPrintable(lib1.errorString()));

        QPluginLoader lib2(QFINDTESTDATA("elftest/corrupt2.elf64.so"));
        QCOMPARE(lib2.load(), false);
        QVERIFY2(lib2.errorString().contains("invalid"), qPrintable(lib2.errorString()));

        QPluginLoader lib3(QFINDTESTDATA("elftest/corrupt3.elf64.so"));
        QCOMPARE(lib3.load(), false);
        QVERIFY2(lib3.errorString().contains("invalid"), qPrintable(lib3.errorString()));
    } else if (sizeof(void*) == 4) {
        QPluginLoader libW(QFINDTESTDATA("elftest/corrupt3.elf64.so"));
        QCOMPARE(libW.load(), false);
        QVERIFY2(libW.errorString().contains("architecture"), qPrintable(libW.errorString()));
    } else {
        QFAIL("Please port QElfParser to this platform or blacklist this test.");
    }
#endif
}
Beispiel #4
0
void tst_QMovie::changeMovieFile()
{
    QMovie movie(QFINDTESTDATA("animations/comicsecard.gif"));
    movie.start();
    movie.stop();
    movie.setFileName(QFINDTESTDATA("animations/trolltech.gif"));
    QVERIFY(movie.currentFrameNumber() == -1);
}
Beispiel #5
0
void tst_QPluginLoader::loadDebugObj()
{
#if defined (__ELF__)
    QVERIFY(QFile::exists(QFINDTESTDATA("elftest/debugobj.so")));
    QPluginLoader lib1(QFINDTESTDATA("elftest/debugobj.so"));
    QCOMPARE(lib1.load(), false);
#endif
}
void TestAnalysisTab::testCommentBox() {
    //Add yuc and 2 decoded videos
    QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    QTest::qSleep(500);
    loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
    //we skip pressing the "Add video" button and use the UndoStack instead
    GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
    QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
    UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
    UndoRedo::UndoStack::getUndoStack().push(addVideo);
    QCoreApplication::processEvents();
    QTest::qSleep(2000);
    QCoreApplication::processEvents();
    addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
    UndoRedo::UndoStack::getUndoStack().push(addVideo);
    QCoreApplication::processEvents();
    QTest::qSleep(2000);
    QCoreApplication::processEvents();
    QPlainTextEdit* lineEditBox1 = mw->findChildren<GUI::AnalysisBox*>().first()->findChildren<QPlainTextEdit*>().first();
    QPlainTextEdit* lineEditBox2 = mw->findChildren<GUI::AnalysisBox*>().at(1)->findChildren<QPlainTextEdit*>().first();

    tabWidget = mw->findChildren<GUI::AnalysisBox*>().first()->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    tabWidget = mw->findChildren<GUI::AnalysisBox*>().at(1)->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    lineEditBox1->selectAll();
    QApplication::postEvent(lineEditBox1,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"test 1"));
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1", "Error writing comment");
    TestMainWindow::triggerAction("Undo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() != "test 1", "Error undoing the writing of a comment");
    TestMainWindow::triggerAction("Redo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1", "Error redoing the writing of a comment");
    lineEditBox2->selectAll();
    QApplication::postEvent(lineEditBox2,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"test 2"));
    TestMainWindow::waitForWindow(300);
    QApplication::postEvent(lineEditBox1,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"continue writing"));
    TestMainWindow::waitForWindow(300);
    QApplication::postEvent(lineEditBox2,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier," more"));
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() == "test 2 more", "Error writing comment");
    TestMainWindow::triggerAction("Undo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() != "test 2 more", "Error undoing writing a comment");
    TestMainWindow::triggerAction("Redo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() == "test 2 more", "Error undoing writing a comment");
}
void tst_QSampleCache::testNotCachedSample()
{
    QSampleCache cache;
    QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));

    QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
    QVERIFY(sample);
    QTRY_COMPARE(loadingSpy.count(), 2);
    QTRY_VERIFY(!cache.isLoading());
    sample->release();

    QVERIFY(!cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
}
void TestAnalysisTab::testGraphs() {
	//Add yuc and decoded video
	QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
	tabWidget->setCurrentIndex(1);
	qApp->processEvents();
	QTest::qSleep(500);
	loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
	//we skip pressing the "Add video" button and use the UndoStack instead
	GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
	QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
	UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
	UndoRedo::UndoStack::getUndoStack().push(addVideo);
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QCoreApplication::processEvents();

	TestMainWindow::clickButton("Red histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(360,250))!=255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))==255 , "Failed clicking Red histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(570,500))==255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(330,600))!=255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,600))==255 , "Failed clicking Red histogramm");

	TestMainWindow::clickButton("Green histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(360,250))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))!=255 , "Failed clicking Green histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(570,500))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(330,600))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,630))!=255 , "Failed clicking Green histogramm");

	TestMainWindow::clickButton("Blue histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(340,250))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))==255 , "Failed clicking Green histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(550,500))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(345,600))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,600))==255 , "Failed clicking Green histogramm");
}
Beispiel #9
0
void tst_jpeg::jpegDecodingQtWebkitStyle()
{
    // QtWebkit currently calls size() to get the image size for layouting purposes.
    // Then when it is in the viewport (we assume that here) it actually gets decoded.
    QString testFile = QFINDTESTDATA("n900.jpeg");
    QVERIFY2(!testFile.isEmpty(), "cannot find test file n900.jpeg!");
    QFile inputJpeg(testFile);
    QVERIFY(inputJpeg.exists());
    inputJpeg.open(QIODevice::ReadOnly);
    QByteArray imageData = inputJpeg.readAll();
    QBuffer buffer;
    buffer.setData(imageData);
    buffer.open(QBuffer::ReadOnly);
    QCOMPARE(buffer.size(), qint64(19016));


    QBENCHMARK{
        for (int i = 0; i < 50; i++) {
            QImageReader reader(&buffer, "jpeg");
            QSize size = reader.size();
            QVERIFY(!size.isNull());
            QByteArray format = reader.format();
            QVERIFY(!format.isEmpty());
            QImage img = reader.read();
            QVERIFY(!img.isNull());
            buffer.reset();
        }
    }
}
Beispiel #10
0
void AnimenfoFetcherTest::testGhost() {
  KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig);
  QString groupName = QLatin1String("AnimeNfo.com");
  if(!config.hasGroup(groupName)) {
    QSKIP("This test requires a config file.", SkipAll);
  }
  KConfigGroup cg(&config, groupName);

  Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Keyword, "Ghost in the Shell");
  Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this));
  fetcher->readConfig(cg, cg.name());

  Tellico::Data::EntryList results = DO_FETCH(fetcher, request);

  QCOMPARE(results.size(), 1);

  // the first entry had better be the right one
  Tellico::Data::EntryPtr entry = results.at(0);
  QVERIFY(entry);

  QCOMPARE(entry->field("title"), QLatin1String("Kokaku Kido Tai"));
  QCOMPARE(entry->field("pub_year"), QLatin1String("1991"));
  QCOMPARE(entry->field("genre"), QLatin1String("Action; Science-Fiction"));
  QCOMPARE(entry->field("publisher"), QLatin1String("Kodansha"));
  QCOMPARE(entry->field("origtitle"), QString::fromUtf8("攻殻機動隊"));
  QCOMPARE(entry->field("author"), QString::fromUtf8("Shiro Masamune (士郎 正宗)"));
  QCOMPARE(entry->field("alttitle"), QLatin1String("Ghost in the Shell"));
  QVERIFY(!entry->field("cover").isEmpty());
  QVERIFY(!entry->field("animenfo").isEmpty());
}
Beispiel #11
0
void tst_QPluginLoader::loadMachO()
{
#ifdef Q_OF_MACH_O
    QFile f(QFINDTESTDATA(QTest::currentDataTag()));
    QVERIFY(f.open(QIODevice::ReadOnly));
    QByteArray data = f.readAll();

    long pos;
    ulong len;
    QString errorString;
    int r = QMachOParser::parse(data.constData(), data.size(), f.fileName(), &errorString, &pos, &len);

    QFETCH(int, parseResult);
    QCOMPARE(r, parseResult);

    if (r == QMachOParser::NotSuitable)
        return;

    QVERIFY(pos > 0);
    QVERIFY(len >= sizeof(void*));
    QVERIFY(pos + long(len) < data.size());
    QCOMPARE(pos & (sizeof(void*) - 1), 0UL);

    void *value = *(void**)(data.constData() + pos);
    QCOMPARE(value, sizeof(void*) > 4 ? (void*)(0xc0ffeec0ffeeL) : (void*)0xc0ffee);

    // now that we know it's valid, let's try to make it invalid
    ulong offeredlen = pos;
    do {
        --offeredlen;
        r = QMachOParser::parse(data.constData(), offeredlen, f.fileName(), &errorString, &pos, &len);
        QVERIFY2(r == QMachOParser::NotSuitable, qPrintable(QString("Failed at size 0x%1").arg(offeredlen, 0, 16)));
    } while (offeredlen);
#endif
}
Beispiel #12
0
void DeliciousTest::testBooks2() {
  QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/delicious2_books.xml"));
  Tellico::Import::DeliciousImporter importer(url);
  Tellico::Data::CollPtr coll = importer.collection();

  QVERIFY(coll);
  QCOMPARE(coll->type(), Tellico::Data::Collection::Book);
  QCOMPARE(coll->entryCount(), 7);

  Tellico::Data::EntryPtr entry = coll->entryById(1);
  QVERIFY(entry);
  QCOMPARE(entry->field("title"), QLatin1String("The Restaurant at the End of the Universe"));
  QCOMPARE(entry->field("isbn"), QLatin1String("0517545357"));
  QCOMPARE(entry->field("cdate"), QLatin1String("2007-12-19"));
  QCOMPARE(entry->field("mdate"), QLatin1String("2009-06-11"));
  QCOMPARE(FIELDS(entry, "author").count(), 1);
  QCOMPARE(FIELDS(entry, "author").first(), QLatin1String("Douglas Adams"));
  QCOMPARE(entry->field("binding"), QLatin1String("Hardback"));
  QCOMPARE(entry->field("rating"), QLatin1String("4.5")); // visually, this gets shown as 4 stars
  QCOMPARE(entry->field("pages"), QLatin1String("250"));
  QCOMPARE(entry->field("pub_year"), QLatin1String("1982"));
  QCOMPARE(entry->field("publisher"), QLatin1String("Harmony"));
  QCOMPARE(entry->field("pur_date"), QLatin1String("2007-12-18"));
  QCOMPARE(entry->field("pur_price"), QLatin1String("$12.95"));
  QCOMPARE(entry->field("signed"), QLatin1String("true"));
  QCOMPARE(entry->field("condition"), QLatin1String("Used"));
}
void KArchiveTest::testTarPrefix()
{
    KTar tar(QFINDTESTDATA(QLatin1String("tar_prefix_test.tar.gz")));
    QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_prefix_test.tar.gz");

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

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

    QCOMPARE(listing[0], QString("mode=40775 user=root group=root path=Test type=dir"));
    QCOMPARE(listing[1], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7 type=dir"));
    QCOMPARE(listing[2], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples type=dir"));
    QCOMPARE(listing[3], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator type=dir"));
    QCOMPARE(listing[4], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original type=dir"));
    QCOMPARE(listing[5], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java type=dir"));
    QCOMPARE(listing[6], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com type=dir"));
    QCOMPARE(listing[7], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech type=dir"));
    QCOMPARE(listing[8], QString("mode=40775 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech/examples type=dir"));
    QCOMPARE(listing[9], QString("mode=664 user=root group=root path=Test/qt-jambi-qtjambi-4_7/examples/generator/trolltech_original/java/com/trolltech/examples/GeneratorExample.html type=file size=43086"));

    QCOMPARE(listing.count(), 10);

    QVERIFY(tar.close());
}
Beispiel #14
0
void tst_QLibrary::errorString_data()
{
    QTest::addColumn<int>("operation");
    QTest::addColumn<QString>("fileName");
    QTest::addColumn<bool>("success");
    QTest::addColumn<QString>("errorString");

    QString appDir = QCoreApplication::applicationDirPath();

    QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*");
    QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error");
#ifdef Q_OS_WINCE
    QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in .*: .*");
#else
    QTest::newRow("bad resolve") << (int)Resolve << appDir + "/mylib" << false << QString("Cannot resolve symbol \"nosuchsymbol\" in \\S+: .*");
#endif
    QTest::newRow("good resolve") << (int)Resolve << appDir + "/mylib" << true << QString("Unknown error");

#ifdef Q_OS_WIN
    QTest::newRow("bad load() with .dll suffix") << (int)Load << QString("nosuchlib.dll") << false << QString("Cannot load library nosuchlib.dll: The specified module could not be found.");
//    QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)");
#elif defined Q_OS_MAC
#else
    QTest::newRow("load invalid file") << (int)Load << QFINDTESTDATA("library_path/invalid.so") << false << QString("Cannot load library.*");
#endif
}
Beispiel #15
0
void tst_CheckXMLFiles::checkXMLFiles_data() const
{
    QTest::addColumn<QString>("file");

    QStringList patterns;
    /* List possible XML files in Qt. */
    patterns.append(QLatin1String("*.xml"));
    patterns.append(QLatin1String("*.gccxml"));
    patterns.append(QLatin1String("*.svg"));
    patterns.append(QLatin1String("*.ui"));
    patterns.append(QLatin1String("*.qrc"));
    patterns.append(QLatin1String("*.ts"));
    /* We don't do HTML files currently because so many of them in 3rd party are broken. */
    patterns.append(QLatin1String("*.xhtml"));

#ifndef Q_OS_WINCE
    QString path = QLatin1String(SOURCETREE);
#else
    QString path = QFINDTESTDATA("xmlfiles");
#endif
    QDirIterator it(path, patterns, QDir::AllEntries, QDirIterator::Subdirectories);
    while(it.hasNext())
    {
        it.next();
        QTest::newRow(it.filePath().toUtf8().constData()) << it.filePath();
    }
}
Beispiel #16
0
void PackageStructureTest::initTestCase()
{
    m_packagePath = QFINDTESTDATA("data/testpackage");
    ps = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/Generic"));
    ps.addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File"));
    ps.setPath(m_packagePath);
}
Beispiel #17
0
void PlasmoidHandlerTest::loadPlasmoidTestData()
{
    const QString packagePath = QFINDTESTDATA("testdata/org.kde.tests.packagehandlertest");
    Q_ASSERT(!packagePath.isEmpty());

    m_packageHandler->setPackagePath(packagePath);
}
Beispiel #18
0
void PlasmoidHandlerTest::createNewPlasmoid()
{
    QString newPlasmoidLocation = QStandardPaths::standardLocations(QStandardPaths::DataLocation).at(0);

    QDir templatesDir(newPlasmoidLocation);
    templatesDir.mkpath(QStringLiteral("templates"));
    templatesDir.cd(QStringLiteral("templates"));

    if (!newPlasmoidLocation.endsWith(QLatin1Char('/'))) {
        newPlasmoidLocation += QLatin1Char('/') + QStringLiteral("org.kde.packagehandlertest.newPlasmoid");
    }

    const QString mainPlasmoidFile = QFINDTESTDATA("testdata/mainPlasmoid.qml");
    Q_ASSERT(!mainPlasmoidFile.isEmpty());

    QFile f(mainPlasmoidFile);
    f.copy(templatesDir.path() + QLatin1Char('/') + QStringLiteral("mainPlasmoid.qml"));

    m_packageHandler->setPackagePath(newPlasmoidLocation);
    m_packageHandler->createPackage(QStringLiteral("author"), QStringLiteral("email"), QStringLiteral("Plasma/Applet"), QStringLiteral("newPlasmoid"));

    QDir dir(newPlasmoidLocation);
    Q_ASSERT(dir.exists());
    Q_ASSERT(dir.exists(QStringLiteral("metadata.desktop")));
    Q_ASSERT(dir.exists(QStringLiteral("contents")));
    Q_ASSERT(dir.cd(QStringLiteral("contents")));
    Q_ASSERT(dir.exists(QStringLiteral("ui")));
    Q_ASSERT(dir.cd(QStringLiteral("ui")));
    Q_ASSERT(dir.exists(QStringLiteral("main.qml")));
}
/**
 * @dataProvider testZipReadRedundantDataDescriptor_data
 */
void KArchiveTest::testZipReadRedundantDataDescriptor()
{
    QFETCH(QString, fileName);

    const QString redundantDataDescriptorZipFileName = QFINDTESTDATA(fileName);
    QVERIFY(!redundantDataDescriptorZipFileName.isEmpty());

    KZip zip(redundantDataDescriptorZipFileName);

    QVERIFY(zip.open(QIODevice::ReadOnly));

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

    const QByteArray fileData("aaaaaaaaaaaaaaa");

    // ZIP has no support for per-file user/group, so omit them from the listing
    const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0);

    QCOMPARE(listing.count(), 2);
    QCOMPARE(listing[0], QString::fromUtf8("mode=100644 path=compressed type=file size=%2").arg(fileData.size()));
    QCOMPARE(listing[1], QString::fromUtf8("mode=100644 path=uncompressed type=file size=%2").arg(fileData.size()));

    const KArchiveFile *fileEntry = static_cast< const KArchiveFile *>(dir->entry(dir->entries()[0]));
    QCOMPARE(fileEntry->data(), fileData);
    fileEntry = static_cast< const KArchiveFile *>(dir->entry(dir->entries()[1]));
    QCOMPARE(fileEntry->data(), fileData);
}
Beispiel #20
0
void AnimenfoFetcherTest::testMegami() {
  KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig);
  QString groupName = QLatin1String("AnimeNfo.com");
  if(!config.hasGroup(groupName)) {
    QSKIP("This test requires a config file.", SkipAll);
  }
  KConfigGroup cg(&config, groupName);

  Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, "Aa! Megami-sama!");
  Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this));
  fetcher->readConfig(cg, cg.name());

  Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);

  QCOMPARE(results.size(), 1);

  // the first entry had better be the right one
  Tellico::Data::EntryPtr entry = results.at(0);
  QVERIFY(entry);

  QCOMPARE(entry->field("title"), QLatin1String("Aa! Megami-sama!: Together Forever"));
  QCOMPARE(entry->field("year"), QLatin1String("2011"));
  QCOMPARE(entry->field("episodes"), QLatin1String("2"));
  QCOMPARE(entry->field("studio"), QLatin1String("AIC (Anime International Company)"));
  QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ああっ女神さまっ ~ いつも二人で"));
  QVERIFY(entry->field("plot").startsWith(QLatin1String("Keiichi finds out")));
  QVERIFY(!entry->field("cover").isEmpty());
}
Beispiel #21
0
void DeliciousTest::testMovies2() {
  QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/delicious2_movies.xml"));
  Tellico::Import::DeliciousImporter importer(url);
  Tellico::Data::CollPtr coll = importer.collection();

  QVERIFY(coll);
  QCOMPARE(coll->type(), Tellico::Data::Collection::Video);
  QCOMPARE(coll->entryCount(), 4);

  Tellico::Data::EntryPtr entry = coll->entryById(2);
  QVERIFY(entry);
  QCOMPARE(entry->field("title"), QLatin1String("2001 - A Space Odyssey"));
  QCOMPARE(entry->field("certification"), QLatin1String("G (USA)"));
  QCOMPARE(entry->field("nationality"), QLatin1String("USA"));
  QCOMPARE(entry->field("aspect-ratio"), QLatin1String("2.35:1"));
  QCOMPARE(entry->field("audio-track"), QLatin1String("Dolby"));
  QCOMPARE(entry->field("widescreen"), QLatin1String("true"));
  QCOMPARE(entry->field("director"), QLatin1String("Stanley Kubrick"));
  QCOMPARE(entry->field("color"), QLatin1String("Color"));
  QCOMPARE(entry->field("format"), QLatin1String("NTSC"));
  QCOMPARE(entry->field("medium"), QLatin1String("DVD"));
  QCOMPARE(entry->field("running-time"), QLatin1String("148"));
  QCOMPARE(entry->field("rating"), QLatin1String("4"));
  QCOMPARE(entry->field("year"), QLatin1String("1968"));
  QCOMPARE(entry->field("pur_date"), QLatin1String("2007-12-19"));
  QCOMPARE(entry->field("cdate"), QLatin1String("2007-12-20"));
  QCOMPARE(entry->field("mdate"), QLatin1String("2009-06-11"));

  entry = coll->entryById(4);
  QVERIFY(entry);
  QCOMPARE(entry->field("region"), QLatin1String("Region 1"));
}
Beispiel #22
0
void tst_QPluginLoader::loadMachO_data()
{
#ifdef Q_OF_MACH_O
    QTest::addColumn<int>("parseResult");

    QTest::newRow("/dev/null") << int(QMachOParser::NotSuitable);
    QTest::newRow("elftest/debugobj.so") << int(QMachOParser::NotSuitable);
    QTest::newRow("tst_qpluginloader.cpp") << int(QMachOParser::NotSuitable);
    QTest::newRow("tst_qpluginloader") << int(QMachOParser::NotSuitable);

#  ifdef Q_PROCESSOR_X86_64
    QTest::newRow("machtest/good.x86_64.dylib") << int(QMachOParser::QtMetaDataSection);
    QTest::newRow("machtest/good.i386.dylib") << int(QMachOParser::NotSuitable);
    QTest::newRow("machtest/good.fat.no-x86_64.dylib") << int(QMachOParser::NotSuitable);
    QTest::newRow("machtest/good.fat.no-i386.dylib") << int(QMachOParser::QtMetaDataSection);
#  elif defined(Q_PROCESSOR_X86_32)
    QTest::newRow("machtest/good.i386.dylib") << int(QMachOParser::QtMetaDataSection);
    QTest::newRow("machtest/good.x86_64.dylib") << int(QMachOParser::NotSuitable);
    QTest::newRow("machtest/good.fat.no-i386.dylib") << int(QMachOParser::NotSuitable);
    QTest::newRow("machtest/good.fat.no-x86_64.dylib") << int(QMachOParser::QtMetaDataSection);
#  endif
#  ifndef Q_PROCESSOR_POWER_64
    QTest::newRow("machtest/good.ppc64.dylib") << int(QMachOParser::NotSuitable);
#  endif

    QTest::newRow("machtest/good.fat.all.dylib") << int(QMachOParser::QtMetaDataSection);
    QTest::newRow("machtest/good.fat.stub-x86_64.dylib") << int(QMachOParser::NotSuitable);
    QTest::newRow("machtest/good.fat.stub-i386.dylib") << int(QMachOParser::NotSuitable);

    QDir d(QFINDTESTDATA("machtest"));
    QStringList badlist = d.entryList(QStringList() << "bad*.dylib");
    foreach (const QString &bad, badlist)
        QTest::newRow(qPrintable("machtest/" + bad)) << int(QMachOParser::NotSuitable);
#endif
}
Beispiel #23
0
void tst_QLayout::smartMaxSize()
{
    QVector<int> expectedWidths;

    QFile f(QFINDTESTDATA("baseline/smartmaxsize"));

    QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Text), true);

    QTextStream stream(&f);

    while(!stream.atEnd()) {
        QString line = stream.readLine(200);
        expectedWidths.append(line.section(QLatin1Char(' '), 6, -1, QString::SectionSkipEmpty).toInt());
    }
    f.close();

    int sizeCombinations[] = { 0, 10, 20, QWIDGETSIZE_MAX};
    QSizePolicy::Policy policies[] = {  QSizePolicy::Fixed,
                                        QSizePolicy::Minimum,
                                        QSizePolicy::Maximum,
                                        QSizePolicy::Preferred,
                                        QSizePolicy::Expanding,
                                        QSizePolicy::MinimumExpanding,
                                        QSizePolicy::Ignored
                                        };
    Qt::Alignment alignments[] = {  0,
                                    Qt::AlignLeft,
                                    Qt::AlignRight,
                                    Qt::AlignHCenter
                                    };

    int expectedIndex = 0;
    int regressionCount = 0;
    for (size_t p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
        QSizePolicy sizePolicy;
        sizePolicy.setHorizontalPolicy(policies[p]);
        for (size_t min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
            int minSize = sizeCombinations[min];
            for (size_t max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
                int maxSize = sizeCombinations[max];
                for (size_t sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
                    int sizeHint = sizeCombinations[sh];
                    for (size_t a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
                        Qt::Alignment align = alignments[a];
                        QSize sz = qSmartMaxSize(QSize(sizeHint, 1), QSize(minSize, 1), QSize(maxSize, 1), sizePolicy, align);
                        int width = sz.width();
                        int expectedWidth = expectedWidths[expectedIndex];
                        if (width != expectedWidth) {
                            qDebug() << "error at index" << expectedIndex << ":" << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
                            ++regressionCount;
                        }
                        ++expectedIndex;
                    }
                }
            }
        }
    }
    QCOMPARE(regressionCount, 0);
}
Beispiel #24
0
void tst_QDesktopServices::openUrl_data()
{
    QTest::addColumn<QUrl>("data");
    QTest::addColumn<QString>("message");

    QUrl localFile = QUrl::fromLocalFile(QFINDTESTDATA("test.txt"));

    QTest::newRow("text-file")
            << localFile
            << "This should open test.txt in a text editor";

    localFile.setQuery("x=y");
    QTest::newRow("text-file-with-query")
            << localFile
            << "This should open test.txt in a text editor. Queries do not usually show up.";

    localFile.setQuery(QString());
    localFile.setFragment("top");
    QTest::newRow("text-file-with-fragment")
            << localFile
            << "This should open test.txt in a text editor. Fragments do not usually show up.";

    QTest::newRow("browser-plain")
            << QUrl("http://qt-project.org")
            << "This should open http://qt-project.org in the default web browser";

    QTest::newRow("search-url")
            << QUrl("http://google.com/search?q=Qt+Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-space")
            << QUrl("http://google.com/search?q=Qt Project")
            << "This should search \"Qt Project\" on Google";

    QTest::newRow("search-url-with-quotes")
            << QUrl("http://google.com/search?q=\"Qt+Project\"")
            << "This should search '\"Qt Project\"' on Google (including the quotes)";

    QTest::newRow("search-url-with-hashtag")
            << QUrl("http://google.com/search?q=%23qtproject")
            << "This should search \"#qtproject\" on Google. The # should appear in the Google search field";

    QTest::newRow("search-url-with-fragment")
            << QUrl("http://google.com/search?q=Qt+Project#top")
            << "This should search \"Qt Project\" on Google. There should be no # in the Google search field";

    // see QTBUG-32311
    QTest::newRow("search-url-with-slashes")
            << QUrl("http://google.com/search?q=/profile/5")
            << "This should search \"/profile/5\" on Google.";

    QTest::newRow("mail")
            << QUrl("mailto:[email protected]")
            << "This should open an email composer with the destination set to [email protected]";

    QTest::newRow("mail-subject")
            << QUrl("mailto:[email protected]?subject=[Development]%20Test%20Mail")
            << "This should open an email composer and tries to set the subject";
}
Beispiel #25
0
void tst_QTextBoundaryFinder::init()
{
#ifndef Q_OS_IRIX
    // chdir into the top-level data dir, then refer to our testdata using relative paths
    QString testdata_dir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
    QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
#endif
}
Beispiel #26
0
void tst_QPluginLoader::loadGarbage()
{
    for (int i=0; i<5; i++) {
        QPluginLoader lib(QFINDTESTDATA(QString("elftest/garbage%1.so").arg(i+1)));
        QCOMPARE(lib.load(), false);
        QVERIFY(lib.errorString() != QString("Unknown error"));
    }
}
Beispiel #27
0
static QString sys_qualifiedLibraryName(const QString &fileName)
{
    QString libname = QFINDTESTDATA(QString("bin/%1%2%3").arg(PREFIX).arg(fileName).arg(SUFFIX));
    QFileInfo fi(libname);
    if (fi.exists())
        return fi.canonicalFilePath();
    return libname;
}
Beispiel #28
0
void DeliciousTest::initTestCase() {
  Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/delicious2tellico.xsl"));
  // need to register the collection type
  Tellico::RegisterCollection<Tellico::Data::BookCollection> registerBook(Tellico::Data::Collection::Book, "book");
  Tellico::RegisterCollection<Tellico::Data::VideoCollection> registerVideo(Tellico::Data::Collection::Video, "video");
  Tellico::RegisterCollection<Tellico::Data::MusicCollection> registerMusic(Tellico::Data::Collection::Album, "album");
  Tellico::RegisterCollection<Tellico::Data::GameCollection> registerGame(Tellico::Data::Collection::Game, "game");
}
void TestFilterConfiguration::init() {
	QString path_ = QFINDTESTDATA("Configtest.txt");
	Model::FilterList* filterList_ = new Model::FilterList();
	filterList_->appendFilter(QString("Blur"));
	filterList_->appendFilter(QString("Edge"));
	configSaver_ = new Utility::FilterConfigurationSaver(path_,*filterList_);
	configLoader_ = new Utility::FilterConfigurationLoader(path_);
}
void tst_QSampleCache::testEnoughCapacity()
{
    QSampleCache cache;
    QSignalSpy loadingSpy(&cache, SIGNAL(isLoadingChanged()));

    QSample* sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
    QVERIFY(sample);
    QTRY_COMPARE(loadingSpy.count(), 2); // make sure sample is loaded
    QTRY_VERIFY(!cache.isLoading());
    int sampleSize = sample->data().size();
    sample->release();
    cache.setCapacity(sampleSize * 2);

    QVERIFY(!cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));

    loadingSpy.clear();
    sample = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
    QVERIFY(sample);
    QTRY_COMPARE(loadingSpy.count(), 2);
    QTRY_VERIFY(!cache.isLoading());
    sample->release();

    QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));

    // load another sample and make sure first sample is not destroyed
    loadingSpy.clear();
    QSample* sampleOther = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav")));
    QVERIFY(sampleOther);
    QTRY_COMPARE(loadingSpy.count(), 2);
    QTRY_VERIFY(!cache.isLoading());
    sampleOther->release();

    QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
    QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav"))));

    loadingSpy.clear();
    QSample* sampleCached = cache.requestSample(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav")));
    QCOMPARE(sample, sampleCached); // sample is cached
    QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.wav"))));
    QVERIFY(cache.isCached(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test2.wav"))));
    QTRY_COMPARE(loadingSpy.count(), 2);
    QTRY_VERIFY(!cache.isLoading());

    sampleCached->release();
}