summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFrans Englich <frans.englich@nokia.com>2009-10-15 08:58:59 (GMT)
committerFrans Englich <frans.englich@nokia.com>2009-10-15 08:58:59 (GMT)
commitd245034a54d20a3ff59575158dbf8705547648a7 (patch)
tree6fdbf2718e6613e8af60b0fa4e77ba9b1f41660a /tests
parent16dab236acbd35c351c1ac1d36dbf018db0d278c (diff)
parent376a5a845ba6d19751a58ea79a8d5701c4ba4d13 (diff)
downloadQt-d245034a54d20a3ff59575158dbf8705547648a7.zip
Qt-d245034a54d20a3ff59575158dbf8705547648a7.tar.gz
Qt-d245034a54d20a3ff59575158dbf8705547648a7.tar.bz2
Merge commit 'origin/4.6' into mmfphonon
Conflicts: src/corelib/kernel/qcoreevent.cpp src/corelib/kernel/qcoreevent.h
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/bic/tst_bic.cpp2
-rw-r--r--tests/auto/gestures/gestures.pro5
-rw-r--r--tests/auto/gestures/tst_gestures.cpp628
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp2
-rw-r--r--tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp10
-rw-r--r--tests/auto/qabstractslider/tst_qabstractslider.cpp18
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp4
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp7
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp2
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp18
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp2
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp81
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp36
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp6
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp14
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp53
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp3
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp3
-rw-r--r--tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp16
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp2
-rw-r--r--tests/auto/qpauseanimation/qpauseanimation.pro5
-rw-r--r--tests/auto/qpauseanimation/tst_qpauseanimation.cpp409
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp26
-rw-r--r--tests/auto/qsidebar/tst_qsidebar.cpp26
-rw-r--r--tests/auto/qsound/qsound.pro2
-rw-r--r--tests/auto/qsound/tst_qsound.cpp4
-rw-r--r--tests/auto/qspinbox/tst_qspinbox.cpp10
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h1
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp48
-rw-r--r--tests/auto/qsqldriver/tst_qsqldriver.cpp15
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp5
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp2
-rw-r--r--tests/auto/qsqlrecord/qsqlrecord.pro6
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp8
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp7
-rw-r--r--tests/auto/qsqlthread/tst_qsqlthread.cpp2
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp1
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp169
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp18
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp9
-rw-r--r--tests/auto/qtoolbar/tst_qtoolbar.cpp123
-rw-r--r--tests/auto/quuid/tst_quuid.cpp26
-rw-r--r--tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp39
-rw-r--r--tests/auto/qwidgetaction/tst_qwidgetaction.cpp2
-rw-r--r--tests/auto/selftests/tst_selftests.cpp2
-rw-r--r--tests/manual/gestures/graphicsview/gestures.cpp131
-rw-r--r--tests/manual/gestures/graphicsview/gestures.h78
-rw-r--r--tests/manual/gestures/graphicsview/graphicsview.pro17
-rw-r--r--tests/manual/gestures/graphicsview/imageitem.cpp93
-rw-r--r--tests/manual/gestures/graphicsview/imageitem.h (renamed from tests/manual/gestures/pinch/pinchwidget.h)47
-rw-r--r--tests/manual/gestures/graphicsview/main.cpp228
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp95
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.h (renamed from tests/manual/gestures/pinch/main.cpp)33
-rw-r--r--tests/manual/gestures/pinch/pinch.pro4
-rw-r--r--tests/manual/gestures/pinch/pinch.qrc5
-rw-r--r--tests/manual/gestures/pinch/pinchwidget.cpp118
-rw-r--r--tests/manual/gestures/pinch/qt-logo.pngbin13923 -> 0 bytes
-rw-r--r--tests/manual/gestures/scrollarea/main.cpp229
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp94
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.h57
-rw-r--r--tests/manual/gestures/scrollarea/scrollarea.pro3
-rw-r--r--tests/manual/gestures/twopanwidgets/main.cpp135
-rw-r--r--tests/manual/gestures/twopanwidgets/twopanwidgets.pro1
66 files changed, 2813 insertions, 440 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index f3ecdae..8e3ce81 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -234,6 +234,7 @@ SUBDIRS += \
qpainterpath \
qpalette \
qparallelanimationgroup \
+ qpauseanimation \
qpathclipper \
qpen \
qpicture \
@@ -398,7 +399,8 @@ SUBDIRS += \
selftests \
symbols \
qrand \
- utf8
+ utf8 \
+ gestures
!wince*:SUBDIRS += $$Q3SUBDIRS
diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp
index 82c8dc0..8c6056e 100644
--- a/tests/auto/bic/tst_bic.cpp
+++ b/tests/auto/bic/tst_bic.cpp
@@ -252,6 +252,7 @@ QBic::Info tst_Bic::getCurrentInfo(const QString &libName)
}
if (proc.exitCode() != 0) {
qWarning() << "gcc returned with" << proc.exitCode();
+ qDebug() << proc.readAllStandardError();
return QBic::Info();
}
@@ -268,6 +269,7 @@ QBic::Info tst_Bic::getCurrentInfo(const QString &libName)
qFatal("Could not locate the GCC output file, update this test");
return QBic::Info();
} else if (files.size() > 1) {
+ qDebug() << files;
qFatal("Located more than one output file, please clean up before running this test");
return QBic::Info();
}
diff --git a/tests/auto/gestures/gestures.pro b/tests/auto/gestures/gestures.pro
new file mode 100644
index 0000000..da5610f
--- /dev/null
+++ b/tests/auto/gestures/gestures.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES += tst_gestures.cpp
+
+
+
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
new file mode 100644
index 0000000..46ed45e
--- /dev/null
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -0,0 +1,628 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+
+#include <qevent.h>
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qgesture.h>
+#include <qgesturerecognizer.h>
+#include <qgraphicsitem.h>
+#include <qgraphicsview.h>
+
+#include <qdebug.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class CustomGesture : public QGesture
+{
+ Q_OBJECT
+public:
+ static Qt::GestureType GestureType;
+
+ CustomGesture(QObject *parent = 0)
+ : QGesture(parent), target(0), serial(0)
+ {
+ }
+
+ QObject *target;
+ int serial;
+
+ static const int SerialMaybeThreshold;
+ static const int SerialStartedThreshold;
+ static const int SerialFinishedThreshold;
+};
+Qt::GestureType CustomGesture::GestureType = Qt::CustomGesture;
+const int CustomGesture::SerialMaybeThreshold = 1;
+const int CustomGesture::SerialStartedThreshold = 3;
+const int CustomGesture::SerialFinishedThreshold = 6;
+
+class CustomEvent : public QEvent
+{
+public:
+ static int EventType;
+
+ CustomEvent(int serial_ = 0)
+ : QEvent(QEvent::Type(CustomEvent::EventType)),
+ serial(serial_), targetObject(0)
+ {
+ }
+
+ int serial;
+ QObject *targetObject;
+ QPoint hotSpot;
+};
+int CustomEvent::EventType = 0;
+
+class CustomGestureRecognizer : public QGestureRecognizer
+{
+public:
+ CustomGestureRecognizer()
+ {
+ CustomEvent::EventType = QEvent::registerEventType();
+ eventsCounter = 0;
+ }
+
+ QGesture* createGesture(QObject *)
+ {
+ return new CustomGesture;
+ }
+
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event)
+ {
+ if (event->type() == CustomEvent::EventType) {
+ QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint;
+ CustomGesture *g = static_cast<CustomGesture*>(state);
+ CustomEvent *e = static_cast<CustomEvent*>(event);
+ g->serial = e->serial;
+ g->setTargetObject(e->targetObject);
+ g->setHotSpot(e->hotSpot);
+ ++eventsCounter;
+ if (g->serial >= CustomGesture::SerialFinishedThreshold)
+ result |= QGestureRecognizer::GestureFinished;
+ else if (g->serial >= CustomGesture::SerialStartedThreshold)
+ result |= QGestureRecognizer::GestureTriggered;
+ else if (g->serial >= CustomGesture::SerialMaybeThreshold)
+ result |= QGestureRecognizer::MaybeGesture;
+ else
+ result = QGestureRecognizer::NotGesture;
+ return result;
+ }
+ return QGestureRecognizer::Ignore;
+ }
+
+ void reset(QGesture *state)
+ {
+ CustomGesture *g = static_cast<CustomGesture*>(state);
+ g->serial = 0;
+ QGestureRecognizer::reset(state);
+ }
+
+ int eventsCounter;
+ QString name;
+};
+
+class GestureWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ GestureWidget(const char *name = 0)
+ {
+ if (name)
+ setObjectName(QLatin1String(name));
+ reset();
+ acceptGestureOverride = false;
+ }
+ void reset()
+ {
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ }
+
+ int customEventsReceived;
+ int gestureEventsReceived;
+ int gestureOverrideEventsReceived;
+ struct Events
+ {
+ QList<Qt::GestureType> all;
+ QList<Qt::GestureType> started;
+ QList<Qt::GestureType> updated;
+ QList<Qt::GestureType> finished;
+ QList<Qt::GestureType> canceled;
+
+ void clear()
+ {
+ all.clear();
+ started.clear();
+ updated.clear();
+ finished.clear();
+ canceled.clear();
+ }
+ } events, overrideEvents;
+
+ bool acceptGestureOverride;
+
+protected:
+ bool event(QEvent *event)
+ {
+ Events *eventsPtr = 0;
+ if (event->type() == QEvent::Gesture) {
+ ++gestureEventsReceived;
+ eventsPtr = &events;
+ } else if (event->type() == QEvent::GestureOverride) {
+ ++gestureOverrideEventsReceived;
+ eventsPtr = &overrideEvents;
+ if (acceptGestureOverride)
+ event->accept();
+ }
+ if (eventsPtr) {
+ QGestureEvent *e = static_cast<QGestureEvent*>(event);
+ QList<QGesture*> gestures = e->allGestures();
+ foreach(QGesture *g, gestures) {
+ eventsPtr->all << g->gestureType();
+ switch(g->state()) {
+ case Qt::GestureStarted:
+ eventsPtr->started << g->gestureType();
+ break;
+ case Qt::GestureUpdated:
+ eventsPtr->updated << g->gestureType();
+ break;
+ case Qt::GestureFinished:
+ eventsPtr->finished << g->gestureType();
+ break;
+ case Qt::GestureCanceled:
+ eventsPtr->canceled << g->gestureType();
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+ }
+ } else if (event->type() == CustomEvent::EventType) {
+ ++customEventsReceived;
+ } else {
+ return QWidget::event(event);
+ }
+ return true;
+ }
+};
+
+static void sendCustomGesture(QObject *object)
+{
+ CustomEvent ev;
+ ev.targetObject = object;
+ for (int i = CustomGesture::SerialMaybeThreshold;
+ i <= CustomGesture::SerialFinishedThreshold; ++i) {
+ ev.serial = i;
+ QApplication::sendEvent(object, &ev);
+ }
+}
+
+class tst_Gestures : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_Gestures();
+ virtual ~tst_Gestures();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void customGesture();
+ void autoCancelingGestures();
+ void gestureOverChild();
+ void multipleWidgetOnlyGestureInTree();
+ void conflictingGestures();
+ void finishedWithoutStarted();
+ void unknownGesture();
+ void graphicsItemGesture();
+};
+
+tst_Gestures::tst_Gestures()
+{
+}
+
+tst_Gestures::~tst_Gestures()
+{
+}
+
+void tst_Gestures::initTestCase()
+{
+ CustomGesture::GestureType = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ QVERIFY(CustomGesture::GestureType != Qt::GestureType(0));
+ QVERIFY(CustomGesture::GestureType != Qt::CustomGesture);
+}
+
+void tst_Gestures::cleanupTestCase()
+{
+}
+
+void tst_Gestures::init()
+{
+}
+
+void tst_Gestures::cleanup()
+{
+}
+
+void tst_Gestures::customGesture()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ sendCustomGesture(&widget);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+ QCOMPARE(widget.customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(widget.gestureOverrideEventsReceived, 0);
+ QCOMPARE(widget.events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < widget.events.all.size(); ++i)
+ QCOMPARE(widget.events.all.at(i), CustomGesture::GestureType);
+ QCOMPARE(widget.events.started.size(), 1);
+ QCOMPARE(widget.events.updated.size(), TotalGestureEventsCount - 2);
+ QCOMPARE(widget.events.finished.size(), 1);
+ QCOMPARE(widget.events.canceled.size(), 0);
+}
+
+void tst_Gestures::autoCancelingGestures()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ // send partial gesture. The gesture will be in the "maybe" state, but will
+ // never get enough events to fire, so Qt will have to kill it.
+ CustomEvent ev;
+ for (int i = CustomGesture::SerialMaybeThreshold;
+ i < CustomGesture::SerialStartedThreshold; ++i) {
+ ev.serial = i;
+ QApplication::sendEvent(&widget, &ev);
+ }
+ // wait long enough so the gesture manager will cancel the gesture
+ QTest::qWait(5000);
+ QCOMPARE(widget.customEventsReceived, CustomGesture::SerialStartedThreshold - CustomGesture::SerialMaybeThreshold);
+ QCOMPARE(widget.gestureEventsReceived, 0);
+ QCOMPARE(widget.gestureOverrideEventsReceived, 0);
+ QCOMPARE(widget.events.all.size(), 0);
+}
+
+void tst_Gestures::gestureOverChild()
+{
+ GestureWidget widget("widget");
+ QVBoxLayout *l = new QVBoxLayout(&widget);
+ GestureWidget *child = new GestureWidget("child");
+ l->addWidget(child);
+
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+
+ sendCustomGesture(child);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(widget.customEventsReceived, 0);
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(widget.gestureEventsReceived, 0);
+ QCOMPARE(widget.gestureOverrideEventsReceived, 0);
+
+ // enable gestures over the children
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+
+ widget.reset();
+ child->reset();
+
+ sendCustomGesture(child);
+
+ QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(widget.customEventsReceived, 0);
+
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(widget.gestureOverrideEventsReceived, 0);
+ for(int i = 0; i < widget.events.all.size(); ++i)
+ QCOMPARE(widget.events.all.at(i), CustomGesture::GestureType);
+ QCOMPARE(widget.events.started.size(), 1);
+ QCOMPARE(widget.events.updated.size(), TotalGestureEventsCount - 2);
+ QCOMPARE(widget.events.finished.size(), 1);
+ QCOMPARE(widget.events.canceled.size(), 0);
+}
+
+void tst_Gestures::multipleWidgetOnlyGestureInTree()
+{
+ GestureWidget parent("parent");
+ QVBoxLayout *l = new QVBoxLayout(&parent);
+ GestureWidget *child = new GestureWidget("child");
+ l->addWidget(child);
+
+ parent.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ child->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(child);
+
+ QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(parent.customEventsReceived, 0);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(parent.gestureEventsReceived, 0);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+
+ parent.reset();
+ child->reset();
+
+ // same for the parent widget
+ sendCustomGesture(&parent);
+
+ QCOMPARE(child->customEventsReceived, 0);
+ QCOMPARE(parent.customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+}
+
+void tst_Gestures::conflictingGestures()
+{
+ GestureWidget parent("parent");
+ QVBoxLayout *l = new QVBoxLayout(&parent);
+ GestureWidget *child = new GestureWidget("child");
+ l->addWidget(child);
+
+ parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+ child->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // child accepts the override, parent will not receive anything
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = true;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+ QCOMPARE(parent.gestureEventsReceived, 0);
+
+ parent.reset();
+ child->reset();
+
+ // parent accepts the override
+ parent.acceptGestureOverride = true;
+ child->acceptGestureOverride = false;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureEventsReceived, 0);
+
+ parent.reset();
+ child->reset();
+
+ // nobody accepts the override, we will send normal events to the closest context (to the child)
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = false;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureEventsReceived, 0);
+}
+
+void tst_Gestures::finishedWithoutStarted()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+
+ // the gesture will claim it finished, but it was never started.
+ CustomEvent ev;
+ ev.serial = CustomGesture::SerialFinishedThreshold;
+ QApplication::sendEvent(&widget, &ev);
+
+ QCOMPARE(widget.customEventsReceived, 1);
+ QCOMPARE(widget.gestureEventsReceived, 2);
+ QCOMPARE(widget.gestureOverrideEventsReceived, 0);
+ QCOMPARE(widget.events.all.size(), 2);
+ QCOMPARE(widget.events.started.size(), 1);
+ QCOMPARE(widget.events.updated.size(), 0);
+ QCOMPARE(widget.events.finished.size(), 1);
+ QCOMPARE(widget.events.canceled.size(), 0);
+}
+
+void tst_Gestures::unknownGesture()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ widget.grabGesture(Qt::CustomGesture, Qt::WidgetGesture);
+ widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::WidgetGesture);
+
+ sendCustomGesture(&widget);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
+}
+
+class GestureItem : public QGraphicsObject
+{
+public:
+ GestureItem()
+ {
+ size = QRectF(0, 0, 100, 100);
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ acceptGestureOverride = false;
+ }
+
+ int customEventsReceived;
+ int gestureEventsReceived;
+ int gestureOverrideEventsReceived;
+ struct Events
+ {
+ QList<Qt::GestureType> all;
+ QList<Qt::GestureType> started;
+ QList<Qt::GestureType> updated;
+ QList<Qt::GestureType> finished;
+ QList<Qt::GestureType> canceled;
+
+ void clear()
+ {
+ all.clear();
+ started.clear();
+ updated.clear();
+ finished.clear();
+ canceled.clear();
+ }
+ } events, overrideEvents;
+
+ bool acceptGestureOverride;
+
+ QRectF size;
+
+protected:
+ QRectF boundingRect() const
+ {
+ return size;
+ }
+ void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ p->fillRect(boundingRect(), Qt::blue);
+ }
+
+ bool event(QEvent *event)
+ {
+ Events *eventsPtr = 0;
+ if (event->type() == QEvent::Gesture) {
+ ++gestureEventsReceived;
+ eventsPtr = &events;
+ } else if (event->type() == QEvent::GestureOverride) {
+ ++gestureOverrideEventsReceived;
+ eventsPtr = &overrideEvents;
+ if (acceptGestureOverride)
+ event->accept();
+ }
+ if (eventsPtr) {
+ QGestureEvent *e = static_cast<QGestureEvent*>(event);
+ QList<QGesture*> gestures = e->allGestures();
+ foreach(QGesture *g, gestures) {
+ eventsPtr->all << g->gestureType();
+ switch(g->state()) {
+ case Qt::GestureStarted:
+ eventsPtr->started << g->gestureType();
+ break;
+ case Qt::GestureUpdated:
+ eventsPtr->updated << g->gestureType();
+ break;
+ case Qt::GestureFinished:
+ eventsPtr->finished << g->gestureType();
+ break;
+ case Qt::GestureCanceled:
+ eventsPtr->canceled << g->gestureType();
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+ }
+ } else if (event->type() == CustomEvent::EventType) {
+ ++customEventsReceived;
+ } else {
+ return QGraphicsObject::event(event);
+ }
+ return true;
+ }
+};
+
+void tst_Gestures::graphicsItemGesture()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item = new GestureItem;
+ scene.addItem(item);
+ item->setPos(100, 100);
+
+ item->grabGesture(CustomGesture::GestureType);
+
+ sendCustomGesture(item);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item->events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < item->events.all.size(); ++i)
+ QCOMPARE(item->events.all.at(i), CustomGesture::GestureType);
+ QCOMPARE(item->events.started.size(), 1);
+ QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2);
+ QCOMPARE(item->events.finished.size(), 1);
+ QCOMPARE(item->events.canceled.size(), 0);
+}
+
+QTEST_MAIN(tst_Gestures)
+#include "tst_gestures.moc"
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index 6b580df..ecc0594 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -137,6 +137,8 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
}
+ else if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
// please never ever change this table; otherwise fix all tests ;)
if ( tst_Databases::isMSAccess( db ) ) {
diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
index 5893687..68e8ce8 100644
--- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
+++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
@@ -107,9 +107,15 @@ void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db )
if ( !db.isValid() )
return;
QSqlQuery q( db );
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
// please never ever change this table; otherwise fix all tests ;)
- QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
- "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
+ if (tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric number, primary key (id, t_varchar) )" ));
+ else
+ QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
}
void tst_Q3SqlSelectCursor::dropTestTables( QSqlDatabase db )
diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp
index 9f7a78e..5c70bde 100644
--- a/tests/auto/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp
@@ -714,7 +714,11 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // delta
<< int(Qt::Vertical) // orientation of slider
<< int(Qt::Vertical) // orientation of wheel
+#ifdef Q_WS_MAC
+ << 1 // expected position after
+#else
<< 20 // expected position after
+#endif
<< QPoint(0,0);
QTest::newRow("Normal data page") << 0 // initial position
@@ -773,7 +777,11 @@ void tst_QAbstractSlider::wheelEvent_data()
<< 1 // delta
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
+#ifdef Q_WS_MAC
+ << 49 // expected position after
+#else
<< 30 // expected position after
+#endif
<< QPoint(1,1);
QTest::newRow("Past end") << 50 // initial position
@@ -784,7 +792,11 @@ void tst_QAbstractSlider::wheelEvent_data()
<< false // inverted controls
<< 1 // wheel scroll lines
<< false // with modifiers
+#ifdef Q_WS_MAC
+ << 60 // delta
+#else
<< 2 // delta
+#endif
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
<< 100 // expected position after
@@ -798,7 +810,11 @@ void tst_QAbstractSlider::wheelEvent_data()
<< false // inverted controls
<< 1 // wheel scroll lines
<< false // with modifiers
- << -2 // delta
+#ifdef Q_WS_MAC
+ << -60 // delta
+#else
+ << -2 // delta
+#endif
<< int(Qt::Horizontal) // orientation of slider
<< int(Qt::Horizontal) // orientation of wheel
<< 0 // expected position after
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index abcacef..97aa092 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -1242,6 +1242,10 @@ public slots:
}
void deleteLaterAndExitLoop()
{
+ // Check that 'p' is not deleted before exec returns, since the call
+ // to QEventLoop::quit() should stop 'eventLoop' from processing
+ // any more events (that is, delete later) until we return to the
+ // _current_ event loop:
QEventLoop eventLoop;
QPointer<QObject> p(this);
QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index b90873e..b46f88d 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -156,9 +156,14 @@ void tst_QAudioOutput::pullFile()
// Wait until finished...
QTestEventLoop::instance().enterLoop(1);
QCOMPARE(audio->totalTime(), qint64(692250));
+
+#ifdef Q_OS_WINCE
+ // 4.wav is a little less than 700ms, so notify should fire 4 times on Wince!
+ QVERIFY(readSignal.count() >= 4);
+#else
// 4.wav is a little less than 700ms, so notify should fire 6 times!
QVERIFY(readSignal.count() >= 6);
-
+#endif
audio->stop();
QTest::qWait(20); // wait 20ms
QVERIFY(audio->state() == QAudio::StopState);
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index 11c1f47..a19f865 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -406,7 +406,7 @@ void tst_QButtonGroup::task106609()
QTestEventLoop::instance().enterLoop(1);
QApplication::setActiveWindow(&dlg);
- QTRY_COMPARE(QApplication::activeWindow(), &dlg);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg));
//qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count();
QCOMPARE(spy2.count(), 2);
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index e76f0f7..0d3469d 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -151,6 +151,7 @@ private slots:
void subControlRectsWithOffset_data();
void subControlRectsWithOffset();
void task260974_menuItemRectangleForComboBoxPopup();
+ void removeItem();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -2398,5 +2399,22 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
#endif
}
+void tst_QComboBox::removeItem()
+{
+ QComboBox cb;
+ cb.removeItem(-1);
+ cb.removeItem(1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+
+ cb.addItem("foo");
+ cb.removeItem(-1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index f6b082f..dc2ca61 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -944,7 +944,7 @@ void tst_QFiledialog::selectFiles()
QVERIFY(listView);
for (int i = 0; i < list.count(); ++i) {
fd.selectFile(fd.directory().path() + "/" + list.at(i));
-#if defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
+#if defined(QT_MAC_USE_COCOA) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
QEXPECT_FAIL("", "This test does not work on Mac, Windows, or Symbian", Abort);
#endif
QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty());
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 29e4fe6..3b24352 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -874,7 +874,7 @@ void tst_QFileSystemModel::sort()
} else {
for(int i = 0; i < myModel->rowCount(parent); ++i)
{
- QVERIFY(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString() == expectedOrder.at(i));
+ QTRY_COMPARE(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(), expectedOrder.at(i));
}
}
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index e4eaf4e..49b76ac 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -6183,7 +6183,7 @@ void tst_QGraphicsItem::opacity2()
MyGraphicsView view(&scene);
view.show();
QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(view.repaints, 1);
+ QTRY_VERIFY(view.repaints >= 1);
#define RESET_REPAINT_COUNTERS \
parent->repaints = 0; \
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 76e7202..58d7896 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -170,6 +170,7 @@ private slots:
void dontCrashWhenDie();
void createProxyForChildWidget();
void actionsContextMenu();
+ void actionsContextMenu_data();
void deleteProxyForChildWidget();
void bypassGraphicsProxyWidget_data();
void bypassGraphicsProxyWidget();
@@ -1756,6 +1757,8 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
QTRY_VERIFY(leftDial->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2);
+
+ delete view;
}
void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
@@ -1878,6 +1881,8 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
QVERIFY(leftDial->hasFocus());
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2);
+
+ delete view;
}
void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
@@ -1988,6 +1993,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
+
+ delete view;
}
void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
@@ -2156,6 +2163,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
@@ -2222,6 +2231,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
// Symmetry
editProxy->clearFocus();
QVERIFY(!edit->hasFocus());
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
@@ -2272,6 +2283,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
QVERIFY(!editProxy->hasFocus());
QVERIFY(edit2->hasFocus());
QVERIFY(edit2Proxy->hasFocus());
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
@@ -2391,6 +2404,8 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
QCOMPARE(eventSpyBox.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpyBox_2.counts[QEvent::FocusIn], 0);
QCOMPARE(eventSpyBox_2.counts[QEvent::FocusOut], 0);
+
+ delete view;
}
void tst_QGraphicsProxyWidget::popup_basic()
@@ -2780,13 +2795,13 @@ void tst_QGraphicsProxyWidget::palettePropagation()
QCOMPARE(proxySpy.counts[QEvent::PaletteChange], 0);
QVERIFY(edit->testAttribute(Qt::WA_SetPalette));
QVERIFY(!proxy.testAttribute(Qt::WA_SetPalette));
- QCOMPARE(proxy.palette(), lineEditPalette);
+ QCOMPARE(proxy.palette(), QPalette());
edit->setPalette(QPalette());
QCOMPARE(editSpy.counts[QEvent::PaletteChange], 2);
QCOMPARE(proxySpy.counts[QEvent::PaletteChange], 0);
QVERIFY(!edit->testAttribute(Qt::WA_SetPalette));
QVERIFY(!proxy.testAttribute(Qt::WA_SetPalette));
- QCOMPARE(proxy.palette(), lineEditPalette);
+ QCOMPARE(proxy.palette(), QPalette());
// Proxy to widget
proxy.setPalette(palette);
@@ -2896,6 +2911,9 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie()
QTest::qWait(100);
QTest::mouseMove(w->view->viewport(), w->view->mapFromScene(w->widget->mapToScene(w->widget->boundingRect().center())));
delete w->item;
+
+ QApplication::processEvents();
+ delete w;
}
void tst_QGraphicsProxyWidget::createProxyForChildWidget()
@@ -3014,30 +3032,67 @@ private slots:
}
};
+void tst_QGraphicsProxyWidget::actionsContextMenu_data()
+{
+ QTest::addColumn<bool>("actionsContextMenu");
+ QTest::addColumn<bool>("hasFocus");
+
+ QTest::newRow("without actionsContextMenu and with focus") << false << true;
+ QTest::newRow("without actionsContextMenu and without focus") << false << false;
+ QTest::newRow("with actionsContextMenu and focus") << true << true;
+ QTest::newRow("with actionsContextMenu without focus") << true << false;
+}
+
void tst_QGraphicsProxyWidget::actionsContextMenu()
{
- ContextMenuWidget *widget = new ContextMenuWidget;
- widget->addAction(new QAction("item 1", widget));
- widget->addAction(new QAction("item 2", widget));
- widget->addAction(new QAction("item 3", widget));
- widget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ QFETCH(bool, hasFocus);
+ QFETCH(bool, actionsContextMenu);
+ ContextMenuWidget *widget = new ContextMenuWidget;
+ if (actionsContextMenu) {
+ widget->addAction(new QAction("item 1", widget));
+ widget->addAction(new QAction("item 2", widget));
+ widget->addAction(new QAction("item 3", widget));
+ widget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ }
QGraphicsScene scene;
- scene.addWidget(widget);
QGraphicsView view(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ view.setFocus();
+ QTRY_VERIFY(view.hasFocus());
+
+ if (hasFocus)
+ scene.addWidget(widget)->setFocus();
+ else
+ scene.addWidget(widget)->clearFocus();
+
+ QApplication::processEvents();
+
QContextMenuEvent contextMenuEvent(QContextMenuEvent::Mouse,
view.viewport()->rect().center(),
view.viewport()->mapToGlobal(view.viewport()->rect().center()));
contextMenuEvent.accept();
qApp->sendEvent(view.viewport(), &contextMenuEvent);
- QVERIFY(widget->embeddedPopup);
- QVERIFY(!widget->gotContextMenuEvent);
+ if (hasFocus) {
+ if (actionsContextMenu) {
+ //actionsContextMenu embedded popup but no contextMenuEvent (widget has focus)
+ QVERIFY(widget->embeddedPopup);
+ QVERIFY(!widget->gotContextMenuEvent);
+ } else {
+ //no embedded popup but contextMenuEvent (widget has focus)
+ QVERIFY(!widget->embeddedPopup);
+ QVERIFY(widget->gotContextMenuEvent);
+ }
+ } else {
+ //qgraphicsproxywidget doesn't have the focus, the widget must not receive any contextMenuEvent and must not create any QMenu
+ QVERIFY(!widget->embeddedPopup);
+ QVERIFY(!widget->gotContextMenuEvent);
+ }
+
}
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 8459331..0589994 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -266,6 +266,7 @@ private slots:
void dispatchHoverOnPress();
void initialFocus_data();
void initialFocus();
+ void polishItems();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -2819,17 +2820,15 @@ void tst_QGraphicsScene::update2()
CustomView view;
view.setScene(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWait(250);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.repaints >= 1);
view.repaints = 0;
// Make sure QGraphicsScene::update only requires one event-loop iteration
// before the view is updated.
scene.update();
qApp->processEvents();
- QCOMPARE(view.repaints, 1);
+ QTRY_COMPARE(view.repaints, 1);
view.repaints = 0;
// The same for partial scene updates.
@@ -3884,5 +3883,32 @@ void tst_QGraphicsScene::initialFocus()
QCOMPARE(rect->hasFocus(), shouldHaveFocus);
}
+class PolishItem : public QGraphicsTextItem
+{
+public:
+ PolishItem(QGraphicsItem *parent = 0) : QGraphicsTextItem(parent) { }
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant& value)
+ {
+ if (change == ItemVisibleChange) {
+ if (value.toBool())
+ qDeleteAll(childItems());
+ }
+ return QGraphicsItem::itemChange(change, value);
+ }
+};
+
+void tst_QGraphicsScene::polishItems()
+{
+ QGraphicsScene scene;
+ PolishItem *parent = new PolishItem;
+ scene.addItem(parent);
+ PolishItem *child = new PolishItem(parent);
+ Q_UNUSED(child)
+ // test that QGraphicsScenePrivate::_q_polishItems() doesn't crash
+ QMetaObject::invokeMethod(&scene,"_q_polishItems");
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index e8979ea..b407fef 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -159,7 +159,11 @@ void tst_QGraphicsTransform::scale()
// definitions correct for the difference.
static inline bool fuzzyCompare(qreal p1, qreal p2)
{
- return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
+ // increase delta on small machines using float instead of double
+ if (sizeof(qreal) == sizeof(float))
+ return (qAbs(p1 - p2) <= 0.00002f * qMin(qAbs(p1), qAbs(p2)));
+ else
+ return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}
static bool fuzzyCompare(const QTransform& t1, const QTransform& t2)
{
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index df3ebef..8acaa72 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -84,6 +84,12 @@ Q_DECLARE_METATYPE(QPolygonF)
Q_DECLARE_METATYPE(QRectF)
Q_DECLARE_METATYPE(Qt::ScrollBarPolicy)
+#ifdef Q_WS_MAC
+//On mac we get full update. So check that the expected region is contained inside the actual
+#define COMPARE_REGIONS(ACTUAL, EXPECTED) QVERIFY((EXPECTED).subtracted(ACTUAL).isEmpty())
+#else
+#define COMPARE_REGIONS QCOMPARE
+#endif
static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton)
{
@@ -115,6 +121,7 @@ public:
}
int count() const { return _count; }
+ void reset() { _count = 0; }
protected:
bool eventFilter(QObject *watched, QEvent *event)
@@ -2938,10 +2945,11 @@ void tst_QGraphicsView::task239729_noViewUpdate()
view->show();
QTest::qWaitForWindowShown(view);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_VERIFY(spy.count() >= 1);
+ spy.reset();
scene.update();
QApplication::processEvents();
- QTRY_COMPARE(spy.count(), 2);
+ QTRY_COMPARE(spy.count(), 1);
delete view;
}
@@ -3177,7 +3185,7 @@ void tst_QGraphicsView::moveItemWhileScrolling()
int a = adjustForAntialiasing ? 2 : 1;
expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a);
expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a);
- QCOMPARE(view.lastPaintedRegion, expectedRegion);
+ COMPARE_REGIONS(view.lastPaintedRegion, expectedRegion);
}
void tst_QGraphicsView::centerOnDirtyItem()
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 26021e0..6b5ad09 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -159,6 +159,7 @@ private slots:
void ensureClipping();
void widgetSendsGeometryChanges();
void respectHFW();
+ void addChildInpolishEvent();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -2716,6 +2717,58 @@ void tst_QGraphicsWidget::respectHFW()
#endif
}
+class PolishWidget : public QGraphicsWidget
+{
+public:
+
+ PolishWidget(Qt::GlobalColor color, QGraphicsItem *parent=0) :
+ QGraphicsWidget(parent), mColor(color)
+ {
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ painter->setBrush(QBrush(mColor));
+ painter->drawRect(boundingRect());
+ }
+
+ void polishEvent()
+ {
+ if (!parentWidget()) {
+ //We add a child in the polish event for the parent
+ PolishWidget *childWidget = new PolishWidget(Qt::black, this);
+ childWidget->setGeometry(QRectF(10,10,30,30));
+ }
+
+ QGraphicsWidget::polishEvent();
+ mColor = Qt::red;
+ update();
+ numberOfPolish++;
+ }
+
+ static int numberOfPolish;
+
+private:
+ Qt::GlobalColor mColor;
+};
+
+int PolishWidget::numberOfPolish = 0;
+
+void tst_QGraphicsWidget::addChildInpolishEvent()
+{
+ QGraphicsScene scene;
+
+ PolishWidget *parentWidget = new PolishWidget(Qt::white);
+ scene.addItem(parentWidget);
+
+ QGraphicsView view(&scene);
+ view.resize(200, 200);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(PolishWidget::numberOfPolish, 2);
+}
+
+
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp
index c3c3db4..a1c4ef7 100644
--- a/tests/auto/qinputcontext/tst_qinputcontext.cpp
+++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp
@@ -129,6 +129,9 @@ public:
RequestSoftwareInputPanelStyle()
: m_rsipBehavior(RSIP_OnMouseClickAndAlreadyFocused)
{
+#ifdef Q_OS_WINCE
+ qApp->setAutoSipEnabled(true);
+#endif
}
~RequestSoftwareInputPanelStyle()
{
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 726ca55..4eb149f 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -812,6 +812,9 @@ public:
void tst_QMenu::task258920_mouseBorder()
{
+#ifdef Q_OS_WINCE_WM
+ QSKIP("Mouse move related signals for Windows Mobile unavailable", SkipAll);
+#endif
Menu258920 menu;
QAction *action = menu.addAction("test");
diff --git a/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp
index 3f9632c..2e21087 100644
--- a/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp
+++ b/tests/auto/qnetworkrequest/tst_qnetworkrequest.cpp
@@ -66,6 +66,7 @@ private slots:
void setHeader();
void rawHeaderParsing_data();
void rawHeaderParsing();
+ void originatingObject();
void removeHeader();
};
@@ -476,5 +477,20 @@ void tst_QNetworkRequest::removeHeader()
QVERIFY(request.hasRawHeader("bar"));
}
+void tst_QNetworkRequest::originatingObject()
+{
+ QNetworkRequest request;
+
+ QVERIFY(!request.originatingObject());
+
+ {
+ QObject dummy;
+ request.setOriginatingObject(&dummy);
+ QCOMPARE(request.originatingObject(), &dummy);
+ }
+
+ QVERIFY(!request.originatingObject());
+}
+
QTEST_MAIN(tst_QNetworkRequest)
#include "tst_qnetworkrequest.moc"
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 9515d87..e4f267d 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -1554,7 +1554,7 @@ void tst_QPainter::drawClippedEllipse_data()
void tst_QPainter::drawClippedEllipse()
{
QFETCH(QRect, rect);
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
if (sizeof(qreal) != sizeof(double))
QSKIP("Test only works for qreal==double", SkipAll);
#endif
diff --git a/tests/auto/qpauseanimation/qpauseanimation.pro b/tests/auto/qpauseanimation/qpauseanimation.pro
new file mode 100644
index 0000000..4599cf0
--- /dev/null
+++ b/tests/auto/qpauseanimation/qpauseanimation.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT = core gui
+SOURCES += tst_qpauseanimation.cpp
+
+
diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
new file mode 100644
index 0000000..62b43c4
--- /dev/null
+++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
@@ -0,0 +1,409 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtCore/qpauseanimation.h>
+#include <QtCore/qpropertyanimation.h>
+#include <QtCore/qsequentialanimationgroup.h>
+
+#include <private/qabstractanimation_p.h>
+
+//TESTED_CLASS=QPauseAnimation
+//TESTED_FILES=
+
+class TestablePauseAnimation : public QPauseAnimation
+{
+ Q_OBJECT
+public:
+ TestablePauseAnimation(QObject *parent = 0)
+ : QPauseAnimation(parent),
+ m_updateCurrentTimeCount(0)
+ {
+ }
+
+ int m_updateCurrentTimeCount;
+protected:
+ void updateCurrentTime(int currentTime)
+ {
+ //qDebug() << this << "update current time: " << currentTime;
+ QPauseAnimation::updateCurrentTime(currentTime);
+ ++m_updateCurrentTimeCount;
+ }
+};
+
+class EnableConsistentTiming
+{
+public:
+ EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+ }
+ ~EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(false);
+ }
+};
+
+class tst_QPauseAnimation : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QPauseAnimation();
+ virtual ~tst_QPauseAnimation();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private slots:
+ void changeDirectionWhileRunning();
+ void noTimerUpdates_data();
+ void noTimerUpdates();
+ void mulitplePauseAnimations();
+ void pauseAndPropertyAnimations();
+ void pauseResume();
+ void sequentialPauseGroup();
+ void sequentialGroupWithPause();
+ void multipleSequentialGroups();
+ void zeroDuration();
+};
+
+tst_QPauseAnimation::tst_QPauseAnimation()
+{
+}
+
+tst_QPauseAnimation::~tst_QPauseAnimation()
+{
+}
+
+void tst_QPauseAnimation::init()
+{
+ qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
+ qRegisterMetaType<QAbstractAnimation::DeletionPolicy>("QAbstractAnimation::DeletionPolicy");
+}
+
+void tst_QPauseAnimation::cleanup()
+{
+}
+
+void tst_QPauseAnimation::changeDirectionWhileRunning()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QTest::qWait(100);
+ QVERIFY(animation.state() == QAbstractAnimation::Running);
+ animation.setDirection(QAbstractAnimation::Backward);
+ QTest::qWait(animation.totalDuration() + 50);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+
+ timer->setConsistentTiming(false);
+}
+
+void tst_QPauseAnimation::noTimerUpdates_data()
+{
+ QTest::addColumn<int>("duration");
+ QTest::addColumn<int>("loopCount");
+
+ QTest::newRow("0") << 200 << 1;
+ QTest::newRow("1") << 160 << 1;
+ QTest::newRow("2") << 160 << 2;
+ QTest::newRow("3") << 200 << 3;
+}
+
+void tst_QPauseAnimation::noTimerUpdates()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+
+ QFETCH(int, duration);
+ QFETCH(int, loopCount);
+
+ TestablePauseAnimation animation;
+ animation.setDuration(duration);
+ animation.setLoopCount(loopCount);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 2);
+
+ timer->setConsistentTiming(false);
+}
+
+void tst_QPauseAnimation::mulitplePauseAnimations()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+
+ TestablePauseAnimation animation;
+ animation.setDuration(200);
+
+ TestablePauseAnimation animation2;
+ animation2.setDuration(800);
+
+ animation.start();
+ animation2.start();
+ QTest::qWait(animation.totalDuration() + 100);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimation::Running);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(550);
+ QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
+
+ timer->setConsistentTiming(false);
+}
+
+void tst_QPauseAnimation::pauseAndPropertyAnimations()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation pause;
+ pause.setDuration(200);
+
+ QObject o;
+ o.setProperty("ole", 42);
+
+ QPropertyAnimation animation(&o, "ole");
+ animation.setEndValue(43);
+
+ pause.start();
+
+ QTest::qWait(100);
+ animation.start();
+
+ QVERIFY(animation.state() == QAbstractAnimation::Running);
+ QVERIFY(pause.state() == QAbstractAnimation::Running);
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimation::Stopped);
+ QVERIFY(pause.m_updateCurrentTimeCount > 3);
+}
+
+void tst_QPauseAnimation::pauseResume()
+{
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QVERIFY(animation.state() == QAbstractAnimation::Running);
+ QTest::qWait(200);
+ animation.pause();
+ QVERIFY(animation.state() == QAbstractAnimation::Paused);
+ animation.start();
+ QTest::qWait(250);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 3);
+}
+
+void tst_QPauseAnimation::sequentialPauseGroup()
+{
+ QSequentialAnimationGroup group;
+
+ TestablePauseAnimation animation1(&group);
+ animation1.setDuration(200);
+ TestablePauseAnimation animation2(&group);
+ animation2.setDuration(200);
+ TestablePauseAnimation animation3(&group);
+ animation3.setDuration(200);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(animation1.state() == QAbstractAnimation::Running);
+ QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
+
+ group.setCurrentTime(250);
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(&animation2, group.currentAnimation());
+ QVERIFY(animation2.state() == QAbstractAnimation::Running);
+ QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
+
+ group.setCurrentTime(500);
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(&animation3, group.currentAnimation());
+ QVERIFY(animation3.state() == QAbstractAnimation::Running);
+
+ group.setCurrentTime(750);
+
+ QVERIFY(group.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
+
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimation::sequentialGroupWithPause()
+{
+ QSequentialAnimationGroup group;
+
+ QObject o;
+ o.setProperty("ole", 42);
+
+ QPropertyAnimation animation(&o, "ole", &group);
+ animation.setEndValue(43);
+ TestablePauseAnimation pause(&group);
+ pause.setDuration(250);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(animation.state() == QAbstractAnimation::Running);
+ QVERIFY(pause.state() == QAbstractAnimation::Stopped);
+
+ group.setCurrentTime(300);
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(&pause, group.currentAnimation());
+ QVERIFY(pause.state() == QAbstractAnimation::Running);
+
+ group.setCurrentTime(600);
+
+ QVERIFY(group.state() == QAbstractAnimation::Stopped);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimation::Stopped);
+
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimation::multipleSequentialGroups()
+{
+ EnableConsistentTiming enabled;
+
+ QParallelAnimationGroup group;
+ group.setLoopCount(2);
+
+ QSequentialAnimationGroup subgroup1(&group);
+
+ QObject o;
+ o.setProperty("ole", 42);
+
+ QPropertyAnimation animation(&o, "ole", &subgroup1);
+ animation.setEndValue(43);
+ animation.setDuration(300);
+ TestablePauseAnimation pause(&subgroup1);
+ pause.setDuration(200);
+
+ QSequentialAnimationGroup subgroup2(&group);
+
+ o.setProperty("ole2", 42);
+ QPropertyAnimation animation2(&o, "ole2", &subgroup2);
+ animation2.setEndValue(43);
+ animation2.setDuration(200);
+ TestablePauseAnimation pause2(&subgroup2);
+ pause2.setDuration(250);
+
+ QSequentialAnimationGroup subgroup3(&group);
+
+ TestablePauseAnimation pause3(&subgroup3);
+ pause3.setDuration(400);
+
+ o.setProperty("ole3", 42);
+ QPropertyAnimation animation3(&o, "ole3", &subgroup3);
+ animation3.setEndValue(43);
+ animation3.setDuration(200);
+
+ QSequentialAnimationGroup subgroup4(&group);
+
+ TestablePauseAnimation pause4(&subgroup4);
+ pause4.setDuration(310);
+
+ TestablePauseAnimation pause5(&subgroup4);
+ pause5.setDuration(60);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimation::Running);
+ QVERIFY(subgroup1.state() == QAbstractAnimation::Running);
+ QVERIFY(subgroup2.state() == QAbstractAnimation::Running);
+ QVERIFY(subgroup3.state() == QAbstractAnimation::Running);
+ QVERIFY(subgroup4.state() == QAbstractAnimation::Running);
+
+ QTest::qWait(group.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (group.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+ QVERIFY(group.state() == QAbstractAnimation::Stopped);
+ QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped);
+ QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped);
+ QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped);
+ QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped);
+
+ QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
+}
+
+void tst_QPauseAnimation::zeroDuration()
+{
+ TestablePauseAnimation animation;
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+ QVERIFY(animation.state() == QAbstractAnimation::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 1);
+}
+
+QTEST_MAIN(tst_QPauseAnimation)
+#include "tst_qpauseanimation.moc"
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 58eaacb..ed9206c 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -812,8 +812,14 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr.data() == aData);
QVERIFY(aData == baseptr.data());
- QVERIFY(bool(operator==<Data,DiffPtrDerivedData>(baseptr, aData)));
+
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(baseptr == aData);
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(aData == baseptr);
}
check();
@@ -829,6 +835,9 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(ptr == baseptr);
QVERIFY(ptr.data() == baseptr.data());
QVERIFY(ptr == aBase);
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(baseptr == aData);
}
check();
@@ -845,6 +854,9 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(ptr.data() == baseptr.data());
QVERIFY(ptr == aBase);
QVERIFY(ptr == aData);
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
@@ -865,6 +877,9 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(ptr.data() == baseptr.data());
QVERIFY(ptr == aBase);
QVERIFY(ptr == aData);
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
@@ -882,6 +897,9 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(ptr.data() == baseptr.data());
QVERIFY(ptr == aBase);
QVERIFY(ptr == aData);
+#if defined(Q_CC_MSVC) && _MSC_VER < 1400
+ QEXPECT_FAIL("", "Compiler bug", Continue);
+#endif
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
@@ -1701,7 +1719,7 @@ void tst_QSharedPointer::invalidConstructs()
"struct DerivedData: public Data { int j; };\n"
"\n"
"extern int forwardDeclaredDestructorRunCount;\n"
- "struct ForwardDeclared;\n"
+ "class ForwardDeclared;\n"
"ForwardDeclared *forwardPointer();\n"
);
@@ -1730,6 +1748,10 @@ void tst_QSharedPointer::invalidConstructs()
bool result = (test.*testFunction)(body);
if (qgetenv("QTEST_EXTERNAL_DEBUG").toInt() > 0) {
qDebug("External test output:");
+#ifdef Q_CC_MSVC
+ // MSVC prints errors to stdout
+ printf("%s\n", test.standardOutput().constData());
+#endif
printf("%s\n", test.standardError().constData());
}
if (!result) {
diff --git a/tests/auto/qsidebar/tst_qsidebar.cpp b/tests/auto/qsidebar/tst_qsidebar.cpp
index 7b157f6..b810305 100644
--- a/tests/auto/qsidebar/tst_qsidebar.cpp
+++ b/tests/auto/qsidebar/tst_qsidebar.cpp
@@ -122,6 +122,12 @@ void tst_QSidebar::addUrls()
QSidebar qsidebar;
qsidebar.init(&fsmodel, emptyUrls);
QAbstractItemModel *model = qsidebar.model();
+#if defined(Q_OS_SYMBIAN)
+ // On Symbian, QDir::rootPath() and QDir::home() are same.
+ QDir testDir = QDir::currentPath();
+#else
+ QDir testDir = QDir::home();
+#endif
// default
QCOMPARE(model->rowCount(), 0);
@@ -146,13 +152,13 @@ void tst_QSidebar::addUrls()
// test inserting with already existing rows
QList<QUrl> moreUrls;
- moreUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ moreUrls << QUrl::fromLocalFile(testDir.absolutePath());
qsidebar.addUrls(moreUrls, -1);
QCOMPARE(model->rowCount(), 3);
// make sure invalid urls are still added
QList<QUrl> badUrls;
- badUrls << QUrl::fromLocalFile(QDir::home().absolutePath() + "/I used to exist");
+ badUrls << QUrl::fromLocalFile(testDir.absolutePath() + "/I used to exist");
qsidebar.addUrls(badUrls, 0);
QCOMPARE(model->rowCount(), 4);
@@ -179,30 +185,30 @@ void tst_QSidebar::addUrls()
QList<QUrl> doubleUrls;
//tow exact same paths, we have only one entry
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath());
qsidebar.setUrls(emptyUrls);
qsidebar.addUrls(doubleUrls, 1);
QCOMPARE(qsidebar.urls().size(), 1);
// Two paths that are effectively pointing to the same location
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath() + "/.");
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath() + "/.");
qsidebar.setUrls(emptyUrls);
qsidebar.addUrls(doubleUrls, 1);
QCOMPARE(qsidebar.urls().size(), 1);
#if defined(Q_OS_WIN)
//Windows is case insensitive so no duplicate entries in that case
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath().toUpper());
qsidebar.setUrls(emptyUrls);
qsidebar.addUrls(doubleUrls, 1);
QCOMPARE(qsidebar.urls().size(), 1);
#else
//Two different paths we should have two entries
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
- doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath());
+ doubleUrls << QUrl::fromLocalFile(testDir.absolutePath().toUpper());
qsidebar.setUrls(emptyUrls);
qsidebar.addUrls(doubleUrls, 1);
QCOMPARE(qsidebar.urls().size(), 2);
diff --git a/tests/auto/qsound/qsound.pro b/tests/auto/qsound/qsound.pro
index c48d50d..383a085 100644
--- a/tests/auto/qsound/qsound.pro
+++ b/tests/auto/qsound/qsound.pro
@@ -4,7 +4,7 @@ SOURCES += tst_qsound.cpp
wince*|symbian*: {
deploy.sources += 4.wav
DEPLOYMENT = deploy
- DEFINES += SRCDIR=\\\"\\\"
+ !symbian:DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
diff --git a/tests/auto/qsound/tst_qsound.cpp b/tests/auto/qsound/tst_qsound.cpp
index dd5f2ce..fdbf6a2 100644
--- a/tests/auto/qsound/tst_qsound.cpp
+++ b/tests/auto/qsound/tst_qsound.cpp
@@ -43,6 +43,10 @@
#include <QtTest/QtTest>
#include <QtGui>
+#if defined(Q_OS_SYMBIAN)
+#define SRCDIR ""
+#endif
+
class tst_QSound : public QObject
{
Q_OBJECT
diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp
index 4829b6b..2389060 100644
--- a/tests/auto/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/qspinbox/tst_qspinbox.cpp
@@ -980,26 +980,28 @@ void tst_QSpinBox::sizeHint()
sizeHint_SpinBox *spinBox = new sizeHint_SpinBox;
layout->addWidget(spinBox);
widget->show();
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(widget);
// Prefix
spinBox->sizeHintRequests = 0;
spinBox->setPrefix(QLatin1String("abcdefghij"));
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
// Suffix
spinBox->sizeHintRequests = 0;
spinBox->setSuffix(QLatin1String("abcdefghij"));
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
// Range
spinBox->sizeHintRequests = 0;
spinBox->setRange(0, 1234567890);
spinBox->setValue(spinBox->maximum());
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
+
+ delete widget;
}
QTEST_MAIN(tst_QSpinBox)
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index c5c3663..25b1e2f 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -258,6 +258,7 @@ public:
// addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2008" );
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" );
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" );
+// addDb( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" );
}
void open()
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index c9c8f5e..13d68ff 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -304,10 +304,11 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db)
// ### stupid workaround until we find a way to hardcode this
// in the MySQL server startup script
q.exec("set table_type=innodb");
- if (tst_Databases::isSqlServer(db)) {
+ else if (tst_Databases::isSqlServer(db)) {
QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON"));
QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF"));
- }
+ } else if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
// please never ever change this table; otherwise fix all tests ;)
if (tst_Databases::isMSAccess(db)) {
@@ -334,6 +335,12 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
{
if (!db.isValid())
return;
+
+ if(tst_Databases::isPostgreSQL(db)) {
+ QSqlQuery q(db);
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+ }
+
// drop the view first, otherwise we'll get dependency problems
tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view") << qTableName("qtest_view2"));
@@ -792,8 +799,8 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
if (val1.type() == QVariant::DateTime || val1.type() == QVariant::Time)
qDebug("Received Time: " + val1.toTime().toString("hh:mm:ss.zzz"));
QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 (etype %4 rtype %5) in checkValues").arg(
- val2.toString()).arg(
- val1.toString()).arg(
+ val2.type() == QVariant::ByteArray ? val2.toByteArray().toHex() : val2.toString()).arg(
+ val1.type() == QVariant::ByteArray ? val1.toByteArray().toHex() : val1.toString()).arg(
fieldDefs[ i ].fieldName()).arg(
val2.typeName()).arg(
val1.typeName())
@@ -1019,6 +1026,10 @@ void tst_QSqlDatabase::recordPSQL()
};
QSqlQuery q(db);
+
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
q.exec("drop sequence " + qTableName("qtestfields") + "_t_bigserial_seq");
q.exec("drop sequence " + qTableName("qtestfields") + "_t_serial_seq");
// older psql cut off the table name
@@ -1292,9 +1303,9 @@ void tst_QSqlDatabase::recordAccess()
FieldDef("varchar(20)", QVariant::String, QString("Blah1")),
FieldDef("single", QVariant::Double, 1.12345),
FieldDef("double", QVariant::Double, 1.123456),
- FieldDef("byte", QVariant::Int, 255),
+ FieldDef("byte", QVariant::UInt, 255),
#ifdef QT3_SUPPORT
- FieldDef("binary", QVariant::ByteArray, Q3CString("Blah2")),
+ FieldDef("binary(5)", QVariant::ByteArray, Q3CString("Blah2")),
#endif
FieldDef("long", QVariant::Int, 2147483647),
FieldDef("memo", QVariant::String, memo),
@@ -1494,6 +1505,11 @@ void tst_QSqlDatabase::psql_schemas()
QSKIP("server does not support schemas", SkipSingle);
QSqlQuery q(db);
+
+ if(tst_Databases::isPostgreSQL(db)) {
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+ }
+
QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema")));
QString table = qTableName("qtestschema") + '.' + qTableName("qtesttable");
@@ -1529,6 +1545,9 @@ void tst_QSqlDatabase::psql_escapedIdentifiers()
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
QString schemaName = qTableName("qtestScHeMa");
QString tableName = qTableName("qtest");
QString field1Name = QString("fIeLdNaMe");
@@ -1643,7 +1662,10 @@ void tst_QSqlDatabase::precisionPolicy()
QSKIP("Driver or database doesn't support setting precision policy", SkipSingle);
// Create a test table with some data
- QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num numeric(18,5))").arg(tableName)));
+ if(tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num number)").arg(tableName)));
+ else
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id smallint, num numeric(18,5))").arg(tableName)));
QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES (?, ?)").arg(tableName)));
q.bindValue(0, 1);
q.bindValue(1, 123);
@@ -2007,6 +2029,7 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QSKIP("MySql has inconsistent behaviour of bit field type across versions.", SkipSingle);
return;
}
+
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)"));
@@ -2038,6 +2061,8 @@ void tst_QSqlDatabase::odbc_testqGetString()
QSqlQuery q(db);
if (tst_Databases::isSqlServer(db))
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(MAX))"));
+ else if(tst_Databases::isMSAccess(db))
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue memo)"));
else
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))"));
@@ -2264,7 +2289,10 @@ void tst_QSqlDatabase::odbc_uintfield()
unsigned int val = 4294967295U;
QSqlQuery q(db);
- q.exec(QString("CREATE TABLE %1(num numeric(10))").arg(tableName));
+ if ( tst_Databases::isMSAccess( db ) )
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(num number)").arg(tableName)));
+ else
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(num numeric(10))").arg(tableName)));
q.prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName));
q.addBindValue(val);
QVERIFY_SQL(q, exec());
@@ -2440,8 +2468,8 @@ void tst_QSqlDatabase::mysql_savepointtest()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
- QSKIP( "Test requires MySQL >= 5.0", SkipSingle );
+ if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toInt()<4.1 )
+ QSKIP( "Test requires MySQL >= 4.1", SkipSingle );
QSqlQuery q(db);
QVERIFY_SQL(q, exec("begin"));
diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp
index f463c9e..5322b97 100644
--- a/tests/auto/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp
@@ -85,6 +85,9 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
{
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) );
QVERIFY_SQL( q, exec("create table " + qTableName("relTEST1") +
@@ -160,7 +163,11 @@ void tst_QSqlDriver::record()
//check that we can't get records using incorrect tablename casing that's been quoted
rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match
else
QCOMPARE(rec.count(), 0);
@@ -208,7 +215,11 @@ void tst_QSqlDriver::primaryIndex()
tablename = tablename.toUpper();
index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing
else
QCOMPARE(index.count(), 0);
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 5ed9cfa..546c105 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -333,6 +333,8 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db )
// ### stupid workaround until we find a way to hardcode this
// in the MySQL server startup script
q.exec( "set table_type=innodb" );
+ else if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
if(tst_Databases::isPostgreSQL(db))
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) );
@@ -1645,6 +1647,9 @@ void tst_QSqlQuery::prepare_bind_exec()
QString createQuery;
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) )
createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(20) null)";
else if ( db.driverName().startsWith( "QMYSQL" ) && useUnicode )
diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 391219b..3131f35 100644
--- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -158,6 +158,8 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db)
{
dropTestTables(db);
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QVERIFY_SQL( q, exec("create table " + qTableName("test") + "(id integer not null, name varchar(20), title integer, primary key (id))"));
QVERIFY_SQL( q, exec("create table " + qTableName("test2") + "(id integer not null, title varchar(20), primary key (id))"));
QVERIFY_SQL( q, exec("create table " + qTableName("test3") + "(id integer not null, primary key (id))"));
diff --git a/tests/auto/qsqlrecord/qsqlrecord.pro b/tests/auto/qsqlrecord/qsqlrecord.pro
index 7a72075..f36f076 100644
--- a/tests/auto/qsqlrecord/qsqlrecord.pro
+++ b/tests/auto/qsqlrecord/qsqlrecord.pro
@@ -9,11 +9,11 @@ symbian {
DEPLOYMENT += sqlite
}
}
-}
-TARGET.EPOCSTACKSIZE=50000
-TARGET.EPOCHEAPSIZE=50000 5000000
+ TARGET.EPOCSTACKSIZE=50000
+ TARGET.EPOCHEAPSIZE=50000 5000000
}
+
QT += sql
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 05d546e..cb24a9f 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -837,10 +837,10 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
QVERIFY_SQL(model, select());
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
- QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name")).toUpper()).toString(),
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2")).toUpper()).toString(),
QString("Trondheim"));
} else {
- QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name"))).toString(),
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2"))).toString(),
QString("Trondheim"));
}
@@ -859,9 +859,9 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
// The duplicate field names is aliased because it's comes from the relation's display column.
if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
- QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name"))).toUpper());
+ QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name_2"))).toUpper());
else
- QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name")));
+ QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name_2")));
QVERIFY(model.insertRecord(-1, rec));
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo"));
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 49e087f..653d944 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -143,6 +143,8 @@ void tst_QSqlTableModel::dropTestTables()
for (int i = 0; i < dbs.dbNames.count(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QStringList tableNames;
tableNames << qTableName("test")
@@ -659,6 +661,9 @@ void tst_QSqlTableModel::primaryKeyOrder()
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))"));
QSqlTableModel model(0, db);
@@ -897,6 +902,8 @@ void tst_QSqlTableModel::sqlite_attachedDatabase()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ if(db.databaseName() == ":memory:")
+ QSKIP(":memory: database, skipping test", SkipSingle);
QSqlDatabase attachedDb = QSqlDatabase::cloneDatabase(db, db.driverName() + QLatin1String("attached"));
attachedDb.setDatabaseName(db.databaseName()+QLatin1String("attached.dat"));
diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp
index c088a47..be66e9e 100644
--- a/tests/auto/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp
@@ -404,6 +404,8 @@ void tst_QSqlThread::readWriteThreading()
if (db.databaseName() == ":memory:")
QSKIP("does not work with in-memory databases", SkipSingle);
+ else if (tst_Databases::isMSAccess(db))
+ QSKIP("does not work with MS Access databases", SkipSingle);
SqlProducer producer(db);
SqlConsumer consumer(db);
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 77e3763..6efe440 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -1377,6 +1377,7 @@ void tst_QSslSocket::waitForMinusOne()
// connect to the server
QSslSocket socket;
+ QTest::qSleep(100);
socket.connectToHost("127.0.0.1", server.serverPort);
QVERIFY(socket.waitForConnected(-1));
socket.ignoreSslErrors();
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 4bf7c2e..eab5a35 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -100,6 +100,9 @@ private slots:
void moveCursor_data();
void moveCursor();
+ void moveCursorStrikesBack_data();
+ void moveCursorStrikesBack();
+
void hideRows_data();
void hideRows();
@@ -252,12 +255,43 @@ public:
row_count(rows),
column_count(columns),
can_fetch_more(false),
- fetch_more_count(0) {}
+ fetch_more_count(0),
+ disabled_rows(),
+ disabled_columns() {}
int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; }
int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; }
bool isEditable(const QModelIndex &) const { return true; }
+ Qt::ItemFlags flags(const QModelIndex &index) const
+ {
+ Qt::ItemFlags index_flags = QAbstractTableModel::flags(index);
+ if (disabled_rows.contains(index.row())
+ || disabled_columns.contains(index.column()))
+ index_flags &= ~Qt::ItemIsEnabled;
+ return index_flags;
+ }
+
+ void disableRow(int row)
+ {
+ disabled_rows.insert(row);
+ }
+
+ void enableRow(int row)
+ {
+ disabled_rows.remove(row);
+ }
+
+ void disableColumn(int column)
+ {
+ disabled_columns.insert(column);
+ }
+
+ void enableColumn(int column)
+ {
+ disabled_columns.remove(column);
+ }
+
QVariant data(const QModelIndex &idx, int role) const
{
if (!idx.isValid() || idx.row() >= row_count || idx.column() >= column_count) {
@@ -363,6 +397,8 @@ public:
int column_count;
bool can_fetch_more;
int fetch_more_count;
+ QSet<int> disabled_rows;
+ QSet<int> disabled_columns;
};
class QtTestTableView : public QTableView
@@ -834,7 +870,7 @@ void tst_QTableView::moveCursor_data()
<< 4 << 4 << -1 << 2
<< 0 << 2
<< int(QtTestTableView::MoveNext) << int(Qt::NoModifier)
- << 1 << 0 << IntPair(0,0) << IntPair(3,0);
+ << 1 << 3 << IntPair(0,0) << IntPair(3,0);
// MoveLeft
QTest::newRow("MoveLeft (0,0)")
@@ -1137,6 +1173,132 @@ void tst_QTableView::moveCursor()
QCOMPARE(newIndex.column(), expectedColumn);
}
+void tst_QTableView::moveCursorStrikesBack_data()
+{
+ QTest::addColumn<int>("hideRow");
+ QTest::addColumn<int>("hideColumn");
+ QTest::addColumn<IntList>("disableRows");
+ QTest::addColumn<IntList>("disableColumns");
+ QTest::addColumn<QRect>("span");
+
+ QTest::addColumn<int>("startRow");
+ QTest::addColumn<int>("startColumn");
+ QTest::addColumn<IntList>("cursorMoveActions");
+ QTest::addColumn<int>("expectedRow");
+ QTest::addColumn<int>("expectedColumn");
+
+ QTest::newRow("Last column disabled. Task QTBUG-3878") << -1 << -1
+ << IntList()
+ << (IntList() << 6)
+ << QRect()
+ << 0 << 5 << (IntList() << int(QtTestTableView::MoveNext))
+ << 1 << 0;
+
+ QTest::newRow("Span, anchor column hidden") << -1 << 1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
+ << 2 << 2;
+
+ QTest::newRow("Span, anchor column disabled") << -1 << -1
+ << IntList()
+ << (IntList() << 1)
+ << QRect(1, 2, 2, 3)
+ << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext))
+ << 2 << 2;
+
+ QTest::newRow("Span, anchor row hidden") << 2 << -1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
+ << 3 << 2;
+
+ QTest::newRow("Span, anchor row disabled") << -1 << -1
+ << (IntList() << 2)
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown))
+ << 3 << 2;
+
+ QTest::newRow("Move through span right") << -1 << -1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 3 << 0 << (IntList() << int(QtTestTableView::MoveRight) << int(QtTestTableView::MoveRight))
+ << 3 << 3;
+
+ QTest::newRow("Move through span left") << -1 << -1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 3 << 3 << (IntList() << int(QtTestTableView::MoveLeft) << int(QtTestTableView::MoveLeft))
+ << 3 << 0;
+
+ QTest::newRow("Move through span down") << -1 << -1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown) << int(QtTestTableView::MoveDown))
+ << 5 << 2;
+
+ QTest::newRow("Move through span up") << -1 << -1
+ << IntList()
+ << IntList()
+ << QRect(1, 2, 2, 3)
+ << 5 << 2 << (IntList() << int(QtTestTableView::MoveUp) << int(QtTestTableView::MoveUp))
+ << 1 << 2;
+}
+
+void tst_QTableView::moveCursorStrikesBack()
+{
+ QFETCH(int, hideRow);
+ QFETCH(int, hideColumn);
+ QFETCH(IntList, disableRows);
+ QFETCH(IntList, disableColumns);
+ QFETCH(QRect, span);
+
+ QFETCH(int, startRow);
+ QFETCH(int, startColumn);
+ QFETCH(IntList, cursorMoveActions);
+ QFETCH(int, expectedRow);
+ QFETCH(int, expectedColumn);
+
+ QtTestTableModel model(7, 7);
+ QtTestTableView view;
+ view.setModel(&model);
+ view.hideRow(hideRow);
+ view.hideColumn(hideColumn);
+
+ foreach (int row, disableRows)
+ model.disableRow(row);
+ foreach (int column, disableColumns)
+ model.disableColumn(column);
+
+ if (span.height() && span.width())
+ view.setSpan(span.top(), span.left(), span.height(), span.width());
+ view.show();
+
+ QModelIndex index = model.index(startRow, startColumn);
+ view.setCurrentIndex(index);
+
+ int newRow = -1;
+ int newColumn = -1;
+ foreach (int cursorMoveAction, cursorMoveActions) {
+ QModelIndex newIndex = view.moveCursor((QtTestTableView::CursorAction)cursorMoveAction, 0);
+ view.setCurrentIndex(newIndex);
+ newRow = newIndex.row();
+ newColumn = newIndex.column();
+ }
+
+ // expected fails, task 119433
+ if(newRow == -1)
+ return;
+ QCOMPARE(newRow, expectedRow);
+ QCOMPARE(newColumn, expectedColumn);
+}
+
void tst_QTableView::hideRows_data()
{
QTest::addColumn<int>("rowCount");
@@ -3407,6 +3569,9 @@ void tst_QTableView::mouseWheel_data()
void tst_QTableView::mouseWheel()
{
+#ifdef Q_OS_WINCE
+ QSKIP("Since different Windows CE versions sport different taskbars, we skip this test", SkipAll);
+#endif
QFETCH(int, scrollMode);
QFETCH(int, delta);
QFETCH(int, horizontalPositon);
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 5ccae94..fe87dfb 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -1085,10 +1085,6 @@ QT_END_NAMESPACE
void tst_QTextLayout::testTabDPIScale()
{
- #ifdef Q_OS_WINCE
- QSKIP("This test fails for large DPIs.", SkipAll);
- #endif
-
class MyPaintDevice : public QPaintDevice {
QPaintEngine *paintEngine () const { return 0; }
int metric (QPaintDevice::PaintDeviceMetric metric) const {
@@ -1118,14 +1114,14 @@ void tst_QTextLayout::testTabDPIScale()
QTextOption option = layout.textOption();
QList<QTextOption::Tab> tabs;
QTextOption::Tab tab;
- tab.position = 100;
+ tab.position = 200;
tabs.append(tab);
- tab.position = 200;
+ tab.position = 400;
tab.type = QTextOption::RightTab;
tabs.append(tab);
- tab.position = 300;
+ tab.position = 600;
tab.type = QTextOption::CenterTab;
tabs.append(tab);
option.setTabs(tabs);
@@ -1133,7 +1129,7 @@ void tst_QTextLayout::testTabDPIScale()
layout.beginLayout();
QTextLine line = layout.createLine();
- line.setLineWidth(500.);
+ line.setLineWidth(1500.);
layout.endLayout();
QCOMPARE(line.cursorToX(0), 0.);
QCOMPARE(line.cursorToX(1), (double) TESTFONT_SIZE); // check that the font does not resize
@@ -1142,9 +1138,9 @@ void tst_QTextLayout::testTabDPIScale()
int fixedScale = (int)( scale * qreal(64)); // into a QFixed
scale = ((qreal)fixedScale)/(qreal)64; // and out of a QFixed
- QCOMPARE(line.cursorToX(6), 100 * scale);
- QCOMPARE(line.cursorToX(12), 200 * scale - TESTFONT_SIZE * 5);
- QCOMPARE(line.cursorToX(18), 300 * scale - TESTFONT_SIZE * 3 / 2.0);
+ QCOMPARE(line.cursorToX(6), tabs.at(0).position * scale);
+ QCOMPARE(line.cursorToX(12), tabs.at(1).position * scale - TESTFONT_SIZE * 5);
+ QCOMPARE(line.cursorToX(18), tabs.at(2).position * scale - TESTFONT_SIZE * 3 / 2.0);
}
void tst_QTextLayout::tabHeight()
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index 0877500..01a6317 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -46,10 +46,6 @@
#include <qtimer.h>
#include <qthread.h>
-
-
-
-
#if defined Q_OS_UNIX
#include <unistd.h>
#endif
@@ -242,7 +238,6 @@ public:
// sleep for 2ms
QTest::qSleep(2);
-
killTimer(te->timerId());
}
@@ -277,9 +272,11 @@ void tst_QTimer::livelock()
#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
QEXPECT_FAIL("zero timer", "", Continue);
QEXPECT_FAIL("non-zero timer", "", Continue);
-#elif defined(Q_OS_WIN)
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
+#elif defined(Q_OS_WINCE)
+ QEXPECT_FAIL("non-zero timer", "Windows CE devices often too slow", Continue);
#endif
QVERIFY(tester.postEventAtRightTime);
}
diff --git a/tests/auto/qtoolbar/tst_qtoolbar.cpp b/tests/auto/qtoolbar/tst_qtoolbar.cpp
index e4f317c..ac86fd9 100644
--- a/tests/auto/qtoolbar/tst_qtoolbar.cpp
+++ b/tests/auto/qtoolbar/tst_qtoolbar.cpp
@@ -54,6 +54,8 @@
#include <qtoolbutton.h>
#include <qlineedit.h>
#include <qkeysequence.h>
+#include <qmenu.h>
+#include <private/qtoolbarextension_p.h>
#include "../../shared/util.h"
@@ -569,6 +571,29 @@ void tst_QToolBar::actionGeometry()
qt_x11_wait_for_window_manager(&tb);
#endif
+ QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();
+
+ QRect rect01;
+ QRect rect02;
+ QRect rect03;
+ QRect rect04;
+ QMenu *popupMenu;
+
+ if (extensions.size() != 0)
+ {
+ QToolBarExtension *extension = extensions.at(0);
+ if (extension->isVisible()) {
+ QRect rect0 = extension->geometry();
+ QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
+ QApplication::processEvents();
+ popupMenu = qobject_cast<QMenu *>(extension->menu());
+ rect01 = popupMenu->actionGeometry(&action1);
+ rect02 = popupMenu->actionGeometry(&action2);
+ rect03 = popupMenu->actionGeometry(&action3);
+ rect04 = popupMenu->actionGeometry(&action4);
+ }
+ }
+
QRect rect1 = tb.actionGeometry(&action1);
QRect rect2 = tb.actionGeometry(&action2);
QRect rect3 = tb.actionGeometry(&action3);
@@ -590,10 +615,25 @@ void tst_QToolBar::actionGeometry()
QVERIFY(!rect4.isNull());
QVERIFY(!rect4.isEmpty());
- QCOMPARE(tb.actionAt(rect1.center()), &action1);
- QCOMPARE(tb.actionAt(rect2.center()), &action2);
- QCOMPARE(tb.actionAt(rect3.center()), &action3);
- QCOMPARE(tb.actionAt(rect4.center()), &action4);
+ if (rect01.isValid())
+ QCOMPARE(popupMenu->actionAt(rect01.center()), &action1);
+ else
+ QCOMPARE(tb.actionAt(rect1.center()), &action1);
+
+ if (rect02.isValid())
+ QCOMPARE(popupMenu->actionAt(rect02.center()), &action2);
+ else
+ QCOMPARE(tb.actionAt(rect2.center()), &action2);
+
+ if (rect03.isValid())
+ QCOMPARE(popupMenu->actionAt(rect03.center()), &action3);
+ else
+ QCOMPARE(tb.actionAt(rect3.center()), &action3);
+
+ if (rect04.isValid())
+ QCOMPARE(popupMenu->actionAt(rect04.center()), &action4);
+ else
+ QCOMPARE(tb.actionAt(rect4.center()), &action4);
}
void tst_QToolBar::actionAt()
@@ -864,33 +904,82 @@ void tst_QToolBar::actionTriggered()
qt_x11_wait_for_window_manager(&tb);
#endif
+ QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();
+
+ QRect rect01;
+ QRect rect02;
+ QRect rect03;
+ QRect rect04;
+ QMenu *popupMenu;
+
+ if (extensions.size() != 0)
+ {
+ QToolBarExtension *extension = extensions.at(0);
+ if (extension->isVisible()) {
+ QRect rect0 = extension->geometry();
+ QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
+ QApplication::processEvents();
+ popupMenu = qobject_cast<QMenu *>(extension->menu());
+ rect01 = popupMenu->actionGeometry(&action1);
+ rect02 = popupMenu->actionGeometry(&action2);
+ rect03 = popupMenu->actionGeometry(&action3);
+ rect04 = popupMenu->actionGeometry(&action4);
+ }
+ }
+
QRect rect1 = tb.actionGeometry(&action1);
QRect rect2 = tb.actionGeometry(&action2);
QRect rect3 = tb.actionGeometry(&action3);
QRect rect4 = tb.actionGeometry(&action4);
- QAbstractButton *button1 = qobject_cast<QAbstractButton *>(tb.childAt(rect1.center()));
- QAbstractButton *button2 = qobject_cast<QAbstractButton *>(tb.childAt(rect2.center()));
- QAbstractButton *button3 = qobject_cast<QAbstractButton *>(tb.childAt(rect3.center()));
- QAbstractButton *button4 = qobject_cast<QAbstractButton *>(tb.childAt(rect4.center()));
- QVERIFY(button1 != 0);
- QVERIFY(button2 != 0);
- QVERIFY(button3 != 0);
- QVERIFY(button4 != 0);
+
+ QAbstractButton *button1;
+ QAbstractButton *button2;
+ QAbstractButton *button3;
+ QAbstractButton *button4;
+
+ if (!rect01.isValid()) {
+ button1 = qobject_cast<QAbstractButton *>(tb.childAt(rect1.center()));
+ QVERIFY(button1 != 0);
+ }
+ if (!rect02.isValid()) {
+ button2 = qobject_cast<QAbstractButton *>(tb.childAt(rect2.center()));
+ QVERIFY(button2 != 0);
+ }
+ if (!rect03.isValid()) {
+ button3 = qobject_cast<QAbstractButton *>(tb.childAt(rect3.center()));
+ QVERIFY(button3 != 0);
+ }
+ if (!rect04.isValid()) {
+ button4 = qobject_cast<QAbstractButton *>(tb.childAt(rect4.center()));
+ QVERIFY(button4 != 0);
+ }
::triggered = 0;
- QTest::mouseClick(button1, Qt::LeftButton);
+ if (!rect01.isValid())
+ QTest::mouseClick(button1, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect01.center(), -1 );
QCOMPARE(::triggered, &action1);
::triggered = 0;
- QTest::mouseClick(button2, Qt::LeftButton);
+ if (!rect02.isValid())
+ QTest::mouseClick(button2, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect02.center(), -1 );
QCOMPARE(::triggered, &action2);
::triggered = 0;
- QTest::mouseClick(button3, Qt::LeftButton);
+ if (!rect03.isValid())
+ QTest::mouseClick(button3, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect03.center(), -1 );
QCOMPARE(::triggered, &action3);
::triggered = 0;
- QTest::mouseClick(button4, Qt::LeftButton);
+ if (!rect04.isValid())
+ QTest::mouseClick(button4, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect04.center(), -1 );
QCOMPARE(::triggered, &action4);
}
@@ -977,7 +1066,7 @@ void tst_QToolBar::accel()
mw.show();
QApplication::setActiveWindow(&mw);
QTest::qWait(100);
- QTRY_COMPARE(QApplication::activeWindow(), &mw);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw));
QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
QTest::qWait(300);
diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp
index e262be7..d78fda5 100644
--- a/tests/auto/quuid/tst_quuid.cpp
+++ b/tests/auto/quuid/tst_quuid.cpp
@@ -72,6 +72,8 @@ private slots:
void variants();
void versions();
+ void threadUniqueness();
+
public:
// Variables
QUuid uuidA;
@@ -169,6 +171,30 @@ void tst_QUuid::versions()
QVERIFY( NCS.version() == QUuid::VerUnknown );
}
+class UuidThread : public QThread
+{
+public:
+ QUuid uuid;
+
+ void run()
+ {
+ uuid = QUuid::createUuid();
+ }
+};
+
+void tst_QUuid::threadUniqueness()
+{
+ QVector<UuidThread *> threads(qMax(2, QThread::idealThreadCount()));
+ for (int i = 0; i < threads.count(); ++i)
+ threads[i] = new UuidThread;
+ for (int i = 0; i < threads.count(); ++i)
+ threads[i]->start();
+ for (int i = 0; i < threads.count(); ++i)
+ QVERIFY(threads[i]->wait(1000));
+ for (int i = 1; i < threads.count(); ++i)
+ QVERIFY(threads[0]->uuid != threads[i]->uuid);
+ qDeleteAll(threads);
+}
QTEST_MAIN(tst_QUuid)
#include "tst_quuid.moc"
diff --git a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
index bc6fe68..9623e80 100644
--- a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
+++ b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp
@@ -120,7 +120,7 @@ void tst_QVideoSurfaceFormat::constructNull()
QCOMPARE(format.frameHeight(), -1);
QCOMPARE(format.viewport(), QRect());
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate());
+ QCOMPARE(format.frameRate(), 0.0);
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
}
@@ -159,7 +159,7 @@ void tst_QVideoSurfaceFormat::construct()
QCOMPARE(format.frameHeight(), frameSize.height());
QCOMPARE(format.viewport(), viewport);
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
- QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate());
+ QCOMPARE(format.frameRate(), 0.0);
QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
}
@@ -315,21 +315,21 @@ void tst_QVideoSurfaceFormat::scanLineDirection()
void tst_QVideoSurfaceFormat::frameRate_data()
{
- QTest::addColumn<QVideoSurfaceFormat::FrameRate>("frameRate");
+ QTest::addColumn<qreal>("frameRate");
QTest::newRow("null")
- << QVideoSurfaceFormat::FrameRate(0, 0);
+ << 0.0;
QTest::newRow("1/1")
- << QVideoSurfaceFormat::FrameRate(1, 1);
+ << 1.0;
QTest::newRow("24/1")
- << QVideoSurfaceFormat::FrameRate(24, 1);
+ << 24.0;
QTest::newRow("15/2")
- << QVideoSurfaceFormat::FrameRate(15, 2);
+ << 7.5;
}
void tst_QVideoSurfaceFormat::frameRate()
{
- QFETCH(QVideoSurfaceFormat::FrameRate, frameRate);
+ QFETCH(qreal, frameRate);
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
@@ -337,29 +337,16 @@ void tst_QVideoSurfaceFormat::frameRate()
format.setFrameRate(frameRate);
QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
- }
- {
- QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
-
- format.setFrameRate(frameRate.first, frameRate.second);
-
- QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(
- qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
+ QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
}
{
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
format.setFrameRate(frameRate);
- format.setProperty(
- "frameRate", qVariantFromValue<QVideoSurfaceFormat::FrameRate>(frameRate));
+ format.setProperty("frameRate", frameRate);
QCOMPARE(format.frameRate(), frameRate);
- QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")),
- frameRate);
+ QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate);
}
}
@@ -609,13 +596,13 @@ void tst_QVideoSurfaceFormat::compare()
QCOMPARE(format1 == format2, true);
QCOMPARE(format1 != format2, false);
- format1.setFrameRate(QVideoSurfaceFormat::FrameRate(15, 2));
+ format1.setFrameRate(7.5);
// Not equal frame rate differs.
QCOMPARE(format1 == format2, false);
QCOMPARE(format1 != format2, true);
- format2.setFrameRate(15, 2);
+ format2.setFrameRate(7.50001);
// Equal.
QCOMPARE(format1 == format2, true);
diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
index 586a707..50b3337 100644
--- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
@@ -125,6 +125,7 @@ void tst_QWidgetAction::defaultWidget()
tb1.addAction(action);
QVERIFY(combo->parent() == &tb1);
qApp->processEvents();
+ qApp->processEvents();
QVERIFY(combo->isVisible());
// not supported, not supposed to work, hence the parent() check
@@ -139,6 +140,7 @@ void tst_QWidgetAction::defaultWidget()
tb2.addAction(action);
qApp->processEvents(); //the call to hide is delayd by the toolbar layout
+ qApp->processEvents();
QVERIFY(combo->parent() == &tb2);
QVERIFY(combo->isVisible());
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 1a2de65..579f4eb 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -299,7 +299,7 @@ void tst_Selftests::runSubTest()
void tst_Selftests::initTestCase()
{
-#ifndef Q_OS_UNIX
+#if !defined(Q_OS_UNIX) || defined(Q_WS_MAC)
m_checkXMLBlacklist.append("crashes"); // This test crashes (XML valid on Unix only)
#endif
m_checkXMLBlacklist.append("waitwithoutgui"); // This test is not a QTestLib test.
diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp
new file mode 100644
index 0000000..5416457
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/gestures.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "gestures.h"
+
+#include <QTouchEvent>
+
+Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture;
+
+QGesture *ThreeFingerSlideGestureRecognizer::createGesture(QObject *)
+{
+ return new ThreeFingerSlideGesture;
+}
+
+QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+{
+ ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state);
+ QGestureRecognizer::Result result;
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ result = QGestureRecognizer::MaybeGesture;
+ case QEvent::TouchEnd:
+ if (d->gestureFired)
+ result = QGestureRecognizer::GestureFinished;
+ else
+ result = QGestureRecognizer::NotGesture;
+ case QEvent::TouchUpdate:
+ if (d->state() != Qt::NoGesture) {
+ QTouchEvent *ev = static_cast<QTouchEvent*>(event);
+ if (ev->touchPoints().size() == 3) {
+ d->gestureFired = true;
+ result = QGestureRecognizer::GestureTriggered;
+ } else {
+ result = QGestureRecognizer::MaybeGesture;
+ for (int i = 0; i < ev->touchPoints().size(); ++i) {
+ const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i);
+ const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength();
+ if (distance > 20) {
+ result = QGestureRecognizer::NotGesture;
+ }
+ }
+ }
+ } else {
+ result = QGestureRecognizer::NotGesture;
+ }
+
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ if (d->state() != Qt::NoGesture)
+ result = QGestureRecognizer::Ignore;
+ else
+ result = QGestureRecognizer::NotGesture;
+ break;
+ default:
+ result = QGestureRecognizer::Ignore;
+ break;
+ }
+ return result;
+}
+
+void ThreeFingerSlideGestureRecognizer::reset(QGesture *state)
+{
+ static_cast<ThreeFingerSlideGesture *>(state)->gestureFired = false;
+ QGestureRecognizer::reset(state);
+}
+
+
+QGesture *RotateGestureRecognizer::createGesture(QObject *)
+{
+ return new QGesture;
+}
+
+QGestureRecognizer::Result RotateGestureRecognizer::filterEvent(QGesture *, QObject *, QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchEnd:
+ case QEvent::TouchUpdate:
+ break;
+ default:
+ break;
+ }
+ return QGestureRecognizer::Ignore;
+}
+
+void RotateGestureRecognizer::reset(QGesture *state)
+{
+ QGestureRecognizer::reset(state);
+}
+
+#include "moc_gestures.cpp"
diff --git a/tests/manual/gestures/graphicsview/gestures.h b/tests/manual/gestures/graphicsview/gestures.h
new file mode 100644
index 0000000..6140b12
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/gestures.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GESTURE_H
+#define GESTURE_H
+
+#include <QGestureRecognizer>
+#include <QGesture>
+
+class ThreeFingerSlideGesture : public QGesture
+{
+ Q_OBJECT
+public:
+ static Qt::GestureType Type;
+
+ ThreeFingerSlideGesture(QObject *parent = 0) : QGesture(parent) { }
+
+ bool gestureFired;
+};
+
+class ThreeFingerSlideGestureRecognizer : public QGestureRecognizer
+{
+private:
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
+
+class RotateGestureRecognizer : public QGestureRecognizer
+{
+public:
+ RotateGestureRecognizer();
+
+private:
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
+
+#endif // GESTURE_H
diff --git a/tests/manual/gestures/graphicsview/graphicsview.pro b/tests/manual/gestures/graphicsview/graphicsview.pro
new file mode 100644
index 0000000..a40c323
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/graphicsview.pro
@@ -0,0 +1,17 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Mon Sep 7 13:26:43 2009
+# #####################################################################
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp \
+ imageitem.cpp \
+ gestures.cpp \
+ mousepangesturerecognizer.cpp
+
+HEADERS += imageitem.h \
+ gestures.h \
+ mousepangesturerecognizer.h
diff --git a/tests/manual/gestures/graphicsview/imageitem.cpp b/tests/manual/gestures/graphicsview/imageitem.cpp
new file mode 100644
index 0000000..307d7e4
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/imageitem.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imageitem.h"
+#include "gestures.h"
+
+#include <QPainter>
+#include <QEvent>
+
+ImageItem::ImageItem(const QImage &image)
+{
+ setImage(image);
+}
+
+void ImageItem::setImage(const QImage &image)
+{
+ image_ = image;
+ pixmap_ = QPixmap::fromImage(image.scaled(400, 400, Qt::KeepAspectRatio));
+ update();
+}
+
+QImage ImageItem::image() const
+{
+ return image_;
+}
+
+QRectF ImageItem::boundingRect() const
+{
+ const QSize size = pixmap_.size();
+ return QRectF(0, 0, size.width(), size.height());
+}
+
+void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
+{
+ painter->drawPixmap(0, 0, pixmap_);
+}
+
+
+GestureImageItem::GestureImageItem(const QImage &image)
+ : ImageItem(image)
+{
+ grabGesture(Qt::PanGesture);
+ grabGesture(ThreeFingerSlideGesture::Type);
+}
+
+bool GestureImageItem::event(QEvent *event)
+{
+ if (event->type() == QEvent::Gesture) {
+ qDebug("gestureimageitem: gesture triggered");
+ return true;
+ }
+ return ImageItem::event(event);
+}
+
+#include "moc_imageitem.cpp"
diff --git a/tests/manual/gestures/pinch/pinchwidget.h b/tests/manual/gestures/graphicsview/imageitem.h
index 7628ffc..776c8d1 100644
--- a/tests/manual/gestures/pinch/pinchwidget.h
+++ b/tests/manual/gestures/graphicsview/imageitem.h
@@ -39,40 +39,39 @@
**
****************************************************************************/
-#ifndef PINCHWIDGET_H
-#define PINCHWIDGET_H
+#ifndef IMAGEITEM_H
+#define IMAGEITEM_H
-#include <QWidget>
+#include <QGraphicsItem>
+#include <QImage>
+#include <QPixmap>
#include <QTransform>
-class QPanGesture;
-class QPinchGesture;
-
-class PinchWidget : public QWidget
+class ImageItem : public QGraphicsObject
{
Q_OBJECT
public:
- PinchWidget(const QImage &image, QWidget *parent = 0);
-
-private Q_SLOTS:
- void acceptTouchEvents();
- void onPanTriggered();
- void onPanFinished();
- void onPinchTriggered();
- void onPinchFinished();
+ ImageItem(const QImage &image);
+ void setImage(const QImage &image);
+ QImage image() const;
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
- void paintEvent(QPaintEvent *);
- QSize sizeHint() const;
+ QImage image_;
+ QPixmap pixmap_;
+ QTransform transform;
+};
- QImage image;
+class GestureImageItem : public ImageItem
+{
+ Q_OBJECT
- QPanGesture *pan;
- QPinchGesture *pinch;
+public:
+ GestureImageItem(const QImage &image);
- QTransform worldTransform;
- QTransform currentPanTransform;
- QTransform currentPinchTransform;
+protected:
+ bool event(QEvent *event);
};
-#endif // PINCHWIDGET_H
+#endif // IMAGEITEM_H
diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp
new file mode 100644
index 0000000..263a963
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/main.cpp
@@ -0,0 +1,228 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imageitem.h"
+#include "gestures.h"
+#include "mousepangesturerecognizer.h"
+
+class GraphicsView : public QGraphicsView
+{
+public:
+ GraphicsView(QGraphicsScene *scene, QWidget *parent = 0)
+ : QGraphicsView(scene, parent)
+ {
+ }
+protected:
+ bool viewportEvent(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent *>(event);
+ if (QPanGesture *pan = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture))) {
+ switch (pan->state()) {
+ case Qt::GestureStarted: qDebug("view: Pan: started"); break;
+ case Qt::GestureFinished: qDebug("view: Pan: finished"); break;
+ case Qt::GestureCanceled: qDebug("view: Pan: canceled"); break;
+ case Qt::GestureUpdated: break;
+ default: qDebug("view: Pan: <unknown state>"); break;
+ }
+
+ const QSizeF offset = pan->offset();
+ QScrollBar *vbar = verticalScrollBar();
+ QScrollBar *hbar = horizontalScrollBar();
+ vbar->setValue(vbar->value() - offset.height());
+ hbar->setValue(hbar->value() - offset.width());
+ ge->accept(pan);
+ return true;
+ }
+ }
+ return QGraphicsView::viewportEvent(event);
+ }
+};
+
+class StandardGestures : public QWidget
+{
+public:
+ StandardGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new QGraphicsView(scene, 0);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class GlobalViewGestures : public QWidget
+{
+ Q_OBJECT
+public:
+ GlobalViewGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new GraphicsView(scene, 0);
+ view->viewport()->grabGesture(Qt::PanGesture);
+ view->viewport()->grabGesture(ThreeFingerSlideGesture::Type);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class GraphicsItemGestures : public QWidget
+{
+ Q_OBJECT
+public:
+ GraphicsItemGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new QGraphicsView(scene, 0);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ void setDirectory(const QString &path);
+
+private:
+ QTabWidget *tabWidget;
+ StandardGestures *standardGestures;
+ GlobalViewGestures *globalViewGestures;
+ GraphicsItemGestures *graphicsItemGestures;
+};
+
+MainWindow::MainWindow()
+{
+ (void)qApp->registerGestureRecognizer(new MousePanGestureRecognizer);
+ ThreeFingerSlideGesture::Type = qApp->registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer);
+
+ tabWidget = new QTabWidget;
+
+ standardGestures = new StandardGestures;
+ tabWidget->addTab(standardGestures, "Standard gestures");
+
+ globalViewGestures = new GlobalViewGestures;
+ tabWidget->addTab(globalViewGestures , "Global gestures");
+
+ graphicsItemGestures = new GraphicsItemGestures;
+ tabWidget->addTab(graphicsItemGestures, "Graphics item gestures");
+
+ setCentralWidget(tabWidget);
+}
+
+void MainWindow::setDirectory(const QString &path)
+{
+ QDir dir(path);
+ QStringList files = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
+ foreach(const QString &file, files) {
+ QImageReader img(path + QLatin1String("/")+file);
+ QImage image = img.read();
+ if (!image.isNull()) {
+ {
+ ImageItem *item = new ImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ standardGestures->scene->addItem(item);
+ }
+ {
+ ImageItem *item = new ImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ globalViewGestures->scene->addItem(item);
+ }
+ {
+ GestureImageItem *item = new GestureImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ graphicsItemGestures->scene->addItem(item);
+ }
+ }
+ }
+
+ {
+ QList<QGraphicsItem*> items = standardGestures->scene->items();
+ if (!items.isEmpty())
+ standardGestures->view->ensureVisible(items.at(0));
+ }
+ {
+ QList<QGraphicsItem*> items = globalViewGestures->scene->items();
+ if (!items.isEmpty())
+ globalViewGestures->view->ensureVisible(items.at(0));
+ }
+ {
+ QList<QGraphicsItem*> items = graphicsItemGestures->scene->items();
+ if (!items.isEmpty())
+ graphicsItemGestures->view->ensureVisible(items.at(0));
+ }
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ if (QApplication::arguments().size() > 1)
+ window.setDirectory(QApplication::arguments().at(1));
+ else
+ window.setDirectory(QFileDialog::getExistingDirectory(0, "Select image folder"));
+ window.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
new file mode 100644
index 0000000..0e7f538
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mousepangesturerecognizer.h"
+
+#include <QEvent>
+#include <QMouseEvent>
+#include <QGesture>
+
+MousePanGestureRecognizer::MousePanGestureRecognizer()
+{
+}
+
+QGesture* MousePanGestureRecognizer::createGesture(QObject *)
+{
+ return new QPanGesture;
+}
+
+QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ QMouseEvent *me = static_cast<QMouseEvent *>(event);
+ if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick
+ || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
+ g->setHotSpot(me->globalPos());
+ g->setProperty("lastPos", me->globalPos());
+ g->setProperty("pressed", QVariant::fromValue<bool>(true));
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) {
+ if (g->property("pressed").toBool()) {
+ QPoint pos = me->globalPos();
+ QPoint lastPos = g->property("lastPos").toPoint();
+ g->setLastOffset(g->offset());
+ lastPos = pos - lastPos;
+ g->setOffset(QSizeF(lastPos.x(), lastPos.y()));
+ g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y()));
+ g->setProperty("lastPos", pos);
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::NotGesture;
+ } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) {
+ return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::Ignore;
+}
+
+void MousePanGestureRecognizer::reset(QGesture *state)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ g->setTotalOffset(QSizeF());
+ g->setLastOffset(QSizeF());
+ g->setOffset(QSizeF());
+ g->setAcceleration(0);
+ g->setProperty("lastPos", QVariant());
+ g->setProperty("pressed", QVariant::fromValue<bool>(false));
+ QGestureRecognizer::reset(state);
+}
diff --git a/tests/manual/gestures/pinch/main.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
index 4d9c14c..b062fd0 100644
--- a/tests/manual/gestures/pinch/main.cpp
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
@@ -39,30 +39,19 @@
**
****************************************************************************/
-#include <QtGui>
-#include "pinchwidget.h"
+#ifndef MOUSEPANGESTURERECOGNIZER_H
+#define MOUSEPANGESTURERECOGNIZER_H
-class MainWindow : public QWidget
+#include <QGestureRecognizer>
+
+class MousePanGestureRecognizer : public QGestureRecognizer
{
public:
- MainWindow();
-};
+ MousePanGestureRecognizer();
-MainWindow::MainWindow()
-{
- QVBoxLayout *l = new QVBoxLayout(this);
- QPushButton *btn = new QPushButton(QLatin1String("AcceptTouchEvents"));
- l->addWidget(btn);
- QImage image(":/images/qt-logo.png");
- PinchWidget *w = new PinchWidget(image);
- l->addWidget(w);
- connect(btn, SIGNAL(clicked()), w, SLOT(acceptTouchEvents()));
-}
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow w;
- w.show();
- return app.exec();
-}
+#endif // MOUSEPANGESTURERECOGNIZER_H
diff --git a/tests/manual/gestures/pinch/pinch.pro b/tests/manual/gestures/pinch/pinch.pro
deleted file mode 100644
index d1f28cc..0000000
--- a/tests/manual/gestures/pinch/pinch.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-SOURCES = main.cpp \
- pinchwidget.cpp
-HEADERS += pinchwidget.h
-RESOURCES += pinch.qrc
diff --git a/tests/manual/gestures/pinch/pinch.qrc b/tests/manual/gestures/pinch/pinch.qrc
deleted file mode 100644
index 0be9ba1..0000000
--- a/tests/manual/gestures/pinch/pinch.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/images" >
- <file>qt-logo.png</file>
- </qresource>
-</RCC>
diff --git a/tests/manual/gestures/pinch/pinchwidget.cpp b/tests/manual/gestures/pinch/pinchwidget.cpp
deleted file mode 100644
index e93c8b5..0000000
--- a/tests/manual/gestures/pinch/pinchwidget.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pinchwidget.h"
-
-#include <QPainter>
-#include <QImage>
-#include <QPixmap>
-#include <QPanGesture>
-#include <QPinchGesture>
-#include <QPushButton>
-
-PinchWidget::PinchWidget(const QImage &image, QWidget *parent)
- : QWidget(parent)
-{
- setMinimumSize(100,100);
- this->image = image;
- pan = new QPanGesture(this);
- connect(pan, SIGNAL(triggered()), this, SLOT(onPanTriggered()));
- connect(pan, SIGNAL(finished()), this, SLOT(onPanFinished()));
- pinch = new QPinchGesture(this);
- connect(pinch, SIGNAL(triggered()), this, SLOT(onPinchTriggered()));
- connect(pinch, SIGNAL(finished()), this, SLOT(onPinchFinished()));
-}
-
-QSize PinchWidget::sizeHint() const
-{
- return image.size()*1.5;
-}
-
-void PinchWidget::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- QTransform t = worldTransform * currentPanTransform * currentPinchTransform;
- p.setTransform(t);
- QPoint center = QPoint(width()/2, height()/2);
- QPoint size = QPoint(image.width()/2, image.height()/2);
- p.translate(center - size);
- p.drawImage(QPoint(0,0), image);
-}
-
-void PinchWidget::acceptTouchEvents()
-{
- setAttribute(Qt::WA_AcceptTouchEvents);
- if (QWidget *w = qobject_cast<QPushButton*>(sender()))
- w->setEnabled(false);
-}
-
-void PinchWidget::onPanTriggered()
-{
- currentPanTransform = QTransform()
- .translate(pan->totalOffset().width(),
- pan->totalOffset().height());
- update();
-}
-
-void PinchWidget::onPanFinished()
-{
- worldTransform *= currentPanTransform;
- currentPanTransform.reset();
- update();
-}
-
-void PinchWidget::onPinchTriggered()
-{
- QPoint transformCenter = worldTransform.map(QPoint(width()/2, height()/2));
- currentPinchTransform = QTransform()
- .translate(transformCenter.x(), transformCenter.y())
- .scale(pinch->totalScaleFactor(), pinch->totalScaleFactor())
- .rotate(pinch->totalRotationAngle())
- .translate(-transformCenter.x(), -transformCenter.y());
- update();
-}
-
-void PinchWidget::onPinchFinished()
-{
- worldTransform *= currentPinchTransform;
- currentPinchTransform.reset();
- update();
-}
diff --git a/tests/manual/gestures/pinch/qt-logo.png b/tests/manual/gestures/pinch/qt-logo.png
deleted file mode 100644
index 7d3e97e..0000000
--- a/tests/manual/gestures/pinch/qt-logo.png
+++ /dev/null
Binary files differ
diff --git a/tests/manual/gestures/scrollarea/main.cpp b/tests/manual/gestures/scrollarea/main.cpp
new file mode 100644
index 0000000..2796637
--- /dev/null
+++ b/tests/manual/gestures/scrollarea/main.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mousepangesturerecognizer.h"
+
+class ScrollArea : public QScrollArea
+{
+ Q_OBJECT
+public:
+ ScrollArea(QWidget *parent = 0)
+ : QScrollArea(parent), outside(false)
+ {
+ viewport()->grabGesture(Qt::PanGesture);
+ }
+
+protected:
+ bool viewportEvent(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ gestureEvent(static_cast<QGestureEvent *>(event));
+ return true;
+ } else if (event->type() == QEvent::GestureOverride) {
+ QGestureEvent *ge = static_cast<QGestureEvent *>(event);
+ if (QPanGesture *pan = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture)))
+ if (pan->state() == Qt::GestureStarted) {
+ outside = false;
+ }
+ }
+ return QScrollArea::viewportEvent(event);
+ }
+ void gestureEvent(QGestureEvent *event)
+ {
+ QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture));
+ if (pan) {
+ switch(pan->state()) {
+ case Qt::GestureStarted: qDebug("area: Pan: started"); break;
+ case Qt::GestureFinished: qDebug("area: Pan: finished"); break;
+ case Qt::GestureCanceled: qDebug("area: Pan: canceled"); break;
+ case Qt::GestureUpdated: break;
+ default: qDebug("area: Pan: <unknown state>"); break;
+ }
+
+ if (pan->state() == Qt::GestureStarted)
+ outside = false;
+ event->ignore();
+ event->ignore(pan);
+ if (outside)
+ return;
+
+ const QSizeF offset = pan->offset();
+ const QSizeF totalOffset = pan->totalOffset();
+ QScrollBar *vbar = verticalScrollBar();
+ QScrollBar *hbar = horizontalScrollBar();
+
+ if ((vbar->value() == vbar->minimum() && totalOffset.height() > 10) ||
+ (vbar->value() == vbar->maximum() && totalOffset.height() < -10)) {
+ outside = true;
+ return;
+ }
+ if ((hbar->value() == hbar->minimum() && totalOffset.width() > 10) ||
+ (hbar->value() == hbar->maximum() && totalOffset.width() < -10)) {
+ outside = true;
+ return;
+ }
+ vbar->setValue(vbar->value() - offset.height());
+ hbar->setValue(hbar->value() - offset.width());
+ event->accept(pan);
+ }
+ }
+
+private:
+ bool outside;
+};
+
+class Slider : public QSlider
+{
+public:
+ Slider(Qt::Orientation orientation, QWidget *parent = 0)
+ : QSlider(orientation, parent)
+ {
+ grabGesture(Qt::PanGesture);
+ }
+protected:
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ gestureEvent(static_cast<QGestureEvent *>(event));
+ return true;
+ }
+ return QSlider::event(event);
+ }
+ void gestureEvent(QGestureEvent *event)
+ {
+ QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture));
+ if (pan) {
+ switch (pan->state()) {
+ case Qt::GestureStarted: qDebug("slider: Pan: started"); break;
+ case Qt::GestureFinished: qDebug("slider: Pan: finished"); break;
+ case Qt::GestureCanceled: qDebug("slider: Pan: canceled"); break;
+ case Qt::GestureUpdated: break;
+ default: qDebug("slider: Pan: <unknown state>"); break;
+ }
+
+ if (pan->state() == Qt::GestureStarted)
+ outside = false;
+ event->ignore();
+ event->ignore(pan);
+ if (outside)
+ return;
+ const QSizeF offset = pan->offset();
+ const QSizeF totalOffset = pan->totalOffset();
+ if (orientation() == Qt::Horizontal) {
+ if ((value() == minimum() && totalOffset.width() < -10) ||
+ (value() == maximum() && totalOffset.width() > 10)) {
+ outside = true;
+ return;
+ }
+ if (totalOffset.height() < 40 && totalOffset.height() > -40) {
+ setValue(value() + offset.width());
+ event->accept(pan);
+ } else {
+ outside = true;
+ }
+ } else if (orientation() == Qt::Vertical) {
+ if ((value() == maximum() && totalOffset.height() < -10) ||
+ (value() == minimum() && totalOffset.height() > 10)) {
+ outside = true;
+ return;
+ }
+ if (totalOffset.width() < 40 && totalOffset.width() > -40) {
+ setValue(value() - offset.height());
+ event->accept(pan);
+ } else {
+ outside = true;
+ }
+ }
+ }
+ }
+private:
+ bool outside;
+};
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow()
+ {
+ rootScrollArea = new ScrollArea;
+ setCentralWidget(rootScrollArea);
+
+ QWidget *root = new QWidget;
+ root->setFixedSize(3000, 3000);
+ rootScrollArea->setWidget(root);
+
+ Slider *verticalSlider = new Slider(Qt::Vertical, root);
+ verticalSlider ->move(650, 1100);
+ Slider *horizontalSlider = new Slider(Qt::Horizontal, root);
+ horizontalSlider ->move(600, 1000);
+
+ childScrollArea = new ScrollArea(root);
+ childScrollArea->move(500, 500);
+ QWidget *w = new QWidget;
+ w->setMinimumWidth(400);
+ QVBoxLayout *l = new QVBoxLayout(w);
+ l->setMargin(20);
+ for (int i = 0; i < 100; ++i) {
+ QWidget *w = new QWidget;
+ QHBoxLayout *ll = new QHBoxLayout(w);
+ ll->addWidget(new QLabel(QString("Label %1").arg(i)));
+ ll->addWidget(new QPushButton(QString("Button %1").arg(i)));
+ l->addWidget(w);
+ }
+ childScrollArea->setWidget(w);
+ }
+private:
+ ScrollArea *rootScrollArea;
+ ScrollArea *childScrollArea;
+};
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ app.registerGestureRecognizer(new MousePanGestureRecognizer);
+ MainWindow w;
+ w.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp
new file mode 100644
index 0000000..79b633e
--- /dev/null
+++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mousepangesturerecognizer.h"
+
+#include <QEvent>
+#include <QMouseEvent>
+#include <QGesture>
+
+MousePanGestureRecognizer::MousePanGestureRecognizer()
+{
+}
+
+QGesture* MousePanGestureRecognizer::createGesture(QObject *) const
+{
+ return new QPanGesture;
+}
+
+QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ QMouseEvent *me = static_cast<QMouseEvent *>(event);
+ if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) {
+ g->setHotSpot(me->globalPos());
+ g->setProperty("lastPos", me->globalPos());
+ g->setProperty("pressed", QVariant::fromValue<bool>(true));
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ } else if (event->type() == QEvent::MouseMove) {
+ if (g->property("pressed").toBool()) {
+ QPoint pos = me->globalPos();
+ QPoint lastPos = g->property("lastPos").toPoint();
+ g->setLastOffset(g->offset());
+ lastPos = pos - lastPos;
+ g->setOffset(QSizeF(lastPos.x(), lastPos.y()));
+ g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y()));
+ g->setProperty("lastPos", pos);
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::NotGesture;
+ } else if (event->type() == QEvent::MouseButtonRelease) {
+ return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::Ignore;
+}
+
+void MousePanGestureRecognizer::reset(QGesture *state)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ g->setTotalOffset(QSizeF());
+ g->setLastOffset(QSizeF());
+ g->setOffset(QSizeF());
+ g->setAcceleration(0);
+ g->setProperty("lastPos", QVariant());
+ g->setProperty("pressed", QVariant::fromValue<bool>(false));
+ QGestureRecognizer::reset(state);
+}
diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h
new file mode 100644
index 0000000..c92d477
--- /dev/null
+++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOUSEPANGESTURERECOGNIZER_H
+#define MOUSEPANGESTURERECOGNIZER_H
+
+#include <QGestureRecognizer>
+
+class MousePanGestureRecognizer : public QGestureRecognizer
+{
+public:
+ MousePanGestureRecognizer();
+
+ QGesture* createGesture(QObject *target) const;
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
+
+#endif // MOUSEPANGESTURERECOGNIZER_H
diff --git a/tests/manual/gestures/scrollarea/scrollarea.pro b/tests/manual/gestures/scrollarea/scrollarea.pro
new file mode 100644
index 0000000..554810e
--- /dev/null
+++ b/tests/manual/gestures/scrollarea/scrollarea.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mousepangesturerecognizer.cpp
+HEADERS += mousepangesturerecognizer.h
diff --git a/tests/manual/gestures/twopanwidgets/main.cpp b/tests/manual/gestures/twopanwidgets/main.cpp
deleted file mode 100644
index 20a35fc..0000000
--- a/tests/manual/gestures/twopanwidgets/main.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-
-static const char text[] =
- "Hello world! This is just a lot of text with to make sure scrollbar appear";
-
-class TextEdit : public QTextEdit
-{
- Q_OBJECT
-public Q_SLOTS:
- void acceptTouch()
- {
- viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
- if (QWidget *w = qobject_cast<QPushButton*>(sender()))
- w->setEnabled(false);
- }
-};
-
-class PlainTextEdit : public QPlainTextEdit
-{
- Q_OBJECT
-public Q_SLOTS:
- void acceptTouch()
- {
- viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
- if (QWidget *w = qobject_cast<QPushButton*>(sender()))
- w->setEnabled(false);
- }
-};
-
-class MainWindow : public QMainWindow
-{
-public:
- MainWindow();
-};
-
-MainWindow::MainWindow()
-{
- QTabWidget *tw = new QTabWidget;
- setCentralWidget(tw);
- {
- QWidget *tab = new QWidget;
- QGridLayout *layout = new QGridLayout(tab);
- QTextEdit *edit1 = new TextEdit;
- QTextEdit *edit2 = new TextEdit;
- QString text1 = QString(text).replace(' ', '\n');
- for (int i = 0; i < 5; ++i) text1 += text1;
- QString text2 = QString(text);
- for (int i = 0; i < 5; ++i) text2 += text2;
- edit1->setPlainText(text1);
- edit2->setPlainText(text2);
- edit2->setWordWrapMode(QTextOption::NoWrap);
- QPushButton *btn1 = new QPushButton(QLatin1String("AcceptTouchEvents"));
- connect(btn1, SIGNAL(clicked()), edit1, SLOT(acceptTouch()));
- QPushButton *btn2 = new QPushButton(QLatin1String("AcceptTouchEvents"));
- connect(btn2, SIGNAL(clicked()), edit2, SLOT(acceptTouch()));
- layout->addWidget(btn1, 0, 0);
- layout->addWidget(btn2, 0, 1);
- layout->addWidget(edit1, 1, 0);
- layout->addWidget(edit2, 1, 1);
- tw->addTab(tab, QLatin1String("QTextEdit"));
- }
- {
- QWidget *tab = new QWidget;
- QGridLayout *layout = new QGridLayout(tab);
- QPlainTextEdit *edit1 = new PlainTextEdit;
- QPlainTextEdit *edit2 = new PlainTextEdit;
- QString text1 = QString(text).replace(' ', '\n');
- for (int i = 0; i < 5; ++i) text1 += text1;
- QString text2 = QString(text);
- for (int i = 0; i < 5; ++i) text2 += text2;
- edit1->setPlainText(text1);
- edit2->setPlainText(text2);
- edit2->setWordWrapMode(QTextOption::NoWrap);
- QPushButton *btn1 = new QPushButton(QLatin1String("AcceptTouchEvents"));
- connect(btn1, SIGNAL(clicked()), edit1, SLOT(acceptTouch()));
- QPushButton *btn2 = new QPushButton(QLatin1String("AcceptTouchEvents"));
- connect(btn2, SIGNAL(clicked()), edit2, SLOT(acceptTouch()));
- layout->addWidget(btn1, 0, 0);
- layout->addWidget(btn2, 0, 1);
- layout->addWidget(edit1, 1, 0);
- layout->addWidget(edit2, 1, 1);
- tw->addTab(tab, QLatin1String("QPlainTextEdit"));
- }
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/tests/manual/gestures/twopanwidgets/twopanwidgets.pro b/tests/manual/gestures/twopanwidgets/twopanwidgets.pro
deleted file mode 100644
index 5254077..0000000
--- a/tests/manual/gestures/twopanwidgets/twopanwidgets.pro
+++ /dev/null
@@ -1 +0,0 @@
-SOURCES = main.cpp \ No newline at end of file