From d1f9f2125e6cbba236dc50309a4aee2dc16a6345 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 3 Dec 2013 09:01:50 +0100 Subject: Stabilize tst_QColumnView::dynamicModelChanges(). Use QTest::qWaitForWindowExposed() and QTRY_COMPARE() instead of hardcoded timeout. Task-number: QTBUG-35308 Change-Id: I27eee9932dd3b6087db4ad13b1a4fb184a487f57 Reviewed-by: Stephen Kelly --- tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index 6c04e5b39a..e2b2fb9551 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -1043,13 +1043,14 @@ void tst_QColumnView::dynamicModelChanges() ColumnView view; view.setModel(&model); view.setItemDelegate(&delegate); + centerOnScreen(&view); view.show(); QStandardItem *item = new QStandardItem(QLatin1String("item")); model.appendRow(item); - QTest::qWait(200); //let the time for painting to occur - QCOMPARE(delegate.paintedIndexes.count(), 1); + QVERIFY(QTest::qWaitForWindowExposed(&view)); //let the time for painting to occur + QTRY_COMPARE(delegate.paintedIndexes.count(), 1); QCOMPARE(*delegate.paintedIndexes.begin(), model.index(0,0)); -- cgit v1.2.3 From c70750f5363999640cc99278ccf90679fb27c84d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 29 Nov 2013 10:06:20 +0100 Subject: Stabilize tst_QGraphicsItem The cursor() test was missing a QTest::moveMouse() before sending of the mouse event (as all the following subtests do). When run on a desktop with the panel on the left side of the screen, the mouse pointer would land over the left item instead of in between them, as assumed by the subtest, and the following QCOMPARE failed. Change-Id: Ib74fdf0cfbfbc8ecb79a906610a2da5cb50c89d0 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 6c26ddb293..fc1d0e34cb 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -4221,6 +4221,7 @@ void tst_QGraphicsItem::cursor() QCursor cursor = view.viewport()->cursor(); { + QTest::mouseMove(view.viewport(), QPoint(100, 50)); QMouseEvent event(QEvent::MouseMove, QPoint(100, 50), Qt::NoButton, 0, 0); QApplication::sendEvent(view.viewport(), &event); } -- cgit v1.2.3 From 9302169bd5ad8380ebe95f50986d2b32eb486901 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 29 Nov 2013 14:06:50 +0100 Subject: QtConcurrent: Workaround GCC bug 58800 in median calculation 1) Revert 880b614 for libstdc++ <= 4.7.3 || (4.8.0 >= ... <= 4.8.2) 2) Fix off-by-one error in reverted code for Median::_bufferSize <= 2. Task-number: QTBUG-35058 Change-Id: I9d226c2806c1cf06c3d5b9c9f371262d2d69bf2b Reviewed-by: Olivier Goffart Reviewed-by: Marc Mutz --- tests/auto/concurrent/concurrent.pro | 1 + .../qtconcurrentmedian/qtconcurrentmedian.pro | 5 ++ .../qtconcurrentmedian/tst_qtconcurrentmedian.cpp | 87 ++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 tests/auto/concurrent/qtconcurrentmedian/qtconcurrentmedian.pro create mode 100644 tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp (limited to 'tests/auto') diff --git a/tests/auto/concurrent/concurrent.pro b/tests/auto/concurrent/concurrent.pro index 20bad24fc1..e67c51aae3 100644 --- a/tests/auto/concurrent/concurrent.pro +++ b/tests/auto/concurrent/concurrent.pro @@ -3,6 +3,7 @@ SUBDIRS=\ qtconcurrentfilter \ qtconcurrentiteratekernel \ qtconcurrentmap \ + qtconcurrentmedian \ qtconcurrentrun \ qtconcurrentthreadengine diff --git a/tests/auto/concurrent/qtconcurrentmedian/qtconcurrentmedian.pro b/tests/auto/concurrent/qtconcurrentmedian/qtconcurrentmedian.pro new file mode 100644 index 0000000000..1eb27d825a --- /dev/null +++ b/tests/auto/concurrent/qtconcurrentmedian/qtconcurrentmedian.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +TARGET = tst_qtconcurrentmedian +QT = core testlib concurrent +SOURCES = tst_qtconcurrentmedian.cpp +DEFINES += QT_STRICT_ITERATORS diff --git a/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp new file mode 100644 index 0000000000..c9fbc790bd --- /dev/null +++ b/tests/auto/concurrent/qtconcurrentmedian/tst_qtconcurrentmedian.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include + +class tst_QtConcurrentMedian: public QObject +{ + Q_OBJECT +private slots: + void median_data(); + void median(); +}; + +void tst_QtConcurrentMedian::median_data() +{ + QTest::addColumn >("values"); + QTest::addColumn("expectedMedian"); + + QTest::newRow("size=1") + << (QList() << 1) + << 1; + + QTest::newRow("size=2") + << (QList() << 3 << 2) + << 3; + + QTest::newRow("size=3") + << (QList() << 3 << 1 << 2) + << 2; + + QTest::newRow("gcc bug 58800 (nth_element)") + << (QList() << 207089 << 202585 << 180067 << 157549 << 211592 << 216096 << 207089) + << 207089; +} + +void tst_QtConcurrentMedian::median() +{ + QFETCH(QList , values); + QFETCH(int, expectedMedian); + + QtConcurrent::Median m(values.size()); + foreach (int value, values) + m.addValue(value); + QCOMPARE(m.median(), expectedMedian); +} + +QTEST_MAIN(tst_QtConcurrentMedian) +#include "tst_qtconcurrentmedian.moc" -- cgit v1.2.3 From 1983bc9c374fc8b83f608ecc1e6ce6ef4f54e572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 2 Dec 2013 23:18:00 +0100 Subject: Make layoutDirection pass with new expose behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A QMenu with no actions gets a size of (0, 0) on OS X. With the new stricter expose event behavior this is considered invalid geometry and the platform plugin won't send an expose event, causing the qWaitForWindowExposed test to fail. Add a menu entry since the layoutDirection test is not really interested in testing the special case of empty menus. Change-Id: I5221dc3f0472ac13edf821df08bacc3a4eb5cd9d Reviewed-by: Simo Fält Reviewed-by: Gunnar Sletta --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 7c1bb957d6..ece9026ba2 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -570,6 +570,7 @@ void tst_QMenu::layoutDirection() win.setLayoutDirection(Qt::RightToLeft); QMenu menu(&win); + menu.addAction("foo"); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); -- cgit v1.2.3 From b9c8073230dfd90962188a24f78d4f4157f9eaad Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 2 Dec 2013 13:08:37 +0100 Subject: QSpinBox: allow positive values to be entered with the '+' prefix. The code was there to do it, but it was using minimumValue instead of maximumValue to test if the '+' should be allowed. Task-number: QTBUG-20691 [ChangeLog][QtWidgets][QSpinBox] Entering positive values with the '+' prefix is now allowed. Change-Id: Iff62d073e350dc9a33b7e06e4b492048c74437c4 Reviewed-by: Marc Mutz --- tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 004fdda5ef..a21f2d70a0 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -142,6 +142,8 @@ private slots: void taskQTBUG_5008_textFromValueAndValidate(); void lineEditReturnPressed(); + + void positiveSign(); public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -1111,5 +1113,20 @@ void tst_QSpinBox::lineEditReturnPressed() QCOMPARE(spyCurrentChanged.count(), 1); } +void tst_QSpinBox::positiveSign() +{ + QSpinBox spinBox; + spinBox.setRange(-20, 20); + spinBox.setValue(-20); + spinBox.show(); + QVERIFY(QTest::qWaitForWindowActive(&spinBox)); + + QTest::keyClick(&spinBox, Qt::Key_End, Qt::ShiftModifier); + QTest::keyClick(&spinBox, Qt::Key_Plus, Qt::ShiftModifier); + QTest::keyClick(&spinBox, Qt::Key_2); + QTest::keyClick(&spinBox, Qt::Key_0); + QCOMPARE(spinBox.text(), QLatin1String("+20")); +} + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" -- cgit v1.2.3 From 689152e7c1c6b0e851937a20de96c99aa7a7ea2b Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 22 Nov 2013 15:03:14 +0100 Subject: QTimeZone: Fix isValidId() Fix isValidId() which was failing valid IDs because it was splitting name parts by \ instead of /. it was also rejecting offset from UTC formats names. Add unit tests. Task-number: QTBUG-35025 Change-Id: I4d23d2e54f4a9fac9afcc4eff0a02d6f4af21385 Reviewed-by: Thiago Macieira --- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index d7643ff55d..b4f13af0a1 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -56,6 +56,7 @@ private slots: void createTest(); void nullTest(); void dataStreamTest(); + void isTimeZoneIdAvailable(); void availableTimeZoneIds(); void stressTest(); void windowsId(); @@ -347,6 +348,36 @@ void tst_QTimeZone::dataStreamTest() QCOMPARE(tz2.id(), tz1.id()); } +void tst_QTimeZone::isTimeZoneIdAvailable() +{ + QList available = QTimeZone::availableTimeZoneIds(); + foreach (const QByteArray &id, available) + QVERIFY(QTimeZone::isTimeZoneIdAvailable(id)); + + // a-z, A-Z, 0-9, '.', '-', '_' are valid chars + // Can't start with '-' + // Parts separated by '/', each part min 1 and max of 14 chars + QCOMPARE(QTimeZonePrivate::isValidId("az"), true); + QCOMPARE(QTimeZonePrivate::isValidId("AZ"), true); + QCOMPARE(QTimeZonePrivate::isValidId("09"), true); + QCOMPARE(QTimeZonePrivate::isValidId("a/z"), true); + QCOMPARE(QTimeZonePrivate::isValidId("a.z"), true); + QCOMPARE(QTimeZonePrivate::isValidId("a-z"), true); + QCOMPARE(QTimeZonePrivate::isValidId("a_z"), true); + QCOMPARE(QTimeZonePrivate::isValidId(".z"), true); + QCOMPARE(QTimeZonePrivate::isValidId("_z"), true); + QCOMPARE(QTimeZonePrivate::isValidId("12345678901234"), true); + QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/12345678901234"), true); + QCOMPARE(QTimeZonePrivate::isValidId("a z"), false); + QCOMPARE(QTimeZonePrivate::isValidId("a\\z"), false); + QCOMPARE(QTimeZonePrivate::isValidId("a,z"), false); + QCOMPARE(QTimeZonePrivate::isValidId("/z"), false); + QCOMPARE(QTimeZonePrivate::isValidId("-z"), false); + QCOMPARE(QTimeZonePrivate::isValidId("123456789012345"), false); + QCOMPARE(QTimeZonePrivate::isValidId("123456789012345/12345678901234"), false); + QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/123456789012345"), false); +} + void tst_QTimeZone::availableTimeZoneIds() { if (debug) { -- cgit v1.2.3 From 03affacaa3d5530e96f869a8a6e900ca5e714918 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 5 Oct 2013 03:20:56 +0200 Subject: QCommandLineParser: pluck some low-hanging fruit re: exception safety Make QCommandLineParser::add{Help,Version}Option() QCommandLineOption::setDefaultValue() QCommandLineOptionPrivate::setNames() have transaction semantics: either they succeed, or they change nothing. It's trivial to provide this guarantee, so do it. Add a test for the surprising property that setDefaultValue("") resets defaultValues() to an empty QStringList instead of one that contains the empty string. Change-Id: I61623019de3c7d2e52c24f42cc2e23ec5fddc4da Reviewed-by: David Faure Reviewed-by: Thiago Macieira --- .../tools/qcommandlineparser/tst_qcommandlineparser.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index f37e192ad3..d111c53551 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -69,6 +69,7 @@ private slots: void testUnknownOptionErrorHandling(); void testDoubleDash_data(); void testDoubleDash(); + void testDefaultValue(); void testProcessNotCalled(); void testEmptyArgsList(); void testMissingOptionValue(); @@ -322,6 +323,17 @@ void tst_QCommandLineParser::testDoubleDash() QCOMPARE(parser.unknownOptionNames(), QStringList()); } +void tst_QCommandLineParser::testDefaultValue() +{ + QCommandLineOption opt(QStringLiteral("name"), QStringLiteral("desc"), + QStringLiteral("valueName"), QStringLiteral("default")); + QCOMPARE(opt.defaultValues(), QStringList(QStringLiteral("default"))); + opt.setDefaultValue(QStringLiteral("")); + QCOMPARE(opt.defaultValues(), QStringList()); + opt.setDefaultValue(QStringLiteral("default")); + QCOMPARE(opt.defaultValues(), QStringList(QStringLiteral("default"))); +} + void tst_QCommandLineParser::testProcessNotCalled() { QCoreApplication app(empty_argc, empty_argv); -- cgit v1.2.3 From 0c936ca83c40b73f30195a619900f2be98b9e968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Thu, 5 Dec 2013 14:48:10 +0000 Subject: Windows: Don't cover the taskbar when maximizing frameless windows Brings Windows QPA on par with other platforms. [ChangeLog][Windows] Don't cover the taskbar when maximizing frameless windows. Task-number: QTBUG-8361 Change-Id: Iba35132f697cb7379650a4c883b616c5c2023d4c Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 - 1 file changed, 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 36a3a8bad5..9090f97ce6 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4571,7 +4571,6 @@ void tst_QWidget::setGeometry_win() RECT rt; ::GetWindowRect(winHandleOf(&widget), &rt); QVERIFY(rt.left <= 0); - QEXPECT_FAIL("", "QTBUG-26424", Continue); QVERIFY(rt.top <= 0); } #endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) -- cgit v1.2.3 From 105d10dea9d790a69595a2e73e8fea80a5d1a3ad Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 5 Dec 2013 16:59:27 +0100 Subject: Fix quadratic behavior in QMetaObjectBuilder when writing string table QHash::key() is O(n) and we're calling it n times. That can make repeated calls to the meta object builder very slow, as for example QQmlPropertyMap when inserting properties repeatedly. Fortunately this is easy to fix, as the value in the hash map is also the index, so we can simply iterate over the hash once. With the exception of the class name, which we have to treat specially to ensure that it is always the first entry in the string table. Task-number: QTBUG-32720 Change-Id: Ic954c45c454107feee83216131f601cc69d4c63b Reviewed-by: Olivier Goffart --- .../kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 8f6bd50cca..5cf3e6d97c 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -75,6 +75,8 @@ private slots: void usage_connect(); void usage_templateConnect(); + void classNameFirstInStringData(); + private: static bool checkForSideEffects (const QMetaObjectBuilder& builder, @@ -1694,6 +1696,20 @@ void tst_QMetaObjectBuilder::usage_templateConnect() QVERIFY(!con); } +void tst_QMetaObjectBuilder::classNameFirstInStringData() +{ + QMetaObjectBuilder builder; + builder.addMetaObject(&SomethingOfEverything::staticMetaObject); + builder.setClassName(QByteArrayLiteral("TestClass")); + QMetaObject *mo = builder.toMetaObject(); + + QByteArrayDataPtr header; + header.ptr = const_cast(mo->d.stringdata); + QCOMPARE(QByteArray(header), QByteArrayLiteral("TestClass")); + + free(mo); +} + QTEST_MAIN(tst_QMetaObjectBuilder) #include "tst_qmetaobjectbuilder.moc" -- cgit v1.2.3 From 29b0a565e9e420a6dc34aaaf3b66976bb75edcb0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Dec 2013 11:24:56 +0100 Subject: fix Windows CE comments Change-Id: Ib42c456c236f59727dddd6a111dfe0946fff1aef Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index d248f022ed..d141c11a90 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -538,7 +538,6 @@ void tst_QProcess::echoTest2() #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -//Batch files are not supported on Winfows CE // Reading and writing to a process is not supported on Qt/CE //----------------------------------------------------------------------------- void tst_QProcess::echoTestGui() @@ -560,7 +559,7 @@ void tst_QProcess::echoTestGui() //----------------------------------------------------------------------------- #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -//Batch files are not supported on Winfows CE +// Batch files are not supported on Windows CE void tst_QProcess::batFiles_data() { QTest::addColumn("batFile"); -- cgit v1.2.3 From 7eecbb07184bc8b2c5e7645af2805ba0a2488082 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 10 Dec 2013 09:21:43 +0100 Subject: SSL: blacklist ANSSI intermediate certificate ... because it was used to operate a man-in-the-middle proxy. Task-number: QTBUG-35474 Change-Id: Ic7f19708b278b866e4f06533cbd84e0ff43357e9 Reviewed-by: Richard J. Moore --- .../more-certificates/blacklisted-anssi-tresor.pem | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-anssi-tresor.pem (limited to 'tests/auto') diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-anssi-tresor.pem b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-anssi-tresor.pem new file mode 100644 index 0000000000..cf212f117e --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-anssi-tresor.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDbDCCAlSgAwIBAgIDAx2nMA0GCSqGSIb3DQEBBQUAMEsxCzAJBgNVBAYTAkZS +MQ4wDAYDVQQKEwVER1RQRTEsMCoGA1UEAxMjQUMgREdUUEUgU2lnbmF0dXJlIEF1 +dGhlbnRpZmljYXRpb24wHhcNMTMwNzE4MTAwNTI4WhcNMTQwNzE4MTAwNTI4WjA+ +MQswCQYDVQQGEwJGUjETMBEGA1UECgwKREcgVHLDqXNvcjEaMBgGA1UEAwwRQUMg +REcgVHLDqXNvciBTU0wwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDI +0WFSUyY+MmtFkqFjTefoFyDgh9b1C/2YvSIvT8oCH62JWT5rpeTCZwaXbqWcjaNf +zggqaFsokqfhBif43HNHNtNJmvKE32VcuLB0SpsLR/1VeTd9F99C1JeHVa+nelum +OHEfouX8rRFrxNXNIYTVeiENT8Y2YqRb/XAril9g7i674uFzLiNR/t/N/F8Exujv +9U8m8rmgud/+tG9WDRaDJwoj3ZFCOnL5qLnSUEcS6TzWpozLmC2JVO5GZKGGd7qC +9FjdBkVilkbVIEGSrYvz2Uz2v5IGqMBIQaFL/kSYWxGTaedTOk2drFEApp9AEPTf +v1NwCWBfegsGQrHUROM3AgMBAAGjZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQQwHQYD +VR0OBBYEFAAMW8lJqJW0DtAv5p3Mjogxvh9lMB8GA1UdIwQYMBaAFOnbkI/9W5nk +FTvwYlyn5A1Y6IeZMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEA +tDfGHkHOLW2d9fiMtwtkEwDauISJLJyCjoRmawzmQbIZXq7HaLliVfE0sdfKUm0i +Q0im1/CpnJLPoTeKyBHvNu1ubLc2m+9dabAYhF3pVdKC+gNaAzBXZ9Gt0p1CLk1l +f8Hg+R10HN2IPCv7V/crz2Ga+c234P3pfwYW8+Nd7alGCuvqot6UYXOlheF7zWUk +Hn6z6tvY+9oMDHKSUAthhA/FB50JgJU89zyTv1egY3ldKwvYBW3W3yNZdTHbPyNs +PJdhqA55mDNsteE5YTp1PyySDb1MSVrbxDEruoH6ZE99Hob4Ih8Amn7MHZatGClE +CgjXWFZ2Gxa7OUCaQpcH8g== +-----END CERTIFICATE----- -- cgit v1.2.3 From aa3eaf9d2ec4927df51e7d773a66f68ec5e4fce9 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 10 Dec 2013 11:15:34 +0100 Subject: QUdpSocket auto test: disable Socks5 over UDP for new test server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... because they fail on the new test server. This commit can be reverted once the Socks5 socket engine is fixed. Task-number: QTBUG-35490 Change-Id: I85635d4b44d26168d40a56b7a121693297564f0f Reviewed-by: Tony Sarajärvi Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 8de66f0f2c..f08afaa9a5 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -144,11 +145,25 @@ tst_QUdpSocket::~tst_QUdpSocket() void tst_QUdpSocket::initTestCase_data() { + // hack: we only enable the Socks5 over UDP tests on the old + // test server, because they fail on the new one. See QTBUG-35490 + bool newTestServer = true; + QTcpSocket socket; + socket.connectToHost(QtNetworkSettings::serverName(), 22); + if (socket.waitForConnected(10000)) { + socket.waitForReadyRead(5000); + QByteArray ba = socket.readAll(); + if (ba.startsWith("SSH-2.0-OpenSSH_5.8p1")) + newTestServer = false; + socket.disconnectFromHost(); + } + QTest::addColumn("setProxy"); QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; - QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); + if (!newTestServer) + QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); -- cgit v1.2.3 From 7009843ae3b12fe86d21040ad96add335c7df5a5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Dec 2013 10:54:12 +0100 Subject: QProcess/Win: allow child processes to change modes of the stdin pipe To be able to call SetNamedPipeHandleState on stdin in a child process, we must create a read-end pipe handle with the FILE_WRITE_ATTRIBUTES flag set. This can't be done with CreateNamedPipe but only with CreateFile. Therefore we're creating the handles for the child process always with CreateFile now. Besides, it's conceptually cleaner to have the server handle of the named pipe in the calling process. [ChangeLog][QtCore][Windows] Fix regression from Qt4 in QProcess. It wasn't possible anymore to alter pipe modes of stdin in child processes. Task-number: QTBUG-35357 Change-Id: I85f09753d0c924bdc8a6cef1ea5dbe6b2299c604 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qprocess/qprocess.pro | 6 ++- .../qprocess/testSetNamedPipeHandleState/main.cpp | 50 ++++++++++++++++++++++ .../testSetNamedPipeHandleState.pro | 4 ++ tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 12 ++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp create mode 100644 tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qprocess/qprocess.pro b/tests/auto/corelib/io/qprocess/qprocess.pro index 4155e3f73d..6ba54b1e92 100644 --- a/tests/auto/corelib/io/qprocess/qprocess.pro +++ b/tests/auto/corelib/io/qprocess/qprocess.pro @@ -8,7 +8,11 @@ SUBDIRS += testProcessSpacesArgs/nospace.pro \ testProcessSpacesArgs/twospaces.pro \ testSpaceInName -win32:!wince*:SUBDIRS+=testProcessEchoGui +win32:!wince* { + SUBDIRS += \ + testProcessEchoGui \ + testSetNamedPipeHandleState +} test.depends += $$SUBDIRS SUBDIRS += test diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp new file mode 100644 index 0000000000..b2cc793b51 --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main() +{ + DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT; + if (SetNamedPipeHandleState(GetStdHandle(STD_INPUT_HANDLE), &mode, NULL, NULL)) + return 0; + return GetLastError(); +} diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro new file mode 100644 index 0000000000..e236e05c7d --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro @@ -0,0 +1,4 @@ +SOURCES = main.cpp +CONFIG -= qt app_bundle +CONFIG += console +DESTDIR = ./ diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index d141c11a90..37f224ff28 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -93,6 +93,7 @@ private slots: void echoTest2(); #ifdef Q_OS_WIN void echoTestGui(); + void testSetNamedPipeHandleState(); void batFiles_data(); void batFiles(); #endif @@ -555,6 +556,17 @@ void tst_QProcess::echoTestGui() QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello")); QCOMPARE(process.readAllStandardError(), QByteArray("Hello")); } + +void tst_QProcess::testSetNamedPipeHandleState() +{ + QProcess process; + process.setProcessChannelMode(QProcess::SeparateChannels); + process.start("testSetNamedPipeHandleState/testSetNamedPipeHandleState"); + QVERIFY2(process.waitForStarted(5000), qPrintable(process.errorString())); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitCode(), 0); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); +} #endif // !Q_OS_WINCE && Q_OS_WIN //----------------------------------------------------------------------------- -- cgit v1.2.3 From 7fef5fe2932401294dea8edac7a64f4e5864c98f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Dec 2013 18:30:08 +0100 Subject: Stabilize tst_qabstractitemview Attempt to fix FAIL! : tst_QAbstractItemView::task200665_itemEntered() Compared values are not the same Actual (spy.count()): 0 Expected (1) : 1 Loc: [tst_qabstractitemview.cpp(1292)] which might have been introduced by removing the absolute qWait(200) in favor of qWaitForWindowExposed() in afe8e368, so trying to compensate with a QTRY_COMPARE. Change-Id: Id437acd810b54e005daaf66ffffd4dd586075ab6 Reviewed-by: Friedemann Kleint --- .../auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 36bf76564f..97ea7d7d32 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1289,7 +1289,7 @@ void tst_QAbstractItemView::task200665_itemEntered() QSignalSpy spy(&view, SIGNAL(entered(QModelIndex))); view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); } void tst_QAbstractItemView::task257481_emptyEditor() -- cgit v1.2.3 From 4d8a12904a49d6724098610f7e39b11821377b3a Mon Sep 17 00:00:00 2001 From: ABBAPOH Date: Sat, 30 Nov 2013 21:06:57 +0400 Subject: Check if device is opened before trying to create image handler. Change-Id: I60f1f6890fdd73e489da4aab9928370163f55f58 Reviewed-by: Friedemann Kleint Reviewed-by: aavit --- .../gui/image/qimagewriter/tst_qimagewriter.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index f1d0e227f6..b10b5704c3 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef Q_OS_UNIX // for geteuid() # include @@ -84,6 +85,7 @@ private slots: void supportedMimeTypes(); void writeToInvalidDevice(); + void testCanWrite(); void supportsOption_data(); void supportsOption(); @@ -402,6 +404,28 @@ void tst_QImageWriter::writeToInvalidDevice() } } +void tst_QImageWriter::testCanWrite() +{ + { + // device is not set + QImageWriter writer; + QVERIFY(!writer.canWrite()); + QCOMPARE(writer.error(), QImageWriter::DeviceError); + } + + { + // check if canWrite won't leave an empty file + QTemporaryDir dir; + QVERIFY(dir.isValid()); + QString fileName(dir.path() + QLatin1String("/001.garble")); + QVERIFY(!QFileInfo(fileName).exists()); + QImageWriter writer(fileName); + QVERIFY(!writer.canWrite()); + QCOMPARE(writer.error(), QImageWriter::UnsupportedFormatError); + QVERIFY(!QFileInfo(fileName).exists()); + } +} + void tst_QImageWriter::supportsOption_data() { QTest::addColumn("fileName"); -- cgit v1.2.3