diff options
Diffstat (limited to 'tests/auto/gui')
17 files changed, 299 insertions, 72 deletions
diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro index 87aea70acb..b6c55c5eaa 100644 --- a/tests/auto/gui/gui.pro +++ b/tests/auto/gui/gui.pro @@ -8,3 +8,5 @@ SUBDIRS=\ text \ util \ itemmodels \ + +!contains(QT_CONFIG, opengl(es1|es2)?): SUBDIRS -= qopengl diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2cd5216c59..7fdb2f4cba 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -728,6 +728,24 @@ void tst_QImage::convertToFormat_data() << int(QImage::Format_RGB888) << 0xffffffffu; QTest::newRow("semiblack pm -> rgb888") << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u << int(QImage::Format_RGB888) << 0xff000000u; + + QTest::newRow("red rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xffff0000 + << int(QImage::Format_ARGB32) << 0xffff0000; + QTest::newRow("green rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff00ff00 + << int(QImage::Format_ARGB32) << 0xff00ff00; + QTest::newRow("blue rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff0000ff + << int(QImage::Format_ARGB32) << 0xff0000ff; + + QTest::newRow("semired rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fff0000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f0000u; + QTest::newRow("semigreen rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f00ff00u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f007f00u; + QTest::newRow("semiblue rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f0000ffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f00007fu; + QTest::newRow("semiwhite rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fffffffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f7f7fu; + QTest::newRow("semiblack rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f000000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u; } @@ -953,6 +971,10 @@ void tst_QImage::rotate_data() << QImage::Format_RGB888 << d; QTest::newRow(qPrintable(title.arg("Format_Indexed8"))) << QImage::Format_Indexed8 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBX8888"))) + << QImage::Format_RGBX8888 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied"))) + << QImage::Format_RGBA8888_Premultiplied << d; } } @@ -1161,6 +1183,21 @@ void tst_QImage::setPixel_data() << 0xff00ff00 << 0x00ff00u; QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888) << 0xff0000ff << 0x0000ffu; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0x00ff00ffu; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0x0000ffffu; +#else + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0xff00ff00u; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0xffff0000u; +#endif } void tst_QImage::setPixel() @@ -1184,6 +1221,9 @@ void tst_QImage::setPixel() case int(QImage::Format_RGB32): case int(QImage::Format_ARGB32): case int(QImage::Format_ARGB32_Premultiplied): + case int(QImage::Format_RGBX8888): + case int(QImage::Format_RGBA8888): + case int(QImage::Format_RGBA8888_Premultiplied): { for (int y = 0; y < h; ++y) { const quint32 *row = (const quint32*)(img.scanLine(y)); @@ -1901,6 +1941,8 @@ void tst_QImage::fillColor_data() "RGB888", "RGB444", "ARGB4444pm", + "RGBx8888", + "RGBA8888pm", 0 }; @@ -1917,7 +1959,9 @@ void tst_QImage::fillColor_data() QImage::Format_ARGB8555_Premultiplied, QImage::Format_RGB888, QImage::Format_RGB444, - QImage::Format_ARGB4444_Premultiplied + QImage::Format_ARGB4444_Premultiplied, + QImage::Format_RGBX8888, + QImage::Format_RGBA8888_Premultiplied, }; for (int i=0; names[i] != 0; ++i) { @@ -1935,6 +1979,7 @@ void tst_QImage::fillColor_data() QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << Qt::transparent << 0xff000000; QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << Qt::transparent << 0x00000000u; QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << Qt::transparent << 0x00000000u; + QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << Qt::transparent << 0x00000000u; } void tst_QImage::fillColor() @@ -2013,6 +2058,8 @@ void tst_QImage::rgbSwapped_data() QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_RGB888") << QImage::Format_RGB888; QTest::newRow("Format_RGB444") << QImage::Format_RGB444; + QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888; + QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied; } void tst_QImage::rgbSwapped() diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 0d0a300eac..e4d9ce9d27 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -24,3 +24,6 @@ SUBDIRS=\ !qtHaveModule(widgets): SUBDIRS -= \ qmouseevent_modal \ qtouchevent + +!qtHaveModule(network): SUBDIRS -= \ + qguieventloop diff --git a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro index c3113ed4b1..211be4c1c0 100644 --- a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro +++ b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qbackingstore QT += core-private gui-private testlib diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 89807f3747..cf786c1dca 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -196,6 +196,7 @@ void tst_QClipboard::testSignals() #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) static bool runHelper(const QString &program, const QStringList &arguments, QByteArray *errorMessage) { +#ifndef QT_NO_PROCESS QProcess process; process.setReadChannelMode(QProcess::ForwardedChannels); process.start(program, arguments); @@ -231,6 +232,12 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt return false; } return true; +#else // QT_NO_PROCESS + Q_UNUSED(program) + Q_UNUSED(arguments) + Q_UNUSED(errorMessage) + return false; +#endif // QT_NO_PROCESS } // Test that pasted text remains on the clipboard after a Qt application exits. diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 663f664d94..0f224c4909 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -765,7 +765,7 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() QStaticPlugin testPluginInfo; testPluginInfo.instance = qt_plugin_instance; - testPluginInfo.metaData = qt_plugin_query_metadata; + testPluginInfo.rawMetaData = qt_plugin_query_metadata; qRegisterStaticPluginFunction(testPluginInfo); int argc = 3; char *argv[] = { const_cast<char*>("tst_qguiapplication"), const_cast<char*>("-plugin"), const_cast<char*>("testplugin") }; diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 75aed3bf8b..6fdf3dc843 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -636,7 +636,7 @@ void tst_QGuiVariant::implicitConstruction() // This is a compile-time test QVariant v; -#define FOR_EACH_GUI_CLASS(F) \ +#define FOR_EACH_GUI_CLASS_BASE(F) \ F(Font) \ F(Pixmap) \ F(Brush) \ @@ -647,7 +647,6 @@ void tst_QGuiVariant::implicitConstruction() F(Polygon) \ F(Region) \ F(Bitmap) \ - F(Cursor) \ F(KeySequence) \ F(Pen) \ F(TextLength) \ @@ -659,7 +658,16 @@ void tst_QGuiVariant::implicitConstruction() F(Vector3D) \ F(Vector4D) \ F(Quaternion) \ - F(PolygonF) \ + F(PolygonF) + +#ifndef QTEST_NO_CURSOR +# define FOR_EACH_GUI_CLASS(F) \ + FOR_EACH_GUI_CLASS_BASE(F) \ + F(Cursor) +#else // !QTEST_NO_CURSOR +# define FOR_EACH_GUI_CLASS(F) \ + FOR_EACH_GUI_CLASS_BASE(F) +#endif // QTEST_NO_CURSOR #define CONSTRUCT(TYPE) \ { \ diff --git a/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro b/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro index ff491c1e25..015cc782eb 100644 --- a/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro +++ b/tests/auto/gui/kernel/qinputmethod/qinputmethod.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qinputmethod SOURCES += tst_qinputmethod.cpp QT += core-private gui-private testlib diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 7cd8642f26..19fcb6ea9f 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <qkeysequence.h> #include <qpa/qplatformtheme.h> +#include <qpa/qplatformtheme_p.h> #include <private/qkeysequence_p.h> #include <private/qguiapplication_p.h> #include <QTranslator> @@ -306,16 +307,16 @@ void tst_QKeySequence::checkMultipleCodes() } /* -* We must ensure that the keyBindings data is always sorted +* We must ensure that the keyBindings data are always sorted by standardKey * so that we can safely perform binary searches. */ #ifdef QT_BUILD_INTERNAL void tst_QKeySequence::ensureSorted() { - uint N = QKeySequencePrivate::numberOfKeyBindings; - uint val = QKeySequencePrivate::keyBindings[0].shortcut; + uint N = QPlatformThemePrivate::numberOfKeyBindings; + uint val = QPlatformThemePrivate::keyBindings[0].standardKey; for ( uint i = 1 ; i < N ; ++i) { - uint nextval = QKeySequencePrivate::keyBindings[i].shortcut; + uint nextval = QPlatformThemePrivate::keyBindings[i].standardKey; if (nextval < val) qDebug() << "Data not sorted at index " << i; QVERIFY(nextval >= val); diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index 0041ad0015..57c4c094a2 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -57,6 +57,10 @@ private slots: void create3(); void create4(); + void modify2(); + void modify3(); + void modify4(); + void length2_data(); void length2(); void length3_data(); @@ -570,6 +574,82 @@ void tst_QVectorND::create4() QVERIFY(v14.isNull()); } +// Test modifying vectors in various ways +void tst_QVectorND::modify2() +{ + const float e = 2.7182818f; + const float pi = 3.14159f; + const QVector2D p(e, pi); + + QVector2D p1; + p1.setX(e); + p1.setY(pi); + QVERIFY(qFuzzyCompare(p, p1)); + + QVector2D p2; + p2[0] = e; + p2[1] = pi; + QVERIFY(qFuzzyCompare(p, p2)); + + QVector2D p3; + for (int i = 0; i < 2; ++i) + p3[i] = p[i]; + QVERIFY(qFuzzyCompare(p, p3)); +} + +void tst_QVectorND::modify3() +{ + const float one = 1.0f; + const float e = 2.7182818f; + const float pi = 3.14159f; + const QVector3D p(one, e, pi); + + QVector3D p1; + p1.setX(one); + p1.setY(e); + p1.setZ(pi); + QVERIFY(qFuzzyCompare(p, p1)); + + QVector3D p2; + p2[0] = one; + p2[1] = e; + p2[2] = pi; + QVERIFY(qFuzzyCompare(p, p2)); + + QVector3D p3; + for (int i = 0; i < 3; ++i) + p3[i] = p[i]; + QVERIFY(qFuzzyCompare(p, p3)); +} + +void tst_QVectorND::modify4() +{ + const float one = 1.0f; + const float e = 2.7182818f; + const float pi = 3.14159f; + const float big = 1.0e6f; + const QVector4D p(one, e, pi, big); + + QVector4D p1; + p1.setX(one); + p1.setY(e); + p1.setZ(pi); + p1.setW(big); + QVERIFY(qFuzzyCompare(p, p1)); + + QVector4D p2; + p2[0] = one; + p2[1] = e; + p2[2] = pi; + p2[3] = big; + QVERIFY(qFuzzyCompare(p, p2)); + + QVector4D p3; + for (int i = 0; i < 4; ++i) + p3[i] = p[i]; + QVERIFY(qFuzzyCompare(p, p3)); +} + // Test vector length computation for 2D vectors. void tst_QVectorND::length2_data() { diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 6fe7961545..1b1f5575b1 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -61,6 +61,8 @@ private slots: void name_data(); void name(); + void namehex_data(); + void namehex(); void setNamedColor(); void constructNamedColorWithSpace(); @@ -254,36 +256,75 @@ void tst_QColor::isValid() QVERIFY(color.isValid() == isValid); } +Q_DECLARE_METATYPE(QColor::NameFormat); + void tst_QColor::name_data() { QTest::addColumn<QColor>("color"); QTest::addColumn<QString>("name"); - - QTest::newRow("invalid") << QColor() << "#000000"; - QTest::newRow("global color black") << QColor(Qt::black) << "#000000"; - QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff"; - QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080"; - QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4"; - QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0"; - QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000"; - QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00"; - QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff"; - QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff"; - QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff"; - QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00"; - QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000"; - QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000"; - QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080"; - QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080"; - QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080"; - QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000"; + QTest::addColumn<QColor::NameFormat>("nameFormat"); + + QTest::newRow("invalid") << QColor() << "#000000" << QColor::HexRgb; + QTest::newRow("global color black") << QColor(Qt::black) << "#000000" << QColor::HexRgb; + QTest::newRow("global color white") << QColor(Qt::white) << "#ffffff" << QColor::HexRgb; + QTest::newRow("global color darkGray") << QColor(Qt::darkGray) << "#808080" << QColor::HexRgb; + QTest::newRow("global color gray") << QColor(Qt::gray) << "#a0a0a4" << QColor::HexRgb; + QTest::newRow("global color lightGray") << QColor(Qt::lightGray) << "#c0c0c0" << QColor::HexRgb; + QTest::newRow("global color red") << QColor(Qt::red) << "#ff0000" << QColor::HexRgb; + QTest::newRow("global color green") << QColor(Qt::green) << "#00ff00" << QColor::HexRgb; + QTest::newRow("global color blue") << QColor(Qt::blue) << "#0000ff" << QColor::HexRgb; + QTest::newRow("global color cyan") << QColor(Qt::cyan) << "#00ffff" << QColor::HexRgb; + QTest::newRow("global color magenta") << QColor(Qt::magenta) << "#ff00ff" << QColor::HexRgb; + QTest::newRow("global color yellow") << QColor(Qt::yellow) << "#ffff00" << QColor::HexRgb; + QTest::newRow("global color darkRed") << QColor(Qt::darkRed) << "#800000" << QColor::HexRgb; + QTest::newRow("global color darkGreen") << QColor(Qt::darkGreen) << "#008000" << QColor::HexRgb; + QTest::newRow("global color darkBlue") << QColor(Qt::darkBlue) << "#000080" << QColor::HexRgb; + QTest::newRow("global color darkCyan") << QColor(Qt::darkCyan) << "#008080" << QColor::HexRgb; + QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080" << QColor::HexRgb; + QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000" << QColor::HexRgb; + QTest::newRow("transparent red") << QColor(255, 0, 0, 102) << "#66ff0000" << QColor::HexArgb; } void tst_QColor::name() { QFETCH(QColor, color); QFETCH(QString, name); - QCOMPARE(color.name(), name); + QFETCH(QColor::NameFormat, nameFormat); + QCOMPARE(color.name(nameFormat), name); +} + +void tst_QColor::namehex_data() +{ + QTest::addColumn<QString>("hexcolor"); + QTest::addColumn<QColor>("color"); + + QTest::newRow("global color black") << "#000000" << QColor(Qt::black); + QTest::newRow("global color white") << "#ffffff" << QColor(Qt::white); + QTest::newRow("global color darkGray") << "#808080" << QColor(Qt::darkGray); + QTest::newRow("global color gray") << "#a0a0a4" << QColor(Qt::gray); + QTest::newRow("global color lightGray") << "#c0c0c0" << QColor(Qt::lightGray); + QTest::newRow("global color red") << "#ff0000" << QColor(Qt::red); + QTest::newRow("global color green") << "#00ff00" << QColor(Qt::green); + QTest::newRow("global color blue") << "#0000ff" << QColor(Qt::blue); + QTest::newRow("global color cyan") << "#00ffff" << QColor(Qt::cyan); + QTest::newRow("global color magenta") << "#ff00ff" << QColor(Qt::magenta); + QTest::newRow("global color yellow") << "#ffff00" << QColor(Qt::yellow); + QTest::newRow("global color darkRed") << "#800000" << QColor(Qt::darkRed); + QTest::newRow("global color darkGreen") << "#008000" << QColor(Qt::darkGreen); + QTest::newRow("global color darkBlue") << "#000080" << QColor(Qt::darkBlue); + QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan); + QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta); + QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow); + QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102); + QTest::newRow("invalid red") << "#gg0000" << QColor(); + QTest::newRow("invalid transparent") << "#gg00ff00" << QColor(); +} + +void tst_QColor::namehex() +{ + QFETCH(QString, hexcolor); + QFETCH(QColor, color); + QCOMPARE(QColor(hexcolor), color); } void tst_QColor::globalColors_data() diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 4f1213dff9..27c0f6e66a 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -79,6 +79,7 @@ Q_DECLARE_METATYPE(QGradientStops) Q_DECLARE_METATYPE(QPainterPath) +Q_DECLARE_METATYPE(QImage::Format) class tst_QPainter : public QObject { @@ -122,10 +123,15 @@ private slots: void drawRect(); void drawRect2(); + void fillRect_data(); void fillRect(); + void fillRect2_data(); void fillRect2(); + void fillRect3_data() { fillRect2_data(); } void fillRect3(); + void fillRect4_data() { fillRect2_data(); } void fillRect4(); + void fillRectNonPremul(); void drawEllipse_data(); void drawEllipse(); @@ -1079,9 +1085,19 @@ void tst_QPainter::drawRect2() } } +void tst_QPainter::fillRect_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; +} + void tst_QPainter::fillRect() { - QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); image.fill(QColor(0, 0, 0, 0).rgba()); QPainter p(&image); @@ -1103,17 +1119,29 @@ void tst_QPainter::fillRect() QRect(0, 0, 50, 100)); } +void tst_QPainter::fillRect2_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32") << QImage::Format_ARGB32; + QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("rgba8888") << QImage::Format_RGBA8888; + QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; +} + void tst_QPainter::fillRect2() { + QFETCH(QImage::Format, format); + QRgb background = 0x0; - QImage img(1, 20, QImage::Format_ARGB32_Premultiplied); + QImage img(1, 20, format); img.fill(background); QPainter p(&img); QRectF rect(0, 1, 1.2, 18); - p.fillRect(rect, Qt::black); + p.fillRect(rect, Qt::yellow); p.end(); @@ -1122,11 +1150,14 @@ void tst_QPainter::fillRect2() QCOMPARE(img.pixel(0, 1), img.pixel(0, 2)); QCOMPARE(img.pixel(0, img.height() - 2), img.pixel(0, img.height() - 3)); + QCOMPARE(img.pixel(0, 1), QColor(Qt::yellow).rgba()); } void tst_QPainter::fillRect3() { - QImage img(1, 1, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage img(1, 1, format); img.fill(QColor(Qt::black).rgba()); QPainter p(&img); @@ -1139,7 +1170,9 @@ void tst_QPainter::fillRect3() void tst_QPainter::fillRect4() { - QImage image(100, 1, QImage::Format_ARGB32_Premultiplied); + QFETCH(QImage::Format, format); + + QImage image(100, 1, format); image.fill(0x0); QImage expected = image; @@ -1157,6 +1190,24 @@ void tst_QPainter::fillRect4() QCOMPARE(image, expected); } +void tst_QPainter::fillRectNonPremul() +{ + QImage img1(1, 1, QImage::Format_ARGB32); + QImage img2(1, 1, QImage::Format_RGBA8888); + + QPainter p1(&img1); + QPainter p2(&img2); + + QRectF rect(0, 0, 1, 1); + p1.fillRect(rect, qRgba(31, 63, 127, 127)); + p2.fillRect(rect, qRgba(31, 63, 127, 127)); + + p1.end(); + p2.end(); + + QCOMPARE(img1.pixel(0, 0), img2.pixel(0,0)); +} + void tst_QPainter::drawPath_data() { QTest::addColumn<QPainterPath>("path"); @@ -1456,8 +1507,6 @@ void tst_QPainter::drawRoundRect() } } -Q_DECLARE_METATYPE(QImage::Format) - void tst_QPainter::qimageFormats_data() { QTest::addColumn<QImage::Format>("format"); @@ -2265,6 +2314,27 @@ void tst_QPainter::setOpacity_data() QTest::newRow("RGB444 on RGB444") << QImage::Format_RGB444 << QImage::Format_RGB444; + + QTest::newRow("RGBA8888P on RGBA8888P") << QImage::Format_RGBA8888_Premultiplied + << QImage::Format_RGBA8888_Premultiplied; + + QTest::newRow("RGBA8888 on RGBA8888") << QImage::Format_RGBA8888 + << QImage::Format_RGBA8888; + + QTest::newRow("RGBx8888 on RGBx8888") << QImage::Format_RGBX8888 + << QImage::Format_RGBX8888; + + QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_RGBA8888_Premultiplied + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_RGBX8888 + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBA8888_Premultiplied; + + QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32 + << QImage::Format_RGBX8888; } void tst_QPainter::setOpacity() @@ -2490,7 +2560,7 @@ public: } uchar data[3]; -} Q_PACKED; +}; void tst_QPainter::drawhelper_blend_color() { @@ -4373,9 +4443,6 @@ void TextDrawerThread::run() void tst_QPainter::drawTextOutsideGuiThread() { - if (!QFontDatabase::supportsThreadedFontRendering()) - QSKIP("No threaded font rendering"); - QImage referenceRendering(100, 100, QImage::Format_ARGB32_Premultiplied); referenceRendering.fill(0); QPainter p(&referenceRendering); diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index ca6c42c9bd..86e282fad2 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -344,8 +344,6 @@ void tst_QCssParser::term_data() val.variant = QVariant(QColor("#ffbb00")); QTest::newRow("hexcolor2") << true << "#fb0" << val; - QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val; - val.type = QCss::Value::Uri; val.variant = QString("www.kde.org"); QTest::newRow("uri1") << true << "url(\"www.kde.org\")" << val; @@ -367,9 +365,6 @@ void tst_QCssParser::term() QFETCH(QString, css); QFETCH(QCss::Value, expectedValue); - if (strcmp(QTest::currentDataTag(), "hexcolor_failure") == 0) - QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'"); - QCss::Parser parser(css); QCss::Value val; QVERIFY(parser.testTerm()); diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index acb55c2d86..aa5fa10a33 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -686,14 +686,6 @@ void tst_QFont::defaultFamily() } } -#if defined(Q_OS_MAC) - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) { - QEXPECT_FAIL("serif", "See QTBUG-32834", Continue); - QEXPECT_FAIL("monospace", "See QTBUG-32834", Continue); - QEXPECT_FAIL("cursive", "See QTBUG-32834", Continue); - QEXPECT_FAIL("fantasy", "See QTBUG-32834", Continue); - } -#endif QVERIFY2(isAcceptable, msgNotAcceptableFont(familyForHint, acceptableFamilies)); } diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index 37868dcfde..6975c4088b 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -2,8 +2,7 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qfontdatabase SOURCES += tst_qfontdatabase.cpp -QT += testlib -!mac: QT += core-private gui-private +QT += testlib core-private gui-private wince* { additionalFiles.files = FreeMono.ttf diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 9cf4082287..104d3465f2 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -44,6 +44,7 @@ #include <qfontdatabase.h> #include <qfontinfo.h> #include <qfontmetrics.h> +#include <qpa/qplatformfontdatabase.h> class tst_QFontDatabase : public QObject { @@ -252,11 +253,8 @@ void tst_QFontDatabase::addAppFont() return; #endif QCOMPARE(fontDbChangedSpy.count(), 1); -// addApplicationFont is supported on Mac, don't skip the test if it breaks. -#ifndef Q_OS_MAC if (id == -1) QSKIP("Skip the test since app fonts are not supported on this system"); -#endif const QStringList addedFamilies = QFontDatabase::applicationFontFamilies(id); QVERIFY(!addedFamilies.isEmpty()); @@ -271,16 +269,9 @@ void tst_QFontDatabase::addAppFont() QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); -#ifdef Q_OS_MAC - QEXPECT_FAIL("font file", "QTBUG-23062", Continue); -#endif QCOMPARE(db.families(), oldFamilies); } -QT_BEGIN_NAMESPACE -Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); -QT_END_NAMESPACE - void tst_QFontDatabase::aliases() { QFontDatabase db; @@ -290,7 +281,7 @@ void tst_QFontDatabase::aliases() QVERIFY(db.hasFamily(firstFont)); const QString alias = QStringLiteral("AliasToFirstFont") + firstFont; QVERIFY(!db.hasFamily(alias)); - qt_registerAliasToFontFamily(firstFont, alias); + QPlatformFontDatabase::registerAliasToFontFamily(firstFont, alias); QVERIFY(db.hasFamily(alias)); } diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 19f60baa29..ae6e450301 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -675,10 +675,6 @@ void tst_QRawFont::fromFont() QFontDatabase fontDatabase; int id = fontDatabase.addApplicationFont(fileName); -#ifdef Q_OS_MACX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("", "See QTBUG-32654", Abort); -#endif QVERIFY(id >= 0); QFont font(familyName); |