void tst_qdbusxml2cpp::process() { QFETCH(QString, xmlSnippet); QFETCH(QRegularExpression, interfaceSearch); QFETCH(QRegularExpression, adaptorSearch); QVERIFY2(interfaceSearch.isValid(), qPrintable(interfaceSearch.errorString())); QVERIFY2(adaptorSearch.isValid(), qPrintable(adaptorSearch.errorString())); // test both interface and adaptor generation QFETCH_GLOBAL(int, outputMode); QFETCH_GLOBAL(QString, commandLineArg); // Run the tool const QString binpath = QLibraryInfo::location(QLibraryInfo::BinariesPath); const QString command = binpath + QLatin1String("/qdbusxml2cpp"); QProcess process; process.start(command, QStringList() << commandLineArg << "-" << "-N"); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); // feed it our XML data static const char xmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE // \n is included "<node>\n" " <interface name=\"local.name.is.not.important\">\n" " <!-- begin data -->\n"; static const char xmlFooter[] = "\n" " <!-- end data -->\n" " </interface>\n" "</node>\n"; process.write(xmlHeader, int(sizeof xmlHeader) - 1); process.write(xmlSnippet.toLatin1()); process.write(xmlFooter, int(sizeof xmlFooter) - 1); while (process.bytesToWrite()) QVERIFY2(process.waitForBytesWritten(), qPrintable(process.errorString())); // fprintf(stderr, "%s%s%s", xmlHeader, xmlSnippet.toLatin1().constData(), xmlFooter); process.closeWriteChannel(); QVERIFY2(process.waitForFinished(), qPrintable(process.errorString())); QByteArray errOutput = process.readAllStandardError(); QVERIFY2(errOutput.isEmpty(), errOutput); QCOMPARE(process.exitCode(), 0); QByteArray fullOutput = process.readAll(); QString output = stripHeader(QString::fromLatin1(fullOutput)); QVERIFY2(!output.isEmpty(), fullOutput); if (outputMode == Interface) QVERIFY2(output.count(interfaceSearch) == 1, qPrintable(interfaceSearch.pattern() + "\nin\n" + output)); else QVERIFY2(output.count(adaptorSearch) == 1, qPrintable(adaptorSearch.pattern() + "\nin\n" + output)); }
xmlFile::xmlFile( string _n ) : buffer( stripComments( stripHeader( ioFile::get( _n ) ) ) ), contents( &( buffer ) ), filename( _n ) { } &xmlFile::operator()()
string strip( string x ) { return stripComments( stripHeader( x ) ); }