QPrinter: fix unit tests for special case when no printer is default
The unit tests of QPrinter assume that a printer which is default- initialized is the same printer as the default printer. However, when no printer is set to default, this is not the case. When no printer is the default printer, a default-initialized QPrinter will be the first printer found. This patch adapts the unit tests to work also when no printer is the default printer, even though printers are available. Change-Id: I4967e5b1c4fb8a7c33c911184289ec5cd283fc58 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
b05e444a92
commit
f8474306e5
@ -1516,7 +1516,13 @@ void tst_QPrinter::outputFormat()
|
||||
QCOMPARE(printer.printerName(), QString());
|
||||
} else {
|
||||
QCOMPARE(printer.outputFormat(), QPrinter::NativeFormat);
|
||||
QCOMPARE(printer.printerName(), QPrinterInfo::defaultPrinter().printerName());
|
||||
|
||||
// If no printer is default, the first available printer should be used.
|
||||
// Otherwise, the default printer should be used.
|
||||
if (QPrinterInfo::defaultPrinter().isNull())
|
||||
QCOMPARE(printer.printerName(), QPrinterInfo::availablePrinters().at(0).printerName());
|
||||
else
|
||||
QCOMPARE(printer.printerName(), QPrinterInfo::defaultPrinter().printerName());
|
||||
}
|
||||
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
|
Loading…
Reference in New Issue
Block a user