From 3402f53a52d6e1a4bce2a0ff084754399c312b08 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 24 Sep 2009 12:49:52 +1000 Subject: Enhance QFxPainted item to work when on non-white backgrounds. Improved version of the fix in 1c011c7f70791e0a4a38bd9f8bb1988cd604305c This fixes the bug with text cursors being an unusally large white rect in the flicker demo. --- src/declarative/fx/qfxpainteditem.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 27f3ca6..ac3de5e 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -231,9 +231,17 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge QPainter qp(&d->imagecache[i]->image); qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); qp.translate(-area.x(), -area.y()); - qp.eraseRect(d->imagecache[i]->dirty); - if (d->fillColor.isValid()) - qp.fillRect(d->imagecache[i]->dirty,d->fillColor); + if (d->fillColor.isValid()){ + if(d->fillColor.alpha() < 255){ + // ### Might not work outside of raster paintengine + QPainter::CompositionMode prev = qp.compositionMode(); + qp.setCompositionMode(QPainter::CompositionMode_Source); + qp.fillRect(d->imagecache[i]->dirty,d->fillColor); + qp.setCompositionMode(prev); + }else{ + qp.fillRect(d->imagecache[i]->dirty,d->fillColor); + } + } qp.setClipRect(d->imagecache[i]->dirty); drawContents(&qp, d->imagecache[i]->dirty); d->imagecache[i]->dirty = QRect(); -- cgit v0.12 From 9b6a71ec68edf836ab29cc3e5db71b53fe3d9346 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 24 Sep 2009 13:21:12 +1000 Subject: Add some visual autotests for QFxTextEdit Includes test for regression against QT-669 (but it doesn't work just yet) --- .../declarative/qfxtextedit/data/QT-669-test.qml | 8 ++++ tests/auto/declarative/qfxtextedit/data/QT-669.png | Bin 0 -> 4762 bytes tests/auto/declarative/qfxtextedit/data/QT-669.qml | 11 ++++++ .../declarative/qfxtextedit/data/basic-test.qml | 5 +++ tests/auto/declarative/qfxtextedit/data/basic.png | Bin 0 -> 8051 bytes tests/auto/declarative/qfxtextedit/data/basic.qml | 12 ++++++ .../declarative/qfxtextedit/data/colorful-test.qml | 5 +++ .../auto/declarative/qfxtextedit/data/colorful.png | Bin 0 -> 9645 bytes .../auto/declarative/qfxtextedit/data/colorful.qml | 18 +++++++++ .../declarative/qfxtextedit/tst_qfxtextedit.cpp | 41 +++++++++++++++++++++ 10 files changed, 100 insertions(+) create mode 100644 tests/auto/declarative/qfxtextedit/data/QT-669-test.qml create mode 100644 tests/auto/declarative/qfxtextedit/data/QT-669.png create mode 100644 tests/auto/declarative/qfxtextedit/data/QT-669.qml create mode 100644 tests/auto/declarative/qfxtextedit/data/basic-test.qml create mode 100644 tests/auto/declarative/qfxtextedit/data/basic.png create mode 100644 tests/auto/declarative/qfxtextedit/data/basic.qml create mode 100644 tests/auto/declarative/qfxtextedit/data/colorful-test.qml create mode 100644 tests/auto/declarative/qfxtextedit/data/colorful.png create mode 100644 tests/auto/declarative/qfxtextedit/data/colorful.qml diff --git a/tests/auto/declarative/qfxtextedit/data/QT-669-test.qml b/tests/auto/declarative/qfxtextedit/data/QT-669-test.qml new file mode 100644 index 0000000..9d6b5e5 --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/QT-669-test.qml @@ -0,0 +1,8 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { msec: 0; image: "QT-669.png" } + Key { key: Qt.Key_Right; count: 20 } + Key { key: Qt.Key_Left; count: 20 } + Frame { msec: 100; image: "QT-669.png" } +} diff --git a/tests/auto/declarative/qfxtextedit/data/QT-669.png b/tests/auto/declarative/qfxtextedit/data/QT-669.png new file mode 100644 index 0000000..657fce9 Binary files /dev/null and b/tests/auto/declarative/qfxtextedit/data/QT-669.png differ diff --git a/tests/auto/declarative/qfxtextedit/data/QT-669.qml b/tests/auto/declarative/qfxtextedit/data/QT-669.qml new file mode 100644 index 0000000..b9bf86a --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/QT-669.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Rectangle { + color: "green" + width:400; + height:40; + TextEdit { + focus: true; + text: "Jackdaws love my big sphinx of Quartz" + } +} diff --git a/tests/auto/declarative/qfxtextedit/data/basic-test.qml b/tests/auto/declarative/qfxtextedit/data/basic-test.qml new file mode 100644 index 0000000..021bfc5 --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/basic-test.qml @@ -0,0 +1,5 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { msec: 0; image: "basic.png" } +} diff --git a/tests/auto/declarative/qfxtextedit/data/basic.png b/tests/auto/declarative/qfxtextedit/data/basic.png new file mode 100644 index 0000000..b3cf1bf Binary files /dev/null and b/tests/auto/declarative/qfxtextedit/data/basic.png differ diff --git a/tests/auto/declarative/qfxtextedit/data/basic.qml b/tests/auto/declarative/qfxtextedit/data/basic.qml new file mode 100644 index 0000000..db4ec1c --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/basic.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Item { + width:600; + height:100; + TextEdit { + focus: false; + font.pointSize: 14 + font.bold: false + text: "Jackdaws love my big sphinx of Quartz" + } +} diff --git a/tests/auto/declarative/qfxtextedit/data/colorful-test.qml b/tests/auto/declarative/qfxtextedit/data/colorful-test.qml new file mode 100644 index 0000000..f148746 --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/colorful-test.qml @@ -0,0 +1,5 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { msec: 80; image: "colorful.png" } +} diff --git a/tests/auto/declarative/qfxtextedit/data/colorful.png b/tests/auto/declarative/qfxtextedit/data/colorful.png new file mode 100644 index 0000000..16189e5 Binary files /dev/null and b/tests/auto/declarative/qfxtextedit/data/colorful.png differ diff --git a/tests/auto/declarative/qfxtextedit/data/colorful.qml b/tests/auto/declarative/qfxtextedit/data/colorful.qml new file mode 100644 index 0000000..36d9c66 --- /dev/null +++ b/tests/auto/declarative/qfxtextedit/data/colorful.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + color:"lightsteelblue" + width:600; + height:100; + Timer{ interval: 20; running: true; repeat: false; onTriggered: "Txt.selectionEnd = 14" } + TextEdit { + id: Txt + focus: false; + font.pointSize: 14 + font.bold: false + color: "red" + selectionColor: "yellow" + selectedTextColor: "blue" + text: "Jackdaws love my big sphinx of Quartz" + } +} diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp index e38e0e7..ab55454 100644 --- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp +++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include class tst_qfxtextedit : public QObject @@ -28,6 +31,8 @@ private slots: void cursorDelegate(); + void visualTests_data(); + void visualTests(); private: QStringList standard; QStringList richText; @@ -41,6 +46,7 @@ private: QStringList colorStrings; QmlEngine engine; + QString qmlviewerBinary; }; tst_qfxtextedit::tst_qfxtextedit() @@ -84,6 +90,16 @@ tst_qfxtextedit::tst_qfxtextedit() // << "#AA0011DD" // << "#00F16B11"; // + + QString binaries = QLibraryInfo::location(QLibraryInfo::BinariesPath); + +#if defined(Q_WS_MAC) + qmlviewerBinary = QDir(binaries).absoluteFilePath("qmlviewer.app/Contents/MacOS/qmlviewer"); +#elif defined(Q_WS_WIN) + qmlviewerBinary = QDir(binaries).absoluteFilePath("qmlviewer.exe"); +#else + qmlviewerBinary = QDir(binaries).absoluteFilePath("qmlviewer"); +#endif } void tst_qfxtextedit::text() @@ -452,6 +468,31 @@ void tst_qfxtextedit::cursorDelegate() QVERIFY(!textEditObject->findChild("cursorInstance")); } +void tst_qfxtextedit::visualTests_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("scriptFile"); + QTest::newRow("basic") << "data/basic.qml" << "data/basic-test"; + QTest::newRow("colorful") << "data/colorful.qml" << "data/colorful-test"; + QTest::newRow("QT-669") << "data/QT-669.qml" << "data/QT-669-test"; +} + +void tst_qfxtextedit::visualTests() +{ + QFETCH(QString, qmlFile); + QFETCH(QString, scriptFile); + + QStringList arguments; + arguments << "-script" << scriptFile + << "-scriptopts" << "play,exitoncomplete,exitonfailure" + << qmlFile; + QProcess p; + p.start(qmlviewerBinary, arguments); + QVERIFY(p.waitForFinished()); + QCOMPARE(p.exitStatus(), QProcess::NormalExit); + QCOMPARE(p.exitCode(), 0); +} + QTEST_MAIN(tst_qfxtextedit) #include "tst_qfxtextedit.moc" -- cgit v0.12