summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-06-02 08:54:38 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-06-02 08:54:38 (GMT)
commitb31819a2871f0479da59c01d9fc7469d36120c2b (patch)
tree66a52c719c144295a3adf9d6d7b4cff3a63c13ea /tests
parentd52fb58f34199e9a6e008929425cd21b92a2674a (diff)
parentd018549a25761b5e50d90939d94384f23d7a01e0 (diff)
downloadQt-b31819a2871f0479da59c01d9fc7469d36120c2b.zip
Qt-b31819a2871f0479da59c01d9fc7469d36120c2b.tar.gz
Qt-b31819a2871f0479da59c01d9fc7469d36120c2b.tar.bz2
Merge branch '4.5' of scm.dev.nokia.troll.no:qt/qt
Conflicts: src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp tests/auto/selftests/expected_skip.txt tests/auto/selftests/tst_selftests.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp8
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp65
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp16
-rw-r--r--tests/auto/qicon/tst_qicon.cpp43
4 files changed, 125 insertions, 7 deletions
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index d7ca7bc..6a69fcc 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -462,7 +462,7 @@ void tst_QDataStream::writeQString(QDataStream* s)
{
QString test(QStringData(dataIndex(QTest::currentDataTag())));
*s << test;
- *s << QString("Faen her spyr man");
+ *s << QString("Her er det noe tekst");
*s << test;
*s << QString();
*s << test;
@@ -480,7 +480,7 @@ void tst_QDataStream::readQString(QDataStream *s)
*s >> S;
QCOMPARE(S, test);
*s >> S;
- QCOMPARE(S, QString("Faen her spyr man"));
+ QCOMPARE(S, QString("Her er det noe tekst"));
*s >> S;
QCOMPARE(S, test);
*s >> S;
@@ -533,7 +533,7 @@ void tst_QDataStream::writeQRegExp(QDataStream* s)
{
QRegExp test(QRegExpData(dataIndex(QTest::currentDataTag())));
*s << test;
- *s << QString("Faen her spyr man");
+ *s << QString("Her er det noe tekst");
*s << test;
*s << QString("nonempty");
*s << test;
@@ -550,7 +550,7 @@ void tst_QDataStream::readQRegExp(QDataStream *s)
*s >> R;
QCOMPARE(R, test);
*s >> S;
- QCOMPARE(S, QString("Faen her spyr man"));
+ QCOMPARE(S, QString("Her er det noe tekst"));
*s >> R;
QCOMPARE(R, test);
*s >> S;
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 59d57ce..b109d4b 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include "../../../src/gui/dialogs/qfilesystemmodel_p.h"
#include <QFileIconProvider>
+#include <QTreeView>
#include "../../shared/util.h"
#include <QTime>
#include <QStyle>
@@ -102,6 +103,7 @@ private slots:
void setData_data();
void setData();
+ void sort_data();
void sort();
void mkdir();
@@ -452,8 +454,12 @@ void tst_QFileSystemModel::rowsInserted()
} else {
QCOMPARE(model->index(model->rowCount(root) - 1, 0, root).data().toString(), QString("b"));
}
- if (spy0.count() > 0)
- if (count == 0) QCOMPARE(spy0.count(), 0); else QVERIFY(spy0.count() >= 1);
+ if (spy0.count() > 0) {
+ if (count == 0)
+ QCOMPARE(spy0.count(), 0);
+ else
+ QVERIFY(spy0.count() >= 1);
+ }
if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
QVERIFY(createFiles(tmp, QStringList(".hidden_file"), 5 + count));
@@ -722,6 +728,19 @@ void tst_QFileSystemModel::setData()
QTRY_COMPARE(model->rowCount(root), files.count());
}
+class MyFriendFileSystemModel : public QFileSystemModel
+{
+ friend class tst_QFileSystemModel;
+ Q_DECLARE_PRIVATE(QFileSystemModel)
+};
+
+void tst_QFileSystemModel::sort_data()
+{
+ QTest::addColumn<bool>("fileDialogMode");
+ QTest::newRow("standard usage") << false;
+ QTest::newRow("QFileDialog usage") << true;
+}
+
void tst_QFileSystemModel::sort()
{
QTemporaryFile file;
@@ -733,8 +752,48 @@ void tst_QFileSystemModel::sort()
model->sort(0, Qt::AscendingOrder);
model->sort(0, Qt::DescendingOrder);
QVERIFY(idx.column() != 0);
-}
+ QFETCH(bool, fileDialogMode);
+
+ MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel();
+ QTreeView *tree = new QTreeView();
+
+ if (fileDialogMode)
+ myModel->d_func()->disableRecursiveSort = true;
+
+ const QString dirPath = QString("%1/sortTemp").arg(QDir::tempPath());
+ QDir dir(dirPath);
+ dir.mkpath(dirPath);
+ QVERIFY(dir.exists());
+ dir.mkdir("a");
+ dir.mkdir("b");
+ dir.mkdir("c");
+ dir.mkdir("d");
+ dir.mkdir("e");
+ dir.mkdir("f");
+ dir.mkdir("g");
+ QTemporaryFile tempFile(dirPath + "/rXXXXXX");
+ tempFile.open();
+ myModel->setRootPath(QDir::rootPath());
+ tree->setModel(myModel);
+ tree->show();
+ QTest::qWait(500);
+ tree->expand(myModel->index(dir.absolutePath(), 0));
+ while (dir.cdUp())
+ {
+ tree->expand(myModel->index(dir.absolutePath(), 0));
+ }
+ QTest::qWait(250);
+ //File dialog Mode means sub trees are not sorted, only the current root
+ if (fileDialogMode)
+ QVERIFY(myModel->index(0, 1, myModel->index(dirPath, 0)).data(QFileSystemModel::FilePathRole).toString() != dirPath + QLatin1String("/a"));
+ else
+ QCOMPARE(myModel->index(0, 1, myModel->index(dirPath, 0)).data(QFileSystemModel::FilePathRole).toString(), dirPath + QLatin1String("/a"));
+
+ delete tree;
+ delete myModel;
+
+}
void tst_QFileSystemModel::mkdir()
{
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index a23ada9..56d42c3 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -51,6 +51,7 @@
#include <qlineedit.h>
#include <qboxlayout.h>
#include <qaction.h>
+#include <qwidgetaction.h>
#include "../../shared/util.h"
@@ -153,6 +154,7 @@ private slots:
void popupMouseGrabber();
void windowFlags_data();
void windowFlags();
+ void shortcutsDeletion();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -2266,6 +2268,20 @@ void tst_QGraphicsWidget::windowFlags()
QCOMPARE(widget5->windowFlags(), Qt::WindowFlags(outputFlags));
}
+void tst_QGraphicsWidget::shortcutsDeletion()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsWidget *widget2 = new QGraphicsWidget;
+ widget->setMinimumSize(40, 40);
+ QWidgetAction *del = new QWidgetAction(widget);
+ del->setIcon(QIcon("edit-delete"));
+ del->setShortcut(Qt::Key_Delete);
+ del->setShortcutContext(Qt::WidgetShortcut);
+ widget2->addAction(del);
+ widget2->addAction(del);
+ delete widget;
+}
+
class ProxyStyle : public QCommonStyle
{
public:
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index 4e9a880..1dd223f 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -72,6 +72,8 @@ private slots:
void svg();
void addFile();
void availableSizes();
+ void streamAvailableSizes_data();
+ void streamAvailableSizes();
void task184901_badCache();
void task223279_inconsistentAddFile();
@@ -540,6 +542,47 @@ void tst_QIcon::availableSizes()
}
}
+void tst_QIcon::streamAvailableSizes_data()
+{
+ QTest::addColumn<QIcon>("icon");
+
+ QIcon icon;
+ icon.addFile(":/image.png", QSize(32,32));
+ QTest::newRow( "32x32" ) << icon;
+ icon.addFile(":/image.png", QSize(64,64));
+ QTest::newRow( "64x64" ) << icon;
+ icon.addFile(":/image.png", QSize(128,128));
+ QTest::newRow( "128x128" ) << icon;
+ icon.addFile(":/image.png", QSize(256,256));
+ QTest::newRow( "256x256" ) << icon;
+}
+
+void tst_QIcon::streamAvailableSizes()
+{
+ QFETCH(QIcon, icon);
+
+ QByteArray ba;
+ // write to QByteArray
+ {
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ QDataStream stream(&buffer);
+ stream << icon;
+ }
+
+ // read from QByteArray
+ {
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::ReadOnly);
+ QDataStream stream(&buffer);
+ QIcon i;
+ stream >> i;
+ QCOMPARE(i.isNull(), icon.isNull());
+ QCOMPARE(i.availableSizes(), icon.availableSizes());
+ }
+}
+
+
static inline bool operator<(const QSize &lhs, const QSize &rhs)
{
if (lhs.width() < rhs.width())