From 174061f9f32ac76c6b8a6d155d772e37708d8cfc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 31 Jul 2019 10:23:39 +0200 Subject: QHighDPI: Fix broken scaling of QPoint(F) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, the overload resolution of the High DPI scale() functions introduced by b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 chose the wrong overloads for QPointF and/or QPoint; it fell back to the generic template intended for qreal, QSize, etc, ignoring the origin. Remove the template and spell out all overloads. Fixes: QTBUG-77255 Change-Id: I5661f16f7326f65156f646f430f5a0c71d5302d2 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/kernel.pro | 3 + .../gui/kernel/qhighdpiscaling/qhighdpiscaling.pro | 6 ++ .../kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp | 77 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro create mode 100644 tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index fbd3b1b371..42135dae24 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -11,6 +11,7 @@ SUBDIRS=\ qguimetatype \ qguitimer \ qguivariant \ + qhighdpiscaling \ qinputmethod \ qkeyevent \ qkeysequence \ @@ -35,6 +36,8 @@ win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtHaveModule(network): SUBDIRS -= \ qguieventloop +!qtConfig(highdpiscaling): SUBDIRS -= qhighdpiscaling + !qtConfig(opengl): SUBDIRS -= qopenglwindow android|uikit: SUBDIRS -= qclipboard diff --git a/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro b/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro new file mode 100644 index 0000000000..6cd7bb01f5 --- /dev/null +++ b/tests/auto/gui/kernel/qhighdpiscaling/qhighdpiscaling.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qhighdpiscaling + +QT += core-private gui-private testlib + +SOURCES += tst_qhighdpiscaling.cpp diff --git a/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp new file mode 100644 index 0000000000..969b2351ec --- /dev/null +++ b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +class tst_QHighDpiScaling: public QObject +{ + Q_OBJECT + +private slots: + void scale(); +}; + +// Emulate the case of a High DPI secondary screen +class MyPlatformScreen : public QPlatformScreen +{ +public: + QRect geometry() const override { return QRect(3840, 0, 3840, 1920); } + QRect availableGeometry() const override { return geometry(); } + + int depth() const override { return 32; } + QImage::Format format() const override { return QImage::Format_ARGB32_Premultiplied; } +}; + +// QTBUG-77255: Test some scaling overloads +void tst_QHighDpiScaling::scale() +{ + QHighDpiScaling::setGlobalFactor(2); + QScopedPointer screen(new MyPlatformScreen); + + qreal nativeValue = 10; + const qreal value = QHighDpi::fromNativePixels(nativeValue, screen.data()); + QCOMPARE(value, qreal(5)); + QCOMPARE(QHighDpi::toNativePixels(value, screen.data()), nativeValue); + + // 10, 10 within screen should translate to 5,5 with origin preserved + const QPoint nativePoint = screen->geometry().topLeft() + QPoint(10, 10); + const QPoint point = QHighDpi::fromNativePixels(nativePoint, screen.data()); + QCOMPARE(point, QPoint(3845, 5)); + QCOMPARE(QHighDpi::toNativePixels(point, screen.data()), nativePoint); + + const QPointF nativePointF(nativePoint); + const QPointF pointF = QHighDpi::fromNativePixels(nativePointF, screen.data()); + QCOMPARE(pointF, QPointF(3845, 5)); + QCOMPARE(QHighDpi::toNativePixels(pointF, screen.data()), nativePointF); +} + +#include "tst_qhighdpiscaling.moc" +QTEST_MAIN(tst_QHighDpiScaling); -- cgit v1.2.3 From 79e0effead13f60676bb5170fe92615d981827e7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 7 Aug 2019 15:25:49 +0200 Subject: Fix crash in QTextDocument::clearUndoRedoStacks() When calling QTextDocument::clearUndoRedoStacks() with UndoStack, there were two bugs: The first was that we were retrieving the item at "undoState" and deleting this. This is actually the upper limit of the for loop. If the stack does not contain any redos, then it would be == undoStack.size() and we would assert. If there were redos, then we would delete the item at undoState multiple times (actually undoState times). In addition, when the loop exited, we first removed the dangling pointers using remove() and then there was a weird resize() to the new size minus the old undoState. This would either assert because we tried to resize to a negative number, or it would arbitrarily remove items from the stack. [ChangeLog][QtGui][Text] Fixed a crash bug in QTextDocument::clearUndoRedoStacks(QTextDocument::UndoStack). Task-number: QTBUG-69546 Change-Id: I8a93e828ec27970763a2756071fa0b01678d2dcd Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Ritt --- tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 32131352c3..c04c841376 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -188,6 +188,8 @@ private slots: void lineHeightType(); void cssLineHeightMultiplier(); + + void clearUndoRedoStacks(); private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3486,5 +3488,16 @@ void tst_QTextDocument::cssLineHeightMultiplier() } } +void tst_QTextDocument::clearUndoRedoStacks() +{ + QTextDocument doc; + QTextCursor c(&doc); + c.insertText(QStringLiteral("lorem ipsum")); + QVERIFY(doc.isUndoAvailable()); + doc.clearUndoRedoStacks(QTextDocument::UndoStack); // Don't crash + QVERIFY(!doc.isUndoAvailable()); +} + + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" -- cgit v1.2.3 From c76b86aec64c4098434340ec17a26d7b2a32338e Mon Sep 17 00:00:00 2001 From: Heikki Halmet Date: Sun, 4 Aug 2019 08:42:26 +0300 Subject: BLACKLIST contains_QPointF for msvc-2019 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-77312 Change-Id: I5197d160d9b3c70b538c2e5a43c31120e1bed5f0 Reviewed-by: Tony Sarajärvi --- tests/auto/gui/painting/qpainterpath/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/auto/gui/painting/qpainterpath/BLACKLIST (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/painting/qpainterpath/BLACKLIST b/tests/auto/gui/painting/qpainterpath/BLACKLIST new file mode 100644 index 0000000000..b3e6d3bfe4 --- /dev/null +++ b/tests/auto/gui/painting/qpainterpath/BLACKLIST @@ -0,0 +1,2 @@ +[contains_QPointF] +msvc-2019 -- cgit v1.2.3 From 5d7f1133205d14002463456c26a97f8ba17d69b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 7 Aug 2019 13:15:51 +0200 Subject: Add nullptr guard to QHighDScaling::scaleAndOrigin(QPlatformScreen *) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit b6ded193 added an unconditional dereference of the platformScreen pointer, for calls where nativePostion is non-nullptr. Change-Id: I4a6fbbd0337f91d4fcb76c17b4dc60e1b9ad10ed Reviewed-by: Tor Arne Vestbø --- .../gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp index 969b2351ec..ec80c2d02c 100644 --- a/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp +++ b/tests/auto/gui/kernel/qhighdpiscaling/tst_qhighdpiscaling.cpp @@ -36,6 +36,7 @@ class tst_QHighDpiScaling: public QObject Q_OBJECT private slots: + void factor(); void scale(); }; @@ -50,6 +51,23 @@ public: QImage::Format format() const override { return QImage::Format_ARGB32_Premultiplied; } }; +void tst_QHighDpiScaling::factor() +{ + QHighDpiScaling::setGlobalFactor(2); + + // Verfy that QHighDpiScaling::factor() does not crash on nullptr contexts. + QPoint fakeNativePosition = QPoint(5, 5); + QPlatformScreen *screenContext = nullptr; + QVERIFY(QHighDpiScaling::factor(screenContext) >= 0); + QVERIFY(QHighDpiScaling::factor(screenContext, &fakeNativePosition) >= 0); + QPlatformScreen *platformScreenContext = nullptr; + QVERIFY(QHighDpiScaling::factor(platformScreenContext) >= 0); + QVERIFY(QHighDpiScaling::factor(platformScreenContext, &fakeNativePosition) >= 0); + QWindow *windowContext = nullptr; + QVERIFY(QHighDpiScaling::factor(windowContext) >= 0); + QVERIFY(QHighDpiScaling::factor(windowContext, &fakeNativePosition) >= 0); +} + // QTBUG-77255: Test some scaling overloads void tst_QHighDpiScaling::scale() { -- cgit v1.2.3 From d45908e24292a41ff7838366b34be7340bf9fda5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 26 Mar 2019 12:48:36 +0100 Subject: Support missing white-space:pre-line CSS A mode that only preserves new lines. Change-Id: I612347b181c6e6c41dfae0cf60b22a662cba1b7e Reviewed-by: Lars Knoll --- tests/auto/gui/text/qcssparser/tst_qcssparser.cpp | 29 ++++++++++++++++++++++ .../tst_qtextdocumentfragment.cpp | 14 ++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 7dbeb13aa7..7764a716ca 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -78,6 +78,8 @@ private slots: void extractBorder(); void noTextDecoration(); void quotedAndUnquotedIdentifiers(); + void whitespaceValues_data(); + void whitespaceValues(); }; void tst_QCssParser::scanner_data() @@ -1746,6 +1748,33 @@ void tst_QCssParser::quotedAndUnquotedIdentifiers() QCOMPARE(decls.at(1).d->values.first().toString(), QLatin1String("bold")); } +void tst_QCssParser::whitespaceValues_data() +{ + QTest::addColumn("value"); + + QTest::newRow("normal") << "normal"; + QTest::newRow("inherit") << "inherit"; + QTest::newRow("nowrap") << "nowrap"; + QTest::newRow("pre") << "pre"; + QTest::newRow("pre-wrap") << "pre-wrap"; + QTest::newRow("pre-line") << "pre-line"; +} + +void tst_QCssParser::whitespaceValues() +{ + QFETCH(QString, value); + QCss::Parser parser(QString("foo { white-space: %1 }").arg(value)); + QCss::StyleSheet sheet; + QVERIFY(parser.parse(&sheet)); + + QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ? + sheet.styleRules.at(0) : *sheet.nameIndex.begin(); + QCOMPARE(rule.declarations.size(), 1); + + QCOMPARE(rule.declarations.at(0).d->property, QLatin1String("white-space")); + QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value); +} + QTEST_MAIN(tst_QCssParser) #include "tst_qcssparser.moc" diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 664ca98a3f..c5243d1535 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -1272,11 +1272,11 @@ void tst_QTextDocumentFragment::html_whitespace_data() QTest::newRow("2") << QString(" nowhitespacehereplease") << QString::fromLatin1("nowhitespacehereplease"); - QTest::newRow("3") << QString(" white space here ") - << QString::fromLatin1(" white space here "); + QTest::newRow("3") << QString(" white space \n\n here ") + << QString::fromLatin1(" white space \n\n here "); - QTest::newRow("4") << QString(" white space here ") - << QString::fromLatin1(" white space here "); + QTest::newRow("4") << QString(" white space \n\n here ") + << QString::fromLatin1(" white space \n\n here "); QTest::newRow("5") << QString("One Two Three\n" "Four") @@ -1291,6 +1291,12 @@ void tst_QTextDocumentFragment::html_whitespace_data() QTest::newRow("8") << QString("
Blah
Blub") << QString("\nBlah\nBlub"); + QTest::newRow("9") << QString(" white space \n\n here ") + << QString::fromLatin1("white space here "); + + QTest::newRow("10") << QString(" white space \n\n here ") + << QString::fromLatin1("white space\n\nhere "); + QTest::newRow("task116492") << QString("

a b c

") << QString("a b c"); -- cgit v1.2.3 From c29a136804f5952c0b4c15920f3ab4032c21573c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 13 Aug 2019 11:01:03 +0200 Subject: Fix tst_QImageReader::saveColorSpace After comparing colorspaces was remove from QImage equality, the test was no longer testing what it was supposed to. Change-Id: Ie7ee8ac2f488ea4254086cbb91a2662dc729e80b Reviewed-by: Eirik Aavitsland --- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 8b42b139a3..866a41c3d1 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1913,6 +1913,7 @@ void tst_QImageReader::saveColorSpace() QImage stored = QImage::fromData(buf.buffer(), "png"); QCOMPARE(stored, orig); + QCOMPARE(stored.colorSpace(), orig.colorSpace()); } void tst_QImageReader::readText_data() -- cgit v1.2.3 From 662fec6f0db32fb58b91357aa11c9d3be94f0c55 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Fri, 9 Aug 2019 11:04:27 +0200 Subject: Update for failures only on dev branch. Use general platform names This patch was generated with tooling from patchset 31 of https://codereview.qt-project.org/c/qt/qtqa/+/267034 in interactive mode. General platform names were chosen if greater than 60% of the currently active platforms of a given type in COIN recently failed. Change-Id: Ia4bde7f0ec422bbb727dc9d7151295159094f146 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/gui/kernel/qguitimer/BLACKLIST | 8 -------- tests/auto/gui/kernel/qwindow/BLACKLIST | 15 +++------------ 2 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 tests/auto/gui/kernel/qguitimer/BLACKLIST (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qguitimer/BLACKLIST b/tests/auto/gui/kernel/qguitimer/BLACKLIST deleted file mode 100644 index 6ab715b922..0000000000 --- a/tests/auto/gui/kernel/qguitimer/BLACKLIST +++ /dev/null @@ -1,8 +0,0 @@ -[basic_chrono] -osx-10.13 -[remainingTime] -osx-10.12 -windows-10 msvc-2015 -osx-10.14 -osx-10.13 - diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 1bb3917948..27463adf99 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -1,7 +1,5 @@ [positioning] opensuse-leap -ubuntu-16.04 -opensuse-42.3 [positioning:default] linux osx-10.12 ci @@ -9,24 +7,17 @@ winrt [positioning:fake] osx-10.12 ci [modalWithChildWindow] -ubuntu-16.04 -opensuse-leap # QTBUG-66851 # QTBUG-69160 -opensuse-42.3 +opensuse-leap [setVisible] # QTBUG-69154 android [modalWindowEnterEventOnHide_QTBUG35109] -ubuntu-16.04 -osx-10.11 -osx-10.13 -osx-10.14 -osx-10.12 +osx [spuriousMouseMove] # QTBUG-69162 -windows-10 msvc-2015 -windows-10 msvc-2017 +windows-10 [testInputEvents] rhel-7.4 [exposeEventOnShrink_QTBUG54040] -- cgit v1.2.3 From d8a9bec35fb0c60a0e5990c1a12ffe6f39fdbf2d Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Thu, 17 Dec 2015 16:38:15 +0100 Subject: QTextDocument: add css-styling of table cell borders to HTML import/export Supported style attributes: style: supports "border-collapse: collapse" and "border-color". border: width of the outer border bordercolor: basic color for all borders style: not supported
/ style: supports the "border", "border-[top|left|bottom|right]]" shorthand styles and the "border-width", "border-color" and "border-style" (and the top/left/bottom/right variants) attributes will render a simple 1px table grid. Notes: The QTextDocument table model is much simpler than the HTML table model. It basically only has
and and
support. So the HTML parser is forced to map markup and styling to the QTextDocument model which is not without loss. In other words: While QTextDocument -> HTML -> QTextDocument should preserve the QTextDocument structure, HTML -> QTextDocument -> HTML does not preserve the HTML DOM at all. So for now the HTML importer and writer only support border styles on the and nodes. In future updates, the HTML parser might be enhanced to map
CSS styles to the cells. Change-Id: If9e7312fa6cbf270cf8f7b3c72ba1fa094107517 Reviewed-by: Shawn Rutledge --- .../gui/text/qtextdocument/tst_qtextdocument.cpp | 29 +++++ .../tst_qtextdocumentfragment.cpp | 134 +++++++++++++++++++++ tests/auto/gui/text/qtexttable/tst_qtexttable.cpp | 108 +++++++++++++++++ 3 files changed, 271 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 58810f73c1..52e56feb5a 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -50,6 +50,7 @@ #include #include "common.h" +// #define DEBUG_WRITE_OUTPUT QT_FORWARD_DECLARE_CLASS(QTextDocument) @@ -196,6 +197,7 @@ private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); static QString cssFontSizeString(const QFont &font); + void writeActualAndExpected(const char* testTag, const QString &actual, const QString &expected); QTextDocument *doc; QTextCursor cursor; @@ -224,6 +226,27 @@ QString tst_QTextDocument::cssFontSizeString(const QFont &font) : QString::number(font.pixelSize()) + QStringLiteral("px"); } +void tst_QTextDocument::writeActualAndExpected(const char *testTag, const QString &actual, const QString &expected) +{ +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out(QDir::temp().absoluteFilePath(QLatin1String(testTag) + QLatin1String("-actual.html"))); + out.open(QFile::WriteOnly); + out.write(actual.toUtf8()); + out.close(); + } { + QFile out(QDir::temp().absoluteFilePath(QLatin1String(testTag) + QLatin1String("-expected.html"))); + out.open(QFile::WriteOnly); + out.write(expected.toUtf8()); + out.close(); + } +#else + Q_UNUSED(testTag) + Q_UNUSED(actual) + Q_UNUSED(expected) +#endif +} + // Testing get/set functions void tst_QTextDocument::getSetCheck() { @@ -1765,6 +1788,8 @@ void tst_QTextDocument::toHtml() QString output = doc->toHtml(); + writeActualAndExpected(QTest::currentDataTag(), output, expectedOutput); + QCOMPARE(output, expectedOutput); QDomDocument document; @@ -1962,6 +1987,8 @@ void tst_QTextDocument::toHtmlRootFrameProperties() expectedOutput.replace("DEFAULTBLOCKSTYLE", "style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\""); expectedOutput.append(htmlTail); + writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedOutput); + QCOMPARE(doc.toHtml(), expectedOutput); } @@ -2734,6 +2761,8 @@ void tst_QTextDocument::backgroundImage_checkExpectedHtml(const QTextDocument &d .arg(defaultFont.weight() * 8) .arg((defaultFont.italic() ? "italic" : "normal")); + writeActualAndExpected(QTest::currentTestFunction(), doc.toHtml(), expectedHtml); + QCOMPARE(doc.toHtml(), expectedHtml); } diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index c5243d1535..b6917f1208 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -181,6 +181,11 @@ private slots: void html_tableCellBackground(); void css_bodyBackground(); void css_tableCellBackground(); + void css_tableCellBorder(); + void css_tableCellBorderShorthand(); + void css_tableCellAllBordersShorthand(); + void css_tableCellOverrideOneBorder(); + void css_tableBorderCollapse(); void css_fontWeight(); void css_float(); void css_textIndent(); @@ -1753,6 +1758,135 @@ void tst_QTextDocumentFragment::css_tableCellBackground() QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } +void tst_QTextDocumentFragment::css_tableCellBorder() +{ + const char html[] = "
Foo
"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(4)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.rightBorder(), qreal(8)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Groove); + + QCOMPARE(cellFormat.bottomBorder(), qreal(8)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Groove); + + QCOMPARE(cellFormat.topBorder(), qreal(8)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Groove); +} + +void tst_QTextDocumentFragment::css_tableCellBorderShorthand() +{ + const char html[] = "
Foo
"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(1)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Solid); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(3)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("yellow"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dotted); + + QCOMPARE(cellFormat.topBorder(), qreal(4)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("blue"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_DotDash); +} + +void tst_QTextDocumentFragment::css_tableCellAllBordersShorthand() +{ + const char html[] = "
Foo
"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(2)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(2)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.topBorder(), qreal(2)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); +} + +void tst_QTextDocumentFragment::css_tableCellOverrideOneBorder() +{ + const char html[] = "
Foo
"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QTextTableCell cell = table->cellAt(0, 0); + QTextTableCellFormat cellFormat = cell.format().toTableCellFormat(); + QCOMPARE(cellFormat.leftBorder(), qreal(4)); + QCOMPARE(cellFormat.leftBorderBrush(), QBrush(QColor("red"))); + QCOMPARE(cellFormat.leftBorderStyle(), QTextFrameFormat::BorderStyle_Solid); + + QCOMPARE(cellFormat.rightBorder(), qreal(2)); + QCOMPARE(cellFormat.rightBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.rightBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.bottomBorder(), qreal(2)); + QCOMPARE(cellFormat.bottomBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.bottomBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); + + QCOMPARE(cellFormat.topBorder(), qreal(2)); + QCOMPARE(cellFormat.topBorderBrush(), QBrush(QColor("green"))); + QCOMPARE(cellFormat.topBorderStyle(), QTextFrameFormat::BorderStyle_Dashed); +} + +void tst_QTextDocumentFragment::css_tableBorderCollapse() +{ + const char html[] = "
Foo
"; + doc->setHtml(html); + + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::NextBlock); + QTextTable *table = cursor.currentTable(); + QVERIFY(table); + + QCOMPARE(table->format().borderCollapse(), true); +} + void tst_QTextDocumentFragment::css_cellPaddings() { const char html[] = "" diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index f21b969aa7..7b2ff4cc10 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -50,6 +50,8 @@ typedef QList IntList; QT_FORWARD_DECLARE_CLASS(QTextDocument) +Q_DECLARE_METATYPE(QTextFrameFormat::BorderStyle); + class tst_QTextTable : public QObject { Q_OBJECT @@ -95,6 +97,8 @@ private slots: #if !defined(QT_NO_PRINTER) && defined(QT_BUILD_INTERNAL) void QTBUG31330_renderBackground(); #endif + void checkBorderAttributes_data(); + void checkBorderAttributes(); private: QTextTable *create2x2Table(); @@ -1170,5 +1174,109 @@ void tst_QTextTable::QTBUG31330_renderBackground() } #endif +void tst_QTextTable::checkBorderAttributes_data() +{ + QTest::addColumn("html"); + QTest::addColumn("topBorderWidth"); + QTest::addColumn("bottomBorderWidth"); + QTest::addColumn("leftBorderWidth"); + QTest::addColumn("rightBorderWidth"); + QTest::addColumn("topBorderStyle"); + QTest::addColumn("bottomBorderStyle"); + QTest::addColumn("leftBorderStyle"); + QTest::addColumn("rightBorderStyle"); + QTest::addColumn("topBorderBrush"); + QTest::addColumn("bottomBorderBrush"); + QTest::addColumn("leftBorderBrush"); + QTest::addColumn("rightBorderBrush"); + + const QString tableHtmlStart = QStringLiteral("" + "
Foo
" + "
OneTwo
ThreeFour
"); + QTest::newRow("1px-solid-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 1px solid blue;" + "border-left: 1px solid green;" + "border-right: 1px solid yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 1.0 << 1.0 << 1.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); + QTest::newRow("MixedWidth-solid-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 2px solid blue;" + "border-left: 3px solid green;" + "border-right: 4px solid yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 2.0 << 3.0 << 4.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Solid + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); + QTest::newRow("MixedWidth-MixedStyle-colors") + << QString("%1" + "td {" + "border-top: 1px solid red;" + "border-bottom: 2px dotted blue;" + "border-left: 3px dashed green;" + "border-right: 4px inset yellow;" + "}" + "%2").arg(tableHtmlStart).arg(tableHtmlEnd) + << 1.0 << 2.0 << 3.0 << 4.0 + << QTextFrameFormat::BorderStyle_Solid << QTextFrameFormat::BorderStyle_Dotted + << QTextFrameFormat::BorderStyle_Dashed << QTextFrameFormat::BorderStyle_Inset + << QBrush(Qt::red) << QBrush(Qt::blue) << QBrush(Qt::darkGreen) << QBrush(Qt::yellow); +} + +void tst_QTextTable::checkBorderAttributes() +{ + QFETCH(QString, html); + QFETCH(qreal, topBorderWidth); + QFETCH(qreal, bottomBorderWidth); + QFETCH(qreal, leftBorderWidth); + QFETCH(qreal, rightBorderWidth); + QFETCH(QTextFrameFormat::BorderStyle, topBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, bottomBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, leftBorderStyle); + QFETCH(QTextFrameFormat::BorderStyle, rightBorderStyle); + QFETCH(QBrush, topBorderBrush); + QFETCH(QBrush, bottomBorderBrush); + QFETCH(QBrush, leftBorderBrush); + QFETCH(QBrush, rightBorderBrush); + + QTextDocument doc; + doc.setHtml(html); + QTextCursor cursor(doc.firstBlock()); + cursor.movePosition(QTextCursor::Right); + + QTextTable *currentTable = cursor.currentTable(); + QVERIFY(currentTable); + for (int row = 0; row < 2; row++) { + for (int column = 0; column < 2; column++) { + QTextTableCell cell = currentTable->cellAt(row, column); + QTextCharFormat cellFormat = cell.format(); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellTopBorder), topBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellBottomBorder), bottomBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellLeftBorder), leftBorderWidth); + QCOMPARE(cellFormat.doubleProperty(QTextFormat::TableCellRightBorder), rightBorderWidth); + QCOMPARE(cellFormat.property(QTextFormat::TableCellTopBorderStyle), topBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellBottomBorderStyle), bottomBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellLeftBorderStyle), leftBorderStyle); + QCOMPARE(cellFormat.property(QTextFormat::TableCellRightBorderStyle), rightBorderStyle); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellTopBorderBrush), topBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellBottomBorderBrush), bottomBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellLeftBorderBrush), leftBorderBrush); + QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellRightBorderBrush), rightBorderBrush); + } + } +} + QTEST_MAIN(tst_QTextTable) #include "tst_qtexttable.moc" -- cgit v1.2.3 From 9e86fdb6e8004a0eba7d5f4b9a7b1f52275fd207 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 19 Aug 2019 12:53:10 +0200 Subject: Support writing color space profile in JPEG That way the image formats with color space supports all have both read and write support. Change-Id: Ib52ebd56192c4a8a0897a6afc7c4a26020319270 Reviewed-by: Eirik Aavitsland --- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 866a41c3d1..eeabfd0413 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1914,6 +1914,13 @@ void tst_QImageReader::saveColorSpace() QCOMPARE(stored, orig); QCOMPARE(stored.colorSpace(), orig.colorSpace()); + + buf.open(QIODevice::WriteOnly); + QVERIFY(orig.save(&buf, "jpeg")); + buf.close(); + stored = QImage::fromData(buf.buffer(), "jpeg"); + + QCOMPARE(stored.colorSpace(), orig.colorSpace()); } void tst_QImageReader::readText_data() -- cgit v1.2.3 From ce73b4db62574fc966192e6a4f65b7e2b2280e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 20 Aug 2019 14:26:05 +0200 Subject: Remove dead code from Qt 4 times MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The benefit of keeping this code around was to inspire or inform changes in the areas to take into account possibly missing features in Qt 5, but at this point that benefit is questionable. We can always use the history to learn about missing pieces if needed. Change-Id: I87a02dc451e9027be9b97554427bf8a1c6b2c025 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 13 ----- tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 60 ----------------------- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 5 -- tests/auto/gui/painting/qregion/tst_qregion.cpp | 24 --------- 4 files changed, 102 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 4d31d80246..ba5df809f2 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -267,10 +267,6 @@ void tst_QPixmap::fromImage() image.fill(0x7f7f7f7f); const QPixmap pixmap = QPixmap::fromImage(image); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle()) - QSKIP("Requires XRender support"); -#endif const QImage result = pixmap.toImage(); image = image.convertToFormat(result.format()); QCOMPARE(result, image); @@ -491,11 +487,6 @@ void tst_QPixmap::fill() else pm = QPixmap(400, 400); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - if (!bitmap && pm.handle()->classId() == QPlatformPixmap::X11Class && !pm.x11PictureHandle()) - QSKIP("Requires XRender support"); -#endif - pm.fill(color); if (syscolor && !bitmap && pm.depth() < 24) { QSKIP("Test does not work on displays without true color"); @@ -521,10 +512,6 @@ void tst_QPixmap::fill() void tst_QPixmap::fill_transparent() { QPixmap pixmap(10, 10); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle()) - QSKIP("Requires XRender support"); -#endif pixmap.fill(Qt::transparent); QVERIFY(pixmap.hasAlphaChannel()); } diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 90a216e14a..c1c231089a 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -111,10 +111,6 @@ private slots: void qcolorprofile_data(); void qcolorprofile(); - -#if 0 // Used to be included in Qt4 for Q_WS_X11 - void setallowX11ColorNames(); -#endif }; // Testing get/set functions @@ -1460,62 +1456,6 @@ void tst_QColor::achromaticHslHue() QCOMPARE(hsl.hslHue(), -1); } -#if 0 // Used to be included in Qt4 for Q_WS_X11 -void tst_QColor::setallowX11ColorNames() -{ - RGBData x11RgbTbl[] = { - // a few standard X11 color names - { "DodgerBlue1", qRgb(30, 144, 255) }, - { "DodgerBlue2", qRgb(28, 134, 238) }, - { "DodgerBlue3", qRgb(24, 116, 205) }, - { "DodgerBlue4", qRgb(16, 78, 139) }, - { "SteelBlue1", qRgb(99, 184, 255) }, - { "SteelBlue2", qRgb(92, 172, 238) }, - { "SteelBlue3", qRgb(79, 148, 205) }, - { "SteelBlue4", qRgb(54, 100, 139) }, - { "DeepSkyBlue1", qRgb(0, 191, 255) }, - { "DeepSkyBlue2", qRgb(0, 178, 238) }, - { "DeepSkyBlue3", qRgb(0, 154, 205) }, - { "DeepSkyBlue4", qRgb(0, 104, 139) }, - { "SkyBlue1", qRgb(135, 206, 255) }, - { "SkyBlue2", qRgb(126, 192, 238) }, - { "SkyBlue3", qRgb(108, 166, 205) }, - { "SkyBlue4", qRgb(74, 112, 139) } - }; - static const int x11RgbTblSize = sizeof(x11RgbTbl) / sizeof(RGBData); - - // X11 color names should not work by default - QVERIFY(!QColor::allowX11ColorNames()); - for (int i = 0; i < x11RgbTblSize; ++i) { - QString colorName = QLatin1String(x11RgbTbl[i].name); - QColor color; - color.setNamedColor(colorName); - QVERIFY(!color.isValid()); - } - - // enable X11 color names - QColor::setAllowX11ColorNames(true); - QVERIFY(QColor::allowX11ColorNames()); - for (int i = 0; i < x11RgbTblSize; ++i) { - QString colorName = QLatin1String(x11RgbTbl[i].name); - QColor color; - color.setNamedColor(colorName); - QColor expected(x11RgbTbl[i].value); - QCOMPARE(color, expected); - } - - // should be able to turn off X11 color names - QColor::setAllowX11ColorNames(false); - QVERIFY(!QColor::allowX11ColorNames()); - for (int i = 0; i < x11RgbTblSize; ++i) { - QString colorName = QLatin1String(x11RgbTbl[i].name); - QColor color; - color.setNamedColor(colorName); - QVERIFY(!color.isValid()); - } -} -#endif - void tst_QColor::premultiply() { // Tests that qPremultiply(qUnpremultiply(x)) returns x. diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 0efeb9b356..4cf23455e1 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -461,11 +461,6 @@ void tst_QPainter::drawPixmap_comp() destPm.fill(c1); srcPm.fill(c2); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - if (!destPm.x11PictureHandle()) - QSKIP("Requires XRender support"); -#endif - QPainter p(&destPm); p.drawPixmap(0, 0, srcPm); p.end(); diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index 24c4583819..d1ea7706b9 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -33,9 +33,6 @@ #include #include #include -#if 0 // Used to be included in Qt4 for Q_WS_X11 -#include -#endif class tst_QRegion : public QObject { @@ -79,9 +76,6 @@ private slots: void isEmpty_data(); void isEmpty(); -#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL) - void clipRectangles(); -#endif void regionFromPath(); void scaleRegions_data(); @@ -910,24 +904,6 @@ void tst_QRegion::isEmpty() #endif } -#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL) -void tst_QRegion::clipRectangles() -{ - QRegion region(30, 30, 30, 30); - int num = 0; - qt_getClipRects(region, num); - QCOMPARE(num, 1); - - region += QRegion(10, 10, 10, 10); - XRectangle *rects2 = static_cast(qt_getClipRects(region, num)); - QCOMPARE(num, 2); - - // Here's the important part (Y-sorted): - QCOMPARE(int(rects2[0].y), 10); - QCOMPARE(int(rects2[1].y), 30); -} -#endif - void tst_QRegion::regionFromPath() { { -- cgit v1.2.3 From d55712153a357cc5cc975bf599470619b7c77faa Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 21 Aug 2019 18:53:41 +0300 Subject: tst_NoQtEventLoop: destroy hidden windows Otherwise, we get a warning: QWARN : tst_NoQtEventLoop::consumeSocketEvents() QWindowsContext::windowsProc: No Qt Window found for event 0x2a3 (WM_MOUSELEAVE), hwnd=0x0x9b80646. in the event loop which is running by another test. So, add missing 'delete' call. Change-Id: Ib9b24155bdd6e78062a5234c317c9f878906e413 Reviewed-by: Friedemann Kleint --- tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 4fca9a07fc..19c5c8a4a0 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -258,8 +258,8 @@ void tst_NoQtEventLoop::consumeMouseEvents() ::SetWindowPos(mainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - Window *childWindow = new Window; - childWindow->setParent(QWindow::fromWinId((WId)mainWnd)); + QWindow *mainWindow = QWindow::fromWinId(reinterpret_cast(mainWnd)); + Window *childWindow = new Window(mainWindow); childWindow->setGeometry(margin, topVerticalMargin, width - 2 * margin, height - margin - topVerticalMargin); childWindow->show(); @@ -276,6 +276,7 @@ void tst_NoQtEventLoop::consumeMouseEvents() if (g_exit) break; } + delete mainWindow; QCOMPARE(testThread->passed(), true); -- cgit v1.2.3 From 5d94aac2bae8bdbf8de7cebeb6a1a17a81685f0a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Jul 2019 15:17:29 +0200 Subject: Introduce QImage::Format_BGR888 Is pretty common on some architectures so we can avoid swizzling by supporting it. Fixes: QTBUG-45671 Change-Id: Ic7a21b5bfb374bf7496fd2b2b1252c2f1ed47705 Reviewed-by: Eirik Aavitsland --- tests/auto/gui/image/qimage/tst_qimage.cpp | 24 ++++++++++++++++++++++ .../gui/image/qimagereader/tst_qimagereader.cpp | 1 + tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 1 + 3 files changed, 26 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 441ec17412..b84aa52465 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -303,6 +303,8 @@ static QLatin1String formatToString(QImage::Format format) return QLatin1String("RGBA64pm"); case QImage::Format_Grayscale16: return QLatin1String("Grayscale16"); + case QImage::Format_BGR888: + return QLatin1String("BGR888"); default: break; }; @@ -844,6 +846,13 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb32 -> rgb888") << int(QImage::Format_RGB32) << 0xff0000ff << int(QImage::Format_RGB888) << 0xff0000ff; + QTest::newRow("red rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xffff0000 + << int(QImage::Format_BGR888) << 0xffff0000; + QTest::newRow("green rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xff00ff00 + << int(QImage::Format_BGR888) << 0xff00ff00; + QTest::newRow("blue rgb32 -> bgr888") << int(QImage::Format_RGB32) << 0xff0000ff + << int(QImage::Format_BGR888) << 0xff0000ff; + QTest::newRow("red rgb16 -> rgb888") << int(QImage::Format_RGB16) << 0xffff0000 << int(QImage::Format_RGB888) << 0xffff0000; QTest::newRow("green rgb16 -> rgb888") << int(QImage::Format_RGB16) << 0xff00ff00 @@ -858,6 +867,13 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb888 -> argb32") << int(QImage::Format_RGB888) << 0xff0000ff << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("red bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xffff0000 + << int(QImage::Format_ARGB32) << 0xffff0000; + QTest::newRow("green bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xff00ff00 + << int(QImage::Format_ARGB32) << 0xff00ff00; + QTest::newRow("blue bgr888 -> argb32") << int(QImage::Format_RGB888) << 0xff0000ff + << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("red rgb888 -> rgbx8888") << int(QImage::Format_RGB888) << 0xffff0000 << int(QImage::Format_RGBX8888) << 0xffff0000; QTest::newRow("green rgb888 -> rgbx8888") << int(QImage::Format_RGB888) << 0xff00ff00 @@ -1338,6 +1354,12 @@ void tst_QImage::setPixel_data() << 0xff00ff00 << 0x00ff00u; QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888) << 0xff0000ff << 0x0000ffu; + QTest::newRow("BGR888 red") << int(QImage::Format_BGR888) + << 0xffff0000 << 0x0000ffu; + QTest::newRow("BGR888 green") << int(QImage::Format_BGR888) + << 0xff00ff00 << 0x00ff00u; + QTest::newRow("BGR888 blue") << int(QImage::Format_BGR888) + << 0xff0000ff << 0xff0000u; #if Q_BYTE_ORDER == Q_BIG_ENDIAN QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) << 0xffff0000u << 0xff0000ffu; @@ -1425,6 +1447,7 @@ void tst_QImage::setPixel() case int(QImage::Format_ARGB8565_Premultiplied): case int(QImage::Format_ARGB8555_Premultiplied): case int(QImage::Format_RGB888): + case int(QImage::Format_BGR888): { for (int y = 0; y < h; ++y) { const quint24 *row = (const quint24*)(img.scanLine(y)); @@ -2445,6 +2468,7 @@ void tst_QImage::mirrored_data() QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false << 16 << 16; QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false << 16 << 16; QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false << 16 << 16; + QTest::newRow("Format_BGR888, vertical") << QImage::Format_BGR888 << true << false << 16 << 16; QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false << 16 << 16; QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false << 16 << 16; QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false << 16 << 16; diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index eeabfd0413..f6ffd7b7c5 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1863,6 +1863,7 @@ void tst_QImageReader::saveFormat_data() QTest::newRow("Format_RGB555") << QImage::Format_RGB555; QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Format_BGR888") << QImage::Format_BGR888; QTest::newRow("Format_RGB444") << QImage::Format_RGB444; QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied; QTest::newRow("Format_RGBA64") << QImage::Format_RGBA64; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 0efeb9b356..61867ec65a 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -1637,6 +1637,7 @@ void tst_QPainter::qimageFormats_data() QTest::newRow("Qimage::Format_RGB555") << QImage::Format_RGB555; QTest::newRow("Qimage::Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Qimage::Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Qimage::Format_BGR888") << QImage::Format_BGR888; QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied; QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30; } -- cgit v1.2.3 From 77de5a329c98c3787725cb3c0a50d8f369b9479c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Aug 2014 22:37:13 +0200 Subject: Long live QColorConstants! QColorConstant is a C++11 version of Qt::GlobalColor, except that instead of Qt::red being an enum, QColorConstants::red is an actual QColor instance, a bit like in the Qt 3 days. In addition, the SVG names that QColor understands are also available, with the same values. Technically, when building a QColor from a color name, QColor ignores casing and whitespaces; we stick to the SVG/CSS official color names (which are lowercase), and prefix them with Svg to clarify where they come from. For instance, note how SVG's gray is not Qt::gray. [ChangeLog][QtGui][[QColor] Added QColorConstants, a namespace containing constexpr QColor instances. Change-Id: Ic9fab26a9a537fcc43cc230da28f4c6314a32438 Reviewed-by: Marc Mutz --- tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 189 ++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 90a216e14a..6c66519dce 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -64,6 +64,10 @@ private slots: void globalColors_data(); void globalColors(); +#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) + void colorConstants_data(); + void colorConstants(); +#endif void setRed(); void setGreen(); @@ -368,6 +372,191 @@ void tst_QColor::globalColors() QCOMPARE(color.rgba(), argb); } +#if defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) +void tst_QColor::colorConstants_data() +{ + QTest::addColumn("color"); + QTest::addColumn("argb"); + + QTest::newRow("invalid") << QColor() << 0xff000000; + QTest::newRow("global color color0") << QColorConstants::Color0 << 0xff000000u; + QTest::newRow("global color color1") << QColorConstants::Color1 << 0xffffffffu; + QTest::newRow("global color black") << QColorConstants::Black << 0xff000000u; + QTest::newRow("global color white") << QColorConstants::White << 0xffffffffu; + QTest::newRow("global color darkGray") << QColorConstants::DarkGray << 0xff808080u; + QTest::newRow("global color gray") << QColorConstants::Gray << 0xffa0a0a4u; + QTest::newRow("global color lightGray") << QColorConstants::LightGray << 0xffc0c0c0u; + QTest::newRow("global color red") << QColorConstants::Red << 0xffff0000u; + QTest::newRow("global color green") << QColorConstants::Green << 0xff00ff00u; + QTest::newRow("global color blue") << QColorConstants::Blue << 0xff0000ffu; + QTest::newRow("global color cyan") << QColorConstants::Cyan << 0xff00ffffu; + QTest::newRow("global color magenta") << QColorConstants::Magenta << 0xffff00ffu; + QTest::newRow("global color yellow") << QColorConstants::Yellow << 0xffffff00u; + QTest::newRow("global color darkRed") << QColorConstants::DarkRed << 0xff800000u; + QTest::newRow("global color darkGreen") << QColorConstants::DarkGreen << 0xff008000u; + QTest::newRow("global color darkBlue") << QColorConstants::DarkBlue << 0xff000080u; + QTest::newRow("global color darkCyan") << QColorConstants::DarkCyan << 0xff008080u; + QTest::newRow("global color darkMagenta") << QColorConstants::DarkMagenta << 0xff800080u; + QTest::newRow("global color darkYellow") << QColorConstants::DarkYellow << 0xff808000u; + QTest::newRow("global color transparent") << QColorConstants::Transparent << 0x00000000u; + + QTest::newRow("SVG aliceblue") << QColorConstants::Svg::aliceblue << 0xfff0f8ffu; + QTest::newRow("SVG antiquewhite") << QColorConstants::Svg::antiquewhite << 0xfffaebd7u; + QTest::newRow("SVG aqua") << QColorConstants::Svg::aqua << 0xff00ffffu; + QTest::newRow("SVG aquamarine") << QColorConstants::Svg::aquamarine << 0xff7fffd4u; + QTest::newRow("SVG azure") << QColorConstants::Svg::azure << 0xfff0ffffu; + QTest::newRow("SVG beige") << QColorConstants::Svg::beige << 0xfff5f5dcu; + QTest::newRow("SVG bisque") << QColorConstants::Svg::bisque << 0xffffe4c4u; + QTest::newRow("SVG black") << QColorConstants::Svg::black << 0xff000000u; + QTest::newRow("SVG blanchedalmond") << QColorConstants::Svg::blanchedalmond << 0xffffebcdu; + QTest::newRow("SVG blue") << QColorConstants::Svg::blue << 0xff0000ffu; + QTest::newRow("SVG blueviolet") << QColorConstants::Svg::blueviolet << 0xff8a2be2u; + QTest::newRow("SVG brown") << QColorConstants::Svg::brown << 0xffa52a2au; + QTest::newRow("SVG burlywood") << QColorConstants::Svg::burlywood << 0xffdeb887u; + QTest::newRow("SVG cadetblue") << QColorConstants::Svg::cadetblue << 0xff5f9ea0u; + QTest::newRow("SVG chartreuse") << QColorConstants::Svg::chartreuse << 0xff7fff00u; + QTest::newRow("SVG chocolate") << QColorConstants::Svg::chocolate << 0xffd2691eu; + QTest::newRow("SVG coral") << QColorConstants::Svg::coral << 0xffff7f50u; + QTest::newRow("SVG cornflowerblue") << QColorConstants::Svg::cornflowerblue << 0xff6495edu; + QTest::newRow("SVG cornsilk") << QColorConstants::Svg::cornsilk << 0xfffff8dcu; + QTest::newRow("SVG crimson") << QColorConstants::Svg::crimson << 0xffdc143cu; + QTest::newRow("SVG cyan") << QColorConstants::Svg::cyan << 0xff00ffffu; + QTest::newRow("SVG darkblue") << QColorConstants::Svg::darkblue << 0xff00008bu; + QTest::newRow("SVG darkcyan") << QColorConstants::Svg::darkcyan << 0xff008b8bu; + QTest::newRow("SVG darkgoldenrod") << QColorConstants::Svg::darkgoldenrod << 0xffb8860bu; + QTest::newRow("SVG darkgray") << QColorConstants::Svg::darkgray << 0xffa9a9a9u; + QTest::newRow("SVG darkgreen") << QColorConstants::Svg::darkgreen << 0xff006400u; + QTest::newRow("SVG darkgrey") << QColorConstants::Svg::darkgrey << 0xffa9a9a9u; + QTest::newRow("SVG darkkhaki") << QColorConstants::Svg::darkkhaki << 0xffbdb76bu; + QTest::newRow("SVG darkmagenta") << QColorConstants::Svg::darkmagenta << 0xff8b008bu; + QTest::newRow("SVG darkolivegreen") << QColorConstants::Svg::darkolivegreen << 0xff556b2fu; + QTest::newRow("SVG darkorange") << QColorConstants::Svg::darkorange << 0xffff8c00u; + QTest::newRow("SVG darkorchid") << QColorConstants::Svg::darkorchid << 0xff9932ccu; + QTest::newRow("SVG darkred") << QColorConstants::Svg::darkred << 0xff8b0000u; + QTest::newRow("SVG darksalmon") << QColorConstants::Svg::darksalmon << 0xffe9967au; + QTest::newRow("SVG darkseagreen") << QColorConstants::Svg::darkseagreen << 0xff8fbc8fu; + QTest::newRow("SVG darkslateblue") << QColorConstants::Svg::darkslateblue << 0xff483d8bu; + QTest::newRow("SVG darkslategray") << QColorConstants::Svg::darkslategray << 0xff2f4f4fu; + QTest::newRow("SVG darkslategrey") << QColorConstants::Svg::darkslategrey << 0xff2f4f4fu; + QTest::newRow("SVG darkturquoise") << QColorConstants::Svg::darkturquoise << 0xff00ced1u; + QTest::newRow("SVG darkviolet") << QColorConstants::Svg::darkviolet << 0xff9400d3u; + QTest::newRow("SVG deeppink") << QColorConstants::Svg::deeppink << 0xffff1493u; + QTest::newRow("SVG deepskyblue") << QColorConstants::Svg::deepskyblue << 0xff00bfffu; + QTest::newRow("SVG dimgray") << QColorConstants::Svg::dimgray << 0xff696969u; + QTest::newRow("SVG dimgrey") << QColorConstants::Svg::dimgrey << 0xff696969u; + QTest::newRow("SVG dodgerblue") << QColorConstants::Svg::dodgerblue << 0xff1e90ffu; + QTest::newRow("SVG firebrick") << QColorConstants::Svg::firebrick << 0xffb22222u; + QTest::newRow("SVG floralwhite") << QColorConstants::Svg::floralwhite << 0xfffffaf0u; + QTest::newRow("SVG forestgreen") << QColorConstants::Svg::forestgreen << 0xff228b22u; + QTest::newRow("SVG fuchsia") << QColorConstants::Svg::fuchsia << 0xffff00ffu; + QTest::newRow("SVG gainsboro") << QColorConstants::Svg::gainsboro << 0xffdcdcdcu; + QTest::newRow("SVG ghostwhite") << QColorConstants::Svg::ghostwhite << 0xfff8f8ffu; + QTest::newRow("SVG gold") << QColorConstants::Svg::gold << 0xffffd700u; + QTest::newRow("SVG goldenrod") << QColorConstants::Svg::goldenrod << 0xffdaa520u; + QTest::newRow("SVG gray") << QColorConstants::Svg::gray << 0xff808080u; + QTest::newRow("SVG green") << QColorConstants::Svg::green << 0xff008000u; + QTest::newRow("SVG greenyellow") << QColorConstants::Svg::greenyellow << 0xffadff2fu; + QTest::newRow("SVG grey") << QColorConstants::Svg::grey << 0xff808080u; + QTest::newRow("SVG honeydew") << QColorConstants::Svg::honeydew << 0xfff0fff0u; + QTest::newRow("SVG hotpink") << QColorConstants::Svg::hotpink << 0xffff69b4u; + QTest::newRow("SVG indianred") << QColorConstants::Svg::indianred << 0xffcd5c5cu; + QTest::newRow("SVG indigo") << QColorConstants::Svg::indigo << 0xff4b0082u; + QTest::newRow("SVG ivory") << QColorConstants::Svg::ivory << 0xfffffff0u; + QTest::newRow("SVG khaki") << QColorConstants::Svg::khaki << 0xfff0e68cu; + QTest::newRow("SVG lavender") << QColorConstants::Svg::lavender << 0xffe6e6fau; + QTest::newRow("SVG lavenderblush") << QColorConstants::Svg::lavenderblush << 0xfffff0f5u; + QTest::newRow("SVG lawngreen") << QColorConstants::Svg::lawngreen << 0xff7cfc00u; + QTest::newRow("SVG lemonchiffon") << QColorConstants::Svg::lemonchiffon << 0xfffffacdu; + QTest::newRow("SVG lightblue") << QColorConstants::Svg::lightblue << 0xffadd8e6u; + QTest::newRow("SVG lightcoral") << QColorConstants::Svg::lightcoral << 0xfff08080u; + QTest::newRow("SVG lightcyan") << QColorConstants::Svg::lightcyan << 0xffe0ffffu; + QTest::newRow("SVG lightgoldenrodyellow") << QColorConstants::Svg::lightgoldenrodyellow << 0xfffafad2u; + QTest::newRow("SVG lightgray") << QColorConstants::Svg::lightgray << 0xffd3d3d3u; + QTest::newRow("SVG lightgreen") << QColorConstants::Svg::lightgreen << 0xff90ee90u; + QTest::newRow("SVG lightgrey") << QColorConstants::Svg::lightgrey << 0xffd3d3d3u; + QTest::newRow("SVG lightpink") << QColorConstants::Svg::lightpink << 0xffffb6c1u; + QTest::newRow("SVG lightsalmon") << QColorConstants::Svg::lightsalmon << 0xffffa07au; + QTest::newRow("SVG lightseagreen") << QColorConstants::Svg::lightseagreen << 0xff20b2aau; + QTest::newRow("SVG lightskyblue") << QColorConstants::Svg::lightskyblue << 0xff87cefau; + QTest::newRow("SVG lightslategray") << QColorConstants::Svg::lightslategray << 0xff778899u; + QTest::newRow("SVG lightslategrey") << QColorConstants::Svg::lightslategrey << 0xff778899u; + QTest::newRow("SVG lightsteelblue") << QColorConstants::Svg::lightsteelblue << 0xffb0c4deu; + QTest::newRow("SVG lightyellow") << QColorConstants::Svg::lightyellow << 0xffffffe0u; + QTest::newRow("SVG lime") << QColorConstants::Svg::lime << 0xff00ff00u; + QTest::newRow("SVG limegreen") << QColorConstants::Svg::limegreen << 0xff32cd32u; + QTest::newRow("SVG linen") << QColorConstants::Svg::linen << 0xfffaf0e6u; + QTest::newRow("SVG magenta") << QColorConstants::Svg::magenta << 0xffff00ffu; + QTest::newRow("SVG maroon") << QColorConstants::Svg::maroon << 0xff800000u; + QTest::newRow("SVG mediumaquamarine") << QColorConstants::Svg::mediumaquamarine << 0xff66cdaau; + QTest::newRow("SVG mediumblue") << QColorConstants::Svg::mediumblue << 0xff0000cdu; + QTest::newRow("SVG mediumorchid") << QColorConstants::Svg::mediumorchid << 0xffba55d3u; + QTest::newRow("SVG mediumpurple") << QColorConstants::Svg::mediumpurple << 0xff9370dbu; + QTest::newRow("SVG mediumseagreen") << QColorConstants::Svg::mediumseagreen << 0xff3cb371u; + QTest::newRow("SVG mediumslateblue") << QColorConstants::Svg::mediumslateblue << 0xff7b68eeu; + QTest::newRow("SVG mediumspringgreen") << QColorConstants::Svg::mediumspringgreen << 0xff00fa9au; + QTest::newRow("SVG mediumturquoise") << QColorConstants::Svg::mediumturquoise << 0xff48d1ccu; + QTest::newRow("SVG mediumvioletred") << QColorConstants::Svg::mediumvioletred << 0xffc71585u; + QTest::newRow("SVG midnightblue") << QColorConstants::Svg::midnightblue << 0xff191970u; + QTest::newRow("SVG mintcream") << QColorConstants::Svg::mintcream << 0xfff5fffau; + QTest::newRow("SVG mistyrose") << QColorConstants::Svg::mistyrose << 0xffffe4e1u; + QTest::newRow("SVG moccasin") << QColorConstants::Svg::moccasin << 0xffffe4b5u; + QTest::newRow("SVG navajowhite") << QColorConstants::Svg::navajowhite << 0xffffdeadu; + QTest::newRow("SVG navy") << QColorConstants::Svg::navy << 0xff000080u; + QTest::newRow("SVG oldlace") << QColorConstants::Svg::oldlace << 0xfffdf5e6u; + QTest::newRow("SVG olive") << QColorConstants::Svg::olive << 0xff808000u; + QTest::newRow("SVG olivedrab") << QColorConstants::Svg::olivedrab << 0xff6b8e23u; + QTest::newRow("SVG orange") << QColorConstants::Svg::orange << 0xffffa500u; + QTest::newRow("SVG orangered") << QColorConstants::Svg::orangered << 0xffff4500u; + QTest::newRow("SVG orchid") << QColorConstants::Svg::orchid << 0xffda70d6u; + QTest::newRow("SVG palegoldenrod") << QColorConstants::Svg::palegoldenrod << 0xffeee8aau; + QTest::newRow("SVG palegreen") << QColorConstants::Svg::palegreen << 0xff98fb98u; + QTest::newRow("SVG paleturquoise") << QColorConstants::Svg::paleturquoise << 0xffafeeeeu; + QTest::newRow("SVG palevioletred") << QColorConstants::Svg::palevioletred << 0xffdb7093u; + QTest::newRow("SVG papayawhip") << QColorConstants::Svg::papayawhip << 0xffffefd5u; + QTest::newRow("SVG peachpuff") << QColorConstants::Svg::peachpuff << 0xffffdab9u; + QTest::newRow("SVG peru") << QColorConstants::Svg::peru << 0xffcd853fu; + QTest::newRow("SVG pink") << QColorConstants::Svg::pink << 0xffffc0cbu; + QTest::newRow("SVG plum") << QColorConstants::Svg::plum << 0xffdda0ddu; + QTest::newRow("SVG powderblue") << QColorConstants::Svg::powderblue << 0xffb0e0e6u; + QTest::newRow("SVG purple") << QColorConstants::Svg::purple << 0xff800080u; + QTest::newRow("SVG red") << QColorConstants::Svg::red << 0xffff0000u; + QTest::newRow("SVG rosybrown") << QColorConstants::Svg::rosybrown << 0xffbc8f8fu; + QTest::newRow("SVG royalblue") << QColorConstants::Svg::royalblue << 0xff4169e1u; + QTest::newRow("SVG saddlebrown") << QColorConstants::Svg::saddlebrown << 0xff8b4513u; + QTest::newRow("SVG salmon") << QColorConstants::Svg::salmon << 0xfffa8072u; + QTest::newRow("SVG sandybrown") << QColorConstants::Svg::sandybrown << 0xfff4a460u; + QTest::newRow("SVG seagreen") << QColorConstants::Svg::seagreen << 0xff2e8b57u; + QTest::newRow("SVG seashell") << QColorConstants::Svg::seashell << 0xfffff5eeu; + QTest::newRow("SVG sienna") << QColorConstants::Svg::sienna << 0xffa0522du; + QTest::newRow("SVG silver") << QColorConstants::Svg::silver << 0xffc0c0c0u; + QTest::newRow("SVG skyblue") << QColorConstants::Svg::skyblue << 0xff87ceebu; + QTest::newRow("SVG slateblue") << QColorConstants::Svg::slateblue << 0xff6a5acdu; + QTest::newRow("SVG slategray") << QColorConstants::Svg::slategray << 0xff708090u; + QTest::newRow("SVG slategrey") << QColorConstants::Svg::slategrey << 0xff708090u; + QTest::newRow("SVG snow") << QColorConstants::Svg::snow << 0xfffffafau; + QTest::newRow("SVG springgreen") << QColorConstants::Svg::springgreen << 0xff00ff7fu; + QTest::newRow("SVG steelblue") << QColorConstants::Svg::steelblue << 0xff4682b4u; + QTest::newRow("SVG tan") << QColorConstants::Svg::tan << 0xffd2b48cu; + QTest::newRow("SVG teal") << QColorConstants::Svg::teal << 0xff008080u; + QTest::newRow("SVG thistle") << QColorConstants::Svg::thistle << 0xffd8bfd8u; + QTest::newRow("SVG tomato") << QColorConstants::Svg::tomato << 0xffff6347u; + QTest::newRow("SVG turquoise") << QColorConstants::Svg::turquoise << 0xff40e0d0u; + QTest::newRow("SVG violet") << QColorConstants::Svg::violet << 0xffee82eeu; + QTest::newRow("SVG wheat") << QColorConstants::Svg::wheat << 0xfff5deb3u; + QTest::newRow("SVG white") << QColorConstants::Svg::white << 0xffffffffu; + QTest::newRow("SVG whitesmoke") << QColorConstants::Svg::whitesmoke << 0xfff5f5f5u; + QTest::newRow("SVG yellow") << QColorConstants::Svg::yellow << 0xffffff00u; + QTest::newRow("SVG yellowgreen") << QColorConstants::Svg::yellowgreen << 0xff9acd32u; +} + +void tst_QColor::colorConstants() +{ + QFETCH(QColor, color); + QFETCH(QRgb, argb); + QCOMPARE(color.rgba(), argb); +} +#endif // defined(Q_COMPILER_CONSTEXPR) & defined(Q_COMPILER_UNIFORM_INIT) + /* CSS color names = SVG 1.0 color names + transparent (rgba(0,0,0,0)) */ -- cgit v1.2.3 From 81408c0e76616b127c46779dc14bbcf084a3d87b Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Mon, 19 Aug 2019 14:20:11 +0300 Subject: QEventDispatcherWin32: avoid livelock in a foreign event loop According to Windows docs, GetMessage() function retrieves the messages from the input queue in defined order, where posted messages are processed ahead of input messages, even if they were posted later. Therefore, if the application produces a posted event permanently, as a result of processing that event, user input messages may be blocked due to hard CPU usage by the application. It's not a problem, if an internal Qt event loop is running. By calling sendPostedEvents() on the beginning of processEvents(), we are sending posted events only once per iteration. However, during execution of the foreign loop, we should artificially lower the priority of the WM_QT_SENDPOSTEDEVENTS message in order to enable delivery of other input messages. To solve the problem, it is proposed to postpone the WM_QT_SENDPOSTEDEVENTS message until the message queue becomes empty, as it works for the internal loop. Task-number: QTBUG-77464 Change-Id: I8dedb6837c6fc41aa6f497e67ab2352c2b4f3772 Reviewed-by: Laszlo Agocs --- .../gui/kernel/noqteventloop/tst_noqteventloop.cpp | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 19c5c8a4a0..3d1876f00f 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -49,7 +50,7 @@ class tst_NoQtEventLoop : public QObject private slots: void consumeMouseEvents(); void consumeSocketEvents(); - + void deliverEventsInLivelock(); }; class Window : public QRasterWindow @@ -312,6 +313,34 @@ void tst_NoQtEventLoop::consumeSocketEvents() QVERIFY(server.hasPendingConnections()); } +void tst_NoQtEventLoop::deliverEventsInLivelock() +{ + int argc = 1; + char *argv[] = { const_cast("test"), 0 }; + QGuiApplication app(argc, argv); + + QTimer livelockTimer; + livelockTimer.start(0); + QTimer::singleShot(100, Qt::CoarseTimer, &livelockTimer, &QTimer::stop); + + QElapsedTimer elapsedTimer; + elapsedTimer.start(); + + // Exec own message loop + MSG msg; + forever { + if (elapsedTimer.hasExpired(3000) || !livelockTimer.isActive()) + break; + + if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } + + QVERIFY(!livelockTimer.isActive()); +} + #include QTEST_APPLESS_MAIN(tst_NoQtEventLoop) -- cgit v1.2.3 From c8d3eb35e73e650e73fcc47c78af6d86ff58bfd9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 12 Jul 2019 15:02:09 +0200 Subject: Fixup move semantics of QColorSpace Stop using QExplicitlySharedDataPointer, makes it possible to inline the move constructor and assign operator. Also protect other methods from nullptr d_ptr, and change the default constructed value to also have a null d_ptr, to match the result after a move. Change-Id: I40928feef90cc956ef84d0516a77b0ee0f8986c7 Reviewed-by: Allan Sandfeld Jensen --- .../gui/painting/qcolorspace/tst_qcolorspace.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index bc1a45013c..9e13dc80b4 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -47,6 +47,7 @@ public: tst_QColorSpace(); private slots: + void movable(); void namedColorSpaces_data(); void namedColorSpaces(); @@ -75,6 +76,28 @@ tst_QColorSpace::tst_QColorSpace() { } +void tst_QColorSpace::movable() +{ + QColorSpace cs1 = QColorSpace::SRgb; + QColorSpace cs2 = QColorSpace::SRgbLinear; + QVERIFY(cs1.isValid()); + QVERIFY(cs2.isValid()); + QCOMPARE(cs1.colorSpaceId(), QColorSpace::SRgb); + + cs2 = std::move(cs1); + QVERIFY(!cs1.isValid()); + QVERIFY(cs2.isValid()); + QCOMPARE(cs2.colorSpaceId(), QColorSpace::SRgb); + QCOMPARE(cs1.colorSpaceId(), QColorSpace::Undefined); + QCOMPARE(cs1, QColorSpace()); + + QColorSpace cs3(std::move(cs2)); + QVERIFY(!cs2.isValid()); + QVERIFY(cs3.isValid()); + QCOMPARE(cs3.colorSpaceId(), QColorSpace::SRgb); + QCOMPARE(cs2.colorSpaceId(), QColorSpace::Undefined); +} + void tst_QColorSpace::namedColorSpaces_data() { QTest::addColumn("colorSpaceId"); -- cgit v1.2.3