summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-07-01 10:49:16 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-07-01 10:49:16 (GMT)
commita3cd7065c5b630d9d949cc53db36f5c2d091c9fc (patch)
treefbf4f2d9b3e6bdbddf287771ef5f5a5e28cd3a3b /tests
parentfed237ecdd891df6ed4bd1e8e5f5b9a414e12a22 (diff)
parent62f17a11be4ff2f545148a9e14a0d4806398765a (diff)
downloadQt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.zip
Qt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.tar.gz
Qt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging: Cocoa: QFileDialog: fix filename filter not applied correctly Fix typo in docs: occurred. Cocoa: fix qtabwidget auto test failure Cocoa: fix qwidget auto test failures Cocoa: Fix qgraphicsproxywidget auto test Use Q_SLOTS instead of slots in public headers. Fix a11y crash: dock doesn't always have a widget. Fix typo in comment. Mac: respect WA_ShowWithoutActivating flag Remove misleading and incorrect information from dropMimeData docs. Provide the resetInternalData slot to cleanly reset data in proxy subclasses. Mac: switch raster off as default paint engine
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp4
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp138
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp5
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp19
4 files changed, 166 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 29c6591..8c52bb8 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -1498,6 +1498,10 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
view.paintEventRegion = QRegion();
view.npaints = 0;
QTimer::singleShot(0, widget, SLOT(updateScroll()));
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa will send us one aggregated update", Abort);
+#endif
QTRY_COMPARE(view.npaints, 2);
// QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2)
// QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2),
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 613c611..30589a8 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -149,6 +149,7 @@ private slots:
void testMultipleProxiesWithSelection();
void mapSelectionFromSource();
+ void testResetInternalData();
void filteredColumns();
protected:
@@ -3271,5 +3272,142 @@ void tst_QSortFilterProxyModel::taskQTBUG_17812_resetInvalidate()
QCOMPARE(ok, works);
}
+/**
+ * A proxy which changes the background color for items ending in 'y' or 'r'
+ */
+class CustomDataProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ CustomDataProxy(QObject *parent = 0)
+ : QSortFilterProxyModel(parent)
+ {
+ setDynamicSortFilter(true);
+ }
+
+ void setSourceModel(QAbstractItemModel *sourceModel)
+ {
+ // It would be possible to use only the modelReset signal of the source model to clear
+ // the data in *this, however, this requires that the slot is connected
+ // before QSortFilterProxyModel::setSourceModel is called, and even then depends
+ // on the order of invokation of slots being the same as the order of connection.
+ // ie, not reliable.
+// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
+ QSortFilterProxyModel::setSourceModel(sourceModel);
+ // Making the connect after the setSourceModel call clears the data too late.
+// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
+
+ // This could be done in data(), but the point is to need to cache something in the proxy
+ // which needs to be cleared on reset.
+ for (int i = 0; i < sourceModel->rowCount(); ++i)
+ {
+ if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('y')))
+ {
+ m_backgroundColours.insert(i, Qt::blue);
+ } else if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('r')))
+ {
+ m_backgroundColours.insert(i, Qt::red);
+ }
+ }
+ }
+
+ QVariant data(const QModelIndex &index, int role) const
+ {
+ if (role != Qt::BackgroundRole)
+ return QSortFilterProxyModel::data(index, role);
+ return m_backgroundColours.value(index.row());
+ }
+
+private slots:
+ void resetInternalData()
+ {
+ m_backgroundColours.clear();
+ }
+
+private:
+ QHash<int, QColor> m_backgroundColours;
+};
+
+class ModelObserver : public QObject
+{
+ Q_OBJECT
+public:
+ ModelObserver(QAbstractItemModel *model, QObject *parent = 0)
+ : QObject(parent), m_model(model)
+ {
+ connect(m_model, SIGNAL(modelAboutToBeReset()), SLOT(modelAboutToBeReset()));
+ connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
+ }
+
+public slots:
+ void modelAboutToBeReset()
+ {
+ int reds = 0, blues = 0;
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ {
+ QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
+ if (color == Qt::blue)
+ ++blues;
+ if (color == Qt::red)
+ ++reds;
+ }
+ QCOMPARE(blues, 11);
+ QCOMPARE(reds, 4);
+ }
+
+ void modelReset()
+ {
+ int reds = 0, blues = 0;
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ {
+ QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
+ if (color == Qt::blue)
+ ++blues;
+ if (color == Qt::red)
+ ++reds;
+ }
+ QCOMPARE(reds, 0);
+ QCOMPARE(blues, 0);
+ }
+
+private:
+ QAbstractItemModel * const m_model;
+
+};
+
+void tst_QSortFilterProxyModel::testResetInternalData()
+{
+
+ QStringListModel model(QStringList() << "Monday"
+ << "Tuesday"
+ << "Wednesday"
+ << "Thursday"
+ << "Friday"
+ << "January"
+ << "February"
+ << "March"
+ << "April"
+ << "May"
+ << "Saturday"
+ << "June"
+ << "Sunday"
+ << "July"
+ << "August"
+ << "September"
+ << "October"
+ << "November"
+ << "December");
+
+ CustomDataProxy proxy;
+ proxy.setSourceModel(&model);
+
+ ModelObserver observer(&proxy);
+
+ // Cause the source model to reset.
+ model.setStringList(QStringList() << "Spam" << "Eggs");
+
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index cc3dfc1..77ae27f 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -44,6 +44,7 @@
#include <qtabwidget.h>
#include <qdebug.h>
#include <qapplication.h>
+#include <private/qapplication_p.h>
#include <qlabel.h>
#include <QtGui/qboxlayout.h>
@@ -618,6 +619,10 @@ void tst_QTabWidget::paintEventCount()
QTest::qWait(100);
QCOMPARE(tab1->count, initalPaintCount);
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa sends an extra updates when the view is shown", Abort);
+#endif
QCOMPARE(tab2->count, 1);
tw->setCurrentIndex(0);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 86773ad..ee06b53 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -4054,6 +4054,11 @@ public:
*/
void tst_QWidget::optimizedResizeMove()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("WA_StaticContents in Cocoa/Native paint engine lacks support", SkipAll);
+#endif
+
QWidget parent;
parent.resize(400, 400);
@@ -8260,6 +8265,10 @@ void tst_QWidget::doubleRepaint()
QCOMPARE(widget.numPaintEvents, 0);
widget.numPaintEvents = 0;
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa will send us an update when showing the window", Continue);
+#endif
// Restore: Should not trigger a repaint.
widget.showNormal();
QTest::qWaitForWindowShown(&widget);
@@ -8369,6 +8378,11 @@ public slots:
void tst_QWidget::setMaskInResizeEvent()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("Updates on masked widgets are not optimized for Cocoa/native paint engine", SkipAll);
+#endif
+
UpdateWidget w;
w.reset();
w.resize(200, 200);
@@ -9043,6 +9057,11 @@ void tst_QWidget::setClearAndResizeMask()
void tst_QWidget::maskedUpdate()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("Updates on masked widgets are not optimized for Cocoa/native paint engine", SkipAll);
+#endif
+
UpdateWidget topLevel;
topLevel.resize(200, 200);
const QRegion topLevelMask(50, 50, 70, 70);