From f0ae973244026ca5382f05630bd799b44154d224 Mon Sep 17 00:00:00 2001 From: Peng Wenhao Date: Thu, 27 Aug 2020 14:21:07 +0800 Subject: Qpagedpaintdevice: Use marginsF instead of internal struct margins resolve remaining Qt6 TODOs Change-Id: Iad659a09ddfe136bdc545bc0635b4c695540c58b Reviewed-by: Lars Knoll --- .../gui/painting/qpdfwriter/tst_qpdfwriter.cpp | 56 +++++++++---------- .../printsupport/kernel/qprinter/tst_qprinter.cpp | 62 ++++++++++------------ 2 files changed, 57 insertions(+), 61 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp index 3fbe16575d..36b8a4726b 100644 --- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp +++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp @@ -90,25 +90,25 @@ void tst_QPdfWriter::basics() QCOMPARE(writer.pageLayout().margins(), QMarginsF(10, 10, 10, 10)); QCOMPARE(writer.pageLayout().units(), QPageLayout::Point); - QCOMPARE(writer.margins().left, 3.53); // mm - QCOMPARE(writer.margins().right, 3.53); - QCOMPARE(writer.margins().top, 3.53); - QCOMPARE(writer.margins().bottom, 3.53); + QCOMPARE(writer.margins().left(), 3.53); // mm + QCOMPARE(writer.margins().right(), 3.53); + QCOMPARE(writer.margins().top(), 3.53); + QCOMPARE(writer.margins().bottom(), 3.53); writer.setPageMargins(QMarginsF(20, 20, 20, 20), QPageLayout::Millimeter); QCOMPARE(writer.pageLayout().margins(), QMarginsF(20, 20, 20, 20)); QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter); - QCOMPARE(writer.margins().left, 20.0); - QCOMPARE(writer.margins().right, 20.0); - QCOMPARE(writer.margins().top, 20.0); - QCOMPARE(writer.margins().bottom, 20.0); + QCOMPARE(writer.margins().left(), 20.0); + QCOMPARE(writer.margins().right(), 20.0); + QCOMPARE(writer.margins().top(), 20.0); + QCOMPARE(writer.margins().bottom(), 20.0); const QMarginsF margins = {50, 50, 50, 50}; writer.setPageMargins(margins, QPageLayout::Millimeter); QCOMPARE(writer.pageLayout().margins(), margins); QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter); - QCOMPARE(writer.margins().left, 50.0); - QCOMPARE(writer.margins().right, 50.0); - QCOMPARE(writer.margins().top, 50.0); - QCOMPARE(writer.margins().bottom, 50.0); + QCOMPARE(writer.margins().left(), 50.0); + QCOMPARE(writer.margins().right(), 50.0); + QCOMPARE(writer.margins().top(), 50.0); + QCOMPARE(writer.margins().bottom(), 50.0); QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210)); QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(50, 50, 197, 110)); @@ -185,10 +185,10 @@ void tst_QPdfWriter::testPageMetrics() if (setMargins) { // Setup the given margins writer.setPageMargins({leftMMf, topMMf, rightMMf, bottomMMf}, QPageLayout::Millimeter); - QCOMPARE(writer.margins().left, leftMMf); - QCOMPARE(writer.margins().right, rightMMf); - QCOMPARE(writer.margins().top, topMMf); - QCOMPARE(writer.margins().bottom, bottomMMf); + QCOMPARE(writer.margins().left(), leftMMf); + QCOMPARE(writer.margins().right(), rightMMf); + QCOMPARE(writer.margins().top(), topMMf); + QCOMPARE(writer.margins().bottom(), bottomMMf); } // Set the given size, in Portrait mode @@ -199,10 +199,10 @@ void tst_QPdfWriter::testPageMetrics() QCOMPARE(int(writer.pageSize()), int(pageSizeId)); QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait); - QCOMPARE(writer.margins().left, leftMMf); - QCOMPARE(writer.margins().right, rightMMf); - QCOMPARE(writer.margins().top, topMMf); - QCOMPARE(writer.margins().bottom, bottomMMf); + QCOMPARE(writer.margins().left(), leftMMf); + QCOMPARE(writer.margins().right(), rightMMf); + QCOMPARE(writer.margins().top(), topMMf); + QCOMPARE(writer.margins().bottom(), bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); @@ -216,10 +216,10 @@ void tst_QPdfWriter::testPageMetrics() QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId); QCOMPARE(int(writer.pageSize()), int(pageSizeId)); QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape); - QCOMPARE(writer.margins().left, leftMMf); - QCOMPARE(writer.margins().right, rightMMf); - QCOMPARE(writer.margins().top, topMMf); - QCOMPARE(writer.margins().bottom, bottomMMf); + QCOMPARE(writer.margins().left(), leftMMf); + QCOMPARE(writer.margins().right(), rightMMf); + QCOMPARE(writer.margins().top(), topMMf); + QCOMPARE(writer.margins().bottom(), bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); @@ -240,10 +240,10 @@ void tst_QPdfWriter::testPageMetrics() QCOMPARE(writer.pageLayout().pageSize().id(), pageSizeId); QCOMPARE(int(writer.pageSize()), int(pageSizeId)); QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape); - QCOMPARE(writer.margins().left, leftMMf); - QCOMPARE(writer.margins().right, rightMMf); - QCOMPARE(writer.margins().top, topMMf); - QCOMPARE(writer.margins().bottom, bottomMMf); + QCOMPARE(writer.margins().left(), leftMMf); + QCOMPARE(writer.margins().right(), rightMMf); + QCOMPARE(writer.margins().top(), topMMf); + QCOMPARE(writer.margins().bottom(), bottomMMf); // QPagedPaintDevice::pageSizeMM() always returns Portrait QCOMPARE(writer.pageSizeMM(), sizeMMf); diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 7529bad833..f3a6c4c695 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -1816,16 +1816,12 @@ void tst_QPrinter::testPageMetrics() if (setMargins) { // Setup the given margins - QPrinter::Margins margins; - margins.left = leftMMf; - margins.right = rightMMf; - margins.top = topMMf; - margins.bottom = bottomMMf; + QMarginsF margins(leftMMf, topMMf, rightMMf, bottomMMf); printer.setMargins(margins); - QCOMPARE(printer.margins().left, leftMMf); - QCOMPARE(printer.margins().right, rightMMf); - QCOMPARE(printer.margins().top, topMMf); - QCOMPARE(printer.margins().bottom, bottomMMf); + QCOMPARE(printer.margins().left(), leftMMf); + QCOMPARE(printer.margins().right(), rightMMf); + QCOMPARE(printer.margins().top(), topMMf); + QCOMPARE(printer.margins().bottom(), bottomMMf); } @@ -1840,17 +1836,17 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.orientation(), QPrinter::Portrait); if (setMargins) { // Check margins unchanged from page size change - QCOMPARE(printer.margins().left, leftMMf); - QCOMPARE(printer.margins().right, rightMMf); - QCOMPARE(printer.margins().top, topMMf); - QCOMPARE(printer.margins().bottom, bottomMMf); + QCOMPARE(printer.margins().left(), leftMMf); + QCOMPARE(printer.margins().right(), rightMMf); + QCOMPARE(printer.margins().top(), topMMf); + QCOMPARE(printer.margins().bottom(), bottomMMf); } else { // Fetch the default margins for the printer and page size // TODO Check against margins from print device when api added - leftMMf = printer.margins().left; - rightMMf = printer.margins().right; - topMMf = printer.margins().top; - bottomMMf = printer.margins().bottom; + leftMMf = printer.margins().left(); + rightMMf = printer.margins().right(); + topMMf = printer.margins().top(); + bottomMMf = printer.margins().bottom(); } // QPagedPaintDevice::pageSizeMM() always returns Portrait @@ -1880,17 +1876,17 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.orientation(), QPrinter::Landscape); if (setMargins) { // Check margins unchanged from page size change - QCOMPARE(printer.margins().left, leftMMf); - QCOMPARE(printer.margins().right, rightMMf); - QCOMPARE(printer.margins().top, topMMf); - QCOMPARE(printer.margins().bottom, bottomMMf); + QCOMPARE(printer.margins().left(), leftMMf); + QCOMPARE(printer.margins().right(), rightMMf); + QCOMPARE(printer.margins().top(), topMMf); + QCOMPARE(printer.margins().bottom(), bottomMMf); } else { // Fetch the default margins for the printer and page size // TODO Check against margins from print device when api added - leftMMf = printer.margins().left; - rightMMf = printer.margins().right; - topMMf = printer.margins().top; - bottomMMf = printer.margins().bottom; + leftMMf = printer.margins().left(); + rightMMf = printer.margins().right(); + topMMf = printer.margins().top(); + bottomMMf = printer.margins().bottom(); } // QPagedPaintDevice::pageSizeMM() always returns Portrait @@ -1921,17 +1917,17 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.orientation(), QPrinter::Landscape); if (setMargins) { // Check margins unchanged from page size change - QCOMPARE(printer.margins().left, leftMMf); - QCOMPARE(printer.margins().right, rightMMf); - QCOMPARE(printer.margins().top, topMMf); - QCOMPARE(printer.margins().bottom, bottomMMf); + QCOMPARE(printer.margins().left(), leftMMf); + QCOMPARE(printer.margins().right(), rightMMf); + QCOMPARE(printer.margins().top(), topMMf); + QCOMPARE(printer.margins().bottom(), bottomMMf); } else { // Fetch the default margins for the printer and page size // TODO Check against margins from print device when api added - leftMMf = printer.margins().left; - rightMMf = printer.margins().right; - topMMf = printer.margins().top; - bottomMMf = printer.margins().bottom; + leftMMf = printer.margins().left(); + rightMMf = printer.margins().right(); + topMMf = printer.margins().top(); + bottomMMf = printer.margins().bottom(); } // QPagedPaintDevice::pageSizeMM() always returns Portrait -- cgit v1.2.3