summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qabstractitemmodeltester.cpp24
-rw-r--r--src/testlib/qabstractitemmodeltester.h2
-rw-r--r--src/testlib/qtestcase.cpp11
3 files changed, 27 insertions, 10 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp
index e970be2c8d..fc6f696ecd 100644
--- a/src/testlib/qabstractitemmodeltester.cpp
+++ b/src/testlib/qabstractitemmodeltester.cpp
@@ -322,9 +322,10 @@ void QAbstractItemModelTesterPrivate::nonDestructiveBasicTest()
Qt::ItemFlags flags = model->flags(QModelIndex());
MODELTESTER_VERIFY(flags == Qt::ItemIsDropEnabled || flags == 0);
model->hasChildren(QModelIndex());
- model->hasIndex(0, 0);
+ const bool hasRow = model->hasIndex(0, 0);
QVariant cache;
- model->match(QModelIndex(), -1, cache);
+ if (hasRow)
+ model->match(model->index(0, 0), -1, cache);
model->mimeTypes();
MODELTESTER_VERIFY(!model->parent(QModelIndex()).isValid());
MODELTESTER_VERIFY(model->rowCount() >= 0);
@@ -712,8 +713,17 @@ void QAbstractItemModelTesterPrivate::rowsAboutToBeRemoved(const QModelIndex &pa
Changing c;
c.parent = parent;
c.oldSize = model->rowCount(parent);
- c.last = model->data(model->index(start - 1, 0, parent));
- c.next = model->data(model->index(end + 1, 0, parent));
+ if (start > 0) {
+ const QModelIndex startIndex = model->index(start - 1, 0, parent);
+ MODELTESTER_VERIFY(startIndex.isValid());
+ c.last = model->data(startIndex);
+ }
+ if (end < c.oldSize - 1) {
+ const QModelIndex endIndex = model->index(end + 1, 0, parent);
+ MODELTESTER_VERIFY(endIndex.isValid());
+ c.next = model->data(endIndex);
+ }
+
remove.push(c);
}
@@ -732,8 +742,10 @@ void QAbstractItemModelTesterPrivate::rowsRemoved(const QModelIndex &parent, int
Changing c = remove.pop();
MODELTESTER_COMPARE(parent, c.parent);
MODELTESTER_COMPARE(model->rowCount(parent), c.oldSize - (end - start + 1));
- MODELTESTER_COMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
- MODELTESTER_COMPARE(model->data(model->index(start, 0, c.parent)), c.next);
+ if (start > 0)
+ MODELTESTER_COMPARE(model->data(model->index(start - 1, 0, c.parent)), c.last);
+ if (end < c.oldSize - 1)
+ MODELTESTER_COMPARE(model->data(model->index(start, 0, c.parent)), c.next);
}
void QAbstractItemModelTesterPrivate::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
diff --git a/src/testlib/qabstractitemmodeltester.h b/src/testlib/qabstractitemmodeltester.h
index 07bc170a7a..757074c6ae 100644
--- a/src/testlib/qabstractitemmodeltester.h
+++ b/src/testlib/qabstractitemmodeltester.h
@@ -42,6 +42,8 @@
#include <QtCore/QObject>
#include <QtTest/qttestglobal.h>
+#include <QtCore/QAbstractItemModel>
+#include <QtCore/QVariant>
#ifdef QT_GUI_LIB
#include <QtGui/QFont>
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 469c423109..7a74afce91 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1634,8 +1634,10 @@ DebugSymbolResolver::DebugSymbolResolver(HANDLE process)
bool success = false;
m_dbgHelpLib = LoadLibraryW(L"dbghelp.dll");
if (m_dbgHelpLib) {
- SymInitializeType symInitialize = (SymInitializeType)(GetProcAddress(m_dbgHelpLib, "SymInitialize"));
- m_symFromAddr = (SymFromAddrType)(GetProcAddress(m_dbgHelpLib, "SymFromAddr"));
+ SymInitializeType symInitialize = reinterpret_cast<SymInitializeType>(
+ reinterpret_cast<QFunctionPointer>(GetProcAddress(m_dbgHelpLib, "SymInitialize")));
+ m_symFromAddr = reinterpret_cast<SymFromAddrType>(
+ reinterpret_cast<QFunctionPointer>(GetProcAddress(m_dbgHelpLib, "SymFromAddr")));
success = symInitialize && m_symFromAddr && symInitialize(process, NULL, TRUE);
}
if (!success)
@@ -2166,8 +2168,9 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
srcdir.setFile(QFile::decodeName(builddir) + QLatin1String("/") + srcdir.filePath());
}
- QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base);
- if (QFileInfo::exists(candidate)) {
+ const QString canonicalPath = srcdir.canonicalFilePath();
+ QString candidate = QString::fromLatin1("%1/%2").arg(canonicalPath, base);
+ if (!canonicalPath.isEmpty() && QFileInfo::exists(candidate)) {
found = candidate;
}
else if (QTestLog::verboseLevel() >= 2) {