summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-13 01:05:02 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-13 01:05:02 +0200
commit6b8f422c5e56b95aad298e1b984fb60fba1da282 (patch)
tree545dac994ef985cc91d92fa77da21581b6762c86 /tests
parentd04982dc84d66bec92b4b3767538676cf925ef17 (diff)
parentd9e66f63a95b24ce3a7d2a30ccaf4dcab85d55a0 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/corelib/global/qglobal.cpp src/corelib/io/qsettings.cpp src/corelib/itemmodels/qstringlistmodel.cpp tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp10
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp77
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp13
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp5
5 files changed, 69 insertions, 38 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 411c73fb90..d6bc75317a 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -2543,7 +2543,7 @@ void tst_QFile::rename()
\since 4.5
Some special files have QFile::atEnd() returning true, even though there is
- more data available. True for corner cases, as well as some mounts on OS X.
+ more data available. True for corner cases, as well as some mounts on \macos.
Here, we reproduce that condition by having a QFile sub-class with this
peculiar atEnd() behavior.
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 04a7129f01..38e3c6890d 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -2129,17 +2129,23 @@ void tst_QSortFilterProxyModel::changeSourceDataForwardsRoles_qtbug35440()
QModelIndex index;
+ // QStringListModel doesn't distinguish between edit and display roles,
+ // so changing one always changes the other, too.
+ QVector<int> expectedChangedRoles;
+ expectedChangedRoles.append(Qt::DisplayRole);
+ expectedChangedRoles.append(Qt::EditRole);
+
index = model.index(0, 0);
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring"), Qt::DisplayRole);
QCOMPARE(spy.length(), 1);
- QCOMPARE(spy.at(0).at(2).value<QVector<int> >(), QVector<int>() << Qt::DisplayRole);
+ QCOMPARE(spy.at(0).at(2).value<QVector<int> >(), expectedChangedRoles);
index = model.index(1, 0);
QVERIFY(index.isValid());
model.setData(index, QStringLiteral("teststring2"), Qt::EditRole);
QCOMPARE(spy.length(), 2);
- QCOMPARE(spy.at(1).at(2).value<QVector<int> >(), QVector<int>() << Qt::EditRole);
+ QCOMPARE(spy.at(1).at(2).value<QVector<int> >(), expectedChangedRoles);
}
void tst_QSortFilterProxyModel::sortFilterRole()
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index 61dda782d8..f99241da3b 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -35,6 +35,8 @@
#include "qmodellistener.h"
#include <qstringlistmodel.h>
+#include <algorithm>
+
void QModelListener::rowsAboutToBeRemovedOrInserted(const QModelIndex & parent, int start, int end )
{
for (int i = 0; start + i <= end; i++) {
@@ -75,6 +77,9 @@ private slots:
void rowsAboutToBeInserted_rowsInserted();
void rowsAboutToBeInserted_rowsInserted_data();
+
+ void setData_emits_both_roles_data();
+ void setData_emits_both_roles();
};
void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
@@ -129,22 +134,19 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved()
QFETCH(QStringList, aboutto);
QFETCH(QStringList, res);
- QStringListModel *model = new QStringListModel(input);
- QModelListener *pListener = new QModelListener(&aboutto, &res, model);
- pListener->connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- pListener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)) );
+ QStringListModel model(input);
+ QModelListener listener(&aboutto, &res, &model);
+ connect(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ &listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
- pListener->connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- pListener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)) );
+ connect(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ &listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
- model->removeRows(row,count);
+ model.removeRows(row, count);
// At this point, control goes to our connected slots inn this order:
// 1. rowsAboutToBeRemovedOrInserted
// 2. rowsRemovedOrInserted
// Control returns here
-
- delete pListener;
- delete model;
}
void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data()
@@ -193,22 +195,59 @@ void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted()
QFETCH(QStringList, aboutto);
QFETCH(QStringList, res);
- QStringListModel *model = new QStringListModel(input);
- QModelListener *pListener = new QModelListener(&aboutto, &res, model);
- connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- pListener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)) );
+ QStringListModel model(input);
+ QModelListener listener(&aboutto, &res, &model);
+ connect(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+ &listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
- pListener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)) );
+ connect(&model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ &listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
- model->insertRows(row,count);
+ model.insertRows(row, count);
// At this point, control goes to our connected slots inn this order:
// 1. rowsAboutToBeRemovedOrInserted
// 2. rowsRemovedOrInserted
// Control returns here
+}
- delete pListener;
- delete model;
+void tst_QStringListModel::setData_emits_both_roles_data()
+{
+ QTest::addColumn<int>("row");
+ QTest::addColumn<QString>("data");
+ QTest::addColumn<int>("role");
+
+#define ROW(row, string, role) \
+ QTest::newRow(#row " -> " string) << row << QString(string) << int(Qt::role)
+ ROW(0, "1", EditRole);
+ ROW(1, "2", DisplayRole);
+#undef ROW
+}
+
+template <class C>
+C sorted(C c)
+{
+ std::sort(c.begin(), c.end());
+ return qMove(c);
+}
+
+void tst_QStringListModel::setData_emits_both_roles()
+{
+ QFETCH(int, row);
+ QFETCH(QString, data);
+ QFETCH(int, role);
+
+ QStringListModel model(QStringList() << "one" << "two");
+ QVector<int> expected;
+ expected.reserve(2);
+ expected.append(Qt::DisplayRole);
+ expected.append(Qt::EditRole);
+
+ QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
+ QVERIFY(spy.isValid());
+ model.setData(model.index(row, 0), data, role);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(sorted(spy.at(0).at(2).value<QVector<int> >()),
+ expected);
}
QTEST_MAIN(tst_QStringListModel)
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index 4bf79cab05..7a94217641 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -55,9 +55,6 @@ class tst_QImageWriter : public QObject
{
Q_OBJECT
-public:
- virtual ~tst_QImageWriter();
-
public slots:
void initTestCase();
@@ -155,16 +152,6 @@ void tst_QImageWriter::getSetCheck()
QCOMPARE(1.1f, obj1.gamma());
}
-tst_QImageWriter::~tst_QImageWriter()
-{
- QDir dir(prefix);
- QStringList filesToDelete = dir.entryList(QStringList() << "gen-*" , QDir::NoDotAndDotDot | QDir::Files);
- foreach( QString file, filesToDelete) {
- QFile::remove(dir.absoluteFilePath(file));
- }
-
-}
-
void tst_QImageWriter::writeImage_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index e85c6b9922..f36528f17d 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1384,7 +1384,8 @@ void tst_QSslSocket::setLocalCertificateChain()
QEventLoop loop;
QTimer::singleShot(5000, &loop, SLOT(quit()));
- socket = new QSslSocket();
+ const QScopedPointer<QSslSocket, QScopedPointerDeleteLater> client(new QSslSocket);
+ socket = client.data();
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
@@ -1396,8 +1397,6 @@ void tst_QSslSocket::setLocalCertificateChain()
QCOMPARE(chain.size(), 2);
QCOMPARE(chain[0].serialNumber(), QByteArray("10:a0:ad:77:58:f6:6e:ae:46:93:a3:43:f9:59:8a:9e"));
QCOMPARE(chain[1].serialNumber(), QByteArray("3b:eb:99:c5:ea:d8:0b:5d:0b:97:5d:4f:06:75:4b:e1"));
-
- socket->deleteLater();
}
void tst_QSslSocket::setPrivateKey()