diff options
author | Liang Qi <liang.qi@qt.io> | 2018-03-28 08:12:21 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-03-28 08:12:21 +0200 |
commit | 794781e7cff9f7d44af64292796428478ed18663 (patch) | |
tree | dae1f8478885d95dac5766ce46d5dd4784ca06f4 /tests | |
parent | f69d32b535d456a2441754ef5733c7fb65411d6c (diff) | |
parent | e83f1900f657a41036bd16e917527fcb7a52fd2b (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/platforms/cocoa/qnsview_mouse.mm
src/testlib/testlib.pro
Change-Id: Ia0ce4243418fe6a485b0f290c67bd433b3b04ff2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 23 | ||||
-rw-r--r-- | tests/auto/cmake/test_use_modules_function/CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/auto/cmake/test_use_modules_function/three.cpp | 45 | ||||
-rw-r--r-- | tests/auto/cmake/test_use_modules_function/two.cpp | 43 | ||||
-rw-r--r-- | tests/auto/corelib/io/qprocess/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | 10 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 70 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 59 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvector/tst_qvector.cpp | 23 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 30 | ||||
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 142 | ||||
-rw-r--r-- | tests/auto/tools/moc/moc.pro | 10 | ||||
-rw-r--r-- | tests/auto/tools/moc/no-keywords.h | 15 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/evaltest.cpp | 16 | ||||
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 26 |
15 files changed, 307 insertions, 226 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 40c86132e9..f1d8657091 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -47,17 +47,7 @@ find_package(Qt5Core REQUIRED) include("${_Qt5CTestMacros}") -if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.9) - # Requires INCLUDE_DIRECTORIES target property in CMake 2.8.8 - # and POSITION_INDEPENDENT_CODE target property in 2.8.9 - if (NOT NO_GUI) - expect_pass(test_use_modules_function) - endif() - expect_pass(test_umbrella_config) -else() - message("CMake version older than 2.8.9 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\" or \"test_umbrella_config\"") -endif() - +expect_pass(test_umbrella_config) expect_pass(test_wrap_cpp_and_resources) if (NOT NO_WIDGETS) expect_pass(test_dependent_modules) @@ -90,12 +80,8 @@ if (NOT NO_DBUS) expect_pass(test_dbus_module) endif() expect_pass(test_multiple_find_package) -if (NOT WIN32 OR (WIN32 AND NOT CMAKE_VERSION VERSION_LESS 2.8.11)) - # Broken on windows on earlier CMake versions. - # http://public.kitware.com/Bug/view.php?id=13392 - expect_pass(test_add_resources_delayed_file) - expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file) -endif() +expect_pass(test_add_resources_delayed_file) +expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file) expect_pass(test_private_includes) expect_pass(test_private_targets) expect_pass(test_testlib_definitions) @@ -153,7 +139,7 @@ if (QT_WITH_ANGLE OR (NOT WIN32 AND NOT APPLE AND NOT NO_EGL)) endif() expect_pass(test_opengl_lib) -if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS) +if (NOT NO_WIDGETS) expect_pass(test_interface) endif() @@ -166,4 +152,3 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8) # /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here # Reason: SKIP_* properties were added in CMake 3.8 only expect_pass(test_QTBUG-63422) -endif() diff --git a/tests/auto/cmake/test_use_modules_function/CMakeLists.txt b/tests/auto/cmake/test_use_modules_function/CMakeLists.txt deleted file mode 100644 index be05c75054..0000000000 --- a/tests/auto/cmake/test_use_modules_function/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -project(test_use_modules_function) - -set(CMAKE_AUTOMOC ON) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -add_executable(two two.cpp) -add_executable(three three.cpp) - -find_package(Qt5Core) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") - -qt5_use_modules(two Test) -qt5_use_modules(three Gui Test) diff --git a/tests/auto/cmake/test_use_modules_function/three.cpp b/tests/auto/cmake/test_use_modules_function/three.cpp deleted file mode 100644 index 507cc8479d..0000000000 --- a/tests/auto/cmake/test_use_modules_function/three.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QtTest> -#include <QWindow> - -class Three : public QObject -{ - Q_OBJECT -public: - Three(QObject *parent = 0) - { - QWindow *w = new QWindow; - w->show(); - } -}; - -QTEST_MAIN(Three) - -#include "three.moc" diff --git a/tests/auto/cmake/test_use_modules_function/two.cpp b/tests/auto/cmake/test_use_modules_function/two.cpp deleted file mode 100644 index 44eb7fe96e..0000000000 --- a/tests/auto/cmake/test_use_modules_function/two.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** 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 <QtTest> - -class Two : public QObject -{ - Q_OBJECT -public: - Two(QObject *parent = 0) - { - - } -}; - -QTEST_MAIN(Two) - -#include "two.moc" diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST index a278af12d3..b355bb0f75 100644 --- a/tests/auto/corelib/io/qprocess/BLACKLIST +++ b/tests/auto/corelib/io/qprocess/BLACKLIST @@ -4,3 +4,6 @@ redhatenterpriselinuxworkstation-6.6 [fileWriterProcess] msvc-2015 ci msvc-2017 ci +[softExitInSlots] +# QTBUG-66903 +windows diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 74beab96a6..ac8aaa1327 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -146,6 +146,7 @@ public: HANDLE eventHandle() const { return notifier.handle(); } int numberOfTimesActivated() const { return activatedCount; } void setEnabled(bool b) { notifier.setEnabled(b); } + bool isEnabled() const { return notifier.isEnabled(); } signals: void activated(); @@ -239,8 +240,9 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot() for (int i = 0; i < count; ++i) events[i].reset(new EventWithNotifier); - auto isActivatedOrNull = [&events](int i) { - return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0; + auto isActivatedOrDisabled = [&events](int i) { + return !events.at(i) || !events.at(i)->isEnabled() + || events.at(i)->numberOfTimesActivated() > 0; }; for (auto &e : events) { @@ -251,8 +253,10 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot() else events.at(i)->setEnabled(false); } - if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), isActivatedOrNull)) + if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), + isActivatedOrDisabled)) { QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop())); + } }); } for (int i : notifiersToSignal) diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 0714883855..79309f960d 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -54,6 +54,7 @@ private slots: void testCbrtDouble(); void testCbrtFloat(); void cpp11(); + void quadraticEquation(); }; void tst_QEasingCurve::type() @@ -804,5 +805,74 @@ void tst_QEasingCurve::cpp11() #endif } +void tst_QEasingCurve::quadraticEquation() { + // We find the value for a given time by solving a cubic equation. + // ax^3 + bx^2 + cx + d = 0 + // However, the solver also needs to take care of cases where a = 0, + // b = 0 or c = 0, and the equation becomes quadratic, linear or invalid. + // A naive cubic solver might divide by zero and return nan, even + // when the solution is a real number. + // This test should triggers those cases. + + { + // If the control points are spaced 1/3 apart of the distance of the + // start- and endpoint, the equation becomes linear. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 1.0 / 3.0; + const qreal p2 = 1.0 - 1.0 / 3.0; + const qreal p3 = 1.0; + + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.15625) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.5) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.84375) < 1e-6); + } + + { + // If both the start point and the first control point + // are placed a 0.0, and the second control point is + // placed at 1/3, we get a case where a = 0 and b != 0 + // i.e. a quadratic equation. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 0.0; + const qreal p2 = 1.0 / 3.0; + const qreal p3 = 1.0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.5) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.792893) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.950962) < 1e-6); + } + + { + // If both the start point and the first control point + // are placed a 0.0, and the second control point is + // placed close to 1/3, we get a case where a = ~0 and b != 0. + // It's not truly a quadratic equation, but should be treated + // as one, because it causes some cubic solvers to fail. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 0.0; + const qreal p2 = 1.0 / 3.0 + 1e-6; + const qreal p3 = 1.0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.499999) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.792892) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.950961) < 1e-6); + } + + { + // A bad case, where the segment is of zero length. + // However, it might still happen in user code, + // and we should return a sensible answer. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p0 = 0.0; + const qreal p1 = p0; + const qreal p2 = p0; + const qreal p3 = p0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + test.addCubicBezierSegment(QPointF(p3, 1.0), QPointF(1.0, 1.0), QPointF(1.0, 1.0)); + QCOMPARE(test.valueForProgress(0.0), 0.0); + } +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index ac4c8c8d4e..5737db760c 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -957,19 +957,21 @@ void tst_QVarLengthArray::insertMove() QCOMPARE(MyBase::copyCount, 0); { - QVarLengthArray<MyMovable, 4> vec; + QVarLengthArray<MyMovable, 6> vec; MyMovable m1; MyMovable m2; MyMovable m3; MyMovable m4; + MyMovable m5; + MyMovable m6; QCOMPARE(MyBase::copyCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); vec.append(std::move(m3)); QVERIFY(m3.wasConstructedAt(nullptr)); QVERIFY(vec.at(0).wasConstructedAt(&m3)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 1); vec.push_back(std::move(m4)); @@ -977,7 +979,7 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(0).wasConstructedAt(&m3)); QVERIFY(vec.at(1).wasConstructedAt(&m4)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 2); vec.prepend(std::move(m1)); @@ -986,7 +988,7 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(1).wasConstructedAt(&m3)); QVERIFY(vec.at(2).wasConstructedAt(&m4)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 3); vec.insert(1, std::move(m2)); @@ -995,11 +997,34 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(1).wasConstructedAt(&m2)); QVERIFY(vec.at(2).wasConstructedAt(&m3)); QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QCOMPARE(MyBase::errorCount, 0); + QCOMPARE(MyBase::liveCount, 6); + QCOMPARE(MyBase::movedCount, 4); + + vec += std::move(m5); + QVERIFY(m5.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QCOMPARE(MyBase::errorCount, 0); + QCOMPARE(MyBase::liveCount, 6); + QCOMPARE(MyBase::movedCount, 5); + + vec << std::move(m6); + QVERIFY(m6.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QVERIFY(vec.at(5).wasConstructedAt(&m6)); QCOMPARE(MyBase::copyCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::movedCount, 4); + QCOMPARE(MyBase::movedCount, 6); } QCOMPARE(MyBase::liveCount, 0); QCOMPARE(MyBase::errorCount, 0); @@ -1013,10 +1038,14 @@ void tst_QVarLengthArray::nonCopyable() std::unique_ptr<int> val2(new int(2)); std::unique_ptr<int> val3(new int(3)); std::unique_ptr<int> val4(new int(4)); + std::unique_ptr<int> val5(new int(5)); + std::unique_ptr<int> val6(new int(6)); int *const ptr1 = val1.get(); int *const ptr2 = val2.get(); int *const ptr3 = val3.get(); int *const ptr4 = val4.get(); + int *const ptr5 = val5.get(); + int *const ptr6 = val6.get(); vec.append(std::move(val3)); QVERIFY(!val3); @@ -1035,6 +1064,22 @@ void tst_QVarLengthArray::nonCopyable() QVERIFY(ptr1 == vec.at(0).get()); QVERIFY(ptr2 == vec.at(1).get()); QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + vec += std::move(val5); + QVERIFY(!val5); + QVERIFY(ptr1 == vec.at(0).get()); + QVERIFY(ptr2 == vec.at(1).get()); + QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + QVERIFY(ptr5 == vec.at(4).get()); + vec << std::move(val6); + QVERIFY(!val6); + QVERIFY(ptr1 == vec.at(0).get()); + QVERIFY(ptr2 == vec.at(1).get()); + QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + QVERIFY(ptr5 == vec.at(4).get()); + QVERIFY(ptr6 == vec.at(5).get()); } QTEST_APPLESS_MAIN(tst_QVarLengthArray) diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 600291715a..a7faeb5ca5 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -2895,12 +2895,14 @@ void tst_QVector::insertMove() const const int instancesCount = Movable::counter.loadAcquire(); { QVector<Movable> vec; - vec.reserve(5); + vec.reserve(7); Movable m0; Movable m1; Movable m2; Movable m3; Movable m4; + Movable m5; + Movable m6; vec.append(std::move(m3)); QVERIFY(m3.wasConstructedAt(nullptr)); @@ -2920,6 +2922,21 @@ void tst_QVector::insertMove() const QVERIFY(vec.at(1).wasConstructedAt(&m2)); QVERIFY(vec.at(2).wasConstructedAt(&m3)); QVERIFY(vec.at(3).wasConstructedAt(&m4)); + vec += std::move(m5); + QVERIFY(m5.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + vec << std::move(m6); + QVERIFY(m6.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QVERIFY(vec.at(5).wasConstructedAt(&m6)); vec.push_front(std::move(m0)); QVERIFY(m0.wasConstructedAt(nullptr)); QVERIFY(vec.at(0).wasConstructedAt(&m0)); @@ -2927,8 +2944,10 @@ void tst_QVector::insertMove() const QVERIFY(vec.at(2).wasConstructedAt(&m2)); QVERIFY(vec.at(3).wasConstructedAt(&m3)); QVERIFY(vec.at(4).wasConstructedAt(&m4)); + QVERIFY(vec.at(5).wasConstructedAt(&m5)); + QVERIFY(vec.at(6).wasConstructedAt(&m6)); - QCOMPARE(Movable::counter.loadAcquire(), instancesCount + 10); + QCOMPARE(Movable::counter.loadAcquire(), instancesCount + 14); } QCOMPARE(Movable::counter.loadAcquire(), instancesCount); } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8dfaa6f5cd..ba405e2860 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -153,6 +153,7 @@ private slots: void setEqualClipRegionAndPath(); void clipRectSaveRestore(); + void clipStateSaveRestore(); void clippedFillPath_data(); void clippedFillPath(); @@ -3425,6 +3426,35 @@ void tst_QPainter::clipRectSaveRestore() QCOMPARE(img.pixel(0, 0), QColor(Qt::black).rgba()); } +void tst_QPainter::clipStateSaveRestore() +{ + QImage img(16, 16, QImage::Format_RGB32); + img.fill(Qt::blue); + { + QPainter p(&img); + p.setClipRect(QRect(5, 5, 10, 10)); + p.save(); + p.setClipping(false); + p.restore(); + p.fillRect(0, 0, 16, 16, Qt::red); + p.end(); + QCOMPARE(img.pixel(0, 0), QColor(Qt::blue).rgb()); + } + + img.fill(Qt::blue); + { + QPainter p(&img); + p.setClipRect(QRect(5, 5, 10, 10)); + p.setClipping(false); + p.save(); + p.setClipping(true); + p.restore(); + p.fillRect(0, 0, 16, 16, Qt::red); + p.end(); + QCOMPARE(img.pixel(0, 0), QColor(Qt::red).rgb()); + } +} + void tst_QPainter::clippedImage() { QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 6843ff7d4a..9093485c40 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -359,7 +359,6 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("more_results", __FILE__, db) << qTableName("blobstest", __FILE__, db) << qTableName("oraRowId", __FILE__, db) - << qTableName("qtest_batch", __FILE__, db) << qTableName("bug43874", __FILE__, db) << qTableName("bug6421", __FILE__, db).toUpper() << qTableName("bug5765", __FILE__, db) @@ -2439,76 +2438,103 @@ void tst_QSqlQuery::batchExec() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - if ( !db.driver()->hasFeature( QSqlDriver::BatchOperations ) ) - QSKIP( "Database can't do BatchOperations"); - QSqlQuery q( db ); const QString tableName = qTableName("qtest_batch", __FILE__, db); - - QVERIFY_SQL(q, exec("create table " + tableName + " (id int, name varchar(20), dt date, num numeric(8, 4), dtstamp TIMESTAMP(3))")); - QVERIFY_SQL(q, prepare("insert into " + tableName + " (id, name, dt, num, dtstamp) values (?, ?, ?, ?, ?)")); - - QVariantList intCol; - intCol << 1 << 2 << QVariant( QVariant::Int ); - - QVariantList charCol; - charCol << QLatin1String( "harald" ) << QLatin1String( "boris" ) << QVariant( QVariant::String ); - - QVariantList dateCol; - QDateTime dt = QDateTime( QDate::currentDate(), QTime( 1, 2, 3 ) ); - dateCol << dt << dt.addDays( -1 ) << QVariant( QVariant::DateTime ); - - QVariantList numCol; - numCol << 2.3 << 3.4 << QVariant( QVariant::Double ); - - QVariantList timeStampCol; - const QDateTime dtStamp = QDateTime(QDate::currentDate(), QTime(1, 2, 3, 4)); - timeStampCol << dtStamp << dtStamp.addDays(-1) << QVariant(QVariant::DateTime); - + tst_Databases::safeDropTable(db, tableName); + QVERIFY_SQL(q, exec(QStringLiteral("create table ") + tableName + + QStringLiteral(" (id int, name varchar(20), dt date, num numeric(8, 4), " + "dtstamp TIMESTAMP(3), extraId int, extraName varchar(20))"))); + + const QVariantList intCol = { 1, 2, QVariant(QVariant::Int) }; + const QVariantList charCol = { QStringLiteral("harald"), QStringLiteral("boris"), + QVariant(QVariant::String) }; + const QDateTime currentDateTime = QDateTime(QDateTime::currentDateTime()); + const QVariantList dateCol = { currentDateTime.date(), currentDateTime.date().addDays(-1), + QVariant(QVariant::Date) }; + const QVariantList numCol = { 2.3, 3.4, QVariant(QVariant::Double) }; + const QVariantList timeStampCol = { currentDateTime, currentDateTime.addDays(-1), + QVariant(QVariant::DateTime) }; + + // Test with positional placeholders + QVERIFY_SQL(q, prepare(QStringLiteral("insert into ") + tableName + + QStringLiteral(" (id, name, dt, num, dtstamp, extraId, extraName) values " + "(?, ?, ?, ?, ?, ?, ?)"))); q.addBindValue(intCol); q.addBindValue( charCol ); q.addBindValue( dateCol ); q.addBindValue( numCol ); q.addBindValue(timeStampCol); + q.addBindValue(intCol); + q.addBindValue(charCol); QVERIFY_SQL( q, execBatch() ); - QVERIFY_SQL(q, exec("select id, name, dt, num, dtstamp from " + tableName + " order by id")); - - QVERIFY( q.next() ); - QCOMPARE( q.value( 0 ).toInt(), 1 ); - QCOMPARE( q.value( 1 ).toString(), QString( "harald" ) ); - QCOMPARE( q.value( 2 ).toDateTime(), dt ); - QCOMPARE( q.value( 3 ).toDouble(), 2.3 ); - QCOMPARE(q.value(4).toDateTime(), dtStamp); + QVERIFY_SQL(q, exec(QStringLiteral("select id, name, dt, num, dtstamp, " + "extraId, extraName from ") + tableName)); - QVERIFY( q.next() ); - QCOMPARE( q.value( 0 ).toInt(), 2 ); - QCOMPARE( q.value( 1 ).toString(), QString( "boris" ) ); - QCOMPARE( q.value( 2 ).toDateTime(), dt.addDays( -1 ) ); - QCOMPARE( q.value( 3 ).toDouble(), 3.4 ); - QCOMPARE(q.value(4).toDateTime(), dtStamp.addDays(-1)); + for (int i = 0; i < intCol.size(); ++i) { + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), intCol.at(i)); + QCOMPARE(q.value(1).toString(), charCol.at(i)); + QCOMPARE(q.value(2).toDate(), dateCol.at(i)); + QCOMPARE(q.value(3).toDouble(), numCol.at(i)); + if (tst_Databases::getDatabaseType(db) == QSqlDriver::MySqlServer && timeStampCol.at(i).isNull()) { + QEXPECT_FAIL("", "This appears to be a bug in MySQL as it converts null datetimes to the " + "current datetime for a timestamp field", Continue); + } + QCOMPARE(q.value(4).toDateTime(), timeStampCol.at(i)); + QCOMPARE(q.value(5).toInt(), intCol.at(i)); + QCOMPARE(q.value(6).toString(), charCol.at(i)); + } - QVERIFY( q.next() ); - QVERIFY( q.value( 0 ).isNull() ); - QVERIFY( q.value( 1 ).isNull() ); - QVERIFY( q.value( 2 ).isNull() ); - QVERIFY( q.value( 3 ).isNull() ); - QVERIFY(q.value(4).isNull()); + // Empty table ready for retesting with duplicated named placeholders + QVERIFY_SQL(q, exec(QStringLiteral("delete from ") + tableName)); + QVERIFY_SQL(q, prepare(QStringLiteral("insert into ") + tableName + + QStringLiteral(" (id, name, dt, num, dtstamp, extraId, extraName) " + "values (:id, :name, :dt, :num, :dtstamp, :id, :name)"))); + q.bindValue(":id", intCol); + q.bindValue(":name", charCol); + q.bindValue(":dt", dateCol); + q.bindValue(":num", numCol); + q.bindValue(":dtstamp", timeStampCol); - const QString procName = qTableName("qtest_batch_proc", __FILE__, db); - QVERIFY_SQL(q, exec("create or replace procedure " + procName + " (x in timestamp, y out timestamp) is\n" - "begin\n" - " y := x;\n" - "end;\n")); - QVERIFY(q.prepare("call " + procName + "(?, ?)")); - q.addBindValue(timeStampCol, QSql::In); - QVariantList emptyDateTimes; - emptyDateTimes.reserve(timeStampCol.size()); - for (int i = 0; i < timeStampCol.size(); i++) - emptyDateTimes << QVariant(QDateTime()); - q.addBindValue(emptyDateTimes, QSql::Out); QVERIFY_SQL(q, execBatch()); - QCOMPARE(q.boundValue(1).toList(), timeStampCol); + QVERIFY_SQL(q, exec(QStringLiteral("select id, name, dt, num, dtstamp, extraId, extraName from ") + + tableName)); + + for (int i = 0; i < intCol.size(); ++i) { + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), intCol.at(i)); + QCOMPARE(q.value(1).toString(), charCol.at(i)); + QCOMPARE(q.value(2).toDate(), dateCol.at(i)); + QCOMPARE(q.value(3).toDouble(), numCol.at(i)); + if (tst_Databases::getDatabaseType(db) == QSqlDriver::MySqlServer && timeStampCol.at(i).isNull()) { + QEXPECT_FAIL("", "This appears to be a bug in MySQL as it converts null datetimes to the " + "current datetime for a timestamp field", Continue); + } + QCOMPARE(q.value(4).toDateTime(), timeStampCol.at(i)); + QCOMPARE(q.value(5).toInt(), intCol.at(i)); + QCOMPARE(q.value(6).toString(), charCol.at(i)); + } + + // Only test the prepared stored procedure approach where the driver has support + // for batch operations as this will not work without it + if (db.driver()->hasFeature(QSqlDriver::BatchOperations)) { + const QString procName = qTableName("qtest_batch_proc", __FILE__, db); + QVERIFY_SQL(q, exec("create or replace procedure " + procName + + " (x in timestamp, y out timestamp) is\n" + "begin\n" + " y := x;\n" + "end;\n")); + QVERIFY(q.prepare("call " + procName + "(?, ?)")); + q.addBindValue(timeStampCol, QSql::In); + QVariantList emptyDateTimes; + emptyDateTimes.reserve(timeStampCol.size()); + for (int i = 0; i < timeStampCol.size(); i++) + emptyDateTimes << QVariant(QDateTime()); + q.addBindValue(emptyDateTimes, QSql::Out); + QVERIFY_SQL(q, execBatch()); + QCOMPARE(q.boundValue(1).toList(), timeStampCol); + } } void tst_QSqlQuery::QTBUG_43874() diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index d2b13f9c4e..3cbc9ebb5e 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -36,11 +36,11 @@ if(*-g++*|*-icc*|*-clang*|*-llvm):!win32-*: HEADERS += os9-newlines.h win-newlin if(*-g++*|*-clang*): HEADERS += dollars.h SOURCES += tst_moc.cpp -QT = core sql network testlib -qtHaveModule(dbus) { - DEFINES += WITH_DBUS - QT += dbus -} +QT = core testlib +qtHaveModule(dbus): QT += dbus +qtHaveModule(concurrent): QT += concurrent +qtHaveModule(network): QT += network +qtHaveModule(sql): QT += sql # tst_Moc::specifyMetaTagsFromCmdline() # Ensure that plugin_metadata.h are moc-ed with some extra -M arguments: diff --git a/tests/auto/tools/moc/no-keywords.h b/tests/auto/tools/moc/no-keywords.h index d31063665b..ca77056503 100644 --- a/tests/auto/tools/moc/no-keywords.h +++ b/tests/auto/tools/moc/no-keywords.h @@ -37,16 +37,19 @@ #define slots Baz #define emit Yoyodyne +#include <QtCore/QtCore> + +#ifdef QT_CONCURRENT_LIB #include <QtConcurrent/QtConcurrent> -#include <QtCore> +#endif +#ifdef QT_NETWORK_LIB #include <QtNetwork/QtNetwork> +#endif +#ifdef QT_SQL_LIB #include <QtSql/QtSql> -//#include <QtSvg> -#if defined(WITH_DBUS) -#include <QtDBus> #endif -#ifdef QT_SCRIPT_LIB -#include <QtScript> +#ifdef QT_DBUS_LIB +#include <QtDBus/QtDBus> #endif #undef signals diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 786b9e72f1..abb7a1a964 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -1604,6 +1604,12 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "" << true; + QTest::newRow("$$absolute_path(): relative file & relative path") + << "VAR = $$absolute_path(dir/file.ext, some/where)" + << "VAR = " + qindir + "/some/where/dir/file.ext" + << "" + << true; + QTest::newRow("$$absolute_path(): file & path") << "VAR = $$absolute_path(dir/file.ext, " EVAL_DRIVE "/root/sub)" << "VAR = " EVAL_DRIVE "/root/sub/dir/file.ext" @@ -1642,6 +1648,12 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "" << true; + QTest::newRow("$$relative_path(): relative file & relative path") + << "VAR = $$relative_path(dir/file.ext, some/where)" + << "VAR = dir/file.ext" + << "" + << true; + QTest::newRow("$$relative_path(): relative file to empty") << "VAR = $$relative_path(dir/..)" << "VAR = ." @@ -2752,9 +2764,9 @@ void tst_qmakelib::proEval_data() // Raw data leak with empty file name. Verify with Valgrind or asan. QTest::newRow("QTBUG-54550") - << "FULL = /there/is\n" + << "FULL = " EVAL_DRIVE "/there/is\n" "VAR = $$absolute_path(, $$FULL/nothing/here/really)" - << "VAR = /there/is/nothing/here/really" + << "VAR = " EVAL_DRIVE "/there/is/nothing/here/really" << "" << true; } diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index c4b26bb350..582c0e36a0 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2992,19 +2992,14 @@ void tst_QGraphicsView::acceptMousePressEvent() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QMouseEvent event(QEvent::MouseButtonPress, - view.viewport()->rect().center(), - view.viewport()->mapToGlobal(view.viewport()->rect().center()), - Qt::LeftButton, 0, 0); - event.setAccepted(false); - QApplication::sendEvent(view.viewport(), &event); + QTest::mouseClick(view.viewport(), Qt::LeftButton); QVERIFY(!view.pressAccepted); + QSignalSpy spy(&scene, &QGraphicsScene::changed); scene.addRect(0, 0, 2000, 2000)->setFlag(QGraphicsItem::ItemIsMovable); + QVERIFY(spy.wait()); - qApp->processEvents(); // ensure scene rect is updated - - QApplication::sendEvent(view.viewport(), &event); + QTest::mouseClick(view.viewport(), Qt::LeftButton); QVERIFY(view.pressAccepted); } @@ -3016,19 +3011,14 @@ void tst_QGraphicsView::acceptMouseDoubleClickEvent() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QMouseEvent event(QEvent::MouseButtonDblClick, - view.viewport()->rect().center(), - view.viewport()->mapToGlobal(view.viewport()->rect().center()), - Qt::LeftButton, 0, 0); - event.setAccepted(false); - QApplication::sendEvent(view.viewport(), &event); + QTest::mouseDClick(view.viewport(), Qt::LeftButton); QVERIFY(!view.doubleClickAccepted); + QSignalSpy spy(&scene, &QGraphicsScene::changed); scene.addRect(0, 0, 2000, 2000)->setFlag(QGraphicsItem::ItemIsMovable); + QVERIFY(spy.wait()); - qApp->processEvents(); // ensure scene rect is updated - - QApplication::sendEvent(view.viewport(), &event); + QTest::mouseDClick(view.viewport(), Qt::LeftButton); QVERIFY(view.doubleClickAccepted); } |