From 3d5e9a0ba1f731352eeead2beecf600d27810e74 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Apr 2016 13:25:16 +0200 Subject: Tablet device_information manual test: show wheel events received MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a bug that proximity events are generating them spuriously; this is a way of testing it. Task-number: QTBUG-52921 Change-Id: I490dfcf8d5b325f612b733e29fd49de9418bb19e Reviewed-by: Morten Johan Sørvig --- tests/manual/qtabletevent/device_information/tabletwidget.cpp | 8 +++++++- tests/manual/qtabletevent/device_information/tabletwidget.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index f1d838f01d..0b33f4e7c6 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -38,7 +38,7 @@ #include #include -TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo) +TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); @@ -87,6 +87,10 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mGPos = event->globalPos(); mTimestamp = event->timestamp(); } + break; + case QEvent::Wheel: + ++mWheelEventCount; + break; default: break; } @@ -181,6 +185,8 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("z: %1").arg(QString::number(mZ)); eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique)); + + eventInfo << QString("Total wheel events: %1").arg(QString::number(mWheelEventCount)); } QString text = eventInfo.join("\n"); diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 95631be57b..97dea8d389 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -66,6 +66,7 @@ private: qint64 mUnique; bool mMouseToo; ulong mTimestamp; + int mWheelEventCount; }; #endif // TABLETWIDGET_H -- cgit v1.2.3 From 3a8f895d3529d59b7a1ea35705f86a2fcdeb35e4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Apr 2016 13:24:02 +0200 Subject: tst_QWidget/XCB: Use bottom/right corner of screen as safe cursor position. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pushing the mouse rapidly to the top left corner causes KDE / KWin to switch to "Present all Windows" (Ctrl+F9) mode, showing all windows. This has been observed to be triggered programmatically by QCursor::setPos(0, 0) if there is no other window beneath and apparently depending on the perceived mouse "speed". Suppress this by using the bottom right corner for XCB. Change-Id: Id18d2f45a095ed4d4f365f010cf45a20b0d9435e Reviewed-by: Tony Sarajärvi --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b9fe40e64c..55b6aff237 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -470,6 +470,7 @@ private: const QString m_platform; QSize m_testWidgetSize; QPoint m_availableTopLeft; + QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; }; @@ -627,6 +628,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() @@ -669,7 +671,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); @@ -5669,7 +5677,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 popup(new QWidget(0, Qt::Popup)); popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass)); popup->setWindowTitle(popup->objectName()); @@ -6020,7 +6028,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); { @@ -8883,7 +8891,7 @@ void tst_QWidget::syntheticEnterLeave() int numLeaveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(m_safeCursorPos); MyWidget window; window.setWindowFlags(Qt::WindowStaysOnTopHint); @@ -9003,7 +9011,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); @@ -10179,7 +10187,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); @@ -10435,7 +10443,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); -- cgit v1.2.3 From adac71c04454219bdca79cbace5a1d9c18ce05c4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Nov 2015 18:34:07 -0800 Subject: tst_compiler: Expand the attribute test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not exhaustive, but was enough to discover ICEs. Change-Id: Ib60be1d298a66b72e3eb9b75ad538f0bf15b5f62 Reviewed-by: Maurice Kalinowski Reviewed-by: Simo Fält Reviewed-by: Thiago Macieira --- tests/auto/other/compiler/tst_compiler.cpp | 90 ++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index af0fa4682d..540c155fd8 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -684,25 +684,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 -- cgit v1.2.3 From 9be4ee52021bbb3227611979319ab5e3106063b2 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Thu, 3 Mar 2016 21:56:53 -0800 Subject: QtDBus: finish all pending call with error if disconnected libdbus will send a local signal if connection gets disconnected. When this happens, end all pending calls with QDBusError::Disconnected. Task-number: QTBUG-51649 Change-Id: I5c7d2a468bb5da746d0c0e53e458c1e376f186a9 Reviewed-by: Thiago Macieira --- .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 21 +++++++++++++++++++++ .../auto/dbus/qdbusconnection/tst_qdbusconnection.h | 1 + 2 files changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index e91f87d6c8..f378091c58 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1218,6 +1218,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 a53ba320f8..720e484cc2 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -121,6 +121,7 @@ private slots: void registerVirtualObject(); void callVirtualObject(); void callVirtualObjectLocal(); + void pendingCallWhenDisconnected(); public: QString serviceName() const { return "org.qtproject.Qt.Autotests.QDBusConnection"; } -- cgit v1.2.3 From 8c2b7405b4a5f7d0fee62b78a17100529e611a5c Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 24 Apr 2016 19:52:37 +0200 Subject: QPdf: Force miter limit into valid range Miter limits below 1.0 are not valid in PDF and trigger an error in the Reader. This change enforces a minimum miter limit of 1.0, and it adds a manual test for producing a PDF file demonstrating this issue. Task-number: QTBUG-52641 Change-Id: I1c78b1c4a44579e95e1cddfb459926d304e60165 Reviewed-by: Lars Knoll --- tests/manual/manual.pro | 1 + tests/manual/qtbug-52641/main.cpp | 87 ++++++++++++++++++++++++++++++++ tests/manual/qtbug-52641/qtbug-52641.pro | 5 ++ 3 files changed, 93 insertions(+) create mode 100644 tests/manual/qtbug-52641/main.cpp create mode 100644 tests/manual/qtbug-52641/qtbug-52641.pro (limited to 'tests') diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 8777cc6e11..bec098d462 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -31,6 +31,7 @@ qsysinfo \ qtabletevent \ qtexteditlist \ qtbug-8933 \ +qtbug-52641 \ qtouchevent \ touch \ qwidget_zorder \ diff --git a/tests/manual/qtbug-52641/main.cpp b/tests/manual/qtbug-52641/main.cpp new file mode 100644 index 0000000000..33ebd8584c --- /dev/null +++ b/tests/manual/qtbug-52641/main.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Kai Pastor +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + QString filepath = QFileDialog::getSaveFileName(nullptr, "Save File", "", + "PDF files (*.pdf)"); + if (filepath.isEmpty()) + return 1; + QPdfWriter writer(filepath); + writer.setPageSize(QPageSize(QPageSize::A4)); + writer.setResolution(300); + + QPainterPath path; + path.moveTo(0,0); + path.lineTo(1000,0); + path.lineTo(1000,1000); + path.lineTo(0,800); + path.lineTo(500,100); + path.lineTo(800,900); + path.lineTo(300,600); + + QPen pen; + pen.setWidth(30); + pen.setJoinStyle(Qt::MiterJoin); + + // The black path on the first page must always be visible in the PDF viewer. + QPainter p(&writer); + pen.setMiterLimit(6.0); + p.setPen(pen); + p.drawPath(path); + + // If a miter limit below 1.0 is written to the PDF, + // broken PDF viewers may not show the red path on the second page. + writer.newPage(); + pen.setMiterLimit(0.6); + pen.setColor(Qt::red); + p.setPen(pen); + p.drawPath(path); + + p.end(); + return 0; +} diff --git a/tests/manual/qtbug-52641/qtbug-52641.pro b/tests/manual/qtbug-52641/qtbug-52641.pro new file mode 100644 index 0000000000..5a9ff6df52 --- /dev/null +++ b/tests/manual/qtbug-52641/qtbug-52641.pro @@ -0,0 +1,5 @@ +TARGET = qtbug-52641 +TEMPLATE = app +QT = core gui widgets +SOURCES = main.cpp + -- cgit v1.2.3 From ab2f768a8f1e1e43e70de4129b2ca9422f5f2dce Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 28 Apr 2016 22:35:14 -0700 Subject: Autotest: fix the QTimeZone::tzTest failure when database contains LMT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some operating systems, tzdata files carry the Local Mean Time (LMT) for the city in question, which better represents how time was tracked before standard, hourly timezones were introduced in the early 20th century. The test was asking for the data for 1653-02-09 and assumed that it would find the first Central European Time (CET) rule, which Germany didn't start using until 1893-04-01. This fix allows us to remove the blacklist that had been applied to this test without investigation. It wasn't related to OpenSUSE, aside from the fact that OpenSUSE tzdata carries the LMT data. Change-Id: Id5480807d25e49e78b79ffff1449bdaf46901367 Reviewed-by: Simon Hausmann Reviewed-by: Tony Sarajärvi --- tests/auto/corelib/tools/qtimezone/BLACKLIST | 2 -- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 tests/auto/corelib/tools/qtimezone/BLACKLIST (limited to 'tests') 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 32bb2aa394..ea835108ee 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -767,16 +767,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::min()); - QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); - QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); + // Test previous to low value is invalid + dat = tzp.previousTransition(-9999999999999); + QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits::min()); + QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); + QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); + } dat = tzp.nextTransition(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); -- cgit v1.2.3 From 91f536dd71cd154675264c27273020f4de310ec2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Apr 2016 14:11:28 +0200 Subject: tst_QMdiArea::subWindowActivated2(): Add activateWindow(). The widget is hidden, reshown and tested for active window, which is flaky. Add a call to activateWindow() which increases the chances of it becoming the active window should another window appear. Change-Id: Ibbecdbc43e2ac9638aec497c47fffaaffa1855af Reviewed-by: Simon Hausmann --- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index aa86e02465..57be110c15 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -497,6 +497,7 @@ void tst_QMdiArea::subWindowActivated2() spy.clear(); mdiArea.show(); + mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); QTRY_COMPARE(spy.count(), 1); QVERIFY(mdiArea.currentSubWindow()); -- cgit v1.2.3 From 002112e80516a29efbb6cef721d74c5fc39fc19d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Apr 2016 14:28:08 +0200 Subject: Fix scroll regression near scroll-view ends Fix regression in a7b0cb467ca5c4a9447d049910c9e3f0abc5897c which caused it to be hard to start scrolling at the ends of a scroll-view if using fine grained scrolling events. Change-Id: I55f3210150b993281545c3ad5a7356d892fa30b5 Reviewed-by: Simon Hausmann --- .../qabstractslider/tst_qabstractslider.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 3c150e77b9..5e461d6a7d 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -82,6 +82,8 @@ private slots: #ifndef QT_NO_WHEELEVENT void wheelEvent_data(); void wheelEvent(); + void fineGrainedWheelEvent_data(); + void fineGrainedWheelEvent(); #endif void sliderPressedReleased_data(); void sliderPressedReleased(); @@ -897,6 +899,55 @@ void tst_QAbstractSlider::wheelEvent() if (expectedSignalCount) QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp); } + +void tst_QAbstractSlider::fineGrainedWheelEvent_data() +{ + QTest::addColumn("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() -- cgit v1.2.3