summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp4
-rw-r--r--tests/auto/gui/painting/qcolor/qcolor.pro2
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp32
3 files changed, 35 insertions, 3 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 997ceaf7b9..e525cd669d 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -2204,13 +2204,13 @@ void tst_QtJson::testDebugStream()
array.append(1);
array.append(QLatin1String("foo"));
value = QJsonValue(array); // array
- QTest::ignoreMessage(QtDebugMsg, "QJsonValue(array, QJsonArray([1,\"foo\"]) )");
+ QTest::ignoreMessage(QtDebugMsg, "QJsonValue(array, QJsonArray([1,\"foo\"]))");
qDebug() << value;
QJsonObject object;
object.insert(QLatin1String("foo"), QLatin1String("bar"));
value = QJsonValue(object); // object
- QTest::ignoreMessage(QtDebugMsg, "QJsonValue(object, QJsonObject({\"foo\":\"bar\"}) )");
+ QTest::ignoreMessage(QtDebugMsg, "QJsonValue(object, QJsonObject({\"foo\":\"bar\"}))");
qDebug() << value;
}
}
diff --git a/tests/auto/gui/painting/qcolor/qcolor.pro b/tests/auto/gui/painting/qcolor/qcolor.pro
index f7439c243c..44d65bb50b 100644
--- a/tests/auto/gui/painting/qcolor/qcolor.pro
+++ b/tests/auto/gui/painting/qcolor/qcolor.pro
@@ -2,4 +2,4 @@ CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qcolor
SOURCES += tst_qcolor.cpp
-QT += testlib
+QT += testlib gui-private core-private
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 3b3334ba1f..95f1da1354 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -38,6 +38,7 @@
#include <qcolor.h>
#include <qdebug.h>
+#include <private/qdrawingprimitive_sse2_p.h>
class tst_QColor : public QObject
{
@@ -102,6 +103,9 @@ private slots:
void achromaticHslHue();
+ void premultiply();
+ void unpremultiply_sse4();
+
#ifdef Q_DEAD_CODE_FROM_QT4_X11
void setallowX11ColorNames();
#endif
@@ -1432,5 +1436,33 @@ void tst_QColor::setallowX11ColorNames()
}
#endif
+void tst_QColor::premultiply()
+{
+ // Tests that qPremultiply(qUnpremultiply(x)) returns x.
+ for (uint a = 0; a < 256; a++) {
+ for (uint c = 0; c <= a; c++) {
+ QRgb p = qRgba(c, a-c, c, a);
+ QCOMPARE(p, qPremultiply(qUnpremultiply(p)));
+ }
+ }
+}
+
+void tst_QColor::unpremultiply_sse4()
+{
+ // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply.
+#if QT_COMPILER_SUPPORTS_HERE(SSE4_1)
+ if (qCpuHasFeature(SSE4_1)) {
+ for (uint a = 0; a < 256; a++) {
+ for (uint c = 0; c <= a; c++) {
+ QRgb p = qRgba(c, a-c, c, a);
+ QCOMPARE(qUnpremultiply(p), qUnpremultiply_sse4(p));
+ }
+ }
+ return;
+ }
+#endif
+ QSKIP("SSE4 not supported on this CPU.");
+}
+
QTEST_MAIN(tst_QColor)
#include "tst_qcolor.moc"