qt5base-lts/tests/auto/printsupport/kernel
Michael Weghorn 1f35be2f38 tests: Fix tst_qprinterinfo for CUPS printer instances
CUPS has a feature called printer instances that allows saving
different sets of default options for a single print queue,
s. section "Creating Saved Options" at [1].

A printer instance can be set up using e.g.

    lpoptions -p printer/instance -o name=value

The printer instance is then listed with the print
queue name and the instance name separated by a slash
in the 'lpstat -e' output.
Qt also supports CUPS printer instances and displays
them using the same as printer names.

However, tst_QPrinterInfo::getPrintersFromSystem was
previously truncating the printer name at the slash,
so the comparison of printer names on a system that
has CUPS printer instances set up would fail e.g. as follows:

    ********* Start testing of tst_QPrinterInfo *********
    Config: Using QtTest library 6.5.0, Qt 6.5.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 12.1.0), debian unknown
    PASS   : tst_QPrinterInfo::initTestCase()
    QDEBUG : tst_QPrinterInfo::testForDefaultPrinter() Test believes Default Printer                              =  "PDF"
    QDEBUG : tst_QPrinterInfo::testForDefaultPrinter() QPrinterInfo::defaultPrinter() believes Default Printer    =  "PDF"
    QDEBUG : tst_QPrinterInfo::testForDefaultPrinter() QPrinterInfo::availablePrinters() believes Default Printer =  "PDF"
    PASS   : tst_QPrinterInfo::testForDefaultPrinter()
    QDEBUG : tst_QPrinterInfo::testForPrinters() Test believes Available Printers                              =  QList("Canon_MX390_series", "PDF", "PDF", "PDF-5cm-margins", "dummy", "dummy-ricoh-c3000", "tofile-hp-officejet-8600", "tofile-ricoh-aficio", "tofile-ricoh-mufu", "tofile-samsung-m2875", "tofile-test-tdf106963", "tofile-xerox-phaser-6510")
    QDEBUG : tst_QPrinterInfo::testForPrinters() QPrinterInfo::availablePrinters() believes Available Printers =  QList("Canon_MX390_series", "PDF", "PDF-5cm-margins", "PDF/myinstance", "dummy", "dummy-ricoh-c3000", "tofile-hp-officejet-8600", "tofile-ricoh-aficio", "tofile-ricoh-mufu", "tofile-samsung-m2875", "tofile-test-tdf106963", "tofile-xerox-phaser-6510")
    FAIL!  : tst_QPrinterInfo::testForPrinters() Compared values are not the same
       Actual   (qtPrinters.at(i))  : "PDF-5cm-margins"
       Expected (testPrinters.at(i)): "PDF"
       Loc: [/home/michi/development/git/qt5/qtbase/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp(232)]

Fix this by adding the slash character to the regex.

[1] https://www.cups.org/doc/options.html

Change-Id: Id0dc27a8b4c592847ed364cebf277e988039cad4
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2022-08-24 14:20:14 +02:00
..
qprintdevice Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
qprinter Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
qprinterinfo tests: Fix tst_qprinterinfo for CUPS printer instances 2022-08-24 14:20:14 +02:00
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00