From 22ec652ebfb659e8597d4986bd32c3ea82e3e075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 7 Jun 2018 17:07:09 +0200 Subject: QFINDTESTDATA,Android: fix 'relative to test source' When cross-compiling for Android on Windows the 'relative to test source' option could end up possibly matching with a matching folder in root ('/') because file is a Windows path and the canonicalFilePath of that path is "". Fixes tst_qxmlstream (and possibly others) on Android when Qt is compiled on Windows. Task-number: QTBUG-68596 Change-Id: I378374e41eea80f43680b3941adaa91fa604934a Reviewed-by: Jesus Fernandez Reviewed-by: Thiago Macieira Reviewed-by: Ulf Hermann --- src/testlib/qtestcase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index adf4b9e1ef..acd676833e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2135,8 +2135,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) { -- cgit v1.2.3 From e21d1d38564dde337ab60636e28bfe8d5b6e67df Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Jun 2018 09:57:55 +0200 Subject: QtCore/QtNetwork/QTestlib: Fix build with MinGW/g++ 8.1 x64 Fix warnings about invalid function type casts (return types conflicting with the FARPROC returned by GetProcAddress()) like: corelib\global\qoperatingsystemversion_win.cpp:100:48: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'RtlGetVersionFunction' {aka 'long int (*)(_OSVERSIONINFOW*)'} [-Werror=cast-function-type] io\qlockfile_win.cpp:158:85: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'GetModuleFileNameExFunc' {aka 'long unsigned int (*)(void*, HINSTANCE__*, wchar_t*, long unsigned int)'} [-Werror=cast-function-type] by introducing nested casts. Task-number: QTBUG-68742 Task-number: QTQAINFRA-2095 Change-Id: I3a5d2ea901bf5dc35963c589d61cf3dc7393377a Reviewed-by: Timur Pocheptsov --- src/testlib/qtestcase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index acd676833e..f5668c274e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1603,8 +1603,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( + reinterpret_cast(GetProcAddress(m_dbgHelpLib, "SymInitialize"))); + m_symFromAddr = reinterpret_cast( + reinterpret_cast(GetProcAddress(m_dbgHelpLib, "SymFromAddr"))); success = symInitialize && m_symFromAddr && symInitialize(process, NULL, TRUE); } if (!success) -- cgit v1.2.3 From 528a16b00e011261c60bc5c14849f54de33c0e4a Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Jun 2018 15:35:40 +0200 Subject: QAbstractItemModelTester: add missing includes The code (in macros) uses these classes, so the header should ensure they are defined. Change-Id: Ic68fa5559b7c0481927b47775b9cb7da12be7979 Reviewed-by: Jesus Fernandez --- src/testlib/qabstractitemmodeltester.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/testlib') 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 #include +#include +#include #ifdef QT_GUI_LIB #include -- cgit v1.2.3 From 27ea5a65dd3fdabdad1569f5330f90248cdca4f5 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Jun 2018 15:50:35 +0200 Subject: QAbstractItemModelTester: fix out-of-bounds index() calls When removing rows, the tester is looking at the data of the row "just before" and the row "just after" the removed rows, to see if they are still the same at the end of the removal operation. Guard this with bounds check, in case there is no row just before or just after. This is the opportunity to use modeltester in tst_qidentityproxymodel, which was already a testcase for removing the only row in a given parent. Change-Id: Iec8228c16b9c670b794e2665356d153679178494 Reviewed-by: Giuseppe D'Angelo --- src/testlib/qabstractitemmodeltester.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index e970be2c8d..04fa99bc4d 100644 --- a/src/testlib/qabstractitemmodeltester.cpp +++ b/src/testlib/qabstractitemmodeltester.cpp @@ -712,8 +712,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 +741,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) -- cgit v1.2.3 From 4af292fe5158c2d19e8ab1351c71c3940c7f1032 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Jun 2018 16:26:46 +0200 Subject: QAbstractItemModelTester: don't call match(QModelIndex(), ...) The documentation for match() indicates that the index has to be valid since it determines which column to search in (in addition to "from which row"). So call match with a valid index, if the model isn't empty. Change-Id: I5f3754cf14d053bf04d207cefe7dcc938e0f4a5a Reviewed-by: Giuseppe D'Angelo --- src/testlib/qabstractitemmodeltester.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index 04fa99bc4d..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); -- cgit v1.2.3