void TestUpdater::updaterCopy() { Updater u; u.setLocalRepository(dataCopy + "/local_repo"); u.copy(testOutputCopy); QSignalSpy spy(&u, SIGNAL(copyFinished(bool))); QVERIFY(spy.wait()); try { (TestUtils::assertFileEquals(dataCopy + "/local_repo/patch_same.txt", testOutputCopy + "/patch_same.txt")); (TestUtils::assertFileEquals(dataCopy + "/local_repo/path_diff.txt", testOutputCopy + "/path_diff.txt")); (TestUtils::assertFileEquals(dataCopy + "/local_repo/path_diff2.txt", testOutputCopy + "/path_diff2.txt")); (TestUtils::assertFileEquals(dataCopy + "/local_repo/rmfile.txt", testOutputCopy + "/rmfile.txt")); } catch(QString &msg) { QFAIL(msg.toLatin1()); } QVERIFY(!QFile::exists(testOutputCopy + "/add.txt")); }
void XmlParserTest::parseTestCourse() { ParseResult result; QString message; try { auto course = parseCourse(QStringLiteral(":/testing/courses/testcourse.xml"), *validator, &result, &message); verifyTestCourse(*course); } catch (Exception& e) { QFAIL(qUtf8Printable(e.message())); } }
void KisCrashFilterTest::testCrashFilters() { QStringList failures; QStringList successes; QList<QString> filterList = KisFilterRegistry::instance()->keys(); qSort(filterList); for (QList<QString>::Iterator it = filterList.begin(); it != filterList.end(); ++it) { if (testFilter(KisFilterRegistry::instance()->value(*it))) successes << *it; else failures << *it; } dbgKrita << "Success: " << successes; if (failures.size() > 0) { QFAIL(QString("Failed filters:\n\t %1").arg(failures.join("\n\t")).toLatin1()); } }
void JsonSnippetFileTest::savesEmptySnippetsCollectionToFile() { QTemporaryFile snippetFile(this); if (!snippetFile.open()) QFAIL("Failed to create temporary snippet file"); SnippetCollection collection; bool success = JsonSnippetFile::save(snippetFile.fileName(), &collection); QVERIFY(success); QTextStream in(&snippetFile); QString fileContent = in.readAll().trimmed(); QVERIFY(fileContent.startsWith("{")); QVERIFY(fileContent.contains("\"snippets\": [")); QVERIFY(fileContent.endsWith("}")); }
void QLoggingRule_parse() { QFETCH(QString, pattern); QFETCH(QString, category); QFETCH(QtMsgType, msgType); QFETCH(LoggingRuleState, result); QLoggingRule rule(QStringRef(&pattern), true); LoggingRuleState state = Invalid; if (rule.flags != 0) { switch (rule.pass(category, msgType)) { case -1: QFAIL("Shoudn't happen, we set pattern to true"); break; case 0: state = NoMatch; break; case 1: state = Match; break; } } QCOMPARE(state, result); }
void TsFactory::TestMakeRetriever() { try { terrama2::core::DataProvider unknownTypeProvider("dummy", terrama2::core::DataProvider::FTP_TYPE); terrama2::collector::DataRetrieverPtr retriever = terrama2::collector::Factory::makeRetriever(unknownTypeProvider); QVERIFY(retriever.get()); terrama2::core::DataProvider ftpTypeProvider("dummy", terrama2::core::DataProvider::FTP_TYPE); retriever = terrama2::collector::Factory::makeRetriever(ftpTypeProvider); terrama2::collector::DataRetrieverFTP* retrieverFtp = dynamic_cast<terrama2::collector::DataRetrieverFTP*>(retriever.get()); QVERIFY(retrieverFtp); } catch(...) { QFAIL(NO_EXCEPTION_EXPECTED); } }
void GdalDataAccess::accessingFeatureData() { try { Ilwis::IFeatureCoverage fc; qDebug() << "Features : accessing data "; DOTEST(fc.prepare(makeInputPath("regions.shp")), "Loading regions.shp"); QString env = fc->envelope().toString(); DOTEST(env == "33.0065 3.40088 47.9605 14.9637","FeatureCoverage: testing envelope (bbox)"); DOTEST(fc.prepare(makeInputPath("rainfall.shp")),"loading point map"); Ilwis::FeatureIterator iter1(fc); Ilwis::SPFeatureI f1 = *(iter1 + 1); QVariant output = f1->cell("RAINFALL"); DOTEST(output.toString() =="taquina","accesing attribute string data of pointmap"); Ilwis::SPFeatureI f2 = *(iter1 + 4); output = f2("JANUARY"); DOCOMPARE(output.toInt(), 85 ,"accesing attribute numeric data of pointmap"); DOTEST(fc.prepare(makeInputPath("drainage.shp")),"loading segment map"); Ilwis::FeatureIterator iter2(fc); Ilwis::SPFeatureI f3 = *(iter2 + 104); output = f3->cell("DRAINAGE"); DOTEST(output.toString() == "lake","accesing attribute string data of line coverage"); Ilwis::SPFeatureI f4 = *(iter2 + 21); output = f4("C1"); DOCOMPARE(output.toInt(), 1 ,"accesing attribute numeric data ofline coverage"); DOTEST(fc.prepare(makeInputPath("geology.shp")),"loading polygon map"); Ilwis::FeatureIterator iter3(fc); Ilwis::SPFeatureI f5 = *(iter3 + 40); output = f5->cell("GEOLOGY"); DOTEST(output.toString() == "Shales","accesing attribute string data of polygon coverage"); }catch (const Ilwis::ErrorObject& err) { QString error = "Test threw exception : " + err.message(); QFAIL(error.toLatin1()); } }
void VCLabel_Test::saveXML() { QWidget w; VCLabel label(&w, m_doc); label.setCaption("Simo Kuassimo"); QDomDocument xmldoc; QDomElement root = xmldoc.createElement("TestRoot"); xmldoc.appendChild(root); QVERIFY(label.saveXML(&xmldoc, &root) == true); QDomNode node = root.firstChild(); QVERIFY(node.nextSibling().isNull() == true); QCOMPARE(node.toElement().tagName(), QString("Label")); QCOMPARE(node.toElement().attribute("Caption"), QString("Simo Kuassimo")); QVERIFY(node.firstChild().isNull() == false); int appearance = 0, windowstate = 0; node = node.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == QString("Appearance")) { appearance++; } else if (tag.tagName() == QString("WindowState")) { windowstate++; } else { QFAIL(QString("Unexpected XML tag: %1").arg(tag.tagName()).toUtf8().constData()); } node = node.nextSibling(); } QCOMPARE(appearance, 1); QCOMPARE(windowstate, 1); }
void CMakeParserTest::testParserWithGoodData() { // QFAIL( "the magic is missing" ); QFETCH( QString, text ); QTemporaryFile tempFile; tempFile.setAutoRemove( false ); tempFile.open(); if ( !QFile::exists( tempFile.fileName() ) ) QFAIL( "Unable to open temporary file" ); tempFile.write( text.toUtf8() ); QString tempName = tempFile.fileName(); tempFile.close(); //hacks to the get name of the file // CMakeAst* ast = new CMakeAst; // bool parseError = CMakeListsParser::parseCMakeFile( ast, qPrintable( tempName ) ); // delete ast; // QVERIFY( parseError == false ); tempFile.remove(); }
void QLCFixtureHead_Test::save() { QLCFixtureHead head; head.addChannel(0); head.addChannel(1); head.addChannel(2); head.addChannel(3); QBuffer buffer; buffer.open(QIODevice::WriteOnly | QIODevice::Text); QXmlStreamWriter xmlWriter(&buffer); QVERIFY(head.saveXML(&xmlWriter)); xmlWriter.setDevice(NULL); buffer.close(); buffer.open(QIODevice::ReadOnly | QIODevice::Text); QXmlStreamReader xmlReader(&buffer); xmlReader.readNextStartElement(); QCOMPARE(xmlReader.name().toString(), QString("Head")); int ch = 0; while (xmlReader.readNextStartElement()) { if (xmlReader.name() == "Channel") { QString chNum = xmlReader.readElementText(); QVERIFY(chNum.toInt() == 0 || chNum.toInt() == 1 || chNum.toInt() == 2 || chNum.toInt() == 3); ch++; } else { QFAIL(QString("Unexpected tag: %1").arg(xmlReader.name().toString()).toUtf8().constData()); xmlReader.skipCurrentElement(); } } QCOMPARE(ch, 4); }
void onlineJobAdministrationTest::initTestCase() { file = MyMoneyFile::instance(); storage = new MyMoneySeqAccessMgr; file->attachStorage(storage); try { MyMoneyAccount account = MyMoneyAccount(); account.setName("Test Account"); account.setAccountType(MyMoneyAccount::Savings); MyMoneyAccount asset = file->asset(); MyMoneyFileTransaction transaction; file->addAccount(account , asset); accountId = account.id(); transaction.commit(); } catch (const MyMoneyException& ex) { QFAIL(qPrintable("Unexpected exception " + ex.what())); } }
void TestLVTS::test_LM35() { QFETCH(int, read); QFETCH(double, temperature); LVTS lvts(1, SENSOR_LVTS_LM35); bool ok = false; //The value will always diff a little, so compare the rounded value... double value = round(lvts.lm35(read, &ok)); if(!ok) { qDebug() << read << temperature << ok; QFAIL("convert failed"); } QCOMPARE(temperature, value); }
void JsonSnippetFileTest::roundtripTest() { QTemporaryFile snippetFile(this); if (!snippetFile.open()) QFAIL("Failed to create temporary snippet file"); Snippet snippet1; snippet1.trigger = "abc"; snippet1.description = "description abc"; snippet1.snippet = "content abc"; snippet1.cursorPosition = 0; snippet1.builtIn = true; Snippet snippet2; snippet2.trigger = "xyz"; snippet2.description = "description xyz"; snippet2.snippet = "content xyz"; snippet2.cursorPosition = 1; snippet2.builtIn = false; SnippetCollection collection1; collection1.insert(snippet1); collection1.insert(snippet2); bool saveSuccess = JsonFile<Snippet>::save(snippetFile.fileName(), &collection1); QVERIFY(saveSuccess); SnippetCollection collection2; bool loadSuccess = JsonFile<Snippet>::load(snippetFile.fileName(), &collection2); QVERIFY(loadSuccess); QCOMPARE(collection2.count(), 2); QCOMPARE(collection2.snippet("abc").description, snippet1.description); QCOMPARE(collection2.snippet("abc").snippet, snippet1.snippet); QCOMPARE(collection2.snippet("abc").cursorPosition, snippet1.cursorPosition); QCOMPARE(collection2.snippet("abc").builtIn, snippet1.builtIn); QCOMPARE(collection2.snippet("xyz").description, snippet2.description); QCOMPARE(collection2.snippet("xyz").snippet, snippet2.snippet); QCOMPARE(collection2.snippet("xyz").cursorPosition, snippet2.cursorPosition); QCOMPARE(collection2.snippet("xyz").builtIn, snippet2.builtIn); }
void AbstractTestSuite::initTestCase() { if (!testsDir.exists()) { QString message = QString::fromLatin1("tests directory (%0) doesn't exist.") .arg(testsDir.path()); QFAIL(qPrintable(message)); return; } if (QFileInfo(skipConfigPath).exists()) TestConfigParser::parse(skipConfigPath, TestConfig::Skip, this); else createSkipConfigFile(); if (QFileInfo(expectFailConfigPath).exists()) TestConfigParser::parse(expectFailConfigPath, TestConfig::ExpectFail, this); else shouldGenerateExpectedFailures = true; }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void MenuStatesTest::ApplicationLibraryState_backSteppingAction() { #ifdef Q_OS_SYMBIAN User::ResetInactivityTime();//it should help for Viewserver11 panic #ifdef UT_MEMORY_CHECK __UHEAP_MARK; #endif//UT_MEMORY_CHECK #endif//Q_OS_SYMBIAN { QFAIL("! Due to bug in hb wk36 we are forced to skip this test !"); QScopedPointer<HbMainWindow> wind(new HbMainWindow); HsScene::setInstance( new HsScene(wind.data()) ); //create statemachine to perform transitions QScopedPointer<QStateMachine> machine(new QStateMachine(0)); HsAppLibraryState *appLibrary = new HsAppLibraryState(machine.data()); machine->setInitialState(appLibrary); machine->start(); qApp->sendPostedEvents(); //initiate transition from collection state appLibrary->mCollectionState->openAppLibrary(); qApp->sendPostedEvents(); QVERIFY(appLibrary->mAllAppsState->mMenuView->view()->menu()); machine->stop(); qApp->removePostedEvents(0); disconnect(appLibrary,SIGNAL(initialize()),this,SLOT(appLibraryEntered())); qApp->processEvents(); } #ifdef Q_OS_SYMBIAN #ifdef UT_MEMORY_CHECK __UHEAP_MARKEND; #endif//UT_MEMORY_CHECK #endif//Q_OS_SYMBIAN }
void tst_Q3Dns::longTxtRecord() { QSKIP("Long TXT records in Q3Dns don't work.", SkipSingle); int c = 0; char **v = 0; QCoreApplication a(c, v); Q3Dns dns(QString::fromLatin1("andreas.hanssen.name"), Q3Dns::Txt); QObject::connect(&dns, SIGNAL(resultsReady()), this, SLOT(longTxtRecordAnswer())); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); QStringList list = dns.texts(); QCOMPARE(list.count(), 1); QCOMPARE(list[0], QString::fromLatin1("I have a remarkable solution to Fermat's last theorem, but it doesn't fit into this TXT record")); }
void tst_Q3Dns::txtRecords() { QSKIP("TXT record support is broken.", SkipAll); int argc = 0; char **argv = 0; QCoreApplication qapp(argc, argv); Q3Dns dns("Sales._ipp._tcp.dns-sd.org", Q3Dns::Txt); connect(&dns, SIGNAL(resultsReady()), SLOT(txtRecordAnswer())); QTestEventLoop::instance().enterLoop(10); if (QTestEventLoop::instance().timeout()) QFAIL("Timed out while looking up TXT record for Sales._ipp._tcp.dns-sd.org"); QStringList texts = dns.texts(); #if defined Q_OS_DARWIN QSKIP("TXT records in Q3Dns don't work for Mac OS X.", SkipSingle); #endif QVERIFY(!texts.isEmpty()); QCOMPARE(texts.at(0), QString("rp=lpt1")); }
/*! * \brief Use QPointer to check pointer in lambda. * QPointer is Qt's smart pointer, which become nullptr when * QObject's derived object is deleted. QPointer is copiable, * then when can copy it directly inside lambda. * * In lambda, we can just check pointer with assert, if the receiver * can have a shorter lifetime than sender, or 'if' statement if * receiver need to have a longer lifetime than sender. */ void ConnectLambdaTest::testCaseLambdaQPointer() { // create sender and receiver objects // use QPointer to check pointer before use QScopedPointer<Object> sender ( new Object ); QPointer<Object> receiver ( new Object ); // connect them with lambda connect(sender.data(), &Object::signalTest, [receiver](int value){ Q_ASSERT(receiver); receiver->setCheckValue(value); }); // delete receiver delete receiver; // emit signal sender->emitSignal(0x800a); // can't test, receiver is nullptr // QCOMPARE(0x800a, receiver->checkValue()); QFAIL("This test need to fail..."); }
void QLCFile_Test::getXMLHeader() { bool insideCreatorTag = false, author = false, appname = false, appversion = false; QDomDocument doc; doc = QLCFile::getXMLHeader(QString()); QVERIFY(doc.isNull() == true); doc = QLCFile::getXMLHeader("Settings"); QVERIFY(doc.isNull() == false); QCOMPARE(doc.doctype().name(), QString("Settings")); QDomNode node(doc.firstChild()); QCOMPARE(node.toElement().tagName(), QString("Settings")); node = node.firstChild(); QCOMPARE(node.toElement().tagName(), QString("Creator")); node = node.firstChild(); while (node.isNull() == false) { // Verify that program enters this while loop insideCreatorTag = true; QDomElement tag(node.toElement()); if (tag.tagName() == KXMLQLCCreatorAuthor) author = true; // User might not have a full name so don't check the contents else if (tag.tagName() == KXMLQLCCreatorName) appname = true; else if (tag.tagName() == KXMLQLCCreatorVersion) appversion = true; else QFAIL(QString("Unrecognized tag: %1").arg(tag.tagName()).toUtf8().constData()); node = node.nextSibling(); } QCOMPARE(insideCreatorTag, true); QCOMPARE(author, true); QCOMPARE(appname, true); QCOMPARE(appversion, true); }
void TaskStructureTests::mergeTaskListsTest_data() { QTest::addColumn<TaskList>("old"); QTest::addColumn<TaskList>("newTasks"); QTest::addColumn<TaskList>("merged"); Q_FOREACH (const QDomElement &testcase, TestHelpers::retrieveTestCases(QLatin1String(":/mergeTaskListsTest/Data"), QLatin1String("mergeTaskListsTest"))) { QString name = testcase.attribute(QStringLiteral("name")); QList<QDomElement> elements; elements << testcase.firstChildElement(Task::taskListTagName()); elements << (elements.first()).nextSiblingElement(Task::taskListTagName()); elements << (elements.at(1)).nextSiblingElement(Task::taskListTagName()); bool oldFound = false, newFound = false, mergedFound = false; TaskList old, newTasks, merged; Q_FOREACH (const QDomElement &element, elements) { QString arg = element.attribute(QStringLiteral("arg")); TaskList tasks = Task::readTasksElement(element, CHARM_DATABASE_VERSION); if (arg == QLatin1String("old")) { old = tasks; oldFound = true; } else if (arg == QLatin1String("new")) { newTasks = tasks; newFound = true; } else if (arg == QLatin1String("merged")) { merged = tasks; qSort(merged.begin(), merged.end(), Task::lowerTaskId); mergedFound = true; } else { QFAIL("invalid XML structure in input data"); } } QVERIFY(oldFound); QVERIFY(newFound); QVERIFY(mergedFound); QTest::newRow(name.toLocal8Bit().constData()) << old << newTasks << merged; qDebug() << "Added test case" << name; }
void ProjectModelTest::getProjectsTable(void) { try { WdgModels::ProjectsTableModel* w = Databases::ProjectDatabase::instance()->getProjectsTable(1); for(Project p : w->getProjects()) { switch(p.getId()) { case 9: case 14: case 47: case 48: QVERIFY(true); break; default: QVERIFY2(false, QString("Oups: "+QString::number(p.getId())).toStdString().c_str()); } } } catch(DbException* e) { QFAIL(e->what()); } }
void LinkTest::linkWohngruppe() { QList< QSharedPointer< ebp::Wohngruppe > > gruppenList = ebp::Wohngruppe::loadAll(aConnection); QList< QSharedPointer< ebp::Mitarbeiter > > mitarbeiterList = ebp::Mitarbeiter::loadAll(aConnection); QSharedPointer< ebp::Wohngruppe > gruppe; QSharedPointer< ebp::Mitarbeiter > mitarbeiter; if(mitarbeiterList.count()>=gruppenList.count()) { for ( int i = 0 ; i< gruppenList.count(); i++) { gruppe = gruppenList.at(i); mitarbeiter = mitarbeiterList.at(i); ebp::Wohngruppe::linkMitarbeiter(gruppe,mitarbeiter); QVERIFY(gruppe->update(aConnection)); } } else QFAIL("Konnte Test nicht durchführen, da zu wenig Mitarbeiter geladen wurden."); }
void Horus::ServerEmulator::Core::EmulatorTest::onFileLineRead(const QString &line) { QString expected = m_file_expected_strings.current(); bool short_date = expected.startsWith("s"); expected = expected.remove(0, 2); QString incoming; if (short_date && m_re_short_time_log_line.exactMatch(line)) { incoming = m_re_short_time_log_line.cap(1); } else if ((short_date==false) && m_re_long_time_log_line.exactMatch(line)) { incoming = m_re_long_time_log_line.cap(1); } else { QFAIL("Wrong date format"); } QCOMPARE(incoming, expected); m_file_expected_strings.succedOne(); }
void DocumentTest::testLineCount() { try { LibModel::Document doc; QCOMPARE(doc.lineCount(), 1); doc.insertCharAt(QPoint(0, 0), 'q'); QCOMPARE(doc.lineCount(), 1); doc.insertLineBreakAt(QPoint(1, 0)); QCOMPARE(doc.lineCount(), 2); doc.insertLineBreakAt(QPoint(0, 1)); QCOMPARE(doc.lineCount(), 3); QCOMPARE(doc.lineAt(0), QString("q")); QCOMPARE(doc.lineAt(1), QString("")); QCOMPARE(doc.lineAt(2), QString("")); } catch(...) { QFAIL("Unexpected exception during test"); } }
/*! * \brief Use lambda with Qt5's new connection syntaxe, with invalide pointer. * The raw pointer become invlide inside the lambda, but the connect is not * destroy when receiver is deleted. Then, emitting signal call lambda * with this invalid pointer, and cause a Undefined Behavior (UB). * * Note: UB doesn't cause crash every time. When I run this tests (MingW 4.9.2 * and MSVC 2013), the test run like object is valid. */ void ConnectLambdaTest::testCaseLambdaAndDeletedObject() { // create sender and receiver objects // we want to delete receiver before end of function, the use raw pointer QScopedPointer<Object> sender ( new Object ); Object* receiver ( new Object ); // connect them with lambda connect(sender.data(), &Object::signalTest, [receiver](int value){ Q_ASSERT(receiver); receiver->setCheckValue(value); }); // delete receiver delete receiver; receiver = nullptr; // emit signal sender->emitSignal(0x2d9b); // can't test, receiver is nullptr // QCOMPARE(0x800a, receiver->checkValue()); QFAIL("This test need to fail..."); }
void ControllerTests::toAndFromXmlTest() { // make sure we have some tasks and associated events: TaskList tasks = m_controller->storage()->getAllTasks(); QVERIFY( tasks.size() > 0 ); // just to be sure nobody f***s it up Event e1 = m_controller->storage()->makeEvent(); e1.setTaskId( tasks[0].id() ); e1.setComment( "Event-1-Comment" ); e1.setStartDateTime(); m_controller->modifyEvent( e1 ); Event e2 = m_controller->storage()->makeEvent(); e2.setTaskId( tasks.last().id() ); e2.setComment( "Event-2-Comment" ); e2.setStartDateTime(); m_controller->modifyEvent( e2 ); Q_ASSERT( m_controller ); // just to be sure TaskList tasksBefore = m_controller->storage()->getAllTasks(); EventList eventsBefore = m_controller->storage()->getAllEvents(); QVERIFY( tasksBefore == tasks ); QDomDocument document = m_controller->exportDatabasetoXml(); if ( ! m_controller->importDatabaseFromXml( document ).isEmpty() ) { QFAIL( "Cannot reimport exported Xml Database Dump" ); } else { TaskList tasksAfter = m_controller->storage()->getAllTasks(); if( tasksBefore != tasksAfter ) { qDebug() << "XML Document created during failed test:" << endl << document.toString(); Q_FOREACH( Task task, tasksBefore ) { task.dump(); } Q_FOREACH( Task task, tasksAfter ) { task.dump(); } } QVERIFY( tasksBefore == tasksAfter ); EventList eventsAfter = m_controller->storage()->getAllEvents(); // this is brittle, and may easily fail, because the event ids are auto-increment QVERIFY( eventsBefore == eventsAfter ); }
void tst_QLibrary::errorString() { QFETCH(int, operation); QFETCH(QString, fileName); QFETCH(bool, success); QFETCH(QString, errorString); QLibrary lib; if (!(operation & DontSetFileName)) { lib.setFileName(fileName); } bool ok = false; switch (operation & OperationMask) { case Load: ok = lib.load(); break; case Unload: ok = lib.load(); //### ok = lib.unload(); break; case Resolve: { ok = lib.load(); QCOMPARE(ok, true); if (success) { ok = lib.resolve("mylibversion"); } else { ok = lib.resolve("nosuchsymbol"); } break;} default: QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation))); break; } QRegExp re(errorString); QString libErrorString = lib.errorString(); QVERIFY(!lib.isLoaded() || lib.unload()); QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString)); QCOMPARE(ok, success); }
void ut_autocontrast::testGenerator() { QImage image = QImage(QSize(3, 1), QImage::Format_RGB32); image.setPixel(QPoint(0, 0), qRgb(64, 64, 64)); image.setPixel(QPoint(1, 0), qRgb(96, 96, 96)); image.setPixel(QPoint(2, 0), qRgb(128, 128, 128)); QuillImageFilter *newFilterGenerator = QuillImageFilterFactory::createImageFilter(filterName); QVERIFY(newFilterGenerator); QCOMPARE(newFilterGenerator->name(), filterName); QuillImageFilterGenerator *filterGenerator = dynamic_cast<QuillImageFilterGenerator*>(newFilterGenerator); QVERIFY(filterGenerator); if(filterGenerator){ filterGenerator->apply(image); QuillImageFilter *filter = filterGenerator->resultingFilter(); QCOMPARE(filter->name(), resultName); // Center: 96 to 127.5 Unittests::compareReal(filter->option(QuillImageFilter::Brightness).toDouble(), 31.5/2.55); // Contrast component: scale 64 to 255 Unittests::compareReal(filter->option(QuillImageFilter::Contrast).toDouble(), (255.0-64.0)/64.0*100.0); image = filter->apply(image); // See that the contrast has really been stretched throughout. QCOMPARE(image.pixel(QPoint(0, 0)), qRgb(0, 0, 0)); QCOMPARE(image.pixel(QPoint(1, 0)), qRgb(128, 128, 128)); QCOMPARE(image.pixel(QPoint(2, 0)), qRgb(255, 255, 255)); delete filter; } else QFAIL("The filterGenerator is null!"); delete newFilterGenerator; }
void TsProcessLogger::testProcessLogger() { try { std::unique_ptr<te::da::MockDataSource> mockDataSource(new ::testing::NiceMock<te::da::MockDataSource>()); EXPECT_CALL(*mockDataSource, open()).WillRepeatedly(::testing::Return()); EXPECT_CALL(*mockDataSource, isOpened()).WillRepeatedly(::testing::Return(true)); EXPECT_CALL(*mockDataSource, dataSetExists(::testing::_)).WillRepeatedly(::testing::Return(false)); /* Every time the mockDataSource object calls a method that returns a DataSourceTransactor * the actualy method called will be the createMockDataSourceTransactor() that returns a * new mocked DataSourceTransactor. * A new mocked object is needed in every call because TerraLib takes ownership from the pointer. */ EXPECT_CALL(*mockDataSource, DataSourceTransactoPtrReturn()).WillRepeatedly(::testing::Invoke(&createMockDataSourceTransactor)); TestLogger log(mockDataSource.release()); RegisterId registerID = log.start(1); log.logValue("tag1", "value1", registerID); log.logValue("tag2", "value2", registerID); log.logValue("tag1", "value3", registerID); log.logValue("tag2", "value4", registerID); log.log(TestLogger::MessageType::ERROR_MESSAGE, "Unit Test Error", registerID); log.log(TestLogger::MessageType::ERROR_MESSAGE, "Unit Test second Error", registerID); log.log(TestLogger::MessageType::INFO_MESSAGE, "Unit Test Info", registerID); log.log(TestLogger::MessageType::INFO_MESSAGE, "Unit Test seconde Info", registerID); std::shared_ptr< te::dt::TimeInstantTZ > dataTime = terrama2::core::TimeUtils::nowUTC(); log.result(terrama2::core::ProcessLogger::Status::ERROR, dataTime, registerID); } catch(const terrama2::Exception& e) { QFAIL(e.what()); } }
void KisFixedPaintDeviceTest::testBltFixedSmall() { QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "fixed_blit_small.png"); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs); fdev->convertFromQImage(image, 0); // Without opacity KisPaintDeviceSP dev = new KisPaintDevice(cs); KisPainter gc(dev); gc.bltFixed(QPoint(0, 0), fdev, image.rect()); QImage result = dev->convertToQImage(0, 0, 0, 51, 51); QPoint errpoint; if (!TestUtil::compareQImages(errpoint, image, result)) { image.save("kis_fixed_paint_device_test_blt_small_image.png"); result.save("kis_fixed_paint_device_test_blt_small_result.png"); QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1()); } }