summaryrefslogtreecommitdiffstats
path: root/tests/auto/printsupport/kernel
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-03-21 17:17:42 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-23 00:41:34 +0100
commitb188221fee0eaacec115b514185a0508ef655897 (patch)
tree167b09e47cc3b63dadf64527339a4248eda770b3 /tests/auto/printsupport/kernel
parent82c974f753e0081f8bedc356ea07a8cfa6fae583 (diff)
Fix QPrinter test in Windows
Fixed Q_WS_WIN flagging to Q_OS_WIN in QPrinter API and related implementation to make API match the documentation and Qt 4.8. Also Removed the unused internal HDC related functions from the API, that were previously behind Q_WS_WIN flag. Some of the properties tested are documented to be valid for native print engine only in X11 environment, so skipped testing those in non-xcb environments. Copy collation is also apparently not supported in Windows native print engine, though this seems to be undocumented, so skipped that only in Windows. At least one of the test blocks in tst_QPrinter::valuePreservation() failed due to default printer not getting set properly, so fixed that, too. Task-number: QTBUG-24191 Task-number: QTBUG-22927 Change-Id: I44a5e3d647a1279fcc7f1e99de6881f9be330246 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/printsupport/kernel')
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 3460ad702b..7b862c6653 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -235,8 +235,8 @@ void tst_QPrinter::testPageSetupDialog()
void tst_QPrinter::testPageSize()
{
-#if 1
- QSKIP("QPrinter::winPageSize(): Windows only and currently not implemented / QTBUG-22927");
+#ifndef Q_OS_WIN
+ QSKIP("QPrinter::winPageSize(): Windows only.");
#else
QPrinter prn;
@@ -255,7 +255,7 @@ void tst_QPrinter::testPageSize()
prn.setWinPageSize(DMPAPER_A4);
MYCOMPARE(prn.winPageSize(), DMPAPER_A4);
MYCOMPARE(prn.pageSize(), QPrinter::A4);
-#endif
+#endif // Q_OS_WIN
}
void tst_QPrinter::testPageRectAndPaperRect_data()
@@ -625,7 +625,25 @@ void tst_QPrinter::valuePreservation()
QPrinter::OutputFormat oldFormat = QPrinter::PdfFormat;
QPrinter::OutputFormat newFormat = QPrinter::NativeFormat; // TODO: Correct?
- {
+ // Some properties are documented to only be supported by NativeFormat in X11 environment
+ bool doX11Tests = QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive) == 0;
+ bool windowsPlatform = QGuiApplication::platformName().compare(QLatin1String("windows"), Qt::CaseInsensitive) == 0;
+ bool manualSourceSupported = true;
+
+#ifdef Q_OS_WIN
+ // QPrinter::supportedPaperSources() is only available on Windows, so just assuming manual is supported on others.
+ QPrinter printer;
+ printer.setOutputFormat(newFormat);
+ QList<QPrinter::PaperSource> sources = printer.supportedPaperSources();
+ if (!sources.contains(QPrinter::Manual)) {
+ manualSourceSupported = false;
+ qWarning() << "Manual paper source not supported by native printer, skipping related test.";
+ }
+#endif // Q_OS_WIN
+
+ // Querying PPK_CollateCopies is hardcoded to return false with Windows native print engine,
+ // so skip testing that in Windows.
+ if (!windowsPlatform) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
bool status = printer.collateCopies();
@@ -653,7 +671,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.colorMode(), QPrinter::ColorMode(!status));
}
- {
+ if (doX11Tests) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
QString status = printer.creator();
@@ -683,7 +701,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.docName(), status);
}
- {
+ if (doX11Tests) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
bool status = printer.doubleSidedPrinting();
@@ -697,7 +715,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.doubleSidedPrinting(), !status);
}
- {
+ if (doX11Tests) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
bool status = printer.fontEmbeddingEnabled();
@@ -754,7 +772,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.outputFileName(), status);
}
- {
+ if (doX11Tests) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
QPrinter::PageOrder status = printer.pageOrder();
@@ -782,7 +800,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.pageSize(), QPrinter::B5);
}
- {
+ if (manualSourceSupported) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
QPrinter::PaperSource status = printer.paperSource();
@@ -796,7 +814,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.paperSource(), QPrinter::Manual);
}
- {
+ if (doX11Tests) {
QPrinter printer;
printer.setOutputFormat(oldFormat);
QString status = printer.printProgram();
@@ -840,6 +858,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.printerName(), status);
}
+ // QPrinter::printerSelectionOption is explicitly documented not to be available on Windows.
#ifndef Q_OS_WIN
{
QPrinter printer;
@@ -856,7 +875,7 @@ void tst_QPrinter::valuePreservation()
printer.setOutputFormat(oldFormat);
QCOMPARE(printer.printerSelectionOption(), status);
}
-#endif
+#endif // Q_OS_WIN
{
QPrinter printer;
printer.setOutputFormat(oldFormat);