summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-23 12:57:30 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-23 12:57:30 (GMT)
commit4ff3e1ca7ce8afab49e5c52a1ae0141abfc8a841 (patch)
tree592d015d93478525504f8e09154b633fa2abdae2 /tests/auto
parentc21d3a0094b0692f2f888b04e258229234200e3c (diff)
parent05aaab72d69a7fa9c23811c1d3ee7d91a9174e46 (diff)
downloadQt-4ff3e1ca7ce8afab49e5c52a1ae0141abfc8a841.zip
Qt-4ff3e1ca7ce8afab49e5c52a1ae0141abfc8a841.tar.gz
Qt-4ff3e1ca7ce8afab49e5c52a1ae0141abfc8a841.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into qscriptprogram
Conflicts: src/script/api/qscriptengine.cpp tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro5
-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.cpp1170
-rw-r--r--tests/auto/linguist/lrelease/testdata/idbased.ts7
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp9
-rw-r--r--tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp10
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp45
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp4
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp2
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp9
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp11
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp18
-rw-r--r--tests/auto/qdom/tst_qdom.cpp1
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp867
-rw-r--r--tests/auto/qfiledialog2/qfiledialog2.pro27
-rw-r--r--tests/auto/qfiledialog2/tst_qfiledialog2.cpp1044
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp24
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp200
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp4
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp11
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp65
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp14
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp135
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp28
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp2
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp24
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp212
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp53
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp7
-rw-r--r--tests/auto/qhttp/tst_qhttp.cpp43
-rw-r--r--tests/auto/qlabel/qlabel.pro21
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp58
-rw-r--r--tests/auto/qlayout/tst_qlayout.cpp28
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp24
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp61
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp14
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp42
-rw-r--r--tests/auto/qpauseanimation/qpauseanimation.pro5
-rw-r--r--tests/auto/qpauseanimation/tst_qpauseanimation.cpp410
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp2
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp14
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp37
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp24
-rw-r--r--tests/auto/qsidebar/tst_qsidebar.cpp26
-rw-r--r--tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp56
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h1
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp55
-rw-r--r--tests/auto/qsqldriver/tst_qsqldriver.cpp15
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp21
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp2
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp8
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp7
-rw-r--r--tests/auto/qsqlthread/tst_qsqlthread.cpp2
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp107
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp238
-rw-r--r--tests/auto/qtablewidget/tst_qtablewidget.cpp21
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp6
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp14
-rw-r--r--tests/auto/qtreewidget/tst_qtreewidget.cpp39
-rw-r--r--tests/auto/qurl/tst_qurl.cpp8
-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.cpp219
-rw-r--r--tests/auto/qwidgetaction/tst_qwidgetaction.cpp2
65 files changed, 4532 insertions, 1178 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index f3ecdae..0f7a7f1 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -127,6 +127,7 @@ SUBDIRS += \
qexplicitlyshareddatapointer \
qfile \
qfiledialog \
+ qfiledialog2 \
qfileinfo \
qfilesystemwatcher \
qfilesystemmodel \
@@ -234,6 +235,7 @@ SUBDIRS += \
qpainterpath \
qpalette \
qparallelanimationgroup \
+ qpauseanimation \
qpathclipper \
qpen \
qpicture \
@@ -398,7 +400,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..92f979f
--- /dev/null
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -0,0 +1,1170 @@
+/****************************************************************************
+**
+** 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=
+
+static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view)
+{
+ return view->mapToGlobal(view->mapFromScene(item->mapToScene(pt)));
+}
+
+class CustomGesture : public QGesture
+{
+ Q_OBJECT
+public:
+ static Qt::GestureType GestureType;
+
+ CustomGesture(QObject *parent = 0)
+ : QGesture(parent), serial(0)
+ {
+ }
+
+ 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_), hasHotSpot(false)
+ {
+ }
+
+ int serial;
+ QPointF hotSpot;
+ bool hasHotSpot;
+};
+int CustomEvent::EventType = 0;
+
+class CustomGestureRecognizer : public QGestureRecognizer
+{
+public:
+ CustomGestureRecognizer()
+ {
+ if (!CustomEvent::EventType)
+ CustomEvent::EventType = QEvent::registerEventType();
+ }
+
+ 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;
+ if (e->hasHotSpot)
+ g->setHotSpot(e->hotSpot);
+ 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);
+ }
+};
+
+// same as CustomGestureRecognizer but triggers early without the maybe state
+class CustomContinuousGestureRecognizer : public QGestureRecognizer
+{
+public:
+ CustomContinuousGestureRecognizer()
+ {
+ if (!CustomEvent::EventType)
+ CustomEvent::EventType = QEvent::registerEventType();
+ }
+
+ 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;
+ if (e->hasHotSpot)
+ g->setHotSpot(e->hotSpot);
+ if (g->serial >= CustomGesture::SerialFinishedThreshold)
+ result |= QGestureRecognizer::GestureFinished;
+ else if (g->serial >= CustomGesture::SerialMaybeThreshold)
+ result |= QGestureRecognizer::GestureTriggered;
+ 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);
+ }
+};
+
+class GestureWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ GestureWidget(const char *name = 0, QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ if (name)
+ setObjectName(QLatin1String(name));
+ reset();
+ acceptGestureOverride = false;
+ }
+ void reset()
+ {
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ ignoredGestures.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;
+ QSet<Qt::GestureType> ignoredGestures;
+
+protected:
+ bool event(QEvent *event)
+ {
+ Events *eventsPtr = 0;
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *e = static_cast<QGestureEvent*>(event);
+ ++gestureEventsReceived;
+ eventsPtr = &events;
+ foreach(Qt::GestureType type, ignoredGestures)
+ e->ignore(e->gesture(type));
+ } 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(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0)
+{
+ for (int i = CustomGesture::SerialMaybeThreshold;
+ i <= CustomGesture::SerialFinishedThreshold; ++i) {
+ event->serial = i;
+ if (scene)
+ scene->sendEvent(qobject_cast<QGraphicsObject *>(object), event);
+ else
+ QApplication::sendEvent(object, event);
+ }
+}
+
+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();
+ void graphicsItemTreeGesture();
+ void explicitGraphicsObjectTarget();
+ void gestureOverChildGraphicsItem();
+ void twoGesturesOnDifferentLevel();
+ void multipleGesturesInTree();
+ void multipleGesturesInComplexTree();
+ void testMapToScene();
+};
+
+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);
+ CustomEvent event;
+ sendCustomGesture(&event, &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);
+
+ CustomEvent event;
+ sendCustomGesture(&event, 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(&event, 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
+ CustomEvent event;
+ sendCustomGesture(&event, 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(&event, &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
+ CustomEvent event;
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ 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(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, 0);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+
+ 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;
+ child->ignoredGestures << CustomGesture::GestureType;
+
+ // sending events to the child and making sure there is no conflict
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 1);
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+
+ parent.reset();
+ child->reset();
+
+ Qt::GestureType ContinuousGesture = qApp->registerGestureRecognizer(new CustomContinuousGestureRecognizer);
+ static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+ child->grabGesture(ContinuousGesture);
+ // child accepts override. And it also receives another custom gesture.
+ parent.acceptGestureOverride = false;
+ child->acceptGestureOverride = true;
+ sendCustomGesture(&event, child);
+
+ QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
+ QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+ 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);
+
+ CustomEvent event;
+ sendCustomGesture(&event, &widget);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
+}
+
+static const QColor InstanceColors[] = {
+ Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::yellow
+};
+
+class GestureItem : public QGraphicsObject
+{
+ static int InstanceCount;
+
+public:
+ GestureItem(const char *name = 0)
+ {
+ instanceNumber = InstanceCount++;
+ if (name)
+ setObjectName(QLatin1String(name));
+ size = QRectF(0, 0, 100, 100);
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ acceptGestureOverride = false;
+ }
+ ~GestureItem()
+ {
+ --InstanceCount;
+ }
+
+ 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;
+ QSet<Qt::GestureType> ignoredGestures;
+
+ QRectF size;
+ int instanceNumber;
+
+ void reset()
+ {
+ customEventsReceived = 0;
+ gestureEventsReceived = 0;
+ gestureOverrideEventsReceived = 0;
+ events.clear();
+ overrideEvents.clear();
+ ignoredGestures.clear();
+ }
+
+protected:
+ QRectF boundingRect() const
+ {
+ return size;
+ }
+ void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+ {
+ QColor color = InstanceColors[instanceNumber % (sizeof(InstanceColors)/sizeof(InstanceColors[0]))];
+ p->fillRect(boundingRect(), color);
+ }
+
+ bool event(QEvent *event)
+ {
+ Events *eventsPtr = 0;
+ if (event->type() == QEvent::Gesture) {
+ ++gestureEventsReceived;
+ eventsPtr = &events;
+ QGestureEvent *e = static_cast<QGestureEvent *>(event);
+ foreach(Qt::GestureType type, ignoredGestures)
+ e->ignore(e->gesture(type));
+ } 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;
+ }
+};
+int GestureItem::InstanceCount = 0;
+
+void tst_Gestures::graphicsItemGesture()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item = new GestureItem("item");
+ scene.addItem(item);
+ item->setPos(100, 100);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ item->grabGesture(CustomGesture::GestureType);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ CustomEvent event;
+ // gesture without hotspot should not be delivered to items in the view
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
+ sendCustomGesture(&event, item, &scene);
+
+ QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item->gestureEventsReceived, 0);
+ QCOMPARE(item->gestureOverrideEventsReceived, 0);
+
+ item->reset();
+
+ // make sure the event is properly delivered if only the hotspot is set.
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item, &scene);
+
+ 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);
+
+ item->reset();
+
+ // send gesture to the item which ignores it.
+ item->ignoredGestures << CustomGesture::GestureType;
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item, &scene);
+ QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item->gestureOverrideEventsReceived, 0);
+}
+
+void tst_Gestures::graphicsItemTreeGesture()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item1 = new GestureItem("item1");
+ item1->setPos(100, 100);
+ item1->size = QRectF(0, 0, 350, 200);
+ scene.addItem(item1);
+
+ GestureItem *item1_child1 = new GestureItem("item1_child1");
+ item1_child1->setPos(50, 50);
+ item1_child1->size = QRectF(0, 0, 100, 100);
+ item1_child1->setParentItem(item1);
+
+ GestureItem *item1_child2 = new GestureItem("item1_child2");
+ item1_child2->size = QRectF(0, 0, 100, 100);
+ item1_child2->setPos(200, 50);
+ item1_child2->setParentItem(item1);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ item1->grabGesture(CustomGesture::GestureType);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item1_child1, &view);
+ event.hasHotSpot = true;
+
+ item1->ignoredGestures << CustomGesture::GestureType;
+ sendCustomGesture(&event, item1_child1, &scene);
+ QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1_child1->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+
+ item1->reset(); item1_child1->reset(); item1_child2->reset();
+
+ item1_child1->grabGesture(CustomGesture::GestureType);
+
+ item1->ignoredGestures << CustomGesture::GestureType;
+ item1_child1->ignoredGestures << CustomGesture::GestureType;
+ sendCustomGesture(&event, item1_child1, &scene);
+ QCOMPARE(item1_child1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1_child2->gestureEventsReceived, 0);
+ QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+}
+
+void tst_Gestures::explicitGraphicsObjectTarget()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item1 = new GestureItem("item1");
+ scene.addItem(item1);
+ item1->setPos(100, 100);
+ item1->setZValue(1);
+
+ GestureItem *item2 = new GestureItem("item2");
+ scene.addItem(item2);
+ item2->setPos(100, 100);
+ item2->setZValue(5);
+
+ GestureItem *item2_child1 = new GestureItem("item2_child1");
+ scene.addItem(item2_child1);
+ item2_child1->setParentItem(item2);
+ item2_child1->setPos(10, 10);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ item1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture);
+ item2->grabGesture(CustomGesture::GestureType, Qt::ItemGesture);
+ item2_child1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // sending events to item1, but the hotSpot is set to item2
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(15, 15), item2, &view);
+ event.hasHotSpot = true;
+
+ sendCustomGesture(&event, item1, &scene);
+
+ QCOMPARE(item1->gestureEventsReceived, 0);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < item2_child1->events.all.size(); ++i)
+ QCOMPARE(item2_child1->events.all.at(i), CustomGesture::GestureType);
+ QCOMPARE(item2_child1->events.started.size(), 1);
+ QCOMPARE(item2_child1->events.updated.size(), TotalGestureEventsCount - 2);
+ QCOMPARE(item2_child1->events.finished.size(), 1);
+ QCOMPARE(item2_child1->events.canceled.size(), 0);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+}
+
+void tst_Gestures::gestureOverChildGraphicsItem()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item0 = new GestureItem("item0");
+ scene.addItem(item0);
+ item0->setPos(0, 0);
+ item0->grabGesture(CustomGesture::GestureType);
+ item0->setZValue(1);
+
+ GestureItem *item1 = new GestureItem("item1");
+ scene.addItem(item1);
+ item1->setPos(100, 100);
+ item1->setZValue(5);
+
+ GestureItem *item2 = new GestureItem("item2");
+ scene.addItem(item2);
+ item2->setPos(100, 100);
+ item2->setZValue(10);
+
+ GestureItem *item2_child1 = new GestureItem("item2_child1");
+ scene.addItem(item2_child1);
+ item2_child1->setParentItem(item2);
+ item2_child1->setPos(0, 0);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ item1->grabGesture(CustomGesture::GestureType);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ CustomEvent event;
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, 0);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 0);
+
+ item0->reset(); item1->reset(); item2->reset(); item2_child1->reset();
+ item2->grabGesture(CustomGesture::GestureType);
+ item2->ignoredGestures << CustomGesture::GestureType;
+
+ event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view);
+ event.hasHotSpot = true;
+ sendCustomGesture(&event, item0, &scene);
+
+ QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureOverrideEventsReceived, 1);
+}
+
+void tst_Gestures::twoGesturesOnDifferentLevel()
+{
+ GestureWidget parent("parent");
+ QVBoxLayout *l = new QVBoxLayout(&parent);
+ GestureWidget *child = new GestureWidget("child");
+ l->addWidget(child);
+
+ Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+
+ parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+ child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture);
+
+ CustomEvent event;
+ // sending events that form a gesture to one widget, but they will be
+ // filtered by two different gesture recognizers and will generate two
+ // QGesture objects. Check that those gesture objects are delivered to
+ // different widgets properly.
+ sendCustomGesture(&event, child);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
+
+ QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(child->gestureOverrideEventsReceived, 0);
+ QCOMPARE(child->events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < child->events.all.size(); ++i)
+ QCOMPARE(child->events.all.at(i), SecondGesture);
+
+ QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(parent.gestureOverrideEventsReceived, 0);
+ QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
+ for(int i = 0; i < child->events.all.size(); ++i)
+ QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType);
+}
+
+void tst_Gestures::multipleGesturesInTree()
+{
+ GestureWidget a("A");
+ GestureWidget *A = &a;
+ GestureWidget *B = new GestureWidget("B", A);
+ GestureWidget *C = new GestureWidget("C", B);
+ GestureWidget *D = new GestureWidget("D", C);
+
+ Qt::GestureType FirstGesture = CustomGesture::GestureType;
+ Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+
+ A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3]
+ A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // |
+ B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // B [ 2 3]
+ B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // |
+ C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // C [1 2 3]
+ C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // |
+ C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // D [1 3]
+ D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture);
+ D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture);
+
+ // make sure all widgets ignore events, so they get propagated.
+ A->ignoredGestures << FirstGesture << ThirdGesture;
+ B->ignoredGestures << SecondGesture << ThirdGesture;
+ C->ignoredGestures << FirstGesture << SecondGesture << ThirdGesture;
+ D->ignoredGestures << FirstGesture << ThirdGesture;
+
+ CustomEvent event;
+ sendCustomGesture(&event, D);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // gesture override events
+ QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0);
+ QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1);
+
+ // normal gesture events
+ QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(SecondGesture), 0);
+ QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(B->events.all.count(FirstGesture), 0);
+ QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(SecondGesture), 0);
+ QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
+}
+
+void tst_Gestures::multipleGesturesInComplexTree()
+{
+ GestureWidget a("A");
+ GestureWidget *A = &a;
+ GestureWidget *B = new GestureWidget("B", A);
+ GestureWidget *C = new GestureWidget("C", B);
+ GestureWidget *D = new GestureWidget("D", C);
+
+ Qt::GestureType FirstGesture = CustomGesture::GestureType;
+ Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FourthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FifthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SixthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SeventhGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+
+ A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4]
+ A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // |
+ A->grabGesture(FourthGesture, Qt::WidgetWithChildrenGesture); // B [2,3,5]
+ B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // |
+ B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // C [1,2,3,6]
+ B->grabGesture(FifthGesture, Qt::WidgetWithChildrenGesture); // |
+ C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // D [1,3,7]
+ C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture);
+ C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture);
+ C->grabGesture(SixthGesture, Qt::WidgetWithChildrenGesture);
+ D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture);
+ D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture);
+ D->grabGesture(SeventhGesture, Qt::WidgetWithChildrenGesture);
+
+ // make sure all widgets ignore events, so they get propagated.
+ QSet<Qt::GestureType> allGestureTypes;
+ allGestureTypes << FirstGesture << SecondGesture << ThirdGesture
+ << FourthGesture << FifthGesture << SixthGesture << SeventhGesture;
+ A->ignoredGestures = B->ignoredGestures = allGestureTypes;
+ C->ignoredGestures = D->ignoredGestures = allGestureTypes;
+
+ CustomEvent event;
+ sendCustomGesture(&event, D);
+
+ static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+
+ // gesture override events
+ QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0);
+ QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1);
+ QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1);
+
+ QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1);
+ QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0);
+ QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1);
+
+ // normal gesture events
+ QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(SecondGesture), 0);
+ QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(D->events.all.count(FourthGesture), 0);
+ QCOMPARE(D->events.all.count(FifthGesture), 0);
+ QCOMPARE(D->events.all.count(SixthGesture), 0);
+ QCOMPARE(D->events.all.count(SeventhGesture), TotalGestureEventsCount);
+
+ QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(FourthGesture), 0);
+ QCOMPARE(C->events.all.count(FifthGesture), 0);
+ QCOMPARE(C->events.all.count(SixthGesture), TotalGestureEventsCount);
+ QCOMPARE(C->events.all.count(SeventhGesture), 0);
+
+ QCOMPARE(B->events.all.count(FirstGesture), 0);
+ QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(FourthGesture), 0);
+ QCOMPARE(B->events.all.count(FifthGesture), TotalGestureEventsCount);
+ QCOMPARE(B->events.all.count(SixthGesture), 0);
+ QCOMPARE(B->events.all.count(SeventhGesture), 0);
+
+ QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(SecondGesture), 0);
+ QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(FourthGesture), TotalGestureEventsCount);
+ QCOMPARE(A->events.all.count(FifthGesture), 0);
+ QCOMPARE(A->events.all.count(SixthGesture), 0);
+ QCOMPARE(A->events.all.count(SeventhGesture), 0);
+}
+
+void tst_Gestures::testMapToScene()
+{
+ QGesture gesture;
+ QList<QGesture*> list;
+ list << &gesture;
+ QGestureEvent event(list);
+ QCOMPARE(event.mapToScene(gesture.hotSpot()), QPointF()); // not set, can't do much
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ GestureItem *item0 = new GestureItem;
+ scene.addItem(item0);
+ item0->setPos(14, 16);
+
+ view.show(); // need to show to give it a global coordinate
+ QTest::qWaitForWindowShown(&view);
+ view.ensureVisible(scene.sceneRect());
+
+ QPoint origin = view.mapToGlobal(QPoint());
+ event.setWidget(view.viewport());
+
+ QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200)));
+}
+
+QTEST_MAIN(tst_Gestures)
+#include "tst_gestures.moc"
diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts
index 61497de..c7555c8 100644
--- a/tests/auto/linguist/lrelease/testdata/idbased.ts
+++ b/tests/auto/linguist/lrelease/testdata/idbased.ts
@@ -9,6 +9,7 @@
</message>
<message id="untranslated_id">
<source>This has no translation.</source>
+ <translation type="unfinished"></translation>
</message>
<message id="this_another_id">
<source>Foo bar.</source>
@@ -17,5 +18,11 @@
<message>
<source>Drop me!</source>
</message>
+ <message id="one_id">
+ <source></source>
+ </message>
+ <message id="two_id">
+ <source></source>
+ </message>
</context>
</TS>
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index 6b580df..4b62302 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 ) ) {
@@ -150,10 +152,10 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
if ( tst_Databases::isSqlServer( db ) ) {
//workaround for SQL SERVER since he can store unicode only in nvarchar fields
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, "
- "t_varchar nvarchar(40) not null, t_char nchar(40) )" ));
+ "t_varchar nvarchar(80) not null, t_char nchar(80) )" ));
} else {
QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, "
- "t_varchar varchar(40) not null," "t_char char(40))" ));
+ "t_varchar varchar(100) not null," "t_char char(100))" ));
}
if (tst_Databases::isMSAccess(db)) {
@@ -519,8 +521,7 @@ void tst_Q3SqlCursor::unicode()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- static const unsigned short utf8arr[] = { 0xd792,0xd79c,0xd792,0xd79c,0xd799,0x20,0xd7a9,0xd799,0x00 };
- static const QString utf8str = QString::fromUcs2( utf8arr );
+ static const QString utf8str = QString::fromUtf8( "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." );
if ( !db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
QSKIP( "DBMS not Unicode capable", SkipSingle );
}
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 d6911d2..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
@@ -1388,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/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/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
index 3945364..3efc346 100644
--- a/tests/auto/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -146,7 +146,7 @@ void tst_QAudioInput::pullFile()
// Check state and periodSize() are valid non-zero values.
QVERIFY(audio->state() == QAudio::ActiveState);
QVERIFY(audio->error() == QAudio::NoError);
- QVERIFY(audio->clock() > 0);
+ QVERIFY(audio->clock() > 10000 && audio->clock() < 800000);
QVERIFY(audio->periodSize() > 0);
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index b90873e..b001af1 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -150,15 +150,20 @@ void tst_QAudioOutput::pullFile()
QVERIFY(audio->state() == QAudio::ActiveState);
QVERIFY(audio->error() == QAudio::NoError);
QVERIFY(audio->periodSize() > 0);
- QVERIFY(audio->clock() > 0);
+ QVERIFY(audio->clock() > 10000 && audio->clock() < 800000);
QVERIFY(stateSignal.count() == 1); // State changed to QAudio::ActiveState
// 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 a19f865..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);
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/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index 6637202..0d58554e 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -322,6 +322,7 @@ void tst_QDom::toString_01_data()
*/
void tst_QDom::toString_01()
{
+ QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)");
QFETCH(QString, fileName);
QFile f(fileName);
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index dc2ca61..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;
@@ -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..83ddd39
--- /dev/null
+++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
@@ -0,0 +1,1044 @@
+/****************************************************************************
+**
+** 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()
+{
+#if defined(Q_OS_WINCE)
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+}
+
+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 fileInfoGatherer;
+ fileInfoGatherer.start();
+ QTest::qWait(1500);
+
+ QFileInfoGatherer::fetchedRoot = false;
+ QString dir(QDir::currentPath());
+ QNonNativeFileDialog fd(0, QString(), dir);
+ fd.show();
+ QCOMPARE(QFileInfoGatherer::fetchedRoot,false);
+ fd.setDirectory("");
+#ifdef Q_OS_WINCE
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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;
+ QSize oldMs = fd.layout()->minimumSize();
+ QStringList history = fd.history();
+ history << QDir::toNativeSeparators("/verylongdirectory/"
+ "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk");
+ fd.setHistory(history);
+ fd.show();
+
+ QSize ms = fd.layout()->minimumSize();
+ QVERIFY(ms.width() <= oldMs.width());
+}
+
+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();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ QNonNativeFileDialog fd2;
+ fd2.setFileMode(QFileDialog::Directory);
+ fd2.restoreState(fd.saveState());
+ current.cd("aaaaaaaaaaaaaaaaaa");
+ fd2.setDirectory(current.absolutePath());
+ fd2.show();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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();
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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);
+#if defined(Q_OS_WINCE)
+ QTest::qWait(1500);
+#else
+ QTest::qWait(500);
+#endif
+ 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());
+ // give the background processes more time on windows mobile
+#ifdef Q_OS_WINCE
+ QTest::qWait(1000);
+#else
+ QTest::qWait(250);
+#endif
+
+ 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 286ea2d..7b87969 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -49,6 +49,14 @@
class tst_QGraphicsAnchorLayout : public QObject {
Q_OBJECT;
+public:
+ tst_QGraphicsAnchorLayout() : QObject() {
+ hasSimplification = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty();
+ }
+
+private:
+ bool hasSimplification;
+
private slots:
void simple();
void simple_center();
@@ -73,6 +81,7 @@ private slots:
void expandingSequenceFairDistribution();
void expandingParallel();
void floatConflict();
+ void infiniteMaxSizes();
};
class RectWidget : public QGraphicsWidget
@@ -152,6 +161,15 @@ static bool layoutHasConflict(QGraphicsAnchorLayout *l)
return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts();
}
+static bool usedSimplex(QGraphicsAnchorLayout *l, Qt::Orientation o)
+{
+ QGraphicsAnchorLayoutPrivate::Orientation oo = (o == Qt::Horizontal) ?
+ QGraphicsAnchorLayoutPrivate::Horizontal :
+ QGraphicsAnchorLayoutPrivate::Vertical;
+
+ return QGraphicsAnchorLayoutPrivate::get(l)->lastCalculationUsedSimplex[oo];
+}
+
void tst_QGraphicsAnchorLayout::simple()
{
QGraphicsWidget *w1 = createItem();
@@ -169,10 +187,16 @@ void tst_QGraphicsAnchorLayout::simple()
l->addAnchors(l, w1, Qt::Vertical);
l->addAnchors(l, w2, Qt::Vertical);
+ QCOMPARE(l->count(), 2);
+
QGraphicsWidget p;
p.setLayout(l);
+ p.adjustSize();
- QCOMPARE(l->count(), 2);
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::simple_center()
@@ -212,6 +236,11 @@ void tst_QGraphicsAnchorLayout::simple_center()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize, QSizeF(200, 20));
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
delete p;
}
@@ -309,6 +338,9 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
QCOMPARE(checkReverseDirection(p), true);
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+
delete p;
delete view;
}
@@ -397,6 +429,11 @@ void tst_QGraphicsAnchorLayout::diagonal()
QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0));
QCOMPARE(p.size(), testA);
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
@@ -473,6 +510,9 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(f->geometry(), QRectF(350, 500, 100, 100));
QCOMPARE(p.size(), layoutMinimumSize);
+ if (!hasSimplification)
+ return;
+
p.resize(layoutPreferredSize);
QCOMPARE(a->geometry(), QRectF(0, 0, 150, 100));
QCOMPARE(b->geometry(), QRectF(150, 100, 150, 100));
@@ -493,6 +533,9 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
+
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
}
void tst_QGraphicsAnchorLayout::parallel2()
@@ -538,6 +581,11 @@ void tst_QGraphicsAnchorLayout::parallel2()
p.resize(layoutMaximumSize);
QCOMPARE(p.size(), layoutMaximumSize);
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::snake()
@@ -729,6 +777,8 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(layoutMaximumSize, QSizeF(300.0, 400.0));
p.resize(layoutMinimumSize);
+ if (!hasSimplification)
+ QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort);
QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 20.0, 100.0));
QCOMPARE(b->geometry(), QRectF(20.0, 100.0, 20.0, 100.0));
QCOMPARE(c->geometry(), QRectF(40.0, 200.0, 20.0, 100.0));
@@ -748,6 +798,11 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0));
QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
@@ -804,6 +859,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(layoutPreferredSize, QSizeF(220.0, 500.0));
QCOMPARE(layoutMaximumSize, QSizeF(400.0, 500.0));
+ if (!hasSimplification)
+ return;
+
p.resize(layoutMinimumSize);
QCOMPARE(a->size(), b->size());
QCOMPARE(a->size(), c->size());
@@ -824,6 +882,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(a->size(), d->size());
QCOMPARE(e->size().width(), 4 * a->size().width());
QCOMPARE(p.size(), layoutMaximumSize);
+
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
}
void tst_QGraphicsAnchorLayout::proportionalPreferred()
@@ -886,6 +947,11 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QCOMPARE(a->size().width(), 10 * factor);
QCOMPARE(c->size().width(), 14 * factor);
QCOMPARE(p.size(), QSizeF(12, 400));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::example()
@@ -969,6 +1035,11 @@ void tst_QGraphicsAnchorLayout::example()
QCOMPARE(a->size(), e->size());
QCOMPARE(b->size(), d->size());
QCOMPARE(f->size(), g->size());
+
+ if (hasSimplification) {
+ QVERIFY(usedSimplex(l, Qt::Horizontal));
+ QVERIFY(usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::setSpacing()
@@ -1225,19 +1296,8 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
l->setSpacing(0);
l->setContentsMargins(0, 0, 0, 0);
- // horizontal
- QGraphicsAnchor *anchor = l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
- anchor->setSpacing(0);
-
- anchor = l->addAnchor(w1, Qt::AnchorRight, l, Qt::AnchorRight);
- anchor->setSpacing(0);
-
- // vertical
- anchor = l->addAnchor(l, Qt::AnchorTop, w1, Qt::AnchorTop);
- anchor->setSpacing(0);
-
- anchor = l->addAnchor(w1, Qt::AnchorBottom, l, Qt::AnchorBottom);
- anchor->setSpacing(0);
+ // horizontal and vertical
+ l->addAnchors(l, w1);
QGraphicsWidget *p = new QGraphicsWidget;
p->setLayout(l);
@@ -1287,9 +1347,53 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
w1->adjustSize();
QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0));
- QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(100, 100));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(0, 0));
QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100));
+ // Anchor size policies
+ w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft);
+ anchor->setSpacing(10);
+
+ // QSizePolicy::Minimum
+ anchor->setSizePolicy(QSizePolicy::Minimum);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(60, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value.
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ // QSizePolicy::Preferred
+ anchor->setSizePolicy(QSizePolicy::Preferred);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value.
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ // QSizePolicy::Maximum
+ anchor->setSizePolicy(QSizePolicy::Maximum);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(60, 50));
+
+ // QSizePolicy::Ignored
+ anchor->setSizePolicy(QSizePolicy::Ignored);
+ QApplication::processEvents();
+
+ QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50));
+ QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
delete p;
delete view;
}
@@ -1380,6 +1484,11 @@ void tst_QGraphicsAnchorLayout::expandingSequence()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize.width(), qreal(200));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution()
@@ -1441,6 +1550,11 @@ void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize.width(), qreal(400));
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
+
// 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.
@@ -1463,6 +1577,11 @@ void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution()
QCOMPARE(b->geometry().size(), pref + QSizeF(25, 0));
QCOMPARE(c->geometry().size(), pref);
QCOMPARE(d->geometry().size(), pref + QSizeF(50, 0));
+
+ if (hasSimplification) {
+ QVERIFY(!usedSimplex(l, Qt::Horizontal));
+ QVERIFY(!usedSimplex(l, Qt::Vertical));
+ }
}
void tst_QGraphicsAnchorLayout::expandingParallel()
@@ -1585,5 +1704,56 @@ void tst_QGraphicsAnchorLayout::floatConflict()
delete p;
}
+void tst_QGraphicsAnchorLayout::infiniteMaxSizes()
+{
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+ l->setSpacing(0);
+
+ QSizeF min(10, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(QWIDGETSIZE_MAX, 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");
+
+ //<!-- Trunk -->
+ 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);
+
+ a->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ c->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QGraphicsWidget p;
+ p.setLayout(l);
+
+ p.resize(200, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, 50, 10));
+ QCOMPARE(b->geometry(), QRectF(50, 0, 50, 10));
+ QCOMPARE(c->geometry(), QRectF(100, 0, 50, 10));
+ QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10));
+
+ if (!hasSimplification)
+ QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort);
+
+ p.resize(1000, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, 450, 10));
+ QCOMPARE(b->geometry(), QRectF(450, 0, 50, 10));
+ QCOMPARE(c->geometry(), QRectF(500, 0, 450, 10));
+ QCOMPARE(d->geometry(), QRectF(950, 0, 50, 10));
+
+ qreal expMaxSize = (QWIDGETSIZE_MAX - 100.0) / 2;
+ p.resize(QWIDGETSIZE_MAX, 10);
+ QCOMPARE(a->geometry(), QRectF(0, 0, expMaxSize, 10));
+ QCOMPARE(b->geometry(), QRectF(expMaxSize, 0, 50, 10));
+ QCOMPARE(c->geometry(), QRectF(expMaxSize + 50, 0, expMaxSize, 10));
+ QCOMPARE(d->geometry(), QRectF(QWIDGETSIZE_MAX - 50, 0, 50, 10));
+}
+
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 148b2c8..1c7a159 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -435,7 +435,7 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor()
layout->removeAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft);
QCOMPARE( layout->count(), 4 );
- QCOMPARE( (int)widget1->parentLayoutItem(), 0 );
+ QVERIFY( !widget1->parentLayoutItem() );
// test that item is not removed from layout if other anchors remain set
layout->setAnchor(widget2, Qt::AnchorLeft, widget3, Qt::AnchorRight, 10);
@@ -1711,8 +1711,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Validate
for (int i = 0; i < result.count(); ++i) {
- if (i == 1)
- QEXPECT_FAIL("Two, mixed", "Works with simplification disabled.", Continue);
const BasicLayoutTestResult item = result[i];
QCOMPARE(widgets[item.index]->geometry(), item.rect);
}
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 554292f..e33c7b6 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -104,6 +104,7 @@ private slots:
void defaultStretchFactors();
void geometries_data();
void geometries();
+ void avoidRecursionInInsertItem();
void task236367_maxSizeHint();
};
@@ -2081,6 +2082,16 @@ void tst_QGraphicsGridLayout::geometries()
delete widget;
}
+void tst_QGraphicsGridLayout::avoidRecursionInInsertItem()
+{
+ QGraphicsWidget window(0, Qt::Window);
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(&window);
+ QCOMPARE(layout->count(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::addItem: cannot insert itself");
+ layout->addItem(layout, 0, 0);
+ QCOMPARE(layout->count(), 0);
+}
+
void tst_QGraphicsGridLayout::task236367_maxSizeHint()
{
QGraphicsWidget *widget = new QGraphicsWidget;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index e4eaf4e..dcad8e1 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);
@@ -390,6 +398,7 @@ private slots:
void modality_mouseGrabber();
void modality_clickFocus();
void modality_keyEvents();
+ void itemIsInFront();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -6183,7 +6192,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 +6299,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 +7126,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 +7401,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 +7411,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 +7422,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 +7435,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()
@@ -9533,5 +9542,47 @@ void tst_QGraphicsItem::modality_keyEvents()
QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0);
}
+void tst_QGraphicsItem::itemIsInFront()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem *rect1 = new QGraphicsRectItem;
+ rect1->setData(0, "rect1");
+ scene.addItem(rect1);
+
+ QGraphicsRectItem *rect1child1 = new QGraphicsRectItem(rect1);
+ rect1child1->setZValue(1);
+ rect1child1->setData(0, "rect1child1");
+
+ QGraphicsRectItem *rect1child2 = new QGraphicsRectItem(rect1);
+ rect1child2->setParentItem(rect1);
+ rect1child2->setData(0, "rect1child2");
+
+ QGraphicsRectItem *rect1child1_1 = new QGraphicsRectItem(rect1child1);
+ rect1child1_1->setData(0, "rect1child1_1");
+
+ QGraphicsRectItem *rect1child1_2 = new QGraphicsRectItem(rect1child1);
+ rect1child1_2->setFlag(QGraphicsItem::ItemStacksBehindParent);
+ rect1child1_2->setData(0, "rect1child1_2");
+
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem;
+ rect2->setData(0, "rect2");
+ scene.addItem(rect2);
+
+ QGraphicsRectItem *rect2child1 = new QGraphicsRectItem(rect2);
+ rect2child1->setData(0, "rect2child1");
+
+ QCOMPARE(qt_closestItemFirst(rect1, rect1), false);
+ QCOMPARE(qt_closestItemFirst(rect1, rect2), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1, rect2child1), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child1), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child2), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child1), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1), true);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2), false);
+ QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 4f28df4..546f92d 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -101,6 +101,7 @@ private slots:
void updateGeometry();
void layoutDirection();
void removeLayout();
+ void avoidRecursionInInsertItem();
// Task specific tests
void task218400_insertStretchCrash();
@@ -146,7 +147,7 @@ void tst_QGraphicsLinearLayout::initTestCase()
// since the style will influence the results, we have to ensure
// that the tests are run using the same style on all platforms
#ifdef Q_WS_S60
- QApplication::setStyle(new QWindowsStyle);
+ QApplication::setStyle(new QWindowsStyle);
#else
QApplication::setStyle(new QPlastiqueStyle);
#endif
@@ -332,6 +333,7 @@ void tst_QGraphicsLinearLayout::alignment()
widget->resize(newSize);
view.show();
widget->show();
+ QTest::qWaitForWindowShown(&view);
QApplication::processEvents();
int x = 0;
@@ -1431,6 +1433,16 @@ void tst_QGraphicsLinearLayout::removeLayout()
QCOMPARE(pushButton->geometry(), r2);
}
+void tst_QGraphicsLinearLayout::avoidRecursionInInsertItem()
+{
+ QGraphicsWidget window(0, Qt::Window);
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(&window);
+ QCOMPARE(layout->count(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::insertItem: cannot insert itself");
+ layout->insertItem(0, layout);
+ QCOMPARE(layout->count(), 0);
+}
+
void tst_QGraphicsLinearLayout::task218400_insertStretchCrash()
{
QGraphicsScene *scene = new QGraphicsScene;
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 76e7202..9269164 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();
@@ -1286,6 +1287,7 @@ void tst_QGraphicsProxyWidget::paintEvent()
QGraphicsView view(&scene);
view.show();
QTest::qWaitForWindowShown(&view);
+ QTest::qWait(70);
SubQGraphicsProxyWidget proxy;
@@ -1296,14 +1298,14 @@ void tst_QGraphicsProxyWidget::paintEvent()
w->show();
QTest::qWaitForWindowShown(w);
QApplication::processEvents();
- QTest::qWait(50);
+ QTest::qWait(100);
proxy.setWidget(w);
scene.addItem(&proxy);
//make sure we flush all the paint events
QTest::qWait(70);
QTRY_VERIFY(proxy.paintCount > 1);
- QTest::qWait(70);
+ QTest::qWait(110);
proxy.paintCount = 0;
w->update();
@@ -1531,7 +1533,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 +1758,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 +1882,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 +1994,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
+
+ delete view;
}
void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
@@ -1999,8 +2007,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1->setText("QLineEdit 1");
QLineEdit *edit2 = new QLineEdit;
edit2->setText("QLineEdit 2");
+ QFontComboBox *fontComboBox = new QFontComboBox;
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->addWidget(edit1);
+ vlayout->addWidget(fontComboBox);
vlayout->addWidget(edit2);
QGroupBox *box = new QGroupBox("QGroupBox");
@@ -2012,8 +2022,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1_2->setText("QLineEdit 1_2");
QLineEdit *edit2_2 = new QLineEdit;
edit2_2->setText("QLineEdit 2_2");
+ QFontComboBox *fontComboBox2 = new QFontComboBox;
vlayout = new QVBoxLayout;
vlayout->addWidget(edit1_2);
+ vlayout->addWidget(fontComboBox2);
vlayout->addWidget(edit2_2);
QGroupBox *box_2 = new QGroupBox("QGroupBox 2");
@@ -2054,8 +2066,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
+ EventSpy eventSpy3(fontComboBox);
EventSpy eventSpy1_2(edit1_2);
EventSpy eventSpy2_2(edit2_2);
+ EventSpy eventSpy2_3(fontComboBox2);
EventSpy eventSpyBox(box);
// Tab into group box
@@ -2076,11 +2090,24 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 0);
+ // Tab to the font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ fontComboBox->hasFocus();
+ QVERIFY(!edit2->hasFocus());
+ QCOMPARE(eventSpy3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
+
// Tab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
edit2->hasFocus();
QVERIFY(!edit1->hasFocus());
+ QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
@@ -2098,6 +2125,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 0);
+ // Tab into right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ QVERIFY(!edit1_2->hasFocus());
+ fontComboBox2->hasFocus();
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 0);
+
// Tab into right bottom line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
@@ -2105,6 +2142,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit2_2->hasFocus();
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 0);
@@ -2121,6 +2160,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2_2->hasFocus();
+ // Backtab into the right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!edit2_2->hasFocus());
+ fontComboBox2->hasFocus();
+
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
@@ -2139,10 +2184,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2->hasFocus();
- // Backtab into line edit 1
+ // Backtab into the font combobox
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
+ fontComboBox->hasFocus();
+
+ // Backtab into line edit 1
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!fontComboBox->hasFocus());
edit1->hasFocus();
// Backtab into line box
@@ -2156,6 +2207,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QApplication::processEvents();
QVERIFY(!box->hasFocus());
leftDial->hasFocus();
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
@@ -2222,6 +2275,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
// Symmetry
editProxy->clearFocus();
QVERIFY(!edit->hasFocus());
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
@@ -2272,6 +2327,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
QVERIFY(!editProxy->hasFocus());
QVERIFY(edit2->hasFocus());
QVERIFY(edit2Proxy->hasFocus());
+
+ delete view;
}
void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
@@ -2391,6 +2448,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()
@@ -2690,7 +2749,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
view.show();
QTest::qWaitForWindowShown(&view);
QApplication::sendPostedEvents();
- QTest::qWait(50);
+ QTest::qWait(150);
qRegisterMetaType<QList<QRectF> >("QList<QRectF>");
QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &)));
@@ -2780,13 +2839,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 +2955,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 +3076,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 f5e9acb..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();
@@ -3882,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 b407fef..eb5c099 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -88,7 +88,7 @@ static QTransform transform2D(const QGraphicsTransform& t)
{
QMatrix4x4 m;
t.applyTo(&m);
- return m.toTransform();
+ return m.toTransform(0);
}
void tst_QGraphicsTransform::scale()
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index df3ebef..dc08d0e 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()
@@ -3652,6 +3664,10 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
{
+#if defined(Q_OS_WINCE)
+ QSKIP("Qt/CE does not implement mouse tracking at this point", SkipAll);
+#endif
+
QGraphicsScene scene(-100, -100, 200, 200);
scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue));
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
index 9567f9e..1bfaf51 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview_2.cpp
@@ -43,6 +43,20 @@
#include <QRectF>
#include <QTransform>
+#ifdef Q_OS_WINCE
+#include <qguifunctions_wince.h>
+
+bool qt_wince_is_high_dpi() {
+ HDC deviceContext = GetDC(0);
+ int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
+ ReleaseDC(0, deviceContext);
+ if ((dpi < 1000) && (dpi > 0))
+ return dpi > 96;
+ else
+ return false;
+}
+#endif
+
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<QRectF>)
Q_DECLARE_METATYPE(QMatrix)
@@ -51,7 +65,7 @@ Q_DECLARE_METATYPE(QPointF)
Q_DECLARE_METATYPE(QRectF)
Q_DECLARE_METATYPE(Qt::ScrollBarPolicy)
-static void _scrollBarRanges_data_1()
+static void _scrollBarRanges_data_1(int offset)
{
// No motif, flat frame
QTest::newRow("1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -59,73 +73,73 @@ static void _scrollBarRanges_data_1()
<< 0 << 0 << 0 << 0 << false << false;
QTest::newRow("2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << false << false;
+ << 0 << (50 + offset) << 0 << offset << false << false;
QTest::newRow("3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (50 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << false << false;
QTest::newRow("5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << false << false;
+ << -100 << (offset -50) << -100 << (-100 + offset) << false << false;
QTest::newRow("6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << false << false;
+ << -100 << (offset -50) << -100 << offset << false << false;
QTest::newRow("7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << false << false;
+ << 0 << (offset + 1) << 0 << offset + 1 << false << false;
QTest::newRow("8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << false << false;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << false << false;
QTest::newRow("9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << false << false;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << false << false;
QTest::newRow("10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << false << false;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << false << false;
QTest::newRow("11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << false << false;
+ << (-101) << (offset + -50) << -101 << (-100 + offset) << false << false;
QTest::newRow("12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << false << false;
+ << (-101) << (offset -50) << (-101) << offset << false << false;
QTest::newRow("13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << false << false;
+ << 0 << (offset + 16) << 0 << (offset + 16) << false << false;
QTest::newRow("14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << false << false;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << false << false;
QTest::newRow("15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << false << false;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << false << false;
QTest::newRow("16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << false << false;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16 ) << (-100 + offset) << false << false;
QTest::newRow("17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << false << false;
+ << (-100 - 16) << (offset -50) << (-100 - 16) << (-100 + offset) << false << false;
QTest::newRow("18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << false << false;
+ << (-100 - 16) << (offset -50) << (-100 - 16) << offset << false << false;
QTest::newRow("1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (150 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << false << false;
+ << 0 << (250 + offset) << 0 << (100 + offset) << false << false;
QTest::newRow("3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << false << false;
+ << 0 << (250 + offset) << 0 << (300 + offset) << false << false;
QTest::newRow("4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << false << false;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << false << false;
QTest::newRow("5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << false << false;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << false << false;
QTest::newRow("6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << false << false;
+ << -200 << (50 + offset) << -200 << (100 + offset) << false << false;
QTest::newRow("1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << false << false;
@@ -272,7 +286,7 @@ static void _scrollBarRanges_data_1()
<< -200 << (50 + 16) << -200 << (100 + 16) << false << false;
}
-static void _scrollBarRanges_data_2()
+static void _scrollBarRanges_data_2(int offset)
{
// Motif, flat frame
QTest::newRow("Motif, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -280,73 +294,73 @@ static void _scrollBarRanges_data_2()
<< 0 << 0 << 0 << 0 << true << false;
QTest::newRow("Motif, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << true << false;
+ << 0 << (50 + offset) << 0 << offset << true << false;
QTest::newRow("Motif, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (50 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << true << false;
QTest::newRow("Motif, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << true << false;
+ << -100 << (offset-50) << -100 << (-100 + offset) << true << false;
QTest::newRow("Motif, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << true << false;
+ << -100 << (offset-50) << -100 << offset << true << false;
QTest::newRow("Motif, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << true << false;
+ << 0 << offset + 1 << 0 << offset + 1 << true << false;
QTest::newRow("Motif, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << true << false;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << true << false;
QTest::newRow("Motif, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << true << false;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << true << false;
QTest::newRow("Motif, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << true << false;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << true << false;
QTest::newRow("Motif, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << true << false;
+ << (-101) << (offset-50) << -101 << (-100 + offset) << true << false;
QTest::newRow("Motif, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << true << false;
+ << (-101) << (offset-50) << (-101) << offset << true << false;
QTest::newRow("Motif, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << true << false;
+ << 0 << (offset + 16) << 0 << (offset + 16) << true << false;
QTest::newRow("Motif, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << true << false;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << true << false;
QTest::newRow("Motif, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << true << false;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << true << false;
QTest::newRow("Motif, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << true << false;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16) << (-100 + offset) << true << false;
QTest::newRow("Motif, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << true << false;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << (-100 + offset) << true << false;
QTest::newRow("Motif, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << true << false;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << offset << true << false;
QTest::newRow("Motif, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (150 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << true << false;
+ << 0 << (250 + offset) << 0 << (100 + offset) << true << false;
QTest::newRow("Motif, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << true << false;
+ << 0 << (250 + offset) << 0 << (300 + offset) << true << false;
QTest::newRow("Motif, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << true << false;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << true << false;
QTest::newRow("Motif, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << true << false;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << true << false;
QTest::newRow("Motif, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << true << false;
+ << -200 << (50 + offset) << -200 << (100 + offset) << true << false;
QTest::newRow("Motif, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << true << false;
@@ -493,7 +507,7 @@ static void _scrollBarRanges_data_2()
<< -200 << (50 + 16) << -200 << (100 + 16) << true << false;
}
-static void _scrollBarRanges_data_3()
+static void _scrollBarRanges_data_3(int offset)
{
// No motif, styled panel
QTest::newRow("Styled, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -501,73 +515,73 @@ static void _scrollBarRanges_data_3()
<< 0 << 0 << 0 << 0 << false << true;
QTest::newRow("Styled, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << 16 << false << true;
+ << 0 << (50 + offset) << 0 << offset << false << true;
QTest::newRow("Styled, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (50 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << false << true;
QTest::newRow("Styled, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << (-100 + 16) << false << true;
+ << -100 << (offset-50) << -100 << (-100 + offset) << false << true;
QTest::newRow("Styled, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16-50) << -100 << 16 << false << true;
+ << -100 << (offset-50) << -100 << offset << false << true;
QTest::newRow("Styled, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << 17 << 0 << 17 << false << true;
+ << 0 << offset + 1 << 0 << offset + 1 << false << true;
QTest::newRow("Styled, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << 17 << false << true;
+ << 0 << (50 + offset + 1) << 0 << offset + 1 << false << true;
QTest::newRow("Styled, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17) << 0 << (100 + 17) << false << true;
+ << 0 << (50 + offset + 1) << 0 << (100 + offset + 1) << false << true;
QTest::newRow("Styled, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16) << -101 << (-100 + 16) << false << true;
+ << -101 << (-100 + offset) << -101 << (-100 + offset) << false << true;
QTest::newRow("Styled, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << -101 << (-100 + 16) << false << true;
+ << (-101) << (offset-50) << -101 << (-100 + offset) << false << true;
QTest::newRow("Styled, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16-50) << (-101) << 16 << false << true;
+ << (-101) << (offset-50) << (-101) << offset << false << true;
QTest::newRow("Styled, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16) << 0 << (16 + 16) << false << true;
+ << 0 << (offset + 16) << 0 << (offset + 16) << false << true;
QTest::newRow("Styled, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (16 + 16) << false << true;
+ << 0 << (50 + offset + 16) << 0 << (offset + 16) << false << true;
QTest::newRow("Styled, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16) << 0 << (100 + 16 + 16) << false << true;
+ << 0 << (50 + offset + 16) << 0 << (100 + offset + 16) << false << true;
QTest::newRow("Styled, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16) << (-100 - 16) << (-100 + 16) << false << true;
+ << (-100 - 16) << (-100 + offset) << (-100 - 16) << (-100 + offset) << false << true;
QTest::newRow("Styled, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << (-100 + 16) << false << true;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << (-100 + offset) << false << true;
QTest::newRow("Styled, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16-50) << (-100 - 16) << 16 << false << true;
+ << (-100 - 16) << (offset-50) << (-100 - 16) << offset << false << true;
QTest::newRow("Styled, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (150 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (100 + 16) << false << true;
+ << 0 << (250 + offset) << 0 << (100 + offset) << false << true;
QTest::newRow("Styled, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16) << 0 << (300 + 16) << false << true;
+ << 0 << (250 + offset) << 0 << (300 + offset) << false << true;
QTest::newRow("Styled, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16) << -200 << (-100 + 16) << false << true;
+ << -200 << (-50 + offset) << -200 << (-100 + offset) << false << true;
QTest::newRow("Styled, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (-100 + 16) << false << true;
+ << -200 << (50 + offset) << -200 << (-100 + offset) << false << true;
QTest::newRow("Styled, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16) << -200 << (100 + 16) << false << true;
+ << -200 << (50 + offset) << -200 << (100 + offset) << false << true;
QTest::newRow("Styled, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << false << true;
@@ -714,7 +728,7 @@ static void _scrollBarRanges_data_3()
<< -200 << (50 + 16) << -200 << (100 + 16) << false << true;
}
-static void _scrollBarRanges_data_4()
+static void _scrollBarRanges_data_4(int offset)
{
// Motif, styled panel
QTest::newRow("Motif, Styled, 1") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
@@ -722,73 +736,73 @@ static void _scrollBarRanges_data_4()
<< 0 << 0 << 0 << 0 << true << true;
QTest::newRow("Motif, Styled, 2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 4) << 0 << (16 + 4) << true << true;
+ << 0 << (50 + offset + 4) << 0 << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 3") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 4") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
<< 0 << 0 << 0 << 0 << true << true;
QTest::newRow("Motif, Styled, 5") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16 + 4 - 50) << -100 << (-100 + 16 + 4) << true << true;
+ << -100 << (offset + 4 - 50) << -100 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 6") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -100 << (16 + 4 - 50) << -100 << (16 + 4) << true << true;
+ << -100 << (offset + 4 - 50) << -100 << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 7") << QSize(150, 100) << QRectF(0, 0, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (17 + 4) << 0 << (17 + 4) << true << true;
+ << 0 << (offset + 1 + 4) << 0 << (offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 8") << QSize(150, 100) << QRectF(0, 0, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17 + 4) << 0 << (17 + 4) << true << true;
+ << 0 << (50 + offset + 1 + 4) << 0 << (offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 9") << QSize(150, 100) << QRectF(0, 0, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 17 + 4) << 0 << (100 + 17 + 4) << true << true;
+ << 0 << (50 + offset + 1 + 4) << 0 << (100 + offset + 1 + 4) << true << true;
QTest::newRow("Motif, Styled, 10") << QSize(150, 100) << QRectF(-101, -101, 151, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -101 << (-100 + 16 + 4) << -101 << (-100 + 16 + 4) << true << true;
+ << -101 << (-100 + offset + 4) << -101 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 11") << QSize(150, 100) << QRectF(-101, -101, 201, 101) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16 + 4 - 50) << -101 << (-100 + 16 + 4) << true << true;
+ << (-101) << (offset + 4 - 50) << -101 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 12") << QSize(150, 100) << QRectF(-101, -101, 201, 201) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-101) << (16 + 4 - 50) << (-101) << (16 + 4) << true << true;
+ << (-101) << (offset + 4 - 50) << (-101) << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 13") << QSize(150, 100) << QRectF(0, 0, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (16 + 16 + 4) << 0 << (16 + 16 + 4) << true << true;
+ << 0 << (offset + 16 + 4) << 0 << (offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 14") << QSize(150, 100) << QRectF(0, 0, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16 + 4) << 0 << (16 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 16 + 4) << 0 << (offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 15") << QSize(150, 100) << QRectF(0, 0, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (50 + 16 + 16 + 4) << 0 << (100 + 16 + 16 + 4) << true << true;
+ << 0 << (50 + offset + 16 + 4) << 0 << (100 + offset + 16 + 4) << true << true;
QTest::newRow("Motif, Styled, 16") << QSize(150, 100) << QRectF(-116, -116, 166, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (-100 + 16 + 4) << (-100 - 16) << (-100 + 16 + 4) << true << true;
+ << (-100 - 16) << (-100 + offset + 4) << (-100 - 16) << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 17") << QSize(150, 100) << QRectF(-116, -116, 216, 116) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16 + 4 - 50) << (-100 - 16) << (-100 + 16 + 4) << true << true;
+ << (-100 - 16) << (offset + 4 - 50) << (-100 - 16) << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 18") << QSize(150, 100) << QRectF(-116, -116, 216, 216) << QTransform()
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << (-100 - 16) << (16 + 4 - 50) << (-100 - 16) << (16 + 4) << true << true;
+ << (-100 - 16) << (offset + 4 - 50) << (-100 - 16) << (offset + 4) << true << true;
QTest::newRow("Motif, Styled, 1 x2") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (150 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (150 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 2 x2") << QSize(150, 100) << QRectF(0, 0, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16 + 4) << 0 << (100 + 16 + 4) << true << true;
+ << 0 << (250 + offset + 4) << 0 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 3 x2") << QSize(150, 100) << QRectF(0, 0, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << 0 << (250 + 16 + 4) << 0 << (300 + 16 + 4) << true << true;
+ << 0 << (250 + offset + 4) << 0 << (300 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 4 x2") << QSize(150, 100) << QRectF(-100, -100, 150, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (-50 + 16 + 4) << -200 << (-100 + 16 + 4) << true << true;
+ << -200 << (-50 + offset + 4) << -200 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 5 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 100) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16 + 4) << -200 << (-100 + 16 + 4) << true << true;
+ << -200 << (50 + offset + 4) << -200 << (-100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 6 x2") << QSize(150, 100) << QRectF(-100, -100, 200, 200) << QTransform().scale(2, 2)
<< Qt::ScrollBarAsNeeded << Qt::ScrollBarAsNeeded
- << -200 << (50 + 16 + 4) << -200 << (100 + 16 + 4) << true << true;
+ << -200 << (50 + offset + 4) << -200 << (100 + offset + 4) << true << true;
QTest::newRow("Motif, Styled, 1 No ScrollBars") << QSize(150, 100) << QRectF(0, 0, 150, 100) << QTransform()
<< Qt::ScrollBarAlwaysOff << Qt::ScrollBarAlwaysOff
<< 0 << 0 << 0 << 0 << true << true;
@@ -949,8 +963,14 @@ void _scrollBarRanges_data()
QTest::addColumn<bool>("useMotif");
QTest::addColumn<bool>("useStyledPanel");
- _scrollBarRanges_data_1();
- _scrollBarRanges_data_2();
- _scrollBarRanges_data_3();
- _scrollBarRanges_data_4();
+ int offset = 16;
+#ifdef Q_OS_WINCE
+ if (qt_wince_is_high_dpi())
+ offset *= 2;
+#endif
+
+ _scrollBarRanges_data_1(offset);
+ _scrollBarRanges_data_2(offset);
+ _scrollBarRanges_data_3(offset);
+ _scrollBarRanges_data_4(offset);
}
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..c13e829 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -682,9 +682,12 @@ void tst_QHeaderView::visualIndexAt()
void tst_QHeaderView::length()
{
-#ifdef Q_OS_WINCE
+#if defined(Q_OS_WINCE)
QFont font(QLatin1String("Tahoma"), 7);
view->setFont(font);
+#elif defined(Q_OS_SYMBIAN)
+ QFont font(QLatin1String("Series 60 Sans"), 6);
+ view->setFont(font);
#endif
view->setStretchLastSection(true);
view->show();
@@ -1836,7 +1839,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/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp
index f6d5e3e..0ea0d15 100644
--- a/tests/auto/qhttp/tst_qhttp.cpp
+++ b/tests/auto/qhttp/tst_qhttp.cpp
@@ -484,6 +484,7 @@ void tst_QHttp::post_data()
QTest::addColumn<bool>("useProxy");
QTest::addColumn<QString>("host");
QTest::addColumn<int>("port");
+ QTest::addColumn<bool>("ssl");
QTest::addColumn<QString>("path");
QTest::addColumn<QByteArray>("result");
@@ -491,25 +492,48 @@ void tst_QHttp::post_data()
md5sum = "d41d8cd98f00b204e9800998ecf8427e";
QTest::newRow("empty-data")
<< QString() << false << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
QTest::newRow("empty-device")
<< QString() << true << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
QTest::newRow("proxy-empty-data")
<< QString() << false << true
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
md5sum = "b3e32ac459b99d3f59318f3ac31e4bee";
QTest::newRow("data") << "rfc3252.txt" << false << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
QTest::newRow("device") << "rfc3252.txt" << true << false
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
QTest::newRow("proxy-data") << "rfc3252.txt" << false << true
- << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi"
+ << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi"
<< md5sum;
+#ifndef QT_NO_OPENSSL
+ md5sum = "d41d8cd98f00b204e9800998ecf8427e";
+ QTest::newRow("empty-data-ssl")
+ << QString() << false << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ QTest::newRow("empty-device-ssl")
+ << QString() << true << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ QTest::newRow("proxy-empty-data-ssl")
+ << QString() << false << true
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum;
+ md5sum = "b3e32ac459b99d3f59318f3ac31e4bee";
+ QTest::newRow("data-ssl") << "rfc3252.txt" << false << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+ QTest::newRow("device-ssl") << "rfc3252.txt" << true << false
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+ QTest::newRow("proxy-data-ssl") << "rfc3252.txt" << false << true
+ << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi"
+ << md5sum;
+#endif
+
// the following test won't work. See task 185996
/*
QTest::newRow("proxy-device") << "rfc3252.txt" << true << true
@@ -525,14 +549,19 @@ void tst_QHttp::post()
QFETCH(bool, useProxy);
QFETCH(QString, host);
QFETCH(int, port);
+ QFETCH(bool, ssl);
QFETCH(QString, path);
http = newHttp(useProxy);
+#ifndef QT_NO_OPENSSL
+ QObject::connect(http, SIGNAL(sslErrors(const QList<QSslError> &)),
+ http, SLOT(ignoreSslErrors()));
+#endif
QCOMPARE(http->currentId(), 0);
QCOMPARE((int)http->state(), (int)QHttp::Unconnected);
if (useProxy)
addRequest(QHttpRequestHeader(), http->setProxy(QtNetworkSettings::serverName(), 3129));
- addRequest(QHttpRequestHeader(), http->setHost(host, port));
+ addRequest(QHttpRequestHeader(), http->setHost(host, (ssl ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp), port));
// add the POST request
QFile file(SRCDIR + source);
diff --git a/tests/auto/qlabel/qlabel.pro b/tests/auto/qlabel/qlabel.pro
index 6d55c13..297f868 100644
--- a/tests/auto/qlabel/qlabel.pro
+++ b/tests/auto/qlabel/qlabel.pro
@@ -1,19 +1,10 @@
load(qttest_p4)
-SOURCES += tst_qlabel.cpp
-
-wince*:{
- DEFINES += SRCDIR=\\\"\\\"
-} else:!symbian {
- DEFINES += SRCDIR=\\\"$$PWD/\\\"
-}
-
-wince*|symbian {
- addFiles.sources = *.png testdata
+SOURCES += tst_qlabel.cpp
+wince*::DEFINES += SRCDIR=\\\"\\\"
+else:!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\"
+wince*|symbian {
+ addFiles.sources = *.png \
+ testdata
addFiles.path = .
DEPLOYMENT += addFiles
}
-
-
-
-
-
diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp
index dd03ef3..9eae9c9 100644
--- a/tests/auto/qlabel/tst_qlabel.cpp
+++ b/tests/auto/qlabel/tst_qlabel.cpp
@@ -50,6 +50,7 @@
#include <qlineedit.h>
#include <qmovie.h>
#include <qpicture.h>
+#include <qmessagebox.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -112,6 +113,9 @@ private slots:
void task226479_movieResize();
void emptyPixmap();
+ void unicodeText_data();
+ void unicodeText();
+
private:
QLabel *testWidget;
QPointer<Widget> test_box;
@@ -451,5 +455,59 @@ void tst_QLabel::emptyPixmap()
QCOMPARE(label1.sizeHint(), label4.sizeHint());
}
+/**
+ Test for QTBUG-4848 - unicode data corrupting QLabel display
+*/
+void tst_QLabel::unicodeText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("languageName");
+
+ /*
+ The "glass" phrase in Thai was the initial report for bug QTBUG-4848, was
+ originally found on http://www.columbia.edu/kermit/utf8.html.
+
+ The phrase is from an internet tradition regarding a striking phrase
+ that is translated into many different languages. The utf8 strings
+ below were generated by using http://translate.google.com.
+
+ The glass phrase in Thai contains the ้ว character which manifests bug
+ QTBUG-4848
+
+ The last long phrase is an excerpt from Churchills "on the beaches"
+ speech, also translated using http://translate.google.com.
+ */
+
+ QTest::newRow("english") << QString::fromUtf8("I can eat glass and it doesn't hurt me.") << QString("english");
+ QTest::newRow("thai") << QString::fromUtf8("ฉันจะกินแก้วและไม่เจ็บฉัน") << QString("thai");
+ QTest::newRow("chinese") << QString::fromUtf8("我可以吃玻璃,并没有伤害我。") << QString("chinese");
+ QTest::newRow("arabic") << QString::fromUtf8("أستطيع أكل الزجاج ، وأنه لا يؤذيني.") << QString("arabic");
+ QTest::newRow("russian") << QString::fromUtf8("Я могу есть стекло, и не больно.") << QString("russian");
+ QTest::newRow("korean") << QString::fromUtf8("유리를 먹을 수있는, 그리고 그게 날 다치게하지 않습니다.") << QString("korean");
+ QTest::newRow("greek") << QString::fromUtf8("Μπορώ να φάτε γυαλί και δεν μου κάνει κακό.") << QString("greek");
+ QTest::newRow("german") << QString::fromUtf8("Ich kann Glas essen und es macht mich nicht heiß.") << QString("german");
+
+ QTest::newRow("thai_long") << QString::fromUtf8("เราจะต่อสู้ในทะเลและมหาสมุทร. เราจะต่อสู้ด้วยความมั่นใจเติบโตและความเจริญเติบโตในอากาศเราจะปกป้องเกาะของเราค่าใช้จ่ายใดๆอาจ."
+ "เราจะต่อสู้บนชายหาดเราจะต่อสู้ในบริเวณเชื่อมโยงไปถึงเราจะต่อสู้ในช่องและในถนนที่เราจะต่อสู้ในภูเขานั้นเราจะไม่ยอม.")
+ << QString("thai_long");
+}
+
+void tst_QLabel::unicodeText()
+{
+ const QString testDataPath("testdata/unicodeText");
+ QFETCH(QString, text);
+ QFETCH(QString, languageName);
+ QFrame frame;
+ QVBoxLayout *layout = new QVBoxLayout();
+ QLabel *label = new QLabel(text, &frame);
+ layout->addWidget(label);
+ layout->setMargin(8);
+ frame.setLayout(layout);
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QVERIFY(frame.isVisible()); // was successfully sized and shown
+ testWidget->show();
+}
+
QTEST_MAIN(tst_QLabel)
#include "tst_qlabel.moc"
diff --git a/tests/auto/qlayout/tst_qlayout.cpp b/tests/auto/qlayout/tst_qlayout.cpp
index 9d6110d..efe14c3 100644
--- a/tests/auto/qlayout/tst_qlayout.cpp
+++ b/tests/auto/qlayout/tst_qlayout.cpp
@@ -83,6 +83,7 @@ private slots:
void layoutItemRect();
void warnIfWrongParent();
void controlTypes();
+ void adjustSizeShouldMakeSureLayoutIsActivated();
};
tst_QLayout::tst_QLayout()
@@ -110,8 +111,8 @@ void tst_QLayout::getSetCheck()
class SizeHinterFrame : public QFrame
{
public:
- SizeHinterFrame(const QSize &s)
- : QFrame(0), sh(s) {
+ SizeHinterFrame(const QSize &sh, const QSize &msh = QSize())
+ : QFrame(0), sh(sh), msh(msh) {
setFrameStyle(QFrame::Box | QFrame::Plain);
}
@@ -119,9 +120,11 @@ public:
void setSizeHint(const QSize &s) { sh = s; }
QSize sizeHint() const { return sh; }
+ QSize minimumSizeHint() const { return msh; }
private:
QSize sh;
+ QSize msh;
};
@@ -333,5 +336,26 @@ void tst_QLayout::controlTypes()
}
+void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated()
+{
+ QWidget main;
+
+ QVBoxLayout *const layout = new QVBoxLayout(&main);
+ layout->setMargin(0);
+ SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
+ frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ layout->addWidget(frame);
+
+ SizeHinterFrame *frame2 = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
+ frame2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ layout->addWidget(frame2);
+
+ main.show();
+
+ frame2->hide();
+ main.adjustSize();
+ QCOMPARE(main.size(), QSize(200, 10));
+}
+
QTEST_MAIN(tst_QLayout)
#include "tst_qlayout.moc"
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 8368114..c676959 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -3304,41 +3304,45 @@ void tst_QLineEdit::task174640_editingFinished()
layout->addWidget(le2);
mw.show();
- QTest::qWait(200);
+ QApplication::setActiveWindow(&mw);
mw.activateWindow();
+ QTest::qWaitForWindowShown(&mw);
QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
le1->setFocus();
- QTest::qWait(200);
- QVERIFY(le1->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 0);
le2->setFocus();
- QTest::qWait(200);
- QVERIFY(le2->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le2->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 1);
editingFinishedSpy.clear();
le1->setFocus();
- QTest::qWait(200);
- QVERIFY(le1->hasFocus());
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
QMenu *testMenu1 = new QMenu(le1);
testMenu1->addAction("foo");
testMenu1->addAction("bar");
testMenu1->show();
- QTest::qWait(200);
+ QTest::qWaitForWindowShown(testMenu1);
+ QTest::qWait(20);
mw.activateWindow();
+
delete testMenu1;
QCOMPARE(editingFinishedSpy.count(), 0);
- QVERIFY(le1->hasFocus());
+ QTRY_VERIFY(le1->hasFocus());
QMenu *testMenu2 = new QMenu(le2);
testMenu2->addAction("foo2");
testMenu2->addAction("bar2");
testMenu2->show();
- QTest::qWait(200);
+ QTest::qWaitForWindowShown(testMenu2);
+ QTest::qWait(20);
mw.activateWindow();
delete testMenu2;
QCOMPARE(editingFinishedSpy.count(), 1);
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 7599ce6a06..6e211ae 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -116,6 +116,9 @@ private slots:
void keyboardSearch();
void shiftSelectionWithNonUniformItemSizes();
void clickOnViewportClearsSelection();
+ void task262152_setModelColumnNavigate();
+ void taskQTBUG_2233_scrollHiddenItems_data();
+ void taskQTBUG_2233_scrollHiddenItems();
};
// Testing get/set functions
@@ -1767,6 +1770,64 @@ void tst_QListView::clickOnViewportClearsSelection()
}
+void tst_QListView::task262152_setModelColumnNavigate()
+{
+ QListView view;
+ QStandardItemModel model(3,2);
+ model.setItem(0,1,new QStandardItem("[0,1]"));
+ model.setItem(1,1,new QStandardItem("[1,1]"));
+ model.setItem(2,1,new QStandardItem("[2,1]"));
+
+ view.setModel(&model);
+ view.setModelColumn(1);
+
+ view.show();
+ QTest::qWait(100);
+ QTest::keyClick(&view, Qt::Key_Down);
+ QTest::qWait(100);
+ QCOMPARE(view.currentIndex(), model.index(1,1));
+ QTest::keyClick(&view, Qt::Key_Down);
+ QTest::qWait(100);
+ QCOMPARE(view.currentIndex(), model.index(2,1));
+
+}
+
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data()
+{
+ QTest::addColumn<int>("flow");
+
+ QTest::newRow("TopToBottom") << static_cast<int>(QListView::TopToBottom);
+ QTest::newRow("LeftToRight") << static_cast<int>(QListView::LeftToRight);
+}
+
+void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
+{
+ QFETCH(int, flow);
+ const int rowCount = 200;
+
+ QListView view;
+ QStringListModel model(&view);
+ QStringList list;
+ for (int i = 0; i < rowCount; ++i)
+ list << QString::fromAscii("Item %1").arg(i);
+
+ model.setStringList(list);
+ view.setModel(&model);
+ view.setViewMode(QListView::ListMode);
+ for (int i = 0; i < rowCount / 2; ++i)
+ view.setRowHidden(2 * i, true);
+ view.setFlow(static_cast<QListView::Flow>(flow));
+ view.resize(130, 130);
+
+ for (int i = 0; i < 10; ++i) {
+ (view.flow() == QListView::TopToBottom
+ ? view.verticalScrollBar()
+ : view.horizontalScrollBar())->setValue(i);
+ QModelIndex index = view.indexAt(QPoint(0,0));
+ QVERIFY(index.isValid());
+ QCOMPARE(index.row(), 2 * i + 1);
+ }
+}
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 4eb149f..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);
@@ -816,6 +827,9 @@ void tst_QMenu::task258920_mouseBorder()
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/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 9515d87..8ed83cb 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -238,6 +238,8 @@ private slots:
void taskQT4444_dontOverflowDashOffset();
+ void painterBegin();
+
private:
void fillData();
QColor baseColor( int k, int intensity=255 );
@@ -1554,7 +1556,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
@@ -4312,5 +4314,43 @@ void tst_QPainter::taskQT4444_dontOverflowDashOffset()
QVERIFY(true); // Don't crash
}
+void tst_QPainter::painterBegin()
+{
+ QImage nullImage;
+ QImage indexed8Image(16, 16, QImage::Format_Indexed8);
+ QImage rgb32Image(16, 16, QImage::Format_RGB32);
+ QImage argb32Image(16, 16, QImage::Format_ARGB32_Premultiplied);
+
+ QPainter p;
+
+ // Painting on null image should fail.
+ QVERIFY(!p.begin(&nullImage));
+
+ // Check that the painter is not messed up by using it on another image.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // If painting on indexed8 image fails, the painter state should still be OK.
+ if (p.begin(&indexed8Image))
+ QVERIFY(p.end());
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(p.end());
+
+ // Try opening a painter on the two different images.
+ QVERIFY(p.begin(&rgb32Image));
+ QVERIFY(!p.begin(&argb32Image));
+ QVERIFY(p.end());
+
+ // Try opening two painters on the same image.
+ QVERIFY(p.begin(&rgb32Image));
+ QPainter q;
+ QVERIFY(!q.begin(&rgb32Image));
+ QVERIFY(!q.end());
+ QVERIFY(p.end());
+
+ // Try ending an inactive painter.
+ QVERIFY(!p.end());
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
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..b11efa0
--- /dev/null
+++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
@@ -0,0 +1,410 @@
+/****************************************************************************
+**
+** 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, 1 + loopCount);
+
+ 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.setDuration(0);
+ 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/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 36c1518..9f5aee2 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -1144,7 +1144,7 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data()
// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0);
// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0);
-#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+#if !defined(__SERIES60_31__)
QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red);
QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red);
#endif
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 51ef2da..7dd17e5 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -130,6 +130,7 @@ private slots:
void valueChanged();
void twoAnimations();
void deletedInUpdateCurrentTime();
+ void totalDuration();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -1199,5 +1200,18 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime()
QCOMPARE(o.value(), 1000);
}
+void tst_QPropertyAnimation::totalDuration()
+{
+ QPropertyAnimation anim;
+ QCOMPARE(anim.totalDuration(), 250);
+ anim.setLoopCount(2);
+ QCOMPARE(anim.totalDuration(), 2*250);
+ anim.setLoopCount(-1);
+ QCOMPARE(anim.totalDuration(), -1);
+ anim.setDuration(0);
+ QCOMPARE(anim.totalDuration(), 0);
+}
+
+
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index bdb0414..81f0ee5 100644
--- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
+++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
@@ -113,6 +113,7 @@ private slots:
void evaluateProgram();
void evaluateProgram_SyntaxError();
void evaluateNullProgram();
+ void hasUncaughtException();
private:
double m_testProperty;
@@ -2269,5 +2270,41 @@ void tst_QScriptEngineAgent::evaluateNullProgram()
QCOMPARE(spy->count(), 0);
}
+class NewSpy :public QScriptEngineAgent
+{
+ bool m_result;
+public:
+ NewSpy(QScriptEngine* eng) : QScriptEngineAgent(eng), m_result(false) {}
+ void functionExit (qint64, const QScriptValue &scriptValue)
+ {
+ if (engine()->hasUncaughtException()) m_result = true;
+ }
+
+ bool isPass() { return m_result; }
+ void reset() { m_result = false; }
+};
+
+void tst_QScriptEngineAgent::hasUncaughtException()
+{
+ QScriptEngine eng;
+ NewSpy* spy = new NewSpy(&eng);
+ eng.setAgent(spy);
+ QScriptValue scriptValue;
+
+ // Check unhandled exception.
+ eng.evaluate("function init () {Unknown.doSth ();}");
+ scriptValue = QScriptValue(eng.globalObject().property("init")).call();
+ QVERIFY(eng.hasUncaughtException());
+ QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag.");
+ spy->reset();
+
+ // Check catched exception.
+ eng.evaluate("function innerFoo() { throw new Error('ciao') }");
+ eng.evaluate("function foo() {try { innerFoo() } catch (e) {} }");
+ scriptValue = QScriptValue(eng.globalObject().property("foo")).call();
+ QVERIFY(!eng.hasUncaughtException());
+ QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag.");
+}
+
QTEST_MAIN(tst_QScriptEngineAgent)
#include "tst_qscriptengineagent.moc"
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 320a429..44adf7e 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -317,6 +317,11 @@ public:
Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject()
{ m_qtFunctionInvoked = 57; return this; }
+ Q_INVOKABLE QObjectList findObjects() const
+ { return findChildren<QObject *>(); }
+ Q_INVOKABLE QList<int> myInvokableNumbers() const
+ { return QList<int>() << 1 << 2 << 3; }
+
void emitMySignal()
{ emit mySignal(); }
void emitMySignalWithIntArg(int arg)
@@ -493,6 +498,7 @@ protected slots:
}
private slots:
+ void registeredTypes();
void getSetStaticProperty();
void getSetDynamicProperty();
void getSetChildren();
@@ -543,6 +549,24 @@ void tst_QScriptExtQObject::cleanup()
delete m_myObject;
}
+// this test has to be first and test that some types are automatically registered
+void tst_QScriptExtQObject::registeredTypes()
+{
+ QScriptEngine e;
+ QObject *t = new MyQObject;
+ QObject *c = new QObject(t);
+ c->setObjectName ("child1");
+
+ e.globalObject().setProperty("MyTest", e.newQObject(t));
+
+ QScriptValue v1 = e.evaluate("MyTest.findObjects()[0].objectName;");
+ QCOMPARE(v1.toString(), c->objectName());
+
+ QScriptValue v2 = e.evaluate("MyTest.myInvokableNumbers()");
+ QCOMPARE(qscriptvalue_cast<QList<int> >(v2), (QList<int>() << 1 << 2 << 3));
+}
+
+
static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
{
if (ctx->argumentCount() != 0)
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/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
index 832605e..6efa85b 100644
--- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
+++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp
@@ -43,9 +43,15 @@
#include "qevent.h"
#include "qdialog.h"
+#include "qpushbutton.h"
#include "qdialogbuttonbox.h"
#include "private/qsoftkeymanager_p.h"
+#ifdef Q_WS_S60
+static const int s60CommandStart = 6000;
+#endif
+
+
class tst_QSoftKeyManager : public QObject
{
Q_OBJECT
@@ -171,22 +177,52 @@ void tst_QSoftKeyManager::handleCommand()
}
/*
- This tests that softkey enable state follows the state of widget that owns the action
- to which the softkey is related to.
+ This tests that the state of a widget that owns softkey action is respected when handling the softkey
+ command.
*/
void tst_QSoftKeyManager::checkSoftkeyEnableStates()
{
- QWidget w1, w2;
- w1.setEnabled(false);
- w2.setEnabled(true);
+ QDialog w;
+ QDialogButtonBox *buttons = new QDialogButtonBox(
+ QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Help,
+ Qt::Horizontal,
+ &w);
+ QPushButton *pBDefaults = buttons->button(QDialogButtonBox::RestoreDefaults);
+ QPushButton *pBHelp = buttons->button(QDialogButtonBox::Help);
+ pBHelp->setEnabled(false);
+ w.show();
+ QApplication::processEvents();
- QAction *disabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w1);
- QAction *enabledAction = QSoftKeyManager::createAction(QSoftKeyManager::OkSoftKey, &w2);
+ QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //restore defaults action
+ QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //disabled help action
- QVERIFY(disabledAction->isEnabled()==false);
- QVERIFY(enabledAction->isEnabled()==true);
+ //Verify that enabled button gets all the action trigger signals and
+ //disabled button gets none.
+ for (int i = 0; i < 10; i++) {
+ //simulate "Restore Defaults" softkey press
+ qApp->symbianHandleCommand(s60CommandStart);
+ //simulate "help" softkey press
+ qApp->symbianHandleCommand(s60CommandStart + 1);
+ }
+ QApplication::processEvents();
+ QCOMPARE(spy0.count(), 10);
+ QCOMPARE(spy1.count(), 0);
+ spy0.clear();
+ spy1.clear();
+
+ for (int i = 0; i < 10; i++) {
+ //simulate "Restore Defaults" softkey press
+ qApp->symbianHandleCommand(s60CommandStart);
+ //simulate "help" softkey press
+ qApp->symbianHandleCommand(s60CommandStart + 1);
+ //switch enabled button to disabled and vice versa
+ pBHelp->setEnabled(!pBHelp->isEnabled());
+ pBDefaults->setEnabled(!pBDefaults->isEnabled());
+ }
+ QApplication::processEvents();
+ QCOMPARE(spy0.count(), 5);
+ QCOMPARE(spy1.count(), 5);
}
-
QTEST_MAIN(tst_QSoftKeyManager)
#include "tst_qsoftkeymanager.moc"
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..82b6066 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
@@ -1061,17 +1072,20 @@ void tst_QSqlDatabase::recordMySQL()
int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt();
int vernum = (major << 16) + (minor << 8) + revision;
-#ifdef QT3_SUPPORT
/* The below is broken in mysql below 5.0.15
see http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded
with space on insert, and trailing spaces are removed on select.
*/
if( vernum >= ((5 << 16) + 15) ) {
+#ifdef QT3_SUPPORT
bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc ")));
varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv ")));
- }
+#else
+ bin10 = FieldDef("binary(10)", QVariant::ByteArray, QString("123abc "));
+ varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QString("123abcv "));
#endif
+ }
static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
static const FieldDef fieldDefs[] = {
@@ -1292,9 +1306,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 +1508,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 +1548,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 +1665,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 +2032,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 +2064,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 +2292,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 +2471,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 ).toDouble()<4.1 )
+ QSKIP( "Test requires MySQL >= 4.1", SkipSingle );
QSqlQuery q(db);
QVERIFY_SQL(q, exec("begin"));
diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp
index f463c9e..5322b97 100644
--- a/tests/auto/qsqldriver/tst_qsqldriver.cpp
+++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp
@@ -85,6 +85,9 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
{
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) );
QVERIFY_SQL( q, exec("create table " + qTableName("relTEST1") +
@@ -160,7 +163,11 @@ void tst_QSqlDriver::record()
//check that we can't get records using incorrect tablename casing that's been quoted
rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match
else
QCOMPARE(rec.count(), 0);
@@ -208,7 +215,11 @@ void tst_QSqlDriver::primaryIndex()
tablename = tablename.toUpper();
index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
- if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db))
+ if (tst_Databases::isMySQL(db)
+ || db.driverName().startsWith("QSQLITE")
+ || db.driverName().startsWith("QTDS")
+ || tst_Databases::isSqlServer(db)
+ || tst_Databases::isMSAccess(db))
QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing
else
QCOMPARE(index.count(), 0);
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 5ed9cfa..8fe6f2e 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -194,7 +194,6 @@ private slots:
void sqlServerReturn0_data() { generic_data(); }
void sqlServerReturn0();
-
private:
// returns all database connections
void generic_data(const QString &engine=QString());
@@ -333,6 +332,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" ) );
@@ -395,7 +396,7 @@ void tst_QSqlQuery::char1SelectUnicode()
QSKIP("Needs someone with more Unicode knowledge than I have to fix", SkipSingle);
if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
- QString uniStr( QChar( 0xfb50 ) );
+ QString uniStr( QChar( 'का' ) );
QSqlQuery q( db );
if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
@@ -508,9 +509,7 @@ void tst_QSqlQuery::mysqlOutValues()
QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () "
"BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) );
QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) );
- QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue);
QVERIFY_SQL( q, next() );
- QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue);
QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) );
QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) );
@@ -1631,8 +1630,7 @@ void tst_QSqlQuery::prepare_bind_exec()
{
// new scope for SQLITE
- static const unsigned short utf8arr[] = { 0xfb50,0xfb60,0xfb70,0xfb80,0xfbe0,0xfbf0,0x00 };
- static const QString utf8str = QString::fromUtf16( utf8arr );
+ static const QString utf8str = QString::fromUtf8( "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥" );
static const QString values[6] = { "Harry", "Trond", "Mark", "Ma?rk", "?", ":id" };
@@ -1645,12 +1643,15 @@ 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 )
- createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(20) character set utf8)";
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(200) null)";
+ else if ( tst_Databases::isMySQL(db) && useUnicode )
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200) character set utf8)";
else
- createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(20))";
+ createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200))";
QVERIFY_SQL( q, exec( createQuery ) );
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/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 05d546e..cb24a9f 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -837,10 +837,10 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
QVERIFY_SQL(model, select());
if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
- QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name")).toUpper()).toString(),
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2")).toUpper()).toString(),
QString("Trondheim"));
} else {
- QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name"))).toString(),
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2"))).toString(),
QString("Trondheim"));
}
@@ -859,9 +859,9 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
// The duplicate field names is aliased because it's comes from the relation's display column.
if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
- QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name"))).toUpper());
+ QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name_2"))).toUpper());
else
- QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name")));
+ QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name_2")));
QVERIFY(model.insertRecord(-1, rec));
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo"));
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 49e087f..653d944 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -143,6 +143,8 @@ void tst_QSqlTableModel::dropTestTables()
for (int i = 0; i < dbs.dbNames.count(); ++i) {
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
QStringList tableNames;
tableNames << qTableName("test")
@@ -659,6 +661,9 @@ void tst_QSqlTableModel::primaryKeyOrder()
QSqlQuery q(db);
+ if(tst_Databases::isPostgreSQL(db))
+ QVERIFY_SQL( q, exec("set client_min_messages='warning'"));
+
QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))"));
QSqlTableModel model(0, db);
@@ -897,6 +902,8 @@ void tst_QSqlTableModel::sqlite_attachedDatabase()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ if(db.databaseName() == ":memory:")
+ QSKIP(":memory: database, skipping test", SkipSingle);
QSqlDatabase attachedDb = QSqlDatabase::cloneDatabase(db, db.driverName() + QLatin1String("attached"));
attachedDb.setDatabaseName(db.databaseName()+QLatin1String("attached.dat"));
diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp
index c088a47..be66e9e 100644
--- a/tests/auto/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp
@@ -404,6 +404,8 @@ void tst_QSqlThread::readWriteThreading()
if (db.databaseName() == ":memory:")
QSKIP("does not work with in-memory databases", SkipSingle);
+ else if (tst_Databases::isMSAccess(db))
+ QSKIP("does not work with MS Access databases", SkipSingle);
SqlProducer producer(db);
SqlConsumer consumer(db);
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 77e3763..2bd1684 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -170,6 +170,7 @@ private slots:
void setEmptyKey();
void spontaneousWrite();
void setReadBufferSize();
+ void setReadBufferSize_task_250027();
void waitForMinusOne();
void verifyMode();
void verifyDepth();
@@ -182,6 +183,7 @@ private slots:
void ignoreSslErrorsListWithSlot_data();
void ignoreSslErrorsListWithSlot();
void readFromClosedSocket();
+ void writeBigChunk();
static void exitLoop()
{
@@ -1240,6 +1242,66 @@ void tst_QSslSocket::setReadBufferSize()
QVERIFY(receiver->bytesAvailable() > oldBytesAvailable);
}
+class SetReadBufferSize_task_250027_handler : public QObject {
+ Q_OBJECT
+public slots:
+ void readyReadSlot() {
+ QTestEventLoop::instance().exitLoop();
+ }
+ void waitSomeMore(QSslSocket *socket) {
+ QTime t;
+ t.start();
+ while (!socket->encryptedBytesAvailable()) {
+ QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250);
+ if (t.elapsed() > 1000 || socket->state() != QAbstractSocket::ConnectedState)
+ return;
+ }
+ }
+};
+
+void tst_QSslSocket::setReadBufferSize_task_250027()
+{
+ // do not execute this when a proxy is set.
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ socket->setReadBufferSize(1000); // limit to 1 kb/sec
+ socket->ignoreSslErrors();
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ socket->ignoreSslErrors();
+ QVERIFY(socket->waitForConnected(10*1000));
+ QVERIFY(socket->waitForEncrypted(10*1000));
+
+ // exit the event loop as soon as we receive a readyRead()
+ SetReadBufferSize_task_250027_handler setReadBufferSize_task_250027_handler;
+ connect(socket, SIGNAL(readyRead()), &setReadBufferSize_task_250027_handler, SLOT(readyReadSlot()));
+
+ // provoke a response by sending a request
+ socket->write("GET /gif/fluke.gif HTTP/1.0\n"); // this file is 27 KB
+ socket->write("Host: ");
+ socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData());
+ socket->write("\n");
+ socket->write("Connection: close\n");
+ socket->write("\n");
+ socket->flush();
+
+ QTestEventLoop::instance().enterLoop(10);
+ setReadBufferSize_task_250027_handler.waitSomeMore(socket);
+ QByteArray firstRead = socket->readAll();
+ // First read should be some data, but not the whole file
+ QVERIFY(firstRead.size() > 0 && firstRead.size() < 20*1024);
+
+ QTestEventLoop::instance().enterLoop(10);
+ setReadBufferSize_task_250027_handler.waitSomeMore(socket);
+ QByteArray secondRead = socket->readAll();
+ // second read should be some more data
+ QVERIFY(secondRead.size() > 0);
+
+ socket->close();
+}
+
class SslServer3 : public QTcpServer
{
Q_OBJECT
@@ -1377,6 +1439,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();
@@ -1697,6 +1760,50 @@ void tst_QSslSocket::readFromClosedSocket()
QVERIFY(!socket->bytesToWrite());
}
+void tst_QSslSocket::writeBigChunk()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ this->socket = socket;
+
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+ QByteArray data;
+ data.resize(1024*1024*10); // 10 MB
+ // init with garbage. needed so ssl cannot compress it in an efficient way.
+ for (int i = 0; i < data.size() / sizeof(int); i++) {
+ int r = qrand();
+ data.data()[i*sizeof(int)] = r;
+ }
+
+ QVERIFY(socket->waitForEncrypted(10000));
+ QString errorBefore = socket->errorString();
+
+ int ret = socket->write(data.constData(), data.size());
+ QVERIFY(data.size() == ret);
+
+ // spin the event loop once so QSslSocket::transmit() gets called
+ QCoreApplication::processEvents();
+ QString errorAfter = socket->errorString();
+
+ // no better way to do this right now since the error is the same as the default error.
+ if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
+ {
+ qWarning() << socket->error() << socket->errorString();
+ QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
+ }
+ // also check the error string. If another error (than UnknownError) occured, it should be different than before
+ QVERIFY(errorBefore == errorAfter);
+
+ // check that everything has been written to OpenSSL
+ QVERIFY(socket->bytesToWrite() == 0);
+
+ socket->close();
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslSocket)
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 55da180..d8110e1 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,157 @@ 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("Last column disabled. Task QTBUG-3878") << -1 << -1
+ << IntList()
+ << (IntList() << 6)
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious))
+ << 0 << 5;
+
+ 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;
+
+ IntList fullList;
+ for (int i = 0; i < 7; ++i)
+ fullList << i;
+
+ QTest::newRow("All disabled, wrap forward. Timeout => FAIL") << -1 << -1
+ << fullList
+ << fullList
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MoveNext))
+ << 1 << 0;
+
+ QTest::newRow("All disabled, wrap backwards. Timeout => FAIL") << -1 << -1
+ << fullList
+ << fullList
+ << QRect()
+ << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious))
+ << 1 << 0;
+}
+
+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);
+
+ 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);
+
+ foreach (int row, disableRows)
+ model.disableRow(row);
+ foreach (int column, disableColumns)
+ model.disableColumn(column);
+
+ 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 +2728,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 +2744,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 +3277,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.
@@ -3612,5 +3808,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/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index 27c19df..1387a92 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -590,9 +590,11 @@ void tst_QTabWidget::paintEventCount()
QTest::qWait(1000);
- // Mac and Windows get multiple repaints on the first show, so use those as a starting point.
+ // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point.
static const int MaxInitialPaintCount =
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WINCE)
+ 4;
+#elif defined(Q_WS_WIN)
2;
#elif defined(Q_WS_MAC)
5;
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 91b2cc5..da58725 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -172,6 +172,7 @@ private slots:
void expandAndCollapse_data();
void expandAndCollapse();
void expandAndCollapseAll();
+ void expandWithNoChildren();
void keyboardNavigation();
void headerSections();
void moveCursor_data();
@@ -1548,6 +1549,19 @@ void tst_QTreeView::expandAndCollapseAll()
// QCOMPARE(collapsedSpy.count(), count);
}
+void tst_QTreeView::expandWithNoChildren()
+{
+ QTreeView tree;
+ QStandardItemModel model(1,1);
+ tree.setModel(&model);
+ tree.setAnimated(true);
+ tree.doItemsLayout();
+ //this test should not output warnings
+ tree.expand(model.index(0,0));
+}
+
+
+
void tst_QTreeView::keyboardNavigation()
{
const int rows = 10;
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 026c30e..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");
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..050d1c5 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -69,6 +69,9 @@
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
+#include <QtGui/QGraphicsView>
+#include <QtGui/QGraphicsProxyWidget>
+
#include "../../shared/util.h"
@@ -239,7 +242,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();
@@ -285,6 +293,7 @@ private slots:
#ifdef Q_WS_X11
void minAndMaxSizeWithX11BypassWindowManagerHint();
void showHideShow();
+ void clean_qt_x11_enforce_cursor();
#endif
void compatibilityChildInsertedEvents();
@@ -4348,6 +4357,161 @@ 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;
+ return true;
+ }
+ 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
+ // Should cause winId of child to change, on all platforms
+ QWidget parent1, parent2;
+ WinIdChangeWidget child(&parent1);
+ const WId winIdBefore = child.winId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ child.setParent(&parent2);
+ const WId winIdAfter = child.internalWinId();
+ QVERIFY(winIdBefore != winIdAfter);
+ QCOMPARE(child.m_winIdChangeEventCount, 2);
+ }
+
+ {
+ // Changing grandparent of a native widget
+ // Should cause winId of grandchild to change only on Symbian
+ QWidget grandparent1, grandparent2;
+ QWidget parent(&grandparent1);
+ WinIdChangeWidget child(&parent);
+ const WId winIdBefore = child.winId();
+ QCOMPARE(child.m_winIdChangeEventCount, 1);
+ parent.setParent(&grandparent2);
+ 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 +4568,7 @@ void tst_QWidget::persistentWinId()
delete parent;
}
+#endif // Q_OS_SYMBIAN
class ShowHideEventWidget : public QWidget
{
@@ -4524,9 +4689,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 +5298,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());
@@ -6060,6 +6213,35 @@ void tst_QWidget::showHideShow()
QVERIFY(w.gotExpectedMapNotify);
}
+
+void tst_QWidget::clean_qt_x11_enforce_cursor()
+{
+ {
+ QWidget window;
+ QWidget *w = new QWidget(&window);
+ QWidget *child = new QWidget(w);
+ child->setAttribute(Qt::WA_SetCursor, true);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QTest::qWaitForWindowShown(&window);
+ QTest::qWait(100);
+ QCursor::setPos(window.geometry().center());
+ QTest::qWait(100);
+
+ child->setFocus();
+ QApplication::processEvents();
+ QTest::qWait(100);
+
+ delete w;
+ }
+
+ QGraphicsScene scene;
+ QLineEdit *edit = new QLineEdit;
+ scene.addWidget(edit);
+
+ // If the test didn't crash, then it passed.
+}
#endif
class EventRecorder : public QObject
@@ -7466,16 +7648,16 @@ 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);
- QTest::qWait(50);
+ QTest::qWait(150);
// Minimize window.
widget.showMinimized();
- QTest::qWait(70);
+ QTest::qWait(110);
widget.reset();
@@ -8176,7 +8358,7 @@ public:
static bool firstTime = true;
if (firstTime)
- QTimer::singleShot(150, this, SLOT(resizeMe()));
+ QTimer::singleShot(250, this, SLOT(resizeMe()));
firstTime = false;
}
@@ -8193,7 +8375,7 @@ void tst_QWidget::moveInResizeEvent()
testWidget.setGeometry(50, 50, 200, 200);
testWidget.show();
QTest::qWaitForWindowShown(&testWidget);
- QTest::qWait(160);
+ QTest::qWait(300);
QRect expectedGeometry(100,100, 100, 100);
QTRY_COMPARE(testWidget.geometry(), expectedGeometry);
@@ -9267,7 +9449,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());