summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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/qabstractitemview/tst_qabstractitemview.cpp48
-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.cpp13
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp18
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp869
-rw-r--r--tests/auto/qfiledialog2/qfiledialog2.pro27
-rw-r--r--tests/auto/qfiledialog2/tst_qfiledialog2.cpp1006
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp24
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp279
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp7
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp22
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp83
-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.cpp20
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp53
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp2
-rw-r--r--tests/auto/qicoimageformat/qicoimageformat.pro9
-rw-r--r--tests/auto/qicon/qicon.pro9
-rw-r--r--tests/auto/qimage/qimage.pro9
-rw-r--r--tests/auto/qimagereader/qimagereader.pro10
-rw-r--r--tests/auto/qimagewriter/qimagewriter.pro9
-rw-r--r--tests/auto/qinputcontext/tst_qinputcontext.cpp3
-rw-r--r--tests/auto/qitemmodel/qitemmodel.pro10
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp17
-rw-r--r--tests/auto/qmovie/qmovie.pro10
-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/qscriptengine/qscriptengine.pro7
-rw-r--r--tests/auto/qscriptstring/tst_qscriptstring.cpp17
-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/qsql/qsql.pro10
-rw-r--r--tests/auto/qsqldatabase/qsqldatabase.pro10
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h1
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp48
-rw-r--r--tests/auto/qsqldriver/qsqldriver.pro10
-rw-r--r--tests/auto/qsqldriver/tst_qsqldriver.cpp15
-rw-r--r--tests/auto/qsqlerror/qsqlerror.pro10
-rw-r--r--tests/auto/qsqlfield/qsqlfield.pro10
-rw-r--r--tests/auto/qsqlquery/qsqlquery.pro10
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp5
-rw-r--r--tests/auto/qsqlquerymodel/qsqlquerymodel.pro10
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp2
-rw-r--r--tests/auto/qsqlrecord/qsqlrecord.pro17
-rw-r--r--tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro10
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp8
-rw-r--r--tests/auto/qsqltablemodel/qsqltablemodel.pro10
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp7
-rw-r--r--tests/auto/qsqlthread/qsqlthread.pro10
-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.cpp216
-rw-r--r--tests/auto/qtablewidget/tst_qtablewidget.cpp21
-rw-r--r--tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp27
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp18
-rw-r--r--tests/auto/qtextstream/test/test.pro8
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp9
-rw-r--r--tests/auto/qtoolbar/tst_qtoolbar.cpp123
-rw-r--r--tests/auto/qtreewidget/tst_qtreewidget.cpp39
-rw-r--r--tests/auto/qurl/tst_qurl.cpp19
-rw-r--r--tests/auto/quuid/tst_quuid.cpp26
-rw-r--r--tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp39
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp161
-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
97 files changed, 4657 insertions, 1430 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 7493d86..d9e060d 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/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index 4e385d5..db840f4 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -223,6 +223,7 @@ private slots:
void task257481_emptyEditor();
void shiftArrowSelectionAfterScrolling();
void shiftSelectionAfterRubberbandSelection();
+ void ctrlRubberbandSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1225,6 +1226,9 @@ void tst_QAbstractItemView::task250754_fontChange()
void tst_QAbstractItemView::task200665_itemEntered()
{
+#ifdef Q_OS_WINCE_WM
+ QSKIP("On Windows Mobile the mouse tracking is unavailable at the moment", SkipAll);
+#endif
//we test that view will emit entered
//when the scrollbar move but not the mouse itself
QStandardItemModel model(1000,1);
@@ -1385,5 +1389,49 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
QVERIFY(selected.contains(index2));
}
+void tst_QAbstractItemView::ctrlRubberbandSelection()
+{
+ QStandardItemModel model;
+ for (int i=0; i<3; ++i) {
+ QStandardItem *item = new QStandardItem(QString("%1").arg(i));
+ model.setItem(i, 0, item);
+ }
+
+ QListView view;
+ view.setFixedSize(150, 450);
+ view.setFlow(QListView::LeftToRight);
+ view.setGridSize(QSize(100, 100));
+ view.setSelectionMode(QListView::ExtendedSelection);
+ view.setViewMode(QListView::IconMode);
+ view.setModel(&model);
+ view.show();
+ QTest::qWait(30);
+
+ QModelIndex index1 = model.index(1, 0);
+ QModelIndex index2 = model.index(2, 0);
+
+ // Select item 1
+ view.setCurrentIndex(index1);
+ QModelIndexList selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 1);
+ QVERIFY(selected.contains(index1));
+
+ // Now press control and draw a rubberband around items 1 and 2.
+ // The mouse move event has to be created manually because the QTest framework does not
+ // contain a function for mouse moves with buttons pressed.
+ QPoint pressPos = view.visualRect(index1).topLeft() - QPoint(1, 1);
+ QPoint releasePos = view.visualRect(index2).bottomRight() + QPoint(1, 1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pressPos);
+ QMouseEvent moveEvent(QEvent::MouseMove, releasePos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier);
+ bool moveEventReceived = qApp->notify(view.viewport(), &moveEvent);
+ QVERIFY(moveEventReceived);
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, releasePos);
+
+ // Verify that item 2 is selected now
+ selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 1);
+ QVERIFY(selected.contains(index2));
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
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..8b0335c 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -128,14 +128,15 @@ void tst_QButtonGroup::cleanup()
{
}
+QT_BEGIN_NAMESPACE
+extern bool Q_GUI_EXPORT qt_tab_all_widgets;
+QT_END_NAMESPACE
+
+
void tst_QButtonGroup::arrowKeyNavigation()
{
-#ifdef Q_WS_MAC
- QSettings appleSettings(QLatin1String("apple.com"));
- QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
- if (!(appleValue.toInt() & 0x2))
+ if (!qt_tab_all_widgets)
QSKIP("This test requires full keyboard control to be enabled.", SkipAll);
-#endif
QDialog dlg(0);
QHBoxLayout layout(&dlg);
@@ -406,7 +407,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..2f9410b 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -140,36 +140,6 @@ private slots:
void clearLineEdit();
void enableChooseButton();
void hooks();
- void listRoot();
- void heapCorruption();
- void deleteDirAndFiles();
- void filter();
- void showNameFilterDetails();
- void unc();
- void emptyUncPath();
-
- void task178897_minimumSize();
- void task180459_lastDirectory_data();
- void task180459_lastDirectory();
- void task227304_proxyOnFileDialog();
- void task227930_correctNavigationKeyboardBehavior();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- void task226366_lowerCaseHardDriveWindows();
-#endif
- void task233037_selectingDirectory();
- void task235069_hideOnEscape();
- void task236402_dontWatchDeletedDir();
- void task203703_returnProperSeparator();
- void task228844_ensurePreviousSorting();
- void task239706_editableFilterCombo();
- void task218353_relativePaths();
- void task251321_sideBarHiddenEntries();
- void task251341_sideBarRemoveEntries();
- void task254490_selectFileMultipleTimes();
- void task257579_sideBarWithNonCleanUrls();
- void task259105_filtersCornerCases();
-
- void QTBUG4419_lineEditSelectAll();
private:
QByteArray userSettings;
@@ -944,7 +914,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());
@@ -1345,842 +1315,5 @@ void tst_QFiledialog::hooks()
QCOMPARE(QFileDialog::getSaveFileName(), QString("saveName"));
}
-void tst_QFiledialog::listRoot()
-{
-#if defined QT_BUILD_INTERNAL
- QFileInfoGatherer::fetchedRoot = false;
- QString dir(QDir::currentPath());
- QNonNativeFileDialog fd(0, QString(), dir);
- fd.show();
- QCOMPARE(QFileInfoGatherer::fetchedRoot,false);
- fd.setDirectory("");
- QTest::qWait(500);
- QCOMPARE(QFileInfoGatherer::fetchedRoot,true);
-#endif
-}
-
-void tst_QFiledialog::heapCorruption()
-{
- QVector<QNonNativeFileDialog*> dialogs;
- for (int i=0; i < 10; i++) {
- QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL);
- dialogs << f;
- }
- qDeleteAll(dialogs);
-}
-
-struct FriendlyQFileDialog : public QFileDialog
-{
- friend class tst_QFileDialog;
- Q_DECLARE_PRIVATE(QFileDialog)
-};
-
-
-void tst_QFiledialog::deleteDirAndFiles()
-{
-#if defined QT_BUILD_INTERNAL
- QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete";
- QDir dir;
- QVERIFY(dir.mkpath(tempPath + "/foo"));
- QVERIFY(dir.mkpath(tempPath + "/foo/B"));
- QVERIFY(dir.mkpath(tempPath + "/foo/B"));
- QVERIFY(dir.mkpath(tempPath + "/foo/c"));
- QVERIFY(dir.mkpath(tempPath + "/bar"));
- QFile(tempPath + "/foo/a");
- QTemporaryFile *t;
- t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
- t->setAutoRemove(false);
- t->open();
- t->close();
- delete t;
-
- t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
- t->setAutoRemove(false);
- t->open();
- t->close();
- delete t;
- FriendlyQFileDialog fd;
- fd.setOption(QFileDialog::DontUseNativeDialog);
- fd.d_func()->removeDirectory(tempPath);
- QFileInfo info(tempPath);
- QTest::qWait(2000);
- QVERIFY(!info.exists());
-#endif
-}
-
-void tst_QFiledialog::filter()
-{
- QNonNativeFileDialog fd;
- QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action");
- QVERIFY(hiddenAction);
- QVERIFY(hiddenAction->isEnabled());
- QVERIFY(!hiddenAction->isChecked());
- QDir::Filters filter = fd.filter();
- filter |= QDir::Hidden;
- fd.setFilter(filter);
- QVERIFY(hiddenAction->isChecked());
-}
-
-void tst_QFiledialog::showNameFilterDetails()
-{
- QNonNativeFileDialog fd;
- QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
- QVERIFY(filters);
- QVERIFY(fd.isNameFilterDetailsVisible());
-
-
- QStringList filterChoices;
- filterChoices << "Image files (*.png *.xpm *.jpg)"
- << "Text files (*.txt)"
- << "Any files (*.*)";
- fd.setFilters(filterChoices);
-
- fd.setNameFilterDetailsVisible(false);
- QCOMPARE(filters->itemText(0), QString("Image files"));
- QCOMPARE(filters->itemText(1), QString("Text files"));
- QCOMPARE(filters->itemText(2), QString("Any files"));
-
- fd.setNameFilterDetailsVisible(true);
- QCOMPARE(filters->itemText(0), filterChoices.at(0));
- QCOMPARE(filters->itemText(1), filterChoices.at(1));
- QCOMPARE(filters->itemText(2), filterChoices.at(2));
-}
-
-void tst_QFiledialog::unc()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- // Only test UNC on Windows./
- QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
-#else
- QString dir(QDir::currentPath());
-#endif
- QVERIFY(QFile::exists(dir));
- QNonNativeFileDialog fd(0, QString(), dir);
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QVERIFY(model);
- QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir));
-}
-
-void tst_QFiledialog::emptyUncPath()
-{
- QNonNativeFileDialog fd;
- fd.show();
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QVERIFY(lineEdit);
- // press 'keys' for the input
- for (int i = 0; i < 3 ; ++i)
- QTest::keyPress(lineEdit, Qt::Key_Backslash);
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QVERIFY(model);
-}
-
-void tst_QFiledialog::task178897_minimumSize()
-{
- QNonNativeFileDialog fd;
- QStringList history = fd.history();
- history << QDir::toNativeSeparators("/verylongdirectory/"
- "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk");
- fd.setHistory(history);
- fd.show();
-
- QSize ms = fd.layout()->minimumSize();
- QVERIFY(ms.width() < 400);
-}
-
-void tst_QFiledialog::task180459_lastDirectory_data()
-{
- QTest::addColumn<QString>("path");
- QTest::addColumn<QString>("directory");
- QTest::addColumn<bool>("isEnabled");
- QTest::addColumn<QString>("result");
-
- QTest::newRow("path+file") << QDir::homePath() + QDir::separator() + "foo"
- << QDir::homePath() << true
- << QDir::homePath() + QDir::separator() + "foo" ;
- QTest::newRow("no path") << ""
- << QDir::tempPath() << false << QString();
- QTest::newRow("file") << "foo"
- << QDir::currentPath() << true
- << QDir::currentPath() + QDir::separator() + "foo" ;
- QTest::newRow("path") << QDir::homePath()
- << QDir::homePath() << false << QString();
- QTest::newRow("path not existing") << "/usr/bin/foo/bar/foo/foo.txt"
- << QDir::tempPath() << true
- << QDir::tempPath() + QDir::separator() + "foo.txt";
-
-}
-
-void tst_QFiledialog::task180459_lastDirectory()
-{
- //first visit the temp directory and close the dialog
- QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath());
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
- QVERIFY(model);
- QCOMPARE(model->index(QDir::tempPath()), model->index(dlg->directory().absolutePath()));
- delete dlg;
-
- QFETCH(QString, path);
- QFETCH(QString, directory);
- QFETCH(bool, isEnabled);
- QFETCH(QString, result);
-
- dlg = new QNonNativeFileDialog(0, "", path);
- model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
- QVERIFY(model);
- dlg->setAcceptMode(QFileDialog::AcceptSave);
- QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory));
-
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
- QVERIFY(button);
- QCOMPARE(button->isEnabled(), isEnabled);
- if (isEnabled)
- QCOMPARE(model->index(result), model->index(dlg->selectedFiles().first()));
-
- delete dlg;
-}
-
-
-
-class FilterDirModel : public QSortFilterProxyModel
-{
-
-public:
- FilterDirModel(QString root, QObject* parent=0):QSortFilterProxyModel(parent), m_root(root)
- {}
- ~FilterDirModel()
- {};
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
- {
- QModelIndex parentIndex;
- parentIndex = source_parent;
-
- QString path;
- path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
-
- do {
- path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path;
- parentIndex = parentIndex.parent();
- } while(parentIndex.isValid());
-
- QFileInfo info(path);
- if (info.isDir() && (QDir(path) != m_root))
- return false;
- return true;
- }
-
-
-private:
- QDir m_root;
-
-
-};
-
-class sortProxy : public QSortFilterProxyModel
-{
-public:
- sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
- {
- }
-protected:
- virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
- {
- QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
- const QFileInfo leftInfo(model->fileInfo(left));
- const QFileInfo rightInfo(model->fileInfo(right));
-
- if (leftInfo.isDir() == rightInfo.isDir())
- return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
- else if (leftInfo.isDir())
- return(false);
- else
- return(true);
- }
-};
-
-class CrashDialog : public QNonNativeFileDialog
-{
- Q_OBJECT
-
-public:
- CrashDialog(QWidget *parent, const QString &caption, const
-QString &dir, const QString &filter)
- : QNonNativeFileDialog(parent, caption, dir, filter)
- {
- sortProxy *proxyModel = new sortProxy(this);
- setProxyModel(proxyModel);
- }
-};
-
-void tst_QFiledialog::task227304_proxyOnFileDialog()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
- fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
- fd.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QTest::qWait(200);
- QTest::keyClick(edit, Qt::Key_T);
- QTest::keyClick(edit, Qt::Key_S);
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
-
- CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
- dialog->setFileMode(QFileDialog::ExistingFile);
- dialog->show();
-
- QListView *list = qFindChild<QListView*>(dialog, "listView");
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
-
- dialog->close();
- fd.close();
-
- QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0);
- QSortFilterProxyModel *pm = new QSortFilterProxyModel;
- fd2.setProxyModel(pm);
- fd2.show();
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar");
- sidebar->setFocus();
- sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
- //We shouldn't crash
-#endif
-}
-
-void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()
-{
- QDir current = QDir::currentPath();
- current.mkdir("test");
- current.cd("test");
- QFile file("test/out.txt");
- QFile file2("test/out2.txt");
- QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
- QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text));
- current.cdUp();
- current.mkdir("test2");
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Backspace);
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QCOMPARE(fd.isVisible(), true);
- QTest::qWait(200);
- file.close();
- file2.close();
- file.remove();
- file2.remove();
- current.rmdir("test");
- current.rmdir("test2");
-}
-
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-void tst_QFiledialog::task226366_lowerCaseHardDriveWindows()
-{
- QNonNativeFileDialog fd;
- fd.setDirectory(QDir::root().path());
- fd.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton");
- QTest::qWait(200);
- QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0));
- QTest::qWait(2000);
- QTest::keyClick(edit, Qt::Key_C);
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- QTest::qWait(200);
- QCOMPARE(edit->text(), QString("C:"));
- QTest::qWait(2000);
- //i clear my previous selection in the completer
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- edit->clear();
- QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT));
- QTest::qWait(200);
- QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
- QCOMPARE(edit->text(), QString("C:"));
-}
-#endif
-
-void tst_QFiledialog::task233037_selectingDirectory()
-{
- QDir current = QDir::currentPath();
- current.mkdir("test");
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QTest::qWait(3000); // Wait for sort to settle (I need a signal).
-#ifdef QT_KEYPAD_NAVIGATION
- list->setEditFocus(true);
-#endif
- QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(100);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
- QVERIFY(button);
- QCOMPARE(button->isEnabled(), true);
- current.rmdir("test");
-}
-
-void tst_QFiledialog::task235069_hideOnEscape()
-{
- QDir current = QDir::currentPath();
- QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Escape);
- QCOMPARE(fd.isVisible(), false);
- QNonNativeFileDialog fd2;
- fd2.setDirectory(current.absolutePath());
- fd2.setAcceptMode( QFileDialog::AcceptSave);
- fd2.show();
- QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit");
- QTest::keyClick(edit, Qt::Key_Escape);
- QCOMPARE(fd2.isVisible(), false);
-}
-
-void tst_QFiledialog::task236402_dontWatchDeletedDir()
-{
-#if defined QT_BUILD_INTERNAL
- //THIS TEST SHOULD NOT DISPLAY WARNINGS
- QDir current = QDir::currentPath();
- //make sure it is the first on the list
- current.mkdir("aaaaaaaaaa");
- FriendlyQFileDialog fd;
- fd.setViewMode(QFileDialog::List);
- fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
- fd.show();
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Backspace);
- QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(200);
- fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
- QTest::qWait(1000);
-#endif
-}
-
-void tst_QFiledialog::task203703_returnProperSeparator()
-{
- QDir current = QDir::currentPath();
- current.mkdir("aaaaaaaaaaaaaaaaaa");
- QNonNativeFileDialog fd;
- fd.setDirectory(current.absolutePath());
- fd.setViewMode(QFileDialog::List);
- fd.setFileMode(QFileDialog::Directory);
- fd.show();
- QTest::qWait(500);
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- list->setFocus();
- QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(1000);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
- QTest::keyClick(button, Qt::Key_Return);
- QTest::qWait(500);
- QString result = fd.selectedFiles().first();
- QVERIFY(result.at(result.count() - 1) != '/');
- QVERIFY(!result.contains('\\'));
- current.rmdir("aaaaaaaaaaaaaaaaaa");
-}
-
-void tst_QFiledialog::task228844_ensurePreviousSorting()
-{
- QDir current = QDir::currentPath();
- current.mkdir("aaaaaaaaaaaaaaaaaa");
- current.cd("aaaaaaaaaaaaaaaaaa");
- current.mkdir("a");
- current.mkdir("b");
- current.mkdir("c");
- current.mkdir("d");
- current.mkdir("e");
- current.mkdir("f");
- current.mkdir("g");
- QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
- tempFile->open();
- current.cdUp();
-
- QNonNativeFileDialog fd;
- fd.setDirectory(current.absolutePath());
- fd.setViewMode(QFileDialog::Detail);
- fd.show();
- QTest::qWait(500);
- QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView");
- tree->header()->setSortIndicator(3,Qt::DescendingOrder);
- QTest::qWait(200);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
- QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
- QTest::mouseClick(button, Qt::LeftButton);
- QTest::qWait(500);
-
- QNonNativeFileDialog fd2;
- fd2.setFileMode(QFileDialog::Directory);
- fd2.restoreState(fd.saveState());
- current.cd("aaaaaaaaaaaaaaaaaa");
- fd2.setDirectory(current.absolutePath());
- fd2.show();
- QTest::qWait(500);
- QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView");
- tree2->setFocus();
-
- QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
-
- QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox");
- QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
- fd2.selectFile("g");
- QTest::mouseClick(button2, Qt::LeftButton);
- QTest::qWait(500);
-
- QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
-
- QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
- fd3.restoreState(fd.saveState());
- fd3.setFileMode(QFileDialog::Directory);
- fd3.show();
- QTest::qWait(500);
- QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView");
- tree3->setFocus();
-
- QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
-
- QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox");
- QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
- QTest::mouseClick(button3, Qt::LeftButton);
- QTest::qWait(500);
-
- QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
-
- current.cd("aaaaaaaaaaaaaaaaaa");
- current.rmdir("a");
- current.rmdir("b");
- current.rmdir("c");
- current.rmdir("d");
- current.rmdir("e");
- current.rmdir("f");
- current.rmdir("g");
- tempFile->close();
- delete tempFile;
- current.cdUp();
- current.rmdir("aaaaaaaaaaaaaaaaaa");
-}
-
-
-void tst_QFiledialog::task239706_editableFilterCombo()
-{
- QNonNativeFileDialog d;
- d.setNameFilter("*.cpp *.h");
-
- d.show();
- QTest::qWait(500);
-
- QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
- QComboBox *filterCombo = 0;
- foreach (QComboBox *combo, comboList) {
- if (combo->objectName() == QString("fileTypeCombo")) {
- filterCombo = combo;
- break;
- }
- }
- Q_ASSERT(filterCombo);
- filterCombo->setEditable(true);
- QTest::mouseClick(filterCombo, Qt::LeftButton);
- QTest::keyPress(filterCombo, Qt::Key_X);
- QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure
-}
-
-void tst_QFiledialog::task218353_relativePaths()
-{
- QDir appDir = QDir::current();
- QVERIFY(appDir.cdUp() != false);
- QNonNativeFileDialog d(0, "TestDialog", "..");
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
-
- d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../"));
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
-
- QDir::current().mkdir("test");
- appDir = QDir::current();
- d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../"));
- QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
- appDir.rmdir("test");
-}
-
-void tst_QFiledialog::task251321_sideBarHiddenEntries()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd;
-
- QDir current = QDir::currentPath();
- current.mkdir(".hidden");
- QDir hiddenDir = QDir(".hidden");
- hiddenDir.mkdir("subdir");
- QDir hiddenSubDir = QDir(".hidden/subdir");
- hiddenSubDir.mkdir("happy");
- hiddenSubDir.mkdir("happy2");
-
- QList<QUrl> urls;
- urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
- fd.setSidebarUrls(urls);
- fd.show();
- QTest::qWait(250);
-
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- sidebar->setFocus();
- sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
-
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2);
-
- hiddenSubDir.rmdir("happy2");
- hiddenSubDir.rmdir("happy");
- hiddenDir.rmdir("subdir");
- current.rmdir(".hidden");
-#endif
-}
-
-#if defined QT_BUILD_INTERNAL
-class MyQSideBar : public QSidebar
-{
-public :
- MyQSideBar(QWidget *parent = 0) : QSidebar(parent)
- {}
-
- void removeSelection() {
- QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
- QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
- indexes.append(idxs.at(i));
-
- for (int i = 0; i < indexes.count(); ++i)
- if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
- model()->removeRow(indexes.at(i).row());
- }
-};
-#endif
-
-void tst_QFiledialog::task251341_sideBarRemoveEntries()
-{
-#if defined QT_BUILD_INTERNAL
- QNonNativeFileDialog fd;
-
- QDir current = QDir::currentPath();
- current.mkdir("testDir");
- QDir testSubDir = QDir("testDir");
-
- QList<QUrl> urls;
- urls << QUrl::fromLocalFile(testSubDir.absolutePath());
- urls << QUrl::fromLocalFile("NotFound");
- fd.setSidebarUrls(urls);
- fd.show();
- QTest::qWait(250);
-
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- sidebar->setFocus();
- //We enter in the first bookmark
- sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
-
- QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
- //There is no file
- QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
- //Icon is not enabled QUrlModel::EnabledRole
- QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2);
- QCOMPARE(qvariant_cast<bool>(value), true);
-
- sidebar->setFocus();
- //We enter in the second bookmark which is invalid
- sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
- QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
-
- //We fallback to root because the entry in the bookmark is invalid
- QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
- //Icon is not enabled QUrlModel::EnabledRole
- value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2);
- QCOMPARE(qvariant_cast<bool>(value), false);
-
- MyQSideBar mySideBar;
- mySideBar.init(model, urls);
- mySideBar.show();
- mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
- QTest::qWait(1000);
- mySideBar.removeSelection();
-
- //We remove the first entry
- QList<QUrl> expected;
- expected << QUrl::fromLocalFile("NotFound");
- QCOMPARE(mySideBar.urls(), expected);
-
- mySideBar.selectUrl(QUrl::fromLocalFile("NotFound"));
- mySideBar.removeSelection();
-
- //We remove the second entry
- expected.clear();
- QCOMPARE(mySideBar.urls(), expected);
-
- current.rmdir("testDir");
-#endif
-}
-
-void tst_QFiledialog::task254490_selectFileMultipleTimes()
-{
- QString tempPath = QDir::tempPath();
- QTemporaryFile *t;
- t = new QTemporaryFile;
- t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog");
-
- fd.setDirectory(tempPath);
- fd.setViewMode(QFileDialog::List);
- fd.setAcceptMode(QFileDialog::AcceptSave);
- fd.setFileMode(QFileDialog::AnyFile);
-
- //This should select the file in the QFileDialog
- fd.selectFile(t->fileName());
-
- //This should clear the selection and write it into the filename line edit
- fd.selectFile("new_file.txt");
-
- fd.show();
- QTest::qWait(250);
-
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
- QVERIFY(lineEdit);
- QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
- QListView *list = qFindChild<QListView*>(&fd, "listView");
- QVERIFY(list);
- QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
-
- t->deleteLater();
-}
-
-void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
-{
-#if defined QT_BUILD_INTERNAL
- QDir tempDir = QDir::temp();
- QLatin1String dirname("autotest_task257579");
- tempDir.rmdir(dirname); //makes sure it doesn't exist any more
- QVERIFY(tempDir.mkdir(dirname));
- QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname);
- QNonNativeFileDialog fd;
- fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
- QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
- QCOMPARE(sidebar->urls().count(), 1);
- QVERIFY(sidebar->urls().first().toLocalFile() != url);
- QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url));
-
-#ifdef Q_OS_WIN
- QCOMPARE(sidebar->model()->index(0,0).data().toString().toLower(), tempDir.dirName().toLower());
-#else
- QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName());
-#endif
-
- //all tests are finished, we can remove the temporary dir
- QVERIFY(tempDir.rmdir(dirname));
-#endif
-}
-
-void tst_QFiledialog::task259105_filtersCornerCases()
-{
- QNonNativeFileDialog fd(0, "TestFileDialog");
- fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- fd.show();
- QTest::qWait(250);
-
- //Extensions are hidden
- QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
- QVERIFY(filters);
- QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-
- //We should have the full names
- fd.setOption(QFileDialog::HideNameFilterDetails, false);
- QTest::qWait(250);
- filters->setCurrentIndex(0);
- QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
-
- //Corner case undocumented of the task
- fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
-
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- filters->setCurrentIndex(0);
- QTest::qWait(500);
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-
- fd.setOption(QFileDialog::HideNameFilterDetails, true);
- filters->setCurrentIndex(0);
- QTest::qWait(500);
- QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
- filters->setCurrentIndex(1);
- QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
-}
-
-void tst_QFiledialog::QTBUG4419_lineEditSelectAll()
-{
- QString tempPath = QDir::tempPath();
- QTemporaryFile *t;
- t = new QTemporaryFile;
- t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName());
-
- fd.setDirectory(tempPath);
- fd.setViewMode(QFileDialog::List);
- fd.setAcceptMode(QFileDialog::AcceptSave);
- fd.setFileMode(QFileDialog::AnyFile);
-
- fd.show();
- QApplication::setActiveWindow(&fd);
- QTest::qWaitForWindowShown(&fd);
- QTRY_COMPARE(fd.isVisible(), true);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
-
- QTest::qWait(250);
- QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
-
- QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
- QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
-}
-
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/qfiledialog2/qfiledialog2.pro b/tests/auto/qfiledialog2/qfiledialog2.pro
new file mode 100644
index 0000000..4ebf977
--- /dev/null
+++ b/tests/auto/qfiledialog2/qfiledialog2.pro
@@ -0,0 +1,27 @@
+############################################################
+# Project file for autotest for file qfiledialog.h
+############################################################
+
+load(qttest_p4)
+
+SOURCES += tst_qfiledialog2.cpp
+
+wince*|symbian {
+ addFiles.sources = *.cpp
+ addFiles.path = .
+ filesInDir.sources = *.pro
+ filesInDir.path = someDir
+ DEPLOYMENT += addFiles filesInDir
+}
+
+symbian:TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h
+
+wince* {
+ DEFINES += SRCDIR=\\\"./\\\"
+} else:symbian {
+ TARGET.UID3 = 0xE0340003
+ DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x",""))
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
new file mode 100644
index 0000000..18f94a9
--- /dev/null
+++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
@@ -0,0 +1,1006 @@
+/****************************************************************************
+**
+** 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 <qcoreapplication.h>
+#include <qdebug.h>
+#include <qfiledialog.h>
+#include <qabstractitemdelegate.h>
+#include <qdirmodel.h>
+#include <qitemdelegate.h>
+#include <qlistview.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qtreeview.h>
+#include <qheaderview.h>
+#include <qcompleter.h>
+#include <qaction.h>
+#include <qdialogbuttonbox.h>
+#include <qsortfilterproxymodel.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include "../../shared/util.h"
+#include "../../../src/gui/dialogs/qsidebar_p.h"
+#include "../../../src/gui/dialogs/qfilesystemmodel_p.h"
+#include "../../../src/gui/dialogs/qfiledialog_p.h"
+
+#include "../network-settings.h"
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+#if defined(Q_OS_SYMBIAN)
+# define STRINGIFY(x) #x
+# define TOSTRING(x) STRINGIFY(x)
+# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/"
+#endif
+
+class QNonNativeFileDialog : public QFileDialog
+{
+ Q_OBJECT
+public:
+ QNonNativeFileDialog(QWidget *parent = 0, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString())
+ : QFileDialog(parent, caption, directory, filter)
+ {
+ setOption(QFileDialog::DontUseNativeDialog, true);
+ }
+};
+
+class tst_QFiledialog : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QFiledialog();
+ virtual ~tst_QFiledialog();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void listRoot();
+ void heapCorruption();
+ void deleteDirAndFiles();
+ void filter();
+ void showNameFilterDetails();
+ void unc();
+ void emptyUncPath();
+
+ void task178897_minimumSize();
+ void task180459_lastDirectory_data();
+ void task180459_lastDirectory();
+ void task227304_proxyOnFileDialog();
+ void task227930_correctNavigationKeyboardBehavior();
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ void task226366_lowerCaseHardDriveWindows();
+#endif
+ void task233037_selectingDirectory();
+ void task235069_hideOnEscape();
+ void task236402_dontWatchDeletedDir();
+ void task203703_returnProperSeparator();
+ void task228844_ensurePreviousSorting();
+ void task239706_editableFilterCombo();
+ void task218353_relativePaths();
+ void task251321_sideBarHiddenEntries();
+ void task251341_sideBarRemoveEntries();
+ void task254490_selectFileMultipleTimes();
+ void task257579_sideBarWithNonCleanUrls();
+ void task259105_filtersCornerCases();
+
+ void QTBUG4419_lineEditSelectAll();
+
+private:
+ QByteArray userSettings;
+};
+
+tst_QFiledialog::tst_QFiledialog()
+{
+}
+
+tst_QFiledialog::~tst_QFiledialog()
+{
+}
+
+void tst_QFiledialog::init()
+{
+ // Save the developers settings so they don't get mad when their sidebar folders are gone.
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("Qt"));
+ userSettings = settings.value(QLatin1String("filedialog")).toByteArray();
+ settings.remove(QLatin1String("filedialog"));
+
+ // populate it with some default settings
+ QNonNativeFileDialog fd;
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QFiledialog::cleanup()
+{
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("Qt"));
+ settings.setValue(QLatin1String("filedialog"), userSettings);
+}
+
+void tst_QFiledialog::listRoot()
+{
+#if defined QT_BUILD_INTERNAL
+ QFileInfoGatherer::fetchedRoot = false;
+ QString dir(QDir::currentPath());
+ QNonNativeFileDialog fd(0, QString(), dir);
+ fd.show();
+ QCOMPARE(QFileInfoGatherer::fetchedRoot,false);
+ fd.setDirectory("");
+ QTest::qWait(500);
+ QCOMPARE(QFileInfoGatherer::fetchedRoot,true);
+#endif
+}
+
+void tst_QFiledialog::heapCorruption()
+{
+ QVector<QNonNativeFileDialog*> dialogs;
+ for (int i=0; i < 10; i++) {
+ QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL);
+ dialogs << f;
+ }
+ qDeleteAll(dialogs);
+}
+
+struct FriendlyQFileDialog : public QFileDialog
+{
+ friend class tst_QFileDialog;
+ Q_DECLARE_PRIVATE(QFileDialog)
+};
+
+
+void tst_QFiledialog::deleteDirAndFiles()
+{
+#if defined QT_BUILD_INTERNAL
+ QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete";
+ QDir dir;
+ QVERIFY(dir.mkpath(tempPath + "/foo"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/B"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/B"));
+ QVERIFY(dir.mkpath(tempPath + "/foo/c"));
+ QVERIFY(dir.mkpath(tempPath + "/bar"));
+ QFile(tempPath + "/foo/a");
+ QTemporaryFile *t;
+ t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
+ t->setAutoRemove(false);
+ t->open();
+ t->close();
+ delete t;
+
+ t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
+ t->setAutoRemove(false);
+ t->open();
+ t->close();
+ delete t;
+ FriendlyQFileDialog fd;
+ fd.setOption(QFileDialog::DontUseNativeDialog);
+ fd.d_func()->removeDirectory(tempPath);
+ QFileInfo info(tempPath);
+ QTest::qWait(2000);
+ QVERIFY(!info.exists());
+#endif
+}
+
+void tst_QFiledialog::filter()
+{
+ QNonNativeFileDialog fd;
+ QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action");
+ QVERIFY(hiddenAction);
+ QVERIFY(hiddenAction->isEnabled());
+ QVERIFY(!hiddenAction->isChecked());
+ QDir::Filters filter = fd.filter();
+ filter |= QDir::Hidden;
+ fd.setFilter(filter);
+ QVERIFY(hiddenAction->isChecked());
+}
+
+void tst_QFiledialog::showNameFilterDetails()
+{
+ QNonNativeFileDialog fd;
+ QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+ QVERIFY(filters);
+ QVERIFY(fd.isNameFilterDetailsVisible());
+
+
+ QStringList filterChoices;
+ filterChoices << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*.*)";
+ fd.setFilters(filterChoices);
+
+ fd.setNameFilterDetailsVisible(false);
+ QCOMPARE(filters->itemText(0), QString("Image files"));
+ QCOMPARE(filters->itemText(1), QString("Text files"));
+ QCOMPARE(filters->itemText(2), QString("Any files"));
+
+ fd.setNameFilterDetailsVisible(true);
+ QCOMPARE(filters->itemText(0), filterChoices.at(0));
+ QCOMPARE(filters->itemText(1), filterChoices.at(1));
+ QCOMPARE(filters->itemText(2), filterChoices.at(2));
+}
+
+void tst_QFiledialog::unc()
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ // Only test UNC on Windows./
+ QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
+#else
+ QString dir(QDir::currentPath());
+#endif
+ QVERIFY(QFile::exists(dir));
+ QNonNativeFileDialog fd(0, QString(), dir);
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QVERIFY(model);
+ QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir));
+}
+
+void tst_QFiledialog::emptyUncPath()
+{
+ QNonNativeFileDialog fd;
+ fd.show();
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QVERIFY(lineEdit);
+ // press 'keys' for the input
+ for (int i = 0; i < 3 ; ++i)
+ QTest::keyPress(lineEdit, Qt::Key_Backslash);
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QVERIFY(model);
+}
+
+void tst_QFiledialog::task178897_minimumSize()
+{
+ QNonNativeFileDialog fd;
+ QStringList history = fd.history();
+ history << QDir::toNativeSeparators("/verylongdirectory/"
+ "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk");
+ fd.setHistory(history);
+ fd.show();
+
+ QSize ms = fd.layout()->minimumSize();
+ QVERIFY(ms.width() < 400);
+}
+
+void tst_QFiledialog::task180459_lastDirectory_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<bool>("isEnabled");
+ QTest::addColumn<QString>("result");
+
+ QTest::newRow("path+file") << QDir::homePath() + QDir::separator() + "foo"
+ << QDir::homePath() << true
+ << QDir::homePath() + QDir::separator() + "foo" ;
+ QTest::newRow("no path") << ""
+ << QDir::tempPath() << false << QString();
+ QTest::newRow("file") << "foo"
+ << QDir::currentPath() << true
+ << QDir::currentPath() + QDir::separator() + "foo" ;
+ QTest::newRow("path") << QDir::homePath()
+ << QDir::homePath() << false << QString();
+ QTest::newRow("path not existing") << "/usr/bin/foo/bar/foo/foo.txt"
+ << QDir::tempPath() << true
+ << QDir::tempPath() + QDir::separator() + "foo.txt";
+
+}
+
+void tst_QFiledialog::task180459_lastDirectory()
+{
+ //first visit the temp directory and close the dialog
+ QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath());
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
+ QVERIFY(model);
+ QCOMPARE(model->index(QDir::tempPath()), model->index(dlg->directory().absolutePath()));
+ delete dlg;
+
+ QFETCH(QString, path);
+ QFETCH(QString, directory);
+ QFETCH(bool, isEnabled);
+ QFETCH(QString, result);
+
+ dlg = new QNonNativeFileDialog(0, "", path);
+ model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model");
+ QVERIFY(model);
+ dlg->setAcceptMode(QFileDialog::AcceptSave);
+ QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory));
+
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
+ QVERIFY(button);
+ QCOMPARE(button->isEnabled(), isEnabled);
+ if (isEnabled)
+ QCOMPARE(model->index(result), model->index(dlg->selectedFiles().first()));
+
+ delete dlg;
+}
+
+
+
+class FilterDirModel : public QSortFilterProxyModel
+{
+
+public:
+ FilterDirModel(QString root, QObject* parent=0):QSortFilterProxyModel(parent), m_root(root)
+ {}
+ ~FilterDirModel()
+ {};
+
+protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
+ {
+ QModelIndex parentIndex;
+ parentIndex = source_parent;
+
+ QString path;
+ path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
+
+ do {
+ path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path;
+ parentIndex = parentIndex.parent();
+ } while(parentIndex.isValid());
+
+ QFileInfo info(path);
+ if (info.isDir() && (QDir(path) != m_root))
+ return false;
+ return true;
+ }
+
+
+private:
+ QDir m_root;
+
+
+};
+
+class sortProxy : public QSortFilterProxyModel
+{
+public:
+ sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
+ {
+ }
+protected:
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
+ {
+ QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
+ const QFileInfo leftInfo(model->fileInfo(left));
+ const QFileInfo rightInfo(model->fileInfo(right));
+
+ if (leftInfo.isDir() == rightInfo.isDir())
+ return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
+ else if (leftInfo.isDir())
+ return(false);
+ else
+ return(true);
+ }
+};
+
+class CrashDialog : public QNonNativeFileDialog
+{
+ Q_OBJECT
+
+public:
+ CrashDialog(QWidget *parent, const QString &caption, const
+QString &dir, const QString &filter)
+ : QNonNativeFileDialog(parent, caption, dir, filter)
+ {
+ sortProxy *proxyModel = new sortProxy(this);
+ setProxyModel(proxyModel);
+ }
+};
+
+void tst_QFiledialog::task227304_proxyOnFileDialog()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
+ fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
+ fd.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QTest::qWait(200);
+ QTest::keyClick(edit, Qt::Key_T);
+ QTest::keyClick(edit, Qt::Key_S);
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+
+ CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ dialog->show();
+
+ QListView *list = qFindChild<QListView*>(dialog, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+
+ dialog->close();
+ fd.close();
+
+ QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0);
+ QSortFilterProxyModel *pm = new QSortFilterProxyModel;
+ fd2.setProxyModel(pm);
+ fd2.show();
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar");
+ sidebar->setFocus();
+ sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
+ QTest::qWait(250);
+ //We shouldn't crash
+#endif
+}
+
+void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("test");
+ current.cd("test");
+ QFile file("test/out.txt");
+ QFile file2("test/out2.txt");
+ QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
+ QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text));
+ current.cdUp();
+ current.mkdir("test2");
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Backspace);
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QCOMPARE(fd.isVisible(), true);
+ QTest::qWait(200);
+ file.close();
+ file2.close();
+ file.remove();
+ file2.remove();
+ current.rmdir("test");
+ current.rmdir("test2");
+}
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+void tst_QFiledialog::task226366_lowerCaseHardDriveWindows()
+{
+ QNonNativeFileDialog fd;
+ fd.setDirectory(QDir::root().path());
+ fd.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton");
+ QTest::qWait(200);
+ QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0));
+ QTest::qWait(2000);
+ QTest::keyClick(edit, Qt::Key_C);
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ QTest::qWait(200);
+ QCOMPARE(edit->text(), QString("C:"));
+ QTest::qWait(2000);
+ //i clear my previous selection in the completer
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ edit->clear();
+ QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT));
+ QTest::qWait(200);
+ QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+ QCOMPARE(edit->text(), QString("C:"));
+}
+#endif
+
+void tst_QFiledialog::task233037_selectingDirectory()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("test");
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QTest::qWait(3000); // Wait for sort to settle (I need a signal).
+#ifdef QT_KEYPAD_NAVIGATION
+ list->setEditFocus(true);
+#endif
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::qWait(100);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
+ QVERIFY(button);
+ QCOMPARE(button->isEnabled(), true);
+ current.rmdir("test");
+}
+
+void tst_QFiledialog::task235069_hideOnEscape()
+{
+ QDir current = QDir::currentPath();
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Escape);
+ QCOMPARE(fd.isVisible(), false);
+ QNonNativeFileDialog fd2;
+ fd2.setDirectory(current.absolutePath());
+ fd2.setAcceptMode( QFileDialog::AcceptSave);
+ fd2.show();
+ QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit");
+ QTest::keyClick(edit, Qt::Key_Escape);
+ QCOMPARE(fd2.isVisible(), false);
+}
+
+void tst_QFiledialog::task236402_dontWatchDeletedDir()
+{
+#if defined QT_BUILD_INTERNAL
+ //THIS TEST SHOULD NOT DISPLAY WARNINGS
+ QDir current = QDir::currentPath();
+ //make sure it is the first on the list
+ current.mkdir("aaaaaaaaaa");
+ FriendlyQFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setDirectory(current.absolutePath());
+ fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.show();
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Backspace);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::qWait(200);
+ fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QFiledialog::task203703_returnProperSeparator()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("aaaaaaaaaaaaaaaaaa");
+ QNonNativeFileDialog fd;
+ fd.setDirectory(current.absolutePath());
+ fd.setViewMode(QFileDialog::List);
+ fd.setFileMode(QFileDialog::Directory);
+ fd.show();
+ QTest::qWait(500);
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ list->setFocus();
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(1000);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
+ QTest::keyClick(button, Qt::Key_Return);
+ QTest::qWait(500);
+ QString result = fd.selectedFiles().first();
+ QVERIFY(result.at(result.count() - 1) != '/');
+ QVERIFY(!result.contains('\\'));
+ current.rmdir("aaaaaaaaaaaaaaaaaa");
+}
+
+void tst_QFiledialog::task228844_ensurePreviousSorting()
+{
+ QDir current = QDir::currentPath();
+ current.mkdir("aaaaaaaaaaaaaaaaaa");
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ current.mkdir("a");
+ current.mkdir("b");
+ current.mkdir("c");
+ current.mkdir("d");
+ current.mkdir("e");
+ current.mkdir("f");
+ current.mkdir("g");
+ QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
+ tempFile->open();
+ current.cdUp();
+
+ QNonNativeFileDialog fd;
+ fd.setDirectory(current.absolutePath());
+ fd.setViewMode(QFileDialog::Detail);
+ fd.show();
+ QTest::qWait(500);
+ QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView");
+ tree->header()->setSortIndicator(3,Qt::DescendingOrder);
+ QTest::qWait(200);
+ QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox");
+ QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
+ QTest::mouseClick(button, Qt::LeftButton);
+ QTest::qWait(500);
+
+ QNonNativeFileDialog fd2;
+ fd2.setFileMode(QFileDialog::Directory);
+ fd2.restoreState(fd.saveState());
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ fd2.setDirectory(current.absolutePath());
+ fd2.show();
+ QTest::qWait(500);
+ QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView");
+ tree2->setFocus();
+
+ QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
+
+ QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox");
+ QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
+ fd2.selectFile("g");
+ QTest::mouseClick(button2, Qt::LeftButton);
+ QTest::qWait(500);
+
+ QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
+
+ QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
+ fd3.restoreState(fd.saveState());
+ fd3.setFileMode(QFileDialog::Directory);
+ fd3.show();
+ QTest::qWait(500);
+ QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView");
+ tree3->setFocus();
+
+ QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
+
+ QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox");
+ QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
+ QTest::mouseClick(button3, Qt::LeftButton);
+ QTest::qWait(500);
+
+ QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
+
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ current.rmdir("a");
+ current.rmdir("b");
+ current.rmdir("c");
+ current.rmdir("d");
+ current.rmdir("e");
+ current.rmdir("f");
+ current.rmdir("g");
+ tempFile->close();
+ delete tempFile;
+ current.cdUp();
+ current.rmdir("aaaaaaaaaaaaaaaaaa");
+}
+
+
+void tst_QFiledialog::task239706_editableFilterCombo()
+{
+ QNonNativeFileDialog d;
+ d.setNameFilter("*.cpp *.h");
+
+ d.show();
+ QTest::qWait(500);
+
+ QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
+ QComboBox *filterCombo = 0;
+ foreach (QComboBox *combo, comboList) {
+ if (combo->objectName() == QString("fileTypeCombo")) {
+ filterCombo = combo;
+ break;
+ }
+ }
+ Q_ASSERT(filterCombo);
+ filterCombo->setEditable(true);
+ QTest::mouseClick(filterCombo, Qt::LeftButton);
+ QTest::keyPress(filterCombo, Qt::Key_X);
+ QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure
+}
+
+void tst_QFiledialog::task218353_relativePaths()
+{
+ QDir appDir = QDir::current();
+ QVERIFY(appDir.cdUp() != false);
+ QNonNativeFileDialog d(0, "TestDialog", "..");
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+
+ d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../"));
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+
+ QDir::current().mkdir("test");
+ appDir = QDir::current();
+ d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../"));
+ QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
+ appDir.rmdir("test");
+}
+
+void tst_QFiledialog::task251321_sideBarHiddenEntries()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir(".hidden");
+ QDir hiddenDir = QDir(".hidden");
+ hiddenDir.mkdir("subdir");
+ QDir hiddenSubDir = QDir(".hidden/subdir");
+ hiddenSubDir.mkdir("happy");
+ hiddenSubDir.mkdir("happy2");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ QTest::qWait(250);
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2);
+
+ hiddenSubDir.rmdir("happy2");
+ hiddenSubDir.rmdir("happy");
+ hiddenDir.rmdir("subdir");
+ current.rmdir(".hidden");
+#endif
+}
+
+#if defined QT_BUILD_INTERNAL
+class MyQSideBar : public QSidebar
+{
+public :
+ MyQSideBar(QWidget *parent = 0) : QSidebar(parent)
+ {}
+
+ void removeSelection() {
+ QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
+ QList<QPersistentModelIndex> indexes;
+ for (int i = 0; i < idxs.count(); i++)
+ indexes.append(idxs.at(i));
+
+ for (int i = 0; i < indexes.count(); ++i)
+ if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
+ model()->removeRow(indexes.at(i).row());
+ }
+};
+#endif
+
+void tst_QFiledialog::task251341_sideBarRemoveEntries()
+{
+#if defined QT_BUILD_INTERNAL
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir("testDir");
+ QDir testSubDir = QDir("testDir");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(testSubDir.absolutePath());
+ urls << QUrl::fromLocalFile("NotFound");
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ //We enter in the first bookmark
+ sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ QTest::qWait(250);
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ //There is no file
+ QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
+ //Icon is not enabled QUrlModel::EnabledRole
+ QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), true);
+
+ sidebar->setFocus();
+ //We enter in the second bookmark which is invalid
+ sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
+ QTest::qWait(250);
+
+ //We fallback to root because the entry in the bookmark is invalid
+ QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
+ //Icon is not enabled QUrlModel::EnabledRole
+ value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), false);
+
+ MyQSideBar mySideBar;
+ mySideBar.init(model, urls);
+ mySideBar.show();
+ mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::qWait(1000);
+ mySideBar.removeSelection();
+
+ //We remove the first entry
+ QList<QUrl> expected;
+ expected << QUrl::fromLocalFile("NotFound");
+ QCOMPARE(mySideBar.urls(), expected);
+
+ mySideBar.selectUrl(QUrl::fromLocalFile("NotFound"));
+ mySideBar.removeSelection();
+
+ //We remove the second entry
+ expected.clear();
+ QCOMPARE(mySideBar.urls(), expected);
+
+ current.rmdir("testDir");
+#endif
+}
+
+void tst_QFiledialog::task254490_selectFileMultipleTimes()
+{
+ QString tempPath = QDir::tempPath();
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+
+ fd.setDirectory(tempPath);
+ fd.setViewMode(QFileDialog::List);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ //This should select the file in the QFileDialog
+ fd.selectFile(t->fileName());
+
+ //This should clear the selection and write it into the filename line edit
+ fd.selectFile("new_file.txt");
+
+ fd.show();
+ QTest::qWait(250);
+
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QVERIFY(lineEdit);
+ QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QVERIFY(list);
+ QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
+
+ t->deleteLater();
+}
+
+void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
+{
+#if defined QT_BUILD_INTERNAL
+ QDir tempDir = QDir::temp();
+ QLatin1String dirname("autotest_task257579");
+ tempDir.rmdir(dirname); //makes sure it doesn't exist any more
+ QVERIFY(tempDir.mkdir(dirname));
+ QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname);
+ QNonNativeFileDialog fd;
+ fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ QCOMPARE(sidebar->urls().count(), 1);
+ QVERIFY(sidebar->urls().first().toLocalFile() != url);
+ QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url));
+
+#ifdef Q_OS_WIN
+ QCOMPARE(sidebar->model()->index(0,0).data().toString().toLower(), tempDir.dirName().toLower());
+#else
+ QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName());
+#endif
+
+ //all tests are finished, we can remove the temporary dir
+ QVERIFY(tempDir.rmdir(dirname));
+#endif
+}
+
+void tst_QFiledialog::task259105_filtersCornerCases()
+{
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+ fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ fd.show();
+ QTest::qWait(250);
+
+ //Extensions are hidden
+ QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+ QVERIFY(filters);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+ //We should have the full names
+ fd.setOption(QFileDialog::HideNameFilterDetails, false);
+ QTest::qWait(250);
+ filters->setCurrentIndex(0);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ //Corner case undocumented of the task
+ fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+}
+
+void tst_QFiledialog::QTBUG4419_lineEditSelectAll()
+{
+ QString tempPath = QDir::tempPath();
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName());
+
+ fd.setDirectory(tempPath);
+ fd.setViewMode(QFileDialog::List);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ fd.show();
+ QApplication::setActiveWindow(&fd);
+ QTest::qWaitForWindowShown(&fd);
+ QTRY_COMPARE(fd.isVisible(), true);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd));
+
+ QTest::qWait(250);
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+
+ QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
+ QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
+}
+
+QTEST_MAIN(tst_QFiledialog)
+#include "tst_qfiledialog2.moc"
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 29e4fe6..f2d9017 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -806,21 +806,13 @@ void tst_QFileSystemModel::sort()
myModel->d_func()->disableRecursiveSort = true;
QDir dir(QDir::tempPath());
- dir.mkdir("sortTemp");
- dir.cd("sortTemp");
+ //initialize the randomness
+ qsrand(QDateTime::currentDateTime().toTime_t());
+ QString tempName = QLatin1String("sortTemp.") + QString::number(qrand());
+ dir.mkdir(tempName);
+ dir.cd(tempName);
QTRY_VERIFY(dir.exists());
- //To be sure we clean the dir if it was there before
- QDirIterator it(dir.absolutePath(), QDir::NoDotAndDotDot);
- while(it.hasNext())
- {
- it.next();
- QFileInfo info = it.fileInfo();
- if (info.isDir())
- dir.rmdir(info.fileName());
- else
- QFile::remove(info.absoluteFilePath());
- }
const QString dirPath = dir.absolutePath();
QVERIFY(dir.exists());
@@ -874,7 +866,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));
}
}
@@ -882,11 +874,11 @@ void tst_QFileSystemModel::sort()
delete myModel;
dir.setPath(QDir::tempPath());
- dir.cd("sortTemp");
+ dir.cd(tempName);
tempFile.remove();
tempFile2.remove();
dir.cdUp();
- dir.rmdir("sortTemp");
+ dir.rmdir(tempName);
}
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 9f13aca..286ea2d 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -69,6 +69,10 @@ private slots:
void delete_anchor();
void conflicts();
void sizePolicy();
+ void expandingSequence();
+ void expandingSequenceFairDistribution();
+ void expandingParallel();
+ void floatConflict();
};
class RectWidget : public QGraphicsWidget
@@ -155,7 +159,15 @@ void tst_QGraphicsAnchorLayout::simple()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
+
+ // Horizontal
+ l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
l->addAnchor(w1, Qt::AnchorRight, w2, Qt::AnchorLeft);
+ l->addAnchor(w2, Qt::AnchorRight, l, Qt::AnchorRight);
+
+ // Vertical
+ l->addAnchors(l, w1, Qt::Vertical);
+ l->addAnchors(l, w2, Qt::Vertical);
QGraphicsWidget p;
p.setLayout(l);
@@ -586,6 +598,20 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0));
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
+
+ QVERIFY(layoutHasConflict(l) == false);
+
+ // Test QSizePolicy::ExpandFlag, it shouldn't change the extreme
+ // points of the layout...
+ b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QSizeF newLayoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
+ QSizeF newLayoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
+ QSizeF newLayoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize);
+
+ QCOMPARE(layoutMinimumSize, newLayoutMinimumSize);
+ QCOMPARE(layoutMaximumSize, newLayoutMaximumSize);
+ QCOMPARE(layoutPreferredSize, newLayoutPreferredSize);
}
void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
@@ -1135,12 +1161,19 @@ void tst_QGraphicsAnchorLayout::delete_anchor()
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setSpacing(0);
l->setContentsMargins(0, 0, 0, 0);
+
+ // Horizontal
l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
l->addAnchor(w1, Qt::AnchorRight, w2, Qt::AnchorLeft);
l->addAnchor(w2, Qt::AnchorRight, l, Qt::AnchorRight);
l->addAnchor(w1, Qt::AnchorRight, w3, Qt::AnchorLeft);
l->addAnchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
+ // Vertical
+ l->addAnchors(l, w1, Qt::Vertical);
+ l->addAnchors(l, w2, Qt::Vertical);
+ l->addAnchors(l, w3, Qt::Vertical);
+
QGraphicsAnchor *anchor = l->anchor(w3, Qt::AnchorRight, l, Qt::AnchorRight);
anchor->setSpacing(10);
@@ -1254,7 +1287,7 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
w1->adjustSize();
QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0));
- QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(0, 0));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(100, 100));
QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100));
delete p;
@@ -1308,5 +1341,249 @@ void tst_QGraphicsAnchorLayout::conflicts()
delete p;
}
+void tst_QGraphicsAnchorLayout::expandingSequence()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(100, 10);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+
+ b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+
+ // horizontal
+ setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
+ setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+
+ // vertical
+ l->addAnchors(l, a, Qt::Vertical);
+ l->addAnchors(l, b, Qt::Vertical);
+
+ QCOMPARE(l->count(), 2);
+
+ QGraphicsWidget p;
+ p.setLayout(l);
+
+ QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
+ QCOMPARE(layoutMinimumSize.width(), qreal(20));
+
+ QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height());
+ p.resize(layoutExpandedSize);
+
+ QCOMPARE(a->geometry().size(), pref);
+ QCOMPARE(b->geometry().size(), max);
+
+ QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
+ QCOMPARE(layoutMaximumSize.width(), qreal(200));
+}
+
+void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(100, 10);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *c = createItem(min, pref, max, "c");
+ QGraphicsWidget *d = createItem(min, pref, max, "d");
+
+ b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+
+ // horizontal
+ setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
+ setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+ setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0);
+ setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+
+ // vertical
+ l->addAnchors(l, a, Qt::Vertical);
+ l->addAnchors(l, b, Qt::Vertical);
+ l->addAnchors(l, c, Qt::Vertical);
+ l->addAnchors(l, d, Qt::Vertical);
+
+ QCOMPARE(l->count(), 4);
+
+ QGraphicsWidget p;
+ p.setLayout(l);
+
+ QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
+ QCOMPARE(layoutMinimumSize.width(), qreal(40));
+
+ QSizeF layoutPartialExpandedSize((2 * pref.width()) + (2 * (pref.width() + 10)),
+ layoutMinimumSize.height());
+ p.resize(layoutPartialExpandedSize);
+
+ QCOMPARE(a->geometry().size(), pref);
+ QCOMPARE(b->geometry().size(), pref + QSizeF(10, 0));
+ QCOMPARE(c->geometry().size(), pref);
+ QCOMPARE(d->geometry().size(), pref + QSizeF(10, 0));
+
+ QSizeF layoutExpandedSize((2 * pref.width()) + (2 * max.width()),
+ layoutMinimumSize.height());
+ p.resize(layoutExpandedSize);
+
+ QCOMPARE(a->geometry().size(), pref);
+ QCOMPARE(b->geometry().size(), max);
+ QCOMPARE(c->geometry().size(), pref);
+ QCOMPARE(d->geometry().size(), max);
+
+ QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
+ QCOMPARE(layoutMaximumSize.width(), qreal(400));
+
+ // Now we change D to have more "room for growth" from its preferred size
+ // to its maximum size. We expect a proportional fair distribution. Note that
+ // this seems to not conform with what QGraphicsLinearLayout does.
+ d->setMaximumSize(QSizeF(150, 10));
+
+ QSizeF newLayoutExpandedSize((2 * pref.width()) + (max.width() + 150),
+ layoutMinimumSize.height());
+ p.resize(newLayoutExpandedSize);
+
+ QCOMPARE(a->geometry().size(), pref);
+ QCOMPARE(b->geometry().size(), max);
+ QCOMPARE(c->geometry().size(), pref);
+ QCOMPARE(d->geometry().size(), QSizeF(150, 10));
+
+ QSizeF newLayoutPartialExpandedSize((4 * pref.width()) + 75,
+ layoutMinimumSize.height());
+ p.resize(newLayoutPartialExpandedSize);
+
+ QCOMPARE(a->geometry().size(), pref);
+ QCOMPARE(b->geometry().size(), pref + QSizeF(25, 0));
+ QCOMPARE(c->geometry().size(), pref);
+ QCOMPARE(d->geometry().size(), pref + QSizeF(50, 0));
+}
+
+void tst_QGraphicsAnchorLayout::expandingParallel()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(100, 10);
+ QSizeF max2(100, 50);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *c = createItem(min, pref, max2, "c");
+
+ b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+
+ // horizontal
+ setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
+ setAnchor(l, l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0);
+
+ setAnchor(l, a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+ setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
+
+ setAnchor(l, c, Qt::AnchorRight, l, Qt::AnchorRight, 0);
+
+ // vertical
+ l->addAnchors(l, c, Qt::Vertical);
+ setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop, 0);
+ setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorVerticalCenter, 0);
+ setAnchor(l, b, Qt::AnchorTop, c, Qt::AnchorVerticalCenter, 0);
+ setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
+
+ QCOMPARE(l->count(), 3);
+
+ QGraphicsWidget p;
+ p.setLayout(l);
+
+ QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
+ QCOMPARE(layoutMinimumSize.width(), qreal(20));
+
+ QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height());
+ p.resize(layoutExpandedSize);
+
+ QCOMPARE(a->geometry().size(), max);
+ QCOMPARE(b->geometry().size(), max);
+ QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20));
+
+ QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
+ QCOMPARE(layoutMaximumSize.width(), qreal(200));
+
+ //
+ // Change the parallel connection to a paralell connection of b with a center...
+ //
+ QGraphicsAnchor *anchor = l->anchor(b, Qt::AnchorRight, c, Qt::AnchorLeft);
+ delete anchor;
+ setAnchor(l, b, Qt::AnchorRight, a, Qt::AnchorHorizontalCenter, 0);
+ a->setMaximumSize(max + QSizeF(100, 0));
+
+ QSizeF newLayoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
+ QCOMPARE(newLayoutMinimumSize.width(), qreal(30));
+
+ QSizeF newLayoutExpandedSize = layoutExpandedSize + QSizeF(100, 0);
+ p.resize(newLayoutExpandedSize);
+
+ QCOMPARE(a->geometry().size(), max + QSizeF(100, 0));
+ QCOMPARE(b->geometry().size(), max);
+ QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20));
+
+ QSizeF newLayoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
+ QCOMPARE(newLayoutMaximumSize.width(), qreal(300));
+}
+
+void tst_QGraphicsAnchorLayout::floatConflict()
+{
+ QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
+ QGraphicsWidget *b = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "b");
+
+ QGraphicsAnchorLayout *l;
+ QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
+
+ l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+
+ p->setLayout(l);
+
+ // horizontal
+ // with this anchor we have two floating items
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
+
+ // Just checking if the layout is handling well the removal of floating items
+ delete l->anchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+ QCOMPARE(l->count(), 0);
+ QCOMPARE(layoutHasConflict(l), false);
+
+ // setting back the same anchor
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft);
+
+ // We don't support floating items but they should be counted as if they are in the layout
+ QCOMPARE(l->count(), 2);
+ // Although, we have an invalid situation
+ QCOMPARE(layoutHasConflict(l), true);
+
+ // Semi-floats are supported
+ setAnchor(l, a, Qt::AnchorLeft, l, Qt::AnchorLeft);
+ QCOMPARE(l->count(), 2);
+
+ // Vertically the layout has floating items. Therefore, we have a conflict
+ QCOMPARE(layoutHasConflict(l), true);
+
+ // No more floating items
+ setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight);
+ setAnchor(l, a, Qt::AnchorTop, l, Qt::AnchorTop);
+ setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ setAnchor(l, b, Qt::AnchorTop, l, Qt::AnchorTop);
+ setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ QCOMPARE(layoutHasConflict(l), false);
+
+ delete p;
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index a521b78..148b2c8 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -530,16 +530,18 @@ void tst_QGraphicsAnchorLayout1::testIsValid()
TestWidget *widget1 = new TestWidget();
TestWidget *widget2 = new TestWidget();
+ // Vertically the layout has floating items. Therefore, we have a conflict
layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1);
layout->setAnchor(layout, Qt::AnchorRight, widget1, Qt::AnchorRight, -0.1);
+ // Horizontally the layout has floating items. Therefore, we have a conflict
layout->setAnchor(layout, Qt::AnchorTop, widget2, Qt::AnchorTop, 0.1);
layout->setAnchor(layout, Qt::AnchorBottom, widget2, Qt::AnchorBottom, -0.1);
widget->setLayout(layout);
widget->setGeometry(QRectF(0,0,100,100));
- QCOMPARE(layout->isValid(), true);
+ QCOMPARE(layout->isValid(), false);
delete widget;
}
}
@@ -1413,9 +1415,6 @@ void tst_QGraphicsAnchorLayout1::testMixedSpacing_data()
QTest::newRow("One widget, unsolvable") << QSizeF(10, 10) << theData << theResult;
}
- // ### BUG. We are not handling "floating" elements properly. Ie. elements that
- // have no anchors in a given orientation.
- if (0)
// Two widgets, one has fixed size
{
BasicLayoutTestDataList theData;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index e4eaf4e..0a6f60e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -82,6 +82,14 @@ Q_DECLARE_METATYPE(QRectF)
#define Q_CHECK_PAINTEVENTS
#endif
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+// On mac (cocoa) we always 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 QTRY_COMPARE
+#endif
+
static void sendMousePress(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton)
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
@@ -6183,7 +6191,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; \
@@ -6290,7 +6298,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2);
expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2);
- QTRY_COMPARE(view.paintedRegion, expectedRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedRegion);
}
class StacksBehindParentHelper : public QGraphicsRectItem
@@ -7117,7 +7125,7 @@ void tst_QGraphicsItem::update()
qApp->processEvents();
QCOMPARE(item->repaints, 1);
QCOMPARE(view.repaints, 1);
- QCOMPARE(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
+ COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
// Make sure moving a parent item triggers an update on the children
// (even though the parent itself is outside the viewport).
@@ -7392,7 +7400,7 @@ void tst_QGraphicsItem::moveItem()
QRegion expectedParentRegion = parentDeviceBoundingRect; // old position
parentDeviceBoundingRect.translate(20, 20);
expectedParentRegion += parentDeviceBoundingRect; // new position
- QCOMPARE(view.paintedRegion, expectedParentRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedParentRegion);
RESET_COUNTERS
@@ -7402,7 +7410,7 @@ void tst_QGraphicsItem::moveItem()
QCOMPARE(child->repaints, 1);
QCOMPARE(view.repaints, 1);
const QRegion expectedChildRegion = expectedParentRegion.translated(20, 20);
- QCOMPARE(view.paintedRegion, expectedChildRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedChildRegion);
RESET_COUNTERS
@@ -7413,7 +7421,7 @@ void tst_QGraphicsItem::moveItem()
QCOMPARE(grandChild->repaints, 1);
QCOMPARE(view.repaints, 1);
const QRegion expectedGrandChildRegion = expectedParentRegion.translated(40, 40);
- QCOMPARE(view.paintedRegion, expectedGrandChildRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedGrandChildRegion);
RESET_COUNTERS
@@ -7426,7 +7434,7 @@ void tst_QGraphicsItem::moveItem()
expectedParentRegion.translate(20, 20);
expectedParentRegion += expectedChildRegion.translated(20, 20);
expectedParentRegion += expectedGrandChildRegion.translated(20, 20);
- QCOMPARE(view.paintedRegion, expectedParentRegion);
+ COMPARE_REGIONS(view.paintedRegion, expectedParentRegion);
}
void tst_QGraphicsItem::sorting_data()
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 76e7202..013a028 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();
@@ -1531,7 +1532,7 @@ void tst_QGraphicsProxyWidget::setWidget_simple()
// Properties
// QCOMPARE(proxy.focusPolicy(), lineEdit->focusPolicy());
- QCOMPARE(proxy.palette(), lineEdit->palette());
+ // QCOMPARE(proxy.palette(), lineEdit->palette());
#ifndef QT_NO_CURSOR
QCOMPARE(proxy.cursor().shape(), lineEdit->cursor().shape());
#endif
@@ -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..389200b 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)
@@ -2203,9 +2210,11 @@ void tst_QGraphicsView::viewportUpdateMode()
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
+#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(15, 15));
QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(15, 15));
+#endif
// Set full update mode.
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
@@ -2938,10 +2947,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 +3187,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()
@@ -3423,10 +3433,12 @@ void tst_QGraphicsView::exposeRegion()
// Make sure it triggers correct repaint on the view.
QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
- QTRY_COMPARE(view.lastUpdateRegions.at(0), expectedExposeRegion);
+ COMPARE_REGIONS(view.lastUpdateRegions.at(0), expectedExposeRegion);
// Make sure the item didn't get any repaints.
+#ifndef QT_MAC_USE_COCOA
QCOMPARE(item->paints, 0);
+#endif
}
void tst_QGraphicsView::update_data()
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/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index 920231d..3286768 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -1836,7 +1836,7 @@ void tst_QHeaderView::preserveHiddenSectionWidth()
model.insertRow(1);
view.showSection(2);
QCOMPARE(view.sectionSize(0), 100);
- QCOMPARE(view.sectionSize(1), 30);
+ QCOMPARE(view.sectionSize(1), view.defaultSectionSize());
QCOMPARE(view.sectionSize(2), 50);
}
diff --git a/tests/auto/qicoimageformat/qicoimageformat.pro b/tests/auto/qicoimageformat/qicoimageformat.pro
index c0aa4b5..b9c8622 100644
--- a/tests/auto/qicoimageformat/qicoimageformat.pro
+++ b/tests/auto/qicoimageformat/qicoimageformat.pro
@@ -15,9 +15,12 @@ wince*: {
} else:symbian* {
addFiles.sources = icons
addFiles.path = .
- addPlugins.sources = qico.dll
- addPlugins.path = imageformats
- DEPLOYMENT += addFiles addPlugins
+ DEPLOYMENT += addFiles
+ qt_not_deployed {
+ addPlugins.sources = qico.dll
+ addPlugins.path = imageformats
+ DEPLOYMENT += addPlugins
+ }
TARGET.UID3 = 0xE0340004
DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x",""))
} else {
diff --git a/tests/auto/qicon/qicon.pro b/tests/auto/qicon/qicon.pro
index 8ae252f..68b888d 100644
--- a/tests/auto/qicon/qicon.pro
+++ b/tests/auto/qicon/qicon.pro
@@ -18,9 +18,12 @@ wince* {
QT += xml svg
addFiles.sources = *.png tst_qicon.cpp *.svg *.svgz
addFiles.path = .
- plugins.sources = qsvgicon.dll
- plugins.path = iconengines
- DEPLOYMENT += addFiles plugins
+ DEPLOYMENT += addFiles
+ qt_not_deployed {
+ plugins.sources = qsvgicon.dll
+ plugins.path = iconengines
+ DEPLOYMENT += plugins
+ }
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
diff --git a/tests/auto/qimage/qimage.pro b/tests/auto/qimage/qimage.pro
index 69d6f0f..3e0bd69 100644
--- a/tests/auto/qimage/qimage.pro
+++ b/tests/auto/qimage/qimage.pro
@@ -10,9 +10,12 @@ wince*: {
TARGET.EPOCHEAPSIZE = 0x200000 0x800000
addImages.sources = images/*
addImages.path = images
- imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll qtiff.dll qico.dll
- imagePlugins.path = imageformats
- DEPLOYMENT += addImages imagePlugins
+ DEPLOYMENT += addImages
+ qt_not_deployed {
+ imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll qtiff.dll qico.dll
+ imagePlugins.path = imageformats
+ DEPLOYMENT += imagePlugins
+ }
} else {
contains(QT_CONFIG, qt3support): QT += qt3support
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro
index 31a9b0f..5b061b0 100644
--- a/tests/auto/qimagereader/qimagereader.pro
+++ b/tests/auto/qimagereader/qimagereader.pro
@@ -30,8 +30,12 @@ symbian*: {
images.sources = images
images.path = .
- imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll
- imagePlugins.path = imageformats
+ DEPLOYMENT += images
- DEPLOYMENT += images imagePlugins
+ qt_not_deployed {
+ imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll
+ imagePlugins.path = imageformats
+
+ DEPLOYMENT += imagePlugins
+ }
}
diff --git a/tests/auto/qimagewriter/qimagewriter.pro b/tests/auto/qimagewriter/qimagewriter.pro
index 5a2c908..8da2942 100644
--- a/tests/auto/qimagewriter/qimagewriter.pro
+++ b/tests/auto/qimagewriter/qimagewriter.pro
@@ -13,9 +13,12 @@ wince*: {
} else:symbian* {
addFiles.sources = images\*.*
addFiles.path = images
- imagePlugins.sources = qjpeg.dll qtiff.dll
- imagePlugins.path = imageformats
- DEPLOYMENT += addFiles imagePlugins
+ DEPLOYMENT += addFiles
+ qt_not_deployed {
+ imagePlugins.sources = qjpeg.dll qtiff.dll
+ imagePlugins.path = imageformats
+ DEPLOYMENT += imagePlugins
+ }
} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
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/qitemmodel/qitemmodel.pro b/tests/auto/qitemmodel/qitemmodel.pro
index eb62b24..2d0bdea 100644
--- a/tests/auto/qitemmodel/qitemmodel.pro
+++ b/tests/auto/qitemmodel/qitemmodel.pro
@@ -16,9 +16,11 @@ QT += sql
symbian {
TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb"
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 726ca55..f12fa92 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -675,7 +675,13 @@ void tst_QMenu::activeSubMenuPosition()
#ifdef Q_OS_WINCE_WM
QSKIP("Not true for Windows Mobile Soft Keys", SkipSingle);
#endif
+
+#ifdef Q_OS_SYMBIAN
+ // On Symbian, QS60Style::pixelMetric(QStyle::PM_SubMenuOverlap) is different with other styles.
+ QVERIFY(sub->pos().x() < main->pos().x());
+#else
QVERIFY(sub->pos().x() > main->pos().x());
+#endif
QCOMPARE(sub->activeAction(), subAction);
}
@@ -778,6 +784,11 @@ void tst_QMenu::menuSizeHint()
int maxWidth =0;
QRect result;
foreach(QAction *action, menu.actions()) {
+#ifdef QT_SOFTKEYS_ENABLED
+ // Softkey actions are not widgets and have no geometry.
+ if (menu.actionGeometry(action).topLeft() == QPoint(0,0))
+ continue;
+#endif
maxWidth = qMax(maxWidth, menu.actionGeometry(action).width());
result |= menu.actionGeometry(action);
QCOMPARE(result.x(), left + hmargin + panelWidth);
@@ -812,7 +823,13 @@ public:
void tst_QMenu::task258920_mouseBorder()
{
+#ifdef Q_OS_WINCE_WM
+ QSKIP("Mouse move related signals for Windows Mobile unavailable", SkipAll);
+#endif
Menu258920 menu;
+ // On Symbian, styleHint(QStyle::SH_Menu_MouseTracking) in QS60Style is false.
+ // For other styles which inherit from QWindowsStyle, the value is true.
+ menu.setMouseTracking(true);
QAction *action = menu.addAction("test");
menu.popup(QApplication::desktop()->availableGeometry().center());
diff --git a/tests/auto/qmovie/qmovie.pro b/tests/auto/qmovie/qmovie.pro
index 15f0c83..30e5901 100644
--- a/tests/auto/qmovie/qmovie.pro
+++ b/tests/auto/qmovie/qmovie.pro
@@ -18,7 +18,9 @@ symbian*: {
addFiles.path = animations
DEPLOYMENT += addFiles
- imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll
- imagePlugins.path = imageformats
- DEPLOYMENT += imagePlugins
-} \ No newline at end of file
+ qt_not_deployed {
+ imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll
+ imagePlugins.path = imageformats
+ DEPLOYMENT += imagePlugins
+ }
+}
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/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro
index d4c0f4c..dd058a4 100644
--- a/tests/auto/qscriptengine/qscriptengine.pro
+++ b/tests/auto/qscriptengine/qscriptengine.pro
@@ -1,7 +1,12 @@
load(qttest_p4)
QT = core gui script
SOURCES += tst_qscriptengine.cpp
-!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+wince* {
+ DEFINES += SRCDIR=\\\"./\\\"
+} else:!symbian {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
wince*|symbian*: {
addFiles.sources = script
diff --git a/tests/auto/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp
index 0968b61..e1a4bc1 100644
--- a/tests/auto/qscriptstring/tst_qscriptstring.cpp
+++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp
@@ -58,6 +58,7 @@ public:
private slots:
void test();
+ void hash();
};
tst_QScriptString::tst_QScriptString()
@@ -138,5 +139,21 @@ void tst_QScriptString::test()
}
}
+void tst_QScriptString::hash()
+{
+ QScriptEngine engine;
+ QHash<QScriptString, int> stringToInt;
+ QScriptString foo = engine.toStringHandle("foo");
+ QScriptString bar = engine.toStringHandle("bar");
+ QVERIFY(!stringToInt.contains(foo));
+ for (int i = 0; i < 1000000; ++i)
+ stringToInt.insert(foo, 123);
+ QCOMPARE(stringToInt.value(foo), 123);
+ QVERIFY(!stringToInt.contains(bar));
+ stringToInt.insert(bar, 456);
+ QCOMPARE(stringToInt.value(bar), 456);
+ QCOMPARE(stringToInt.value(foo), 123);
+}
+
QTEST_MAIN(tst_QScriptString)
#include "tst_qscriptstring.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/qsql/qsql.pro b/tests/auto/qsql/qsql.pro
index 167a38d..0ec581d 100644
--- a/tests/auto/qsql/qsql.pro
+++ b/tests/auto/qsql/qsql.pro
@@ -10,9 +10,11 @@ wince*: {
}
symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
diff --git a/tests/auto/qsqldatabase/qsqldatabase.pro b/tests/auto/qsqldatabase/qsqldatabase.pro
index 964c8c9..6381219 100644
--- a/tests/auto/qsqldatabase/qsqldatabase.pro
+++ b/tests/auto/qsqldatabase/qsqldatabase.pro
@@ -23,10 +23,12 @@ symbian {
TARGET.EPOCHEAPSIZE=5000 5000000
TARGET.EPOCSTACKSIZE=50000
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
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/qsqldriver.pro b/tests/auto/qsqldriver/qsqldriver.pro
index 7f289a6..d04ca83 100644
--- a/tests/auto/qsqldriver/qsqldriver.pro
+++ b/tests/auto/qsqldriver/qsqldriver.pro
@@ -17,9 +17,11 @@ wince*: {
}
symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
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/qsqlerror/qsqlerror.pro b/tests/auto/qsqlerror/qsqlerror.pro
index 2eb7934..456f585 100644
--- a/tests/auto/qsqlerror/qsqlerror.pro
+++ b/tests/auto/qsqlerror/qsqlerror.pro
@@ -8,9 +8,11 @@ QT = core sql
SOURCES += tst_qsqlerror.cpp
symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
diff --git a/tests/auto/qsqlfield/qsqlfield.pro b/tests/auto/qsqlfield/qsqlfield.pro
index 6e5b461..7339854 100644
--- a/tests/auto/qsqlfield/qsqlfield.pro
+++ b/tests/auto/qsqlfield/qsqlfield.pro
@@ -4,10 +4,12 @@ SOURCES += tst_qsqlfield.cpp
QT += sql
symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
diff --git a/tests/auto/qsqlquery/qsqlquery.pro b/tests/auto/qsqlquery/qsqlquery.pro
index 494ca4c..97646ed 100644
--- a/tests/auto/qsqlquery/qsqlquery.pro
+++ b/tests/auto/qsqlquery/qsqlquery.pro
@@ -15,9 +15,11 @@ wince*: {
}
symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}
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/qsqlquerymodel.pro b/tests/auto/qsqlquerymodel/qsqlquerymodel.pro
index cd8586c..cda8cab 100644
--- a/tests/auto/qsqlquerymodel/qsqlquerymodel.pro
+++ b/tests/auto/qsqlquerymodel/qsqlquerymodel.pro
@@ -7,10 +7,12 @@ wince*: {
DEPLOYMENT_PLUGIN += qsqlite
LIBS += -lws2
}else:symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
} else {
win32:LIBS += -lws2_32
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 67e8ab9..f36f076 100644
--- a/tests/auto/qsqlrecord/qsqlrecord.pro
+++ b/tests/auto/qsqlrecord/qsqlrecord.pro
@@ -2,15 +2,18 @@ load(qttest_p4)
SOURCES += tst_qsqlrecord.cpp
symbian {
-contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
-}
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
+ }
-TARGET.EPOCSTACKSIZE=50000
-TARGET.EPOCHEAPSIZE=50000 5000000
+ TARGET.EPOCSTACKSIZE=50000
+ TARGET.EPOCHEAPSIZE=50000 5000000
}
+
QT += sql
diff --git a/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro b/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro
index 2fddd03..ee4f2f0 100644
--- a/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro
+++ b/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro
@@ -9,10 +9,12 @@ wince*: {
DEPLOYMENT += plugFiles
LIBS += -lws2
}else:symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
} else {
win32-g++ {
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/qsqltablemodel.pro b/tests/auto/qsqltablemodel/qsqltablemodel.pro
index a046fb1..9a23237 100644
--- a/tests/auto/qsqltablemodel/qsqltablemodel.pro
+++ b/tests/auto/qsqltablemodel/qsqltablemodel.pro
@@ -9,10 +9,12 @@ wince*: {
DEPLOYMENT += plugFiles
LIBS += -lws2
}else:symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}else {
win32:LIBS += -lws2_32
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/qsqlthread.pro b/tests/auto/qsqlthread/qsqlthread.pro
index 2708f1a..5522232 100644
--- a/tests/auto/qsqlthread/qsqlthread.pro
+++ b/tests/auto/qsqlthread/qsqlthread.pro
@@ -10,10 +10,12 @@ wince*: {
DEPLOYMENT += plugFiles
LIBS += -lws2
}else:symbian {
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- sqlite.path = /sys/bin
- sqlite.sources = sqlite3.dll
- DEPLOYMENT += sqlite
+ qt_not_deployed {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
}
}else {
win32:LIBS += -lws2_32
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..d75cfa7 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();
@@ -190,6 +193,7 @@ private slots:
void mouseWheel();
void addColumnWhileEditing();
+ void task234926_setHeaderSorting();
};
// Testing get/set functions
@@ -252,12 +256,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 +398,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 +871,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 +1174,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");
@@ -2540,6 +2703,7 @@ void tst_QTableView::indexAt()
QtTestTableView view;
view.show();
+ QTest::qWaitForWindowShown(&view);
//some styles change the scroll mode in their polish
view.setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
@@ -2555,9 +2719,10 @@ void tst_QTableView::indexAt()
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
- QTest::qWait(0); // ### needed to pass the test
+ QTest::qWait(20);
view.horizontalScrollBar()->setValue(horizontalScroll);
view.verticalScrollBar()->setValue(verticalScroll);
+ QTest::qWait(20);
QModelIndex index = view.indexAt(QPoint(x, y));
QCOMPARE(index.row(), expectedRow);
@@ -3087,9 +3252,15 @@ void tst_QTableView::resizeToContents()
}
+QT_BEGIN_NAMESPACE
+extern bool Q_GUI_EXPORT qt_tab_all_widgets; // qapplication.cpp
+QT_END_NAMESPACE
void tst_QTableView::tabFocus()
{
+ if (!qt_tab_all_widgets)
+ QSKIP("This test requires full keyboard control to be enabled.", SkipAll);
+
// QTableView enables tabKeyNavigation by default, but you should be able
// to change focus on an empty table view, or on a table view that doesn't
// have this property set.
@@ -3407,6 +3578,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);
@@ -3609,5 +3783,41 @@ void tst_QTableView::task191545_dragSelectRows()
}
}
+void tst_QTableView::task234926_setHeaderSorting()
+{
+ QStringListModel model;
+ QStringList data;
+ data << "orange" << "apple" << "banana" << "lemon" << "pumpkin";
+ QStringList sortedDataA = data;
+ QStringList sortedDataD = data;
+ qSort(sortedDataA);
+ qSort(sortedDataD.begin(), sortedDataD.end(), qGreater<QString>());
+ model.setStringList(data);
+ QTableView view;
+ view.setModel(&model);
+// view.show();
+ QTest::qWait(20);
+ QCOMPARE(model.stringList(), data);
+ view.setSortingEnabled(true);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+
+ QHeaderView *h = new QHeaderView(Qt::Horizontal);
+ h->setModel(&model);
+ view.setHorizontalHeader(h);
+ h->setSortIndicator(0, Qt::AscendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataA);
+
+ h->setSortIndicator(0, Qt::DescendingOrder);
+ QApplication::processEvents();
+ QCOMPARE(model.stringList() , sortedDataD);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"
diff --git a/tests/auto/qtablewidget/tst_qtablewidget.cpp b/tests/auto/qtablewidget/tst_qtablewidget.cpp
index 5aa2d1d..b85851f 100644
--- a/tests/auto/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/qtablewidget/tst_qtablewidget.cpp
@@ -102,6 +102,7 @@ private slots:
void cellWidget();
void task231094();
void task219380_removeLastRow();
+ void task262056_sortDuplicate();
private:
QTableWidget *testWidget;
@@ -1474,6 +1475,26 @@ void tst_QTableWidget::task219380_removeLastRow()
QCOMPARE(testWidget->cellWidget(18, 0)->geometry(), testWidget->visualItemRect(&item));
}
+void tst_QTableWidget::task262056_sortDuplicate()
+{
+ testWidget->setColumnCount(2);
+ testWidget->setRowCount(8);
+ testWidget->setSortingEnabled(true);
+ QStringList items = (QStringList() << "AAA" << "BBB" << "CCC" << "CCC" << "DDD"\
+ << "EEE" << "FFF" << "GGG");
+ for (int i = 0; i<8; i++ ) {
+ QTableWidgetItem *twi = new QTableWidgetItem(items.at(i));
+ testWidget->setItem(i,0,twi);
+ testWidget->setItem(i,1,new QTableWidgetItem(QString("item %1").arg(i)));
+ }
+ testWidget->sortItems(0, Qt::AscendingOrder);
+ QSignalSpy layoutChangedSpy(testWidget->model(), SIGNAL(layoutChanged()));
+ testWidget->item(3,0)->setBackgroundColor(Qt::red);
+
+ QCOMPARE(layoutChangedSpy.count(),0);
+
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"
diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index a5748ae..3b1e18f 100644
--- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
@@ -66,6 +66,7 @@ struct TestIterator
};
#include <qiterator.h>
+#ifndef QT_NO_STL
namespace std {
template <>
struct iterator_traits<TestIterator>
@@ -79,6 +80,7 @@ int distance(TestIterator &a, TestIterator &b)
}
}
+#endif
#include <qtconcurrentiteratekernel.h>
@@ -112,7 +114,7 @@ class PrintFor : public IterateKernel<TestIterator, void>
{
public:
PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) {iterations = 0; }
- inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *)
+ bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *)
{
iterations.fetchAndAddRelaxed(end - begin);
#ifdef PRINT
@@ -120,6 +122,11 @@ public:
#endif
return false;
}
+ bool runIteration(TestIterator it, int index , void *result)
+ {
+ return runIterations(it, index, index + 1, result);
+ }
+
};
class SleepPrintFor : public IterateKernel<TestIterator, void>
@@ -135,6 +142,10 @@ public:
#endif
return false;
}
+ bool runIteration(TestIterator it, int index , void *result)
+ {
+ return runIterations(it, index, index + 1, result);
+ }
};
@@ -165,6 +176,10 @@ public:
counter.fetchAndAddRelaxed(end - begin);
return false;
}
+ bool runIteration(TestIterator it, int index , void *result)
+ {
+ return runIterations(it, index, index + 1, result);
+ }
};
void tst_iteratekernel::stresstest()
@@ -215,6 +230,10 @@ public:
return false;
}
+ bool runIteration(TestIterator it, int index , void *result)
+ {
+ return runIterations(it, index, index + 1, result);
+ }
bool shouldThrottleThread()
{
@@ -254,6 +273,9 @@ public:
void tst_iteratekernel::blockSize()
{
+#ifdef QT_NO_STL
+ QSKIP("Missing stl iterators prevent correct block size calculation", SkipAll);
+#endif
const int expectedMinimumBlockSize = 1024 / QThread::idealThreadCount();
BlockSizeRecorder(0, 10000).startBlocking();
if (peakBlockSize < expectedMinimumBlockSize)
@@ -276,6 +298,9 @@ public:
void tst_iteratekernel::multipleResults()
{
+#ifdef QT_NO_STL
+ QSKIP("Missing stl iterators prevent correct summation", SkipAll);
+#endif
QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously();
QCOMPARE(f.results().count() , 10);
QCOMPARE(f.resultAt(0), 0);
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/qtextstream/test/test.pro b/tests/auto/qtextstream/test/test.pro
index 9f117d5..c70c27b 100644
--- a/tests/auto/qtextstream/test/test.pro
+++ b/tests/auto/qtextstream/test/test.pro
@@ -30,9 +30,11 @@ wince*: {
}else:symbian {
load(data_caging_paths)
# Symbian can't define SRCDIR meaningfully here
- codecs_plugins.sources = qcncodecs.dll qjpcodecs.dll qtwcodecs.dll qkrcodecs.dll
- codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs
- DEPLOYMENT += codecs_plugins
+ qt_not_deployed {
+ codecs_plugins.sources = qcncodecs.dll qjpcodecs.dll qtwcodecs.dll qkrcodecs.dll
+ codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs
+ DEPLOYMENT += codecs_plugins
+ }
}else {
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
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/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp
index 11c4543..6defd7b 100644
--- a/tests/auto/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp
@@ -49,6 +49,9 @@
#include <qheaderview.h>
#include <qlineedit.h>
#include <QScrollBar>
+#include <QStyledItemDelegate>
+
+#include "../../shared/util.h"
//TESTED_CLASS=
@@ -163,6 +166,7 @@ private slots:
void task217309();
void setCurrentItemExpandsParent();
void task239150_editorWidth();
+ void setTextUpdate();
public slots:
void itemSelectionChanged();
@@ -3233,6 +3237,41 @@ void tst_QTreeWidget::task239150_editorWidth()
+void tst_QTreeWidget::setTextUpdate()
+{
+ QTreeWidget treeWidget;
+ treeWidget.setColumnCount(2);
+
+ class MyItemDelegate : public QStyledItemDelegate
+ {
+ public:
+ MyItemDelegate() : numPaints(0) { }
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ numPaints++;
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+
+ mutable int numPaints;
+ } delegate;
+
+ treeWidget.setItemDelegate(&delegate);
+ treeWidget.show();
+ QStringList strList;
+ strList << "variable1" << "0";
+ QTreeWidgetItem *item = new QTreeWidgetItem(strList);
+ treeWidget.insertTopLevelItem(0, item);
+ QTest::qWait(50);
+ QTRY_VERIFY(delegate.numPaints > 0);
+ delegate.numPaints = 0;
+
+ item->setText(1, "42");
+ QApplication::processEvents();
+ QTRY_VERIFY(delegate.numPaints > 0);
+}
+
+
QTEST_MAIN(tst_QTreeWidget)
#include "tst_qtreewidget.moc"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 8856792..72c13bf 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -137,6 +137,7 @@ private slots:
void ipv6();
void ipv6_2_data();
void ipv6_2();
+ void moreIpv6();
void toPercentEncoding_data();
void toPercentEncoding();
void isRelative_data();
@@ -2276,6 +2277,13 @@ void tst_QUrl::ipv6_2()
QCOMPARE(url.toString(), output);
}
+void tst_QUrl::moreIpv6()
+{
+ QUrl waba1("http://www.kde.org/cgi/test.cgi");
+ waba1.setHost("::ffff:129.144.52.38");
+ QCOMPARE(QString::fromLatin1(waba1.toEncoded()), QString::fromLatin1("http://[::ffff:129.144.52.38]/cgi/test.cgi"));
+}
+
void tst_QUrl::punycode_data()
{
QTest::addColumn<QString>("original");
@@ -2624,6 +2632,13 @@ void tst_QUrl::tolerantParser()
//QCOMPARE(tsdgeosQUrl.toEncoded(), tsdgeosExpected); // unusable output from qtestlib...
QCOMPARE(QString(tsdgeosQUrl.toEncoded()), QString(tsdgeosExpected));
}
+
+ {
+ QUrl url;
+ url.setUrl("http://strange<username>@hostname/", QUrl::TolerantMode);
+ QVERIFY(url.isValid());
+ QCOMPARE(QString(url.toEncoded()), QString("http://strange%3Cusername%3E@hostname/"));
+ }
}
void tst_QUrl::correctEncodedMistakes_data()
@@ -3594,9 +3609,9 @@ void tst_QUrl::setAuthority()
void tst_QUrl::errorString()
{
- QUrl u = QUrl::fromEncoded("http://strange<username>@ok_hostname/", QUrl::StrictMode);
+ QUrl u = QUrl::fromEncoded("http://strange<username>@bad_hostname/", QUrl::StrictMode);
QVERIFY(!u.isValid());
- QString errorString = "Invalid URL \"http://strange<username>@ok_hostname/\": "
+ QString errorString = "Invalid URL \"http://strange<username>@bad_hostname/\": "
"error at position 14: expected end of URL, but found '<'";
QCOMPARE(u.errorString(), errorString);
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/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index f8341c3..758821b 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -239,7 +239,12 @@ private slots:
void setFixedSize();
void ensureCreated();
+ void winIdChangeEvent();
+#ifdef Q_OS_SYMBIAN
+ void reparentCausesChildWinIdChange();
+#else
void persistentWinId();
+#endif
void qobject_castInDestroyedSlot();
void showHideEvent_data();
@@ -4348,6 +4353,144 @@ void tst_QWidget::ensureCreated()
}
}
+class WinIdChangeWidget : public QWidget {
+public:
+ WinIdChangeWidget(QWidget *p = 0)
+ : QWidget(p)
+ , m_winIdChangeEventCount(0)
+ {
+
+ }
+protected:
+ bool event(QEvent *e){
+ if(e->type() == QEvent::WinIdChange)
+ ++m_winIdChangeEventCount;
+ else
+ return QWidget::event(e);
+ }
+public:
+ int m_winIdChangeEventCount;
+};
+
+void tst_QWidget::winIdChangeEvent()
+{
+ {
+ // Transforming an alien widget into a native widget
+ WinIdChangeWidget widget;
+ const WId winIdBefore = widget.internalWinId();
+ const WId winIdAfter = widget.winId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(widget.m_winIdChangeEventCount, 1);
+ }
+
+ {
+ // Changing parent of a native widget
+ QWidget parent1, parent2;
+ WinIdChangeWidget child(&parent1);
+ const WId winIdBefore = child.winId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ child.setParent(&parent2);
+ const WId winIdAfter = child.internalWinId();
+#ifdef Q_OS_SYMBIAN
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+#else
+ QCOMPARE(winIdBefore, winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+#endif
+ }
+
+ {
+ // Changing parent of an alien widget
+ QWidget parent1, parent2;
+ WinIdChangeWidget child(&parent1);
+ const WId winIdBefore = child.internalWinId();
+ child.setParent(&parent2);
+ const WId winIdAfter = child.internalWinId();
+ QCOMPARE(winIdBefore, winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 0);
+ }
+
+ {
+ // Making native child widget into a top-level window
+ QWidget parent;
+ WinIdChangeWidget child(&parent);
+ child.winId();
+ const WId winIdBefore = child.internalWinId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ const Qt::WindowFlags flags = child.windowFlags();
+ child.setWindowFlags(flags | Qt::Window);
+ const WId winIdAfter = child.internalWinId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+ }
+}
+
+#ifdef Q_OS_SYMBIAN
+void tst_QWidget::reparentCausesChildWinIdChange()
+{
+ QWidget *parent = new QWidget;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+ QWidget *w3 = new QWidget;
+ w1->setParent(parent);
+ w2->setParent(w1);
+ w3->setParent(w2);
+
+ WId winId1 = w1->winId();
+ WId winId2 = w2->winId();
+ WId winId3 = w3->winId();
+
+ // reparenting causes winIds of the widget being reparented, and all of its children, to change
+ w1->setParent(0);
+ QVERIFY(w1->winId() != winId1);
+ winId1 = w1->winId();
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w1->setParent(parent);
+ QVERIFY(w1->winId() != winId1);
+ winId1 = w1->winId();
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(0);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(parent);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w2->setParent(w1);
+ QVERIFY(w2->winId() != winId2);
+ winId2 = w2->winId();
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(0);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(w1);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ w3->setParent(w2);
+ QVERIFY(w3->winId() != winId3);
+ winId3 = w3->winId();
+
+ delete parent;
+}
+#else
void tst_QWidget::persistentWinId()
{
QWidget *parent = new QWidget;
@@ -4404,6 +4547,7 @@ void tst_QWidget::persistentWinId()
delete parent;
}
+#endif // Q_OS_SYMBIAN
class ShowHideEventWidget : public QWidget
{
@@ -4524,9 +4668,6 @@ void tst_QWidget::update()
QCOMPARE(child.paintedRegion, child.visibleRegion());
QCOMPARE(w.numPaintEvents, 1);
QCOMPARE(w.visibleRegion(), QRegion(w.rect()));
-#ifdef QT_MAC_USE_COCOA
- QEXPECT_FAIL(0, "Cocoa compositor paints the content view", Continue);
-#endif
QCOMPARE(w.paintedRegion, child.visibleRegion().translated(childOffset));
w.reset();
@@ -5136,15 +5277,6 @@ void tst_QWidget::windowMoveResize()
// now hide
widget.hide();
QTest::qWait(10);
-#if defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- QEXPECT_FAIL("130,100 0x200, flags 800",
- "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height",
- Abort);
-
- QEXPECT_FAIL("130,100 0x200, flags 0",
- "Cocoa's Delegate sends a spurios move event when the window has a width of zero and non-zero height",
- Abort);
-#endif
QTRY_COMPARE(widget.pos(), rect.topLeft());
QTRY_COMPARE(widget.size(), rect.size());
@@ -7466,8 +7598,8 @@ void tst_QWidget::updateWhileMinimized()
UpdateWidget widget;
// Filter out activation change and focus events to avoid update() calls in QWidget.
widget.updateOnActivationChangeAndFocusIn = false;
- widget.show();
widget.reset();
+ widget.show();
QTest::qWaitForWindowShown(&widget);
QApplication::processEvents();
QTRY_VERIFY(widget.numPaintEvents > 0);
@@ -9267,7 +9399,8 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QPixmap correct(main.size());
correct.fill(Qt::green);
- QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage(), correct.toImage());
+ QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().convertToFormat(QImage::Format_RGB32),
+ correct.toImage().convertToFormat(QImage::Format_RGB32));
QApplication::restoreOverrideCursor();
}
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