1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2014 John Layt <jlayt@kde.org> |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include <QtTest/QtTest> |
30 | |
31 | #include <qpa/qplatformprintplugin.h> |
32 | #include <qpa/qplatformprintersupport.h> |
33 | |
34 | #include <private/qprintdevice_p.h> |
35 | |
36 | class tst_QPrintDevice : public QObject |
37 | { |
38 | Q_OBJECT |
39 | |
40 | private slots: |
41 | void basics(); |
42 | }; |
43 | |
44 | void tst_QPrintDevice::basics() |
45 | { |
46 | #ifndef QT_NO_PRINTER |
47 | QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); |
48 | if (!ps) |
49 | QSKIP("Could not load platform plugin"); |
50 | |
51 | QString defaultId = ps->defaultPrintDeviceId(); |
52 | if (defaultId.isEmpty()) { |
53 | qDebug() << "No default printer found"; |
54 | } else { |
55 | QVERIFY(ps->availablePrintDeviceIds().contains(defaultId)); |
56 | } |
57 | |
58 | qDebug() << "Available Printer IDs :"<< ps->availablePrintDeviceIds(); |
59 | |
60 | // Just exercise the api for now as we don't know what is installed |
61 | foreach (const QString id, ps->availablePrintDeviceIds()) { |
62 | QPrintDevice printDevice = ps->createPrintDevice(id); |
63 | const char quote = id == defaultId ? '*' : '"'; |
64 | qDebug().noquote().nospace() << "\nCreated printer "<< quote << id |
65 | << quote << ":\n"<< printDevice << '\n'; |
66 | QCOMPARE(printDevice.isValid(), true); |
67 | printDevice.id(); |
68 | printDevice.name(); |
69 | printDevice.location(); |
70 | printDevice.makeAndModel(); |
71 | printDevice.isValid(); |
72 | printDevice.isDefault(); |
73 | printDevice.isRemote(); |
74 | printDevice.state(); |
75 | printDevice.supportsMultipleCopies(); |
76 | printDevice.supportsCollateCopies(); |
77 | printDevice.defaultPageSize(); |
78 | printDevice.supportedPageSizes(); |
79 | printDevice.supportsCustomPageSizes(); |
80 | printDevice.minimumPhysicalPageSize(); |
81 | printDevice.maximumPhysicalPageSize(); |
82 | printDevice.defaultResolution(); |
83 | printDevice.supportedResolutions(); |
84 | printDevice.defaultInputSlot(); |
85 | printDevice.supportedInputSlots(); |
86 | printDevice.defaultOutputBin(); |
87 | printDevice.supportedOutputBins(); |
88 | printDevice.defaultDuplexMode(); |
89 | printDevice.supportedDuplexModes(); |
90 | printDevice.defaultColorMode(); |
91 | printDevice.supportedColorModes(); |
92 | printDevice.supportedMimeTypes(); |
93 | } |
94 | #endif // QT_NO_PRINTER |
95 | } |
96 | |
97 | QTEST_MAIN(tst_QPrintDevice) |
98 | |
99 | #include "tst_qprintdevice.moc" |
100 |