From 3b8df0ea44b048b8fcc4317ffdfd074e2547a95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Thu, 24 Mar 2016 23:50:24 +0100 Subject: QtWidgets: Send show/hide event to children on restore/minimize Child widgets should get the show/hide event when the TLW changes its state, because child widgets are also visible or invisible. This restores the Qt4 behavior (fixes the Qt4->Qt5 regression). Restoring/minimizing the TLW now sends the spontaneous show/hide event. Show events are now handled also in the expose event handler in the QWidgetWindow class, because the show event must occur before the expose event to avoid possible flicker e.g. the OpenGL content. This can happen e.g. on XCB platform. If the "WindowStateChange" event occur before the expose event (e.g. Windows platform) then the code in expose event handler will be ignored to prevent event duplications. Added autotest. Task-number: QTBUG-50589 Change-Id: Ie9a9329b1f29bff876de28d5948d0d5fb6bc1f05 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 48 ++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b7c152603c..34a1835413 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -294,6 +294,7 @@ private slots: void showHideEvent_data(); void showHideEvent(); void showHideEventWhileMinimize(); + void showHideChildrenWhileMinimize_QTBUG50589(); void lostUpdatesOnHide(); @@ -4078,19 +4079,30 @@ class ShowHideEventWidget : public QWidget { public: int numberOfShowEvents, numberOfHideEvents; + int numberOfSpontaneousShowEvents, numberOfSpontaneousHideEvents; ShowHideEventWidget(QWidget *parent = 0) - : QWidget(parent), numberOfShowEvents(0), numberOfHideEvents(0) + : QWidget(parent) + , numberOfShowEvents(0), numberOfHideEvents(0) + , numberOfSpontaneousShowEvents(0), numberOfSpontaneousHideEvents(0) { } void create() { QWidget::create(); } - void showEvent(QShowEvent *) - { ++numberOfShowEvents; } + void showEvent(QShowEvent *e) + { + ++numberOfShowEvents; + if (e->spontaneous()) + ++numberOfSpontaneousShowEvents; + } - void hideEvent(QHideEvent *) - { ++numberOfHideEvents; } + void hideEvent(QHideEvent *e) + { + ++numberOfHideEvents; + if (e->spontaneous()) + ++numberOfSpontaneousHideEvents; + } }; void tst_QWidget::showHideEvent_data() @@ -4182,6 +4194,32 @@ void tst_QWidget::showHideEventWhileMinimize() QTRY_COMPARE(widget.numberOfShowEvents, showEventsBeforeMinimize + 1); } +void tst_QWidget::showHideChildrenWhileMinimize_QTBUG50589() +{ + const QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); + if (!pi->hasCapability(QPlatformIntegration::MultipleWindows) + || !pi->hasCapability(QPlatformIntegration::NonFullScreenWindows) + || !pi->hasCapability(QPlatformIntegration::WindowManagement)) { + QSKIP("This test requires window management capabilities"); + } + + QWidget parent; + ShowHideEventWidget child(&parent); + + parent.setWindowTitle(QTest::currentTestFunction()); + parent.resize(m_testWidgetSize); + centerOnScreen(&parent); + parent.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); + + const int showEventsBeforeMinimize = child.numberOfSpontaneousShowEvents; + const int hideEventsBeforeMinimize = child.numberOfSpontaneousHideEvents; + parent.showMinimized(); + QTRY_COMPARE(child.numberOfSpontaneousHideEvents, hideEventsBeforeMinimize + 1); + parent.showNormal(); + QTRY_COMPARE(child.numberOfSpontaneousShowEvents, showEventsBeforeMinimize + 1); +} + void tst_QWidget::update() { #ifdef Q_OS_OSX -- cgit v1.2.3 From 3370ab9119df09ca14f7d4641c555e60c1b3f478 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 22 Aug 2016 14:32:05 +0200 Subject: Never return char variants when reading prepared MySQL statements This has undesired effects when converting a QSqlRecord to JSON. A char(0) e.g. has special semantics that are undesired when reading a Tinyint column. I don't think that returning bool for the special case of a Tinyint(1) is required. This also did not happen before, and is also not happening when not using a prepared statement. Instead, a plain int/uint QVariant is returned. This patch extends tst_QSqlQuery::integralTypesMysql to also cover reading and writing booleans from/to a MySQL table column of type Tinyint(1). Additionally, the reading is now also done with a prepared statement and we also check the raw variant value. The broken behavior fixed by this patch was introduced by me in commit 194403a3483b7317cc9511bc8b2ab307775643c5. Change-Id: I028a3abd83fdd2b42d98d478950d205e5b6bbeb5 Task-number: QTBUG-53397 Reviewed-by: Andy Shaw --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 45 ++++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index f1c4333ccd..ba3cfb243a 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -4007,12 +4007,14 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName)); QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")")); - const int steps = 20; - const T increment = max / steps - min / steps; + const int steps = (max == min + 1) ? 2 : 20; + const T increment = (max == min + 1) ? 1 : (max / steps - min / steps); // insert some values QVector values; + QVector variantValues; values.resize(steps); + variantValues.resize(steps); T v = min; if (withPreparedStatement) { QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)")); @@ -4025,17 +4027,30 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")")); } values[i] = v; + variantValues[i] = QVariant::fromValue(v); v += increment; } // ensure we can read them back properly - QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + if (withPreparedStatement) { + QVERIFY_SQL(q, prepare("SELECT id FROM " + tableName)); + QVERIFY_SQL(q, exec()); + } else { + QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + } QVector actualValues; + QVector actualVariantValues; actualValues.reserve(values.size()); while (q.next()) { - actualValues << q.value(0).value(); + QVariant value = q.value(0); + actualVariantValues << value; + actualValues << value.value(); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId()); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId()); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId()); } QCOMPARE(actualValues, values); + QCOMPARE(actualVariantValues, variantValues); } void tst_QSqlQuery::integralTypesMysql() @@ -4046,16 +4061,18 @@ void tst_QSqlQuery::integralTypesMysql() for (int i = 0; i < 2; ++i) { const bool withPreparedStatement = (i == 1); - runIntegralTypesMysqlTest(db, "tinyIntTest", "TINYINT", withPreparedStatement); - runIntegralTypesMysqlTest(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest(db, "smallIntTest", "SMALLINT", withPreparedStatement); - runIntegralTypesMysqlTest(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); - runIntegralTypesMysqlTest(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); - runIntegralTypesMysqlTest(db, "intTest", "INT", withPreparedStatement); - runIntegralTypesMysqlTest(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest(db, "bigIntTest", "BIGINT", withPreparedStatement); - runIntegralTypesMysqlTest(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement); + runIntegralTypesMysqlTest(db, "unsignedTinyInt1Test", "TINYINT(1) UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest(db, "tinyIntTest", "TINYINT", withPreparedStatement); + runIntegralTypesMysqlTest(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest(db, "smallIntTest", "SMALLINT", withPreparedStatement); + runIntegralTypesMysqlTest(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); + runIntegralTypesMysqlTest(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); + runIntegralTypesMysqlTest(db, "intTest", "INT", withPreparedStatement); + runIntegralTypesMysqlTest(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest(db, "bigIntTest", "BIGINT", withPreparedStatement); + runIntegralTypesMysqlTest(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); } } -- cgit v1.2.3 From 7a593c8c98462380b3bd77053bd0a4a35c2b31f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Thu, 18 Aug 2016 15:46:16 +0300 Subject: Blacklist selftest runSubTest This one selftest is currently blocking OS X 10.11 from entering the CI. It can't be reproduced when run manually. Task-number: QTBUG-55155 Change-Id: I4553ef2d7813b29f5dc8577976c4482686346504 Reviewed-by: Timur Pocheptsov --- tests/auto/testlib/selftests/test/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/testlib/selftests/test/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/test/BLACKLIST b/tests/auto/testlib/selftests/test/BLACKLIST new file mode 100644 index 0000000000..2d4adf1feb --- /dev/null +++ b/tests/auto/testlib/selftests/test/BLACKLIST @@ -0,0 +1,3 @@ +#QTBUG-55155 +[runSubTest:maxwarnings all loggers] +osx-10.11 -- cgit v1.2.3 From a54d44298f6d2ecc1ec4d8c5c42c89c8a06fc5dd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 14 Sep 2016 16:14:16 +0200 Subject: QLatin1String: Fix UB (nullptr passed) in relational operators Found by UBSan: qstring.h:1160:44: runtime error: null pointer passed as argument 1, which is declared to never be null qstring.h:1160:44: runtime error: null pointer passed as argument 2, which is declared to never be null Fix by avoiding the memcmp() calls if there's a chance that they might be called with nullptr. While at it, also implement !=, >, <=, >= in terms of ==, <, and add a test, because this particular UB was not fingered by any of the QtCore test cases, but by a Qt3D one. Change-Id: I413792dcc8431ef14f0c79f26e89a3e9fab69465 Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- .../tools/qlatin1string/tst_qlatin1string.cpp | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp index 290c9fc12a..6f16120bd0 100644 --- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp +++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp @@ -35,6 +35,15 @@ #include +// Preserve QLatin1String-ness (QVariant(QLatin1String) creates a QVariant::String): +struct QLatin1StringContainer { + QLatin1String l1; +}; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(QLatin1StringContainer, Q_MOVABLE_TYPE); +QT_END_NAMESPACE +Q_DECLARE_METATYPE(QLatin1StringContainer) + class tst_QLatin1String : public QObject { Q_OBJECT @@ -42,6 +51,8 @@ class tst_QLatin1String : public QObject private Q_SLOTS: void nullString(); void emptyString(); + void relationalOperators_data(); + void relationalOperators(); }; void tst_QLatin1String::nullString() @@ -119,7 +130,53 @@ void tst_QLatin1String::emptyString() } } +void tst_QLatin1String::relationalOperators_data() +{ + QTest::addColumn("lhs"); + QTest::addColumn("lhsOrderNumber"); + QTest::addColumn("rhs"); + QTest::addColumn("rhsOrderNumber"); + struct Data { + QLatin1String l1; + int order; + } data[] = { + { QLatin1String(), 0 }, + { QLatin1String(""), 0 }, + { QLatin1String("a"), 1 }, + { QLatin1String("aa"), 2 }, + { QLatin1String("b"), 3 }, + }; + + for (Data *lhs = data; lhs != data + sizeof data / sizeof *data; ++lhs) { + for (Data *rhs = data; rhs != data + sizeof data / sizeof *data; ++rhs) { + QLatin1StringContainer l = { lhs->l1 }, r = { rhs->l1 }; + QTest::newRow(qPrintable(QString::asprintf("\"%s\" <> \"%s\"", + lhs->l1.data() ? lhs->l1.data() : "nullptr", + rhs->l1.data() ? rhs->l1.data() : "nullptr"))) + << l << lhs->order << r << rhs->order; + } + } +} + +void tst_QLatin1String::relationalOperators() +{ + QFETCH(QLatin1StringContainer, lhs); + QFETCH(int, lhsOrderNumber); + QFETCH(QLatin1StringContainer, rhs); + QFETCH(int, rhsOrderNumber); + +#define CHECK(op) \ + QCOMPARE(lhs.l1 op rhs.l1, lhsOrderNumber op rhsOrderNumber) \ + /*end*/ + CHECK(==); + CHECK(!=); + CHECK(< ); + CHECK(> ); + CHECK(<=); + CHECK(>=); +#undef CHECK +} QTEST_APPLESS_MAIN(tst_QLatin1String) -- cgit v1.2.3 From 25c9a6c9b46e6ae58dcccdc3ba158d14945cbf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Wed, 4 May 2016 00:23:16 +0200 Subject: QtWidgets: Fix enter/leave events on popup menus If the sloppy menu popups - send the leave event to the last active menu (except Cocoa), because only currect active menu gets enter/leave events (currently Cocoa is an exception). Check that the menu really has a mouse before hiding the sloppy menu - don't rely on enter events. This patch removes some unnecessary synthetic mouse enter/leave events from QMenu which causes event duplications with different mouse cursor position. Refactor sloppy menu timer handling - start or restart timers on mouse move events. Enter/leave events are not reliable. Fixes: - better enter/leave events handling for native widget actions, - reduce duplicated enter/leave events for menu actions, - better handle torn off sloppy menus. Partially reverts: 0ed68f3f58c63bd1496cb268bd83881da180051f Amends: 57ecd5aeeb1f609206933be66b92fcdf703703d7 Task-number: QTBUG-53068 Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e Reviewed-by: Shawn Rutledge --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 34a1835413..50d7b258bc 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -10358,8 +10358,11 @@ void tst_QWidget::underMouse() QCOMPARE(childWidget2.leaves, 0); // Mouse leaves popup and enters topLevelWidget, should cause leave for popup - // but no enter to topLevelWidget. Again, artificial leave event needed. + // but no enter to topLevelWidget. +#ifdef Q_OS_DARWIN + // Artificial leave event needed for Cocoa. QWindowSystemInterface::handleLeaveEvent(popupWindow); +#endif QTest::mouseMove(popupWindow, popupWindow->mapFromGlobal(window->mapToGlobal(inWindowPoint))); QApplication::processEvents(); QVERIFY(!topLevelWidget.underMouse()); -- cgit v1.2.3 From 1f925d47e9f28e78f0b96dc8a6fd8ed8fde88070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 14 Sep 2016 14:29:26 +0200 Subject: =?UTF-8?q?Blacklist=20modalWindowModallity=20on=20macOS=20aka=20?= =?UTF-8?q?=E2=80=9Cosx=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passes locally, unstable on CI. Change-Id: I132268ad0f6ad8b969701c9571fdb609d8225d07 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/qwindow/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 0fe40e8db3..93b7310d10 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -10,3 +10,5 @@ ubuntu-14.04 ubuntu-14.04 [modalDialogClosingOneOfTwoModal] osx +[modalWindowModallity] +osx -- cgit v1.2.3 From 9f2c260f881b384ae719c60ea9833feb42251058 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 27 Sep 2015 01:26:28 +0200 Subject: Add missing test for QReguarExpression for QTextDocument::findMultiple Change-Id: Ia9b3eb21a178da4ae2844dba37b7e1cc669d6b50 Reviewed-by: Simon Hausmann --- .../auto/gui/text/qtextdocument/tst_qtextdocument.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index bb20d99e30..3c9de9d211 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -468,6 +468,24 @@ void tst_QTextDocument::findMultiple() cursor = doc->find(expr, cursor); QCOMPARE(cursor.selectionStart(), text.lastIndexOf("bar")); QCOMPARE(cursor.selectionEnd(), cursor.selectionStart() + 3); + + QRegularExpression regularExpression("bar"); + + cursor.movePosition(QTextCursor::End); + cursor = doc->find(regularExpression, cursor, QTextDocument::FindBackward); + QCOMPARE(cursor.selectionStart(), text.lastIndexOf("bar")); + QCOMPARE(cursor.selectionEnd(), cursor.selectionStart() + 3); + cursor = doc->find(regularExpression, cursor, QTextDocument::FindBackward); + QCOMPARE(cursor.selectionStart(), text.indexOf("bar")); + QCOMPARE(cursor.selectionEnd(), cursor.selectionStart() + 3); + + cursor.movePosition(QTextCursor::Start); + cursor = doc->find(regularExpression, cursor); + QCOMPARE(cursor.selectionStart(), text.indexOf("bar")); + QCOMPARE(cursor.selectionEnd(), cursor.selectionStart() + 3); + cursor = doc->find(regularExpression, cursor); + QCOMPARE(cursor.selectionStart(), text.lastIndexOf("bar")); + QCOMPARE(cursor.selectionEnd(), cursor.selectionStart() + 3); } void tst_QTextDocument::basicIsModifiedChecks() -- cgit v1.2.3 From 0889e9da20b8f016795ec2e7352b1e2f1678098d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 19 Aug 2016 09:48:14 +0200 Subject: QColor: provide QLatin1String overloads of functions taking QString The inefficiency of QColor(const char*) came to light by a recent refactoring which showed that the existing char* overload of qt_get_hex_rgb() was never called. So, provide a QLatin1String interface for named colors that allows user code to reach that internal function without converting to QString first. Change-Id: I74df7b570ef28c00e35ca4adf46c4b7c7e9994b3 Reviewed-by: Edward Welbourne Reviewed-by: Anton Kudryavtsev --- tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 52 +++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 00e7436c0f..ab893385e3 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -52,6 +52,7 @@ private slots: void name(); void namehex_data(); void namehex(); + void setNamedColor_data(); void setNamedColor(); void constructNamedColorWithSpace(); @@ -525,26 +526,49 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); #undef rgb -void tst_QColor::setNamedColor() +void tst_QColor::setNamedColor_data() { - for (int i = 0; i < rgbTblSize; ++i) { - QColor expected; - expected.setRgba(rgbTbl[i].value); - - QColor color; - color.setNamedColor(QLatin1String(rgbTbl[i].name)); - QCOMPARE(color, expected); + QTest::addColumn("byCtor"); + QTest::addColumn("bySetNamedColor"); + QTest::addColumn("expected"); + for (const auto e : rgbTbl) { + QColor expected; + expected.setRgba(e.value); + +#define ROW(expr) \ + do { \ + QColor bySetNamedColor; \ + bySetNamedColor.setNamedColor(expr); \ + auto byCtor = QColor(expr); \ + QTest::newRow(e.name + QByteArrayLiteral(#expr)) \ + << byCtor << bySetNamedColor << expected; \ + } while (0) \ + /*end*/ + + ROW(QLatin1String(e.name)); + ROW(QString(QLatin1String(e.name))); // name should be case insensitive - color.setNamedColor(QString(rgbTbl[i].name).toUpper()); - QCOMPARE(color, expected); - + ROW(QLatin1String(QByteArray(e.name).toUpper())); + ROW(QString(e.name).toUpper()); // spaces should be ignored - color.setNamedColor(QString(rgbTbl[i].name).insert(1, ' ')); - QCOMPARE(color, expected); + ROW(QLatin1String(QByteArray(e.name).insert(1, ' '))); + ROW(QString(e.name).insert(1, ' ')); +#undef ROW } } +void tst_QColor::setNamedColor() +{ + QFETCH(QColor, byCtor); + QFETCH(QColor, bySetNamedColor); + QFETCH(QColor, expected); + + QCOMPARE(byCtor, expected); + QCOMPARE(bySetNamedColor, expected); +} + + void tst_QColor::constructNamedColorWithSpace() { QColor whiteSmoke("white smoke"); @@ -556,7 +580,7 @@ void tst_QColor::colorNames() QStringList all = QColor::colorNames(); QCOMPARE(all.size(), rgbTblSize); for (int i = 0; i < all.size(); ++i) - QCOMPARE(all.at(i), QString::fromLatin1(rgbTbl[i].name)); + QCOMPARE(all.at(i), QLatin1String(rgbTbl[i].name)); } void tst_QColor::spec() -- cgit v1.2.3 From 9888a2c138c675c5f83ec4d4b8aeac075bc12009 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 23 Sep 2016 07:42:48 +0200 Subject: Fix test for WinRT Only on win32 we can omit creating a new window. Change-Id: Ie49ef45ccb745aaa43f58096e7810c71671124ba Reviewed-by: Oliver Wolff --- tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp index f57ed12ed3..add23d46cf 100644 --- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp @@ -46,7 +46,7 @@ void tst_qdesktopservices::openUrl() { // At the bare minimum check that they return false for invalid url's QCOMPARE(QDesktopServices::openUrl(QUrl()), false); -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // this test is only valid on windows on other systems it might mean open a new document in the application handling .file const QRegularExpression messagePattern("ShellExecute 'file://invalid\\.file' failed \\(error \\d+\\)\\."); QVERIFY(messagePattern.isValid()); -- cgit v1.2.3 From 0be620ac58d43d2ad977944682b24ef1df3c21e0 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 22 Sep 2016 15:01:55 +0200 Subject: Fix test for targets without process support There is no need to switch to the current directory, when there is no process support. This also fixes running the test on sandboxed target platforms. Change-Id: I25fabb8b22d3510062a012884eb1eaab682901d3 Reviewed-by: Oliver Wolff --- tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index bfa15744c2..b1ec94403a 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -73,8 +73,10 @@ void tst_QClipboard::cleanupTestCase() void tst_QClipboard::init() { +#ifndef QT_NO_PROCESS const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath(); QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); +#endif } Q_DECLARE_METATYPE(QClipboard::Mode) -- cgit v1.2.3