diff options
Diffstat (limited to 'tests/auto')
8 files changed, 186 insertions, 20 deletions
diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/tools/qtimezone/BLACKLIST deleted file mode 100644 index 665e78bc08..0000000000 --- a/tests/auto/corelib/tools/qtimezone/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[tzTest] -opensuse-13.1 diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index 077a6a20f1..9fd418742c 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -762,16 +762,22 @@ void tst_QTimeZone::tzTest() // Warning: This could vary depending on age of TZ file! // Test low date uses first rule found + // Note: Depending on the OS in question, the database may be carrying the + // Local Mean Time. which for Berlin is 0:53:28 QTimeZonePrivate::Data dat = tzp.data(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-9999999999999); - QCOMPARE(dat.standardTimeOffset, 3600); QCOMPARE(dat.daylightTimeOffset, 0); + if (dat.abbreviation == "LMT") { + QCOMPARE(dat.standardTimeOffset, 3208); + } else { + QCOMPARE(dat.standardTimeOffset, 3600); - // Test previous to low value is invalid - dat = tzp.previousTransition(-9999999999999); - QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits<qint64>::min()); - QCOMPARE(dat.standardTimeOffset, std::numeric_limits<int>::min()); - QCOMPARE(dat.daylightTimeOffset, std::numeric_limits<int>::min()); + // Test previous to low value is invalid + dat = tzp.previousTransition(-9999999999999); + QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits<qint64>::min()); + QCOMPARE(dat.standardTimeOffset, std::numeric_limits<int>::min()); + QCOMPARE(dat.daylightTimeOffset, std::numeric_limits<int>::min()); + } dat = tzp.nextTransition(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 3418a34c12..0163f44a36 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1213,6 +1213,27 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.replyArguments, subPathReply.arguments()); } +void tst_QDBusConnection::pendingCallWhenDisconnected() +{ + if (!QCoreApplication::instance()) + QSKIP("Test requires a QCoreApplication"); + + QDBusServer *server = new QDBusServer; + QDBusConnection con = QDBusConnection::connectToPeer(server->address(), "disconnect"); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(con.isConnected()); + QDBusMessage message = QDBusMessage::createMethodCall("", "/", QString(), "method"); + QDBusPendingCall reply = con.asyncCall(message); + + delete server; + + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!con.isConnected()); + QVERIFY(reply.isFinished()); + QVERIFY(reply.isError()); + QVERIFY(reply.error().type() == QDBusError::Disconnected); +} + QString MyObject::path; QString MyObjectWithoutInterface::path; QString MyObjectWithoutInterface::interface; diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h index 0e2943b1c4..0402889c6e 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -116,6 +116,7 @@ private slots: void registerVirtualObject(); void callVirtualObject(); void callVirtualObjectLocal(); + void pendingCallWhenDisconnected(); public: QString serviceName() const { return "org.qtproject.Qt.Autotests.QDBusConnection"; } diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index d554a50c8d..50cfe48cdf 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -679,25 +679,105 @@ void tst_Compiler::cxx11_atomics() #endif } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wignored-attributes") +QT_WARNING_DISABLE_CLANG("-Wunused-local-typedefs") +QT_WARNING_DISABLE_GCC("-Wattributes") +QT_WARNING_DISABLE_GCC("-Wunused-local-typedefs") + +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif +#ifdef Q_COMPILER_ATTRIBUTES +[[noreturn]] void attribute_f1(); +void attribute_f2 [[noreturn]] (); +# if (defined(__cpp_namespace_attributes) && __cpp_namespace_attributes >= 201411) && __has_cpp_attribute(deprecated) +namespace NS [[deprecated]] { } +# endif +#endif + void tst_Compiler::cxx11_attributes() { #ifndef Q_COMPILER_ATTRIBUTES QSKIP("Compiler does not support C++11 feature"); #else - struct [[deprecated]] C {}; + // Attributes in function parameters and using clauses cause MSVC 2015 to crash + // https://connect.microsoft.com/VisualStudio/feedback/details/2011594 +# if (!defined(Q_CC_MSVC) || _MSC_FULL_VER >= 190023811) && !defined(Q_CC_INTEL) + void f([[ ]] int); + [[ ]] using namespace QtPrivate; + [[ ]] try { + } catch ([[]] int) { + } +# endif + + struct [[ ]] A { }; + struct B : A { + [[ ]] int m_i : 32; + [[noreturn]] void f() const { ::exit(0); } + +# ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS + [[ ]] ~B() = default; + [[ ]] B(const B &) = delete; +# endif + }; +# if __has_cpp_attribute(deprecated) + struct [[deprecated]] C { }; +# endif + enum [[ ]] E { }; + [[ ]] void [[ ]] * [[ ]] * [[ ]] ptr = 0; + int B::* [[ ]] pmm = 0; + +# if __has_cpp_attribute(deprecated) + enum [[deprecated]] E2 { +# if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411 + value [[deprecated]] = 0 +# endif + }; +# endif +# ifdef Q_COMPILER_LAMBDA + []()[[ ]] {}(); +# endif +# ifdef Q_COMPILER_TEMPLATE_ALIAS + using B2 [[ ]] = B; +# endif + + [[ ]] goto end; +# ifdef Q_CC_GNU + // Attributes in gnu:: namespace + [[gnu::unused]] end: + ; [[gnu::unused]] struct D {} d; - [[noreturn]] void f(); struct D e [[gnu::used, gnu::unused]]; - [[gnu::aligned(8)]] int i; + [[gnu::aligned(8)]] int i [[ ]]; + int array[][[]] = { 1 }; +# else + // Non GNU, so use an empty attribute + [[ ]] end: + ; + [[ ]] struct D {} d; + struct D e [[ ]]; + [[ ]] int i [[ ]]; + int array[][[]] = { 1 }; +# endif -[[gnu::unused]] end: - ; + int & [[ ]] lref = i; + int && [[ ]] rref = 1; + [[ ]] (void)1; + [[ ]] for (i = 0; i < 2; ++i) + ; + Q_UNUSED(ptr); + Q_UNUSED(pmm); Q_UNUSED(d); Q_UNUSED(e); Q_UNUSED(i); + Q_UNUSED(array); + Q_UNUSED(lref); + Q_UNUSED(rref); #endif } +QT_WARNING_POP #ifdef Q_COMPILER_AUTO_FUNCTION auto autoFunction() -> unsigned diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 3183fc7375..f0e7cb5901 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -465,6 +465,7 @@ private: const QString m_platform; QSize m_testWidgetSize; QPoint m_availableTopLeft; + QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; }; @@ -622,6 +623,7 @@ void tst_QWidget::getSetCheck() tst_QWidget::tst_QWidget() : m_platform(QGuiApplication::platformName().toLower()) + , m_safeCursorPos(0, 0) , m_windowsAnimationsEnabled(windowsAnimationsEnabled()) { if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild() @@ -664,7 +666,13 @@ void tst_QWidget::initTestCase() // to avoid Windows warnings about minimum size for decorated windows. int width = 200; const QScreen *screen = QGuiApplication::primaryScreen(); - m_availableTopLeft = screen->availableGeometry().topLeft(); + const QRect availableGeometry = screen->availableGeometry(); + m_availableTopLeft = availableGeometry.topLeft(); + // XCB: Determine "safe" cursor position at bottom/right corner of screen. + // Pushing the mouse rapidly to the top left corner can trigger KDE / KWin's + // "Present all Windows" (Ctrl+F9) feature also programmatically. + if (m_platform == QLatin1String("xcb")) + m_safeCursorPos = availableGeometry.bottomRight() - QPoint(40, 40); const int screenWidth = screen->geometry().width(); if (screenWidth > 2000) width = 100 * ((screenWidth + 500) / 1000); @@ -5664,7 +5672,7 @@ void tst_QWidget::setToolTip() // Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform. #ifndef Q_OS_WINCE_WM for (int pass = 0; pass < 2; ++pass) { - QCursor::setPos(0, 0); + QCursor::setPos(m_safeCursorPos); QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup)); popup->setObjectName(QLatin1String("tst_qwidget setToolTip #") + QString::number(pass)); popup->setWindowTitle(popup->objectName()); @@ -6015,7 +6023,7 @@ void tst_QWidget::childEvents() // Move away the cursor; otherwise it might result in an enter event if it's // inside the widget when the widget is shown. - QCursor::setPos(qApp->desktop()->availableGeometry().bottomRight()); + QCursor::setPos(m_safeCursorPos); QTest::qWait(100); { @@ -8878,7 +8886,7 @@ void tst_QWidget::syntheticEnterLeave() int numLeaveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(m_safeCursorPos); MyWidget window; window.setWindowFlags(Qt::WindowStaysOnTopHint); @@ -8998,7 +9006,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() int numEnterEvents, numMouseMoveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(m_safeCursorPos); SELParent parent; parent.move(200, 200); @@ -10174,7 +10182,7 @@ void tst_QWidget::destroyedSignal() void tst_QWidget::underMouse() { // Move the mouse cursor to a safe location - QCursor::setPos(0,0); + QCursor::setPos(m_safeCursorPos); ColorWidget topLevelWidget(0, Qt::FramelessWindowHint, Qt::blue); ColorWidget childWidget1(&topLevelWidget, Qt::Widget, Qt::yellow); @@ -10430,7 +10438,7 @@ public: void tst_QWidget::taskQTBUG_27643_enterEvents() { // Move the mouse cursor to a safe location so it won't interfere - QCursor::setPos(0,0); + QCursor::setPos(m_safeCursorPos); EnterTestMainDialog dialog; QPushButton button(&dialog); diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index d4b221a4a7..e68463a00e 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -77,6 +77,8 @@ private slots: #ifndef QT_NO_WHEELEVENT void wheelEvent_data(); void wheelEvent(); + void fineGrainedWheelEvent_data(); + void fineGrainedWheelEvent(); #endif void sliderPressedReleased_data(); void sliderPressedReleased(); @@ -892,6 +894,55 @@ void tst_QAbstractSlider::wheelEvent() if (expectedSignalCount) QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp); } + +void tst_QAbstractSlider::fineGrainedWheelEvent_data() +{ + QTest::addColumn<bool>("invertedControls"); + QTest::newRow("invertedControls=false") << false; + QTest::newRow("invertedControls=true") << true; +} + +void tst_QAbstractSlider::fineGrainedWheelEvent() +{ + QFETCH(bool, invertedControls); + + QCoreApplication *applicationInstance = QCoreApplication::instance(); + QVERIFY(applicationInstance != 0); + QApplication::setWheelScrollLines(3); + + slider->setRange(0, 10); + slider->setSingleStep(1); + slider->setPageStep(10); + slider->setInvertedControls(invertedControls); + slider->setOrientation(Qt::Vertical); + slider->setSliderPosition(0); + + const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3); + + QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2, + Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 1); + + QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2, + Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 1); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 1); +} + #endif // !QT_NO_WHEELEVENT void tst_QAbstractSlider::sliderPressedReleased_data() diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 607fc1625a..d568cf63d4 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -492,6 +492,7 @@ void tst_QMdiArea::subWindowActivated2() spy.clear(); mdiArea.show(); + mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); QTRY_COMPARE(spy.count(), 1); QVERIFY(mdiArea.currentSubWindow()); |