summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2015-03-02 09:23:07 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2015-03-02 09:23:07 +0100
commit2b5982aac8ad103443e33379fe5654f5bd419c87 (patch)
tree8cc1d4e00029a6c0f5a23d87e9c97cdfc4619538 /tests/auto/gui/text
parentefe3f631f232e6cc3966de59b9237653bf7fa96e (diff)
parentfc3733cba4652f2b8930c66665103fcb20874735 (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp115
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index 0ee066be63..c8d3122e6d 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -44,6 +44,11 @@
#ifndef QT_NO_WIDGETS
#include <qtextedit.h>
#endif
+#ifndef QT_NO_PRINTER
+#include <QPagedPaintDevice>
+#include <QPainter>
+#include <QPaintEngine>
+#endif
typedef QList<int> IntList;
@@ -96,6 +101,9 @@ private slots:
void QTBUG11282_insertBeforeMergedEnding();
#endif
void QTBUG22011_insertBeforeRowSpan();
+#ifndef QT_NO_PRINTER
+ void QTBUG31330_renderBackground();
+#endif
private:
QTextTable *create2x2Table();
@@ -1024,5 +1032,112 @@ void tst_QTextTable::QTBUG22011_insertBeforeRowSpan()
QCOMPARE(table->columns(), 6);
}
+#ifndef QT_NO_PRINTER
+namespace {
+class QTBUG31330_PaintDevice : public QPagedPaintDevice
+{
+public:
+ class PaintEngine : public QPaintEngine
+ {
+ public:
+ QList<QRectF> rects;
+
+ PaintEngine()
+ : QPaintEngine(0)
+ {}
+ virtual Type type() const
+ {
+ return User;
+ }
+ virtual bool begin(QPaintDevice *)
+ {
+ return true;
+ }
+ virtual bool end()
+ {
+ return true;
+ }
+ virtual void updateState(const QPaintEngineState &)
+ {}
+ virtual void drawRects(const QRect *, int)
+ {}
+ virtual void drawRects(const QRectF *r, int)
+ {
+ if (painter()->brush() == QBrush(Qt::green))
+ {
+ rects.append(*r);
+ }
+ }
+ virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
+ {}
+ };
+
+ int pages;
+ QPaintEngine* engine;
+
+ QTBUG31330_PaintDevice(QPaintEngine* engine)
+ : pages(1), engine(engine)
+ {
+ QPageLayout layout = pageLayout();
+ layout.setUnits(QPageLayout::Point);
+ setPageLayout(layout);
+ }
+ virtual int metric(PaintDeviceMetric metric) const
+ {
+ if (PdmDevicePixelRatio == metric)
+ return 1;
+ if (PdmDpiY == metric)
+ return 96;
+ if (PdmDpiX == metric)
+ return 96;
+ if (PdmHeight == metric)
+ return 1000;
+ if (PdmWidth == metric)
+ return 700;
+ return 900;
+ }
+ virtual QPaintEngine *paintEngine() const
+ {
+ return engine;
+ }
+ bool newPage()
+ {
+ ++pages;
+ return true;
+ }
+};
+}
+
+void tst_QTextTable::QTBUG31330_renderBackground()
+{
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
+ QTextTable* table = cursor.insertTable(4, 2);
+
+ QTextTableCell cell = table->cellAt(3, 0);
+
+ QTextCharFormat cellFormat = cell.format();
+ cellFormat.setBackground(QBrush(Qt::green));
+ cell.setFormat(cellFormat);
+
+ QTextCursor tc = cell.firstCursorPosition();
+ for (int i = 0; i < 60; ++i) {
+ tc.insertBlock();
+ }
+ QTBUG31330_PaintDevice::PaintEngine engine;
+ QTBUG31330_PaintDevice paintDevice(&engine);
+ paintDevice.setPageSize(QPagedPaintDevice::A4);
+ doc.print(&paintDevice);
+
+ QVERIFY(paintDevice.pages >= 2);
+ QCOMPARE(engine.rects.count(), paintDevice.pages);
+ for (int i = 0; i < engine.rects.count(); ++i) {
+ QRectF rect = engine.rects[i];
+ QVERIFY(rect.top() > 0);
+ QVERIFY(rect.bottom() < 1000);
+ }
+}
+#endif
+
QTEST_MAIN(tst_QTextTable)
#include "tst_qtexttable.moc"