From 0986dab7c77fced09ddb4400b20d3939f4ba1002 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 30 Sep 2009 14:47:15 +0200 Subject: Add more debug information to the QPrinterInfo test Reviewed-by: Paul --- tests/auto/qprinterinfo/tst_qprinterinfo.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp index e397b76..2fa7515 100644 --- a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp @@ -101,6 +101,8 @@ void tst_QPrinterInfo::macFixNameFormat(QString *printerName) #ifdef Q_WS_MAC printerName->replace(QLatin1String("___"), QLatin1String(" @ ")); printerName->replace(QLatin1String("_"), QLatin1String(".")); +#else + Q_UNUSED(printerName); #endif } @@ -282,16 +284,17 @@ void tst_QPrinterInfo::testForPrinters() QCOMPARE(printers.size(), sysPrinters.size()); + QHash qtPrinters; + + for (int j = 0; j < printers.size(); ++j) { + qtPrinters.insert(printers.at(j).printerName(), !printers.at(j).isNull()); + } + for (int i = 0; i < sysPrinters.size(); ++i) { - bool found = false; - for (int j = 0; j < printers.size(); ++j) { - if (sysPrinters.at(i) == printers.at(j).printerName()) { - QVERIFY(!printers.at(j).isNull()); - found = true; - break; - } + if (!qtPrinters.value(sysPrinters.at(i))) { + qDebug() << "Avaliable printers: " << qtPrinters; + QFAIL(qPrintable(QString("Printer '%1' reported by system, but not reported by Qt").arg(sysPrinters.at(i)))); } - if (!found) QFAIL("Printer reported by system, but not reported by Qt"); } #else QSKIP("Test doesn't work on non-Unix", SkipAll); -- cgit v0.12