WinRT: Fix various test compilations

- Remove irrelevant test subdirs via .pro files
- Follow WinCE codepaths where applicable
- Replace unsupported Win32 APIs with WinRT equivalents

This does not aim to fix any failures in the tests themselves; it only
makes them compile.

Change-Id: Ia82bc0cc402891f8f6238d4c261ee9152b51be80
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Andrew Knight 2013-09-01 19:05:46 +03:00 committed by The Qt Project
parent c097670bf8
commit c6af0a504f
46 changed files with 165 additions and 68 deletions

View File

@ -52,3 +52,9 @@ SUBDIRS=\
win32:!contains(QT_CONFIG, private_tests): SUBDIRS -= \
qfilesystementry
winrt: SUBDIRS -= \
qprocess \
qprocess-noapplication \
qprocessenvironment \
qwinoverlappedionotifier

View File

@ -13,5 +13,5 @@ TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \
../Makefile ../forCopying.txt ../forRenaming.txt \
../resources/file1.ext1
win32: LIBS+=-lole32 -luuid
win32:!winrt: LIBS+=-lole32 -luuid
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0

View File

@ -527,7 +527,7 @@ void tst_QFile::open_data()
<< false << QFile::OpenError;
QTest::newRow("noreadfile") << QString::fromLatin1(noReadFile) << int(QIODevice::ReadOnly)
<< false << QFile::OpenError;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
//opening devices requires administrative privileges (and elevation).
HANDLE hTest = CreateFile(_T("\\\\.\\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hTest != INVALID_HANDLE_VALUE) {
@ -1057,7 +1057,7 @@ void tst_QFile::ungetChar()
QCOMPARE(buf[2], '4');
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QString driveLetters()
{
wchar_t volumeName[MAX_PATH];
@ -1094,7 +1094,7 @@ void tst_QFile::invalidFile_data()
#if !defined(Q_OS_WIN)
QTest::newRow( "x11" ) << QString( "qwe//" );
#else
#if !defined(Q_OS_WINCE)
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid");
#endif
QTest::newRow( "colon3" ) << QString( ":failinvalid" );
@ -1338,10 +1338,12 @@ void tst_QFile::copyFallback()
#ifdef Q_OS_WIN
#include <objbase.h>
#ifndef Q_OS_WINPHONE
#include <shlobj.h>
#endif
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static QString getWorkingDirectoryForLink(const QString &linkFileName)
{
bool neededCoInit = false;
@ -1400,7 +1402,7 @@ void tst_QFile::link()
QCOMPARE(QFile::symLinkTarget("myLink.lnk"), referenceTarget);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath());
QCOMPARE(QDir::fromNativeSeparators(wd), QDir::cleanPath(info1.absolutePath()));
#endif
@ -2690,8 +2692,12 @@ void tst_QFile::nativeHandleLeaks()
}
#ifdef Q_OS_WIN
# ifndef Q_OS_WINRT
handle1 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
# else
handle1 = ::CreateFile2(L"qt_file.tmp", GENERIC_READ, 0, OPEN_ALWAYS, NULL);
# endif
QVERIFY( INVALID_HANDLE_VALUE != handle1 );
QVERIFY( ::CloseHandle(handle1) );
#endif
@ -2705,8 +2711,12 @@ void tst_QFile::nativeHandleLeaks()
}
#ifdef Q_OS_WIN
# ifndef Q_OS_WINRT
handle2 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
# else
handle2 = ::CreateFile2(L"qt_file.tmp", GENERIC_READ, 0, OPEN_ALWAYS, NULL);
# endif
QVERIFY( INVALID_HANDLE_VALUE != handle2 );
QVERIFY( ::CloseHandle(handle2) );
#endif

View File

@ -6,5 +6,5 @@ RESOURCES += qfileinfo.qrc
TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resources/file1.ext1 resources/file1.ext1.ext2
win32*:!wince*:LIBS += -ladvapi32 -lnetapi32
win32*:!wince*:!winrt:LIBS += -ladvapi32 -lnetapi32
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0

View File

@ -62,7 +62,7 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
#include <qlibrary.h>
#if !defined(Q_OS_WINCE)
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#include <lm.h>
#endif
#endif
@ -176,7 +176,7 @@ private slots:
void refresh();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void ntfsJunctionPointsAndSymlinks_data();
void ntfsJunctionPointsAndSymlinks();
void brokenShortcut();
@ -193,7 +193,7 @@ private slots:
void detachingOperations();
#if !defined(Q_OS_WINCE)
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void owner();
#endif
void group();
@ -1058,7 +1058,7 @@ void tst_QFileInfo::fileTimes()
//In Vista the last-access timestamp is not updated when the file is accessed/touched (by default).
//To enable this the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisableLastAccessUpdate
//is set to 0, in the test machine.
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
HKEY key;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\FileSystem",
0, KEY_READ, &key)) {
@ -1085,8 +1085,8 @@ void tst_QFileInfo::fileTimes()
void tst_QFileInfo::fileTimes_oldFile()
{
// This is not supported on WinCE
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// This is not supported on WinCE or WinRT
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// All files are opened in share mode (both read and write).
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
@ -1329,7 +1329,7 @@ void tst_QFileInfo::refresh()
QCOMPARE(info2.size(), info.size());
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
{
QTest::addColumn<QString>("path");
@ -1680,7 +1680,7 @@ void tst_QFileInfo::detachingOperations()
QVERIFY(!info1.caching());
}
#if !defined(Q_OS_WINCE)
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#if defined (Q_OS_WIN)
BOOL IsUserAdmin()
{

View File

@ -55,6 +55,7 @@ class tst_QFileSystemWatcher : public QObject
public:
tst_QFileSystemWatcher();
#ifndef QT_NO_FILESYSTEMWATCHER
private slots:
void basicTest_data();
void basicTest();
@ -83,16 +84,20 @@ private slots:
private:
QString m_tempDirPattern;
#endif // QT_NO_FILESYSTEMWATCHER
};
tst_QFileSystemWatcher::tst_QFileSystemWatcher()
{
#ifndef QT_NO_FILESYSTEMWATCHER
m_tempDirPattern = QDir::tempPath();
if (!m_tempDirPattern.endsWith(QLatin1Char('/')))
m_tempDirPattern += QLatin1Char('/');
m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX");
#endif // QT_NO_FILESYSTEMWATCHER
}
#ifndef QT_NO_FILESYSTEMWATCHER
void tst_QFileSystemWatcher::basicTest_data()
{
QTest::addColumn<QString>("backend");
@ -676,6 +681,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
QTRY_COMPARE(changedSpy.count(), 10);
}
#endif // QT_NO_FILESYSTEMWATCHER
QTEST_MAIN(tst_QFileSystemWatcher)
#include "tst_qfilesystemwatcher.moc"

View File

@ -118,7 +118,7 @@ private slots:
#if !defined(Q_OS_WIN) && !defined(QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER)
void dontReorderIniKeysNeedlessly();
#endif
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void consistentRegistryStorage();
#endif
@ -273,7 +273,7 @@ void tst_QSettings::init()
QSettings::setSystemIniPath(settingsPath("__system__"));
QSettings::setUserIniPath(settingsPath("__user__"));
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QSettings("HKEY_CURRENT_USER\\Software\\software.org", QSettings::NativeFormat).clear();
QSettings("HKEY_LOCAL_MACHINE\\Software\\software.org", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\other.software.org", QSettings::NativeFormat).clear();
@ -1501,7 +1501,7 @@ void tst_QSettings::sync()
// Now "some other app" will change other.software.org.ini
QString userConfDir = settingsPath("__user__") + QDir::separator();
#if !defined(Q_OS_WINCE)
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
unlink((userConfDir + "other.software.org.ini").toLatin1());
rename((userConfDir + "software.org.ini").toLatin1(),
(userConfDir + "other.software.org.ini").toLatin1());
@ -3189,7 +3189,7 @@ void tst_QSettings::recursionBug()
}
}
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
static DWORD readKeyType(HKEY handle, const QString &rSubKey)
{

View File

@ -257,7 +257,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir()
void tst_QTemporaryDir::openOnRootDrives()
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
#endif
// If it's possible to create a file in the root directory, it
@ -271,7 +271,7 @@ void tst_QTemporaryDir::openOnRootDrives()
QVERIFY(dir.isValid());
}
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
SetErrorMode(lastErrorMode);
#endif
}

View File

@ -371,7 +371,7 @@ void tst_QTemporaryFile::resize()
void tst_QTemporaryFile::openOnRootDrives()
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
#endif
// If it's possible to create a file in the root directory, it
@ -385,7 +385,7 @@ void tst_QTemporaryFile::openOnRootDrives()
QVERIFY(file.open());
}
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
SetErrorMode(lastErrorMode);
#endif
}

View File

@ -31,6 +31,6 @@ SUBDIRS=\
qsharedmemory
# This test is only applicable on Windows
!win32*:SUBDIRS -= qwineventnotifier
!win32*|winrt: SUBDIRS -= qwineventnotifier
android|qnx: SUBDIRS -= qsharedmemory qsystemsemaphore

View File

@ -4,7 +4,7 @@ TARGET = tst_qeventloop
QT = core network testlib core-private
SOURCES = $$PWD/tst_qeventloop.cpp
win32:!wince*:LIBS += -luser32
win32:!wince*:!winrt:LIBS += -luser32
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
contains(QT_CONFIG, glib): DEFINES += HAVE_GLIB

View File

@ -6,11 +6,11 @@ SOURCES = tst_qmetatype.cpp
TESTDATA=./typeFlags.bin
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
win32-msvc*|wince {
win32-msvc*|wince|winrt {
# Prevents "fatal error C1128: number of sections exceeded object file format limit".
QMAKE_CXXFLAGS += /bigobj
# Reduce compile time
win32-msvc2012|wince {
win32-msvc2012|wince|winrt {
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CFLAGS_RELEASE -= -O2
}

View File

@ -52,6 +52,8 @@
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
#include <windows.h>
#define sleep(X) Sleep(X)
#elif defined(Q_OS_WINRT)
#define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE);
#endif
//on solaris, threads that loop on the release bool variable

View File

@ -232,7 +232,7 @@ void tst_QThreadStorage::adoptedThreads()
const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers);
QCOMPARE(state, 0);
pthread_join(thread, 0);
#elif defined Q_OS_WIN
#elif defined Q_OS_WIN && !defined(Q_OS_WINRT)
HANDLE thread;
#if defined(Q_OS_WINCE)
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)testAdoptedThreadStorageWin, &pointers, 0, NULL);

View File

@ -546,6 +546,9 @@ void tst_QCommandLineParser::testHelpOption()
void tst_QCommandLineParser::testQuoteEscaping()
{
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
QCoreApplication app(empty_argc, empty_argv);
QProcess process;
process.start("testhelper/qcommandlineparser_test_helper", QStringList() <<
@ -561,6 +564,7 @@ void tst_QCommandLineParser::testQuoteEscaping()
QVERIFY2(output.contains("KEY2=\\\"VALUE2\\\""), qPrintable(output));
QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output));
QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output));
#endif // !QT_NO_PROCESS
}
QTEST_APPLESS_MAIN(tst_QCommandLineParser)

View File

@ -49,6 +49,9 @@
#ifdef Q_OS_WIN
# include <windows.h>
# if defined(Q_OS_WINRT)
# define tzset()
# endif
#endif
class tst_QDateTime : public QObject
@ -173,7 +176,7 @@ void tst_QDateTime::init()
{
#if defined(Q_OS_WINCE)
SetUserDefaultLCID(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
#elif defined(Q_OS_WIN)
#elif defined(Q_OS_WIN32)
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
#endif
}

View File

@ -133,7 +133,7 @@ public:
private slots:
void initTestCase();
void cleanupTestCase();
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void windowsDefaultLocale();
#endif
#ifdef Q_OS_MAC
@ -1472,7 +1472,7 @@ void tst_QLocale::macDefaultLocale()
}
#endif // Q_OS_MAC
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
#include <qt_windows.h>
static QString getWinLocaleInfo(LCTYPE type)
@ -1526,7 +1526,7 @@ public:
#endif // Q_OS_WIN
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void tst_QLocale::windowsDefaultLocale()
{
RestoreLocaleHelper systemLocale;

View File

@ -5,7 +5,7 @@ QT += core-private gui-private testlib
qtHaveModule(widgets): QT += widgets widgets-private
SOURCES += tst_qpixmap.cpp
!wince* {
!wince*:!winrt {
win32:LIBS += -lgdi32 -luser32
}

View File

@ -116,7 +116,7 @@ private slots:
void convertFromImageDetach();
void convertFromImageCacheKey();
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void toWinHBITMAP_data();
void toWinHBITMAP();
void fromWinHBITMAP_data();
@ -805,7 +805,7 @@ void tst_QPixmap::convertFromImageCacheKey()
QCOMPARE(copy.cacheKey(), pix.cacheKey());
}
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
@ -1024,7 +1024,7 @@ void tst_QPixmap::fromWinHICON()
#endif // Q_OS_WINCE
}
#endif // Q_OS_WIN
#endif // Q_OS_WIN && !Q_OS_WINRT
void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()
{

View File

@ -50,6 +50,9 @@
#include <qdatastream.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
# if defined(Q_OS_WINRT)
# include <winsock2.h>
# endif
#endif
class tst_QHostAddress : public QObject

View File

@ -67,7 +67,7 @@
#include <time.h>
#include <qlibrary.h>
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
#if defined(Q_OS_WIN)
#include <windows.h>
#else
#include <unistd.h>

View File

@ -55,11 +55,14 @@
#include <QtSql/private/qsqldriver_p.h>
#include <QtTest/QtTest>
#if defined (Q_OS_WIN) || defined (Q_OS_WIN32)
#if defined(Q_OS_WIN)
# include <qt_windows.h>
# if defined (Q_OS_WINCE)
# if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# include <winsock2.h>
# endif
# if defined(Q_OS_WINRT) && !defined(Q_OS_WINPHONE)
static inline int gethostname(char *name, int len) { qstrcpy(name, "localhost"); return 9; }
# endif
#else
#include <unistd.h>
#endif

View File

@ -57,7 +57,7 @@ private slots:
void tst_Crashes::crash()
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
//we avoid the error dialogbox to appear on windows
SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif

View File

@ -416,7 +416,14 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi
wchar_t nativeHiddenFile[MAX_PATH];
memset(nativeHiddenFile, 0, sizeof(nativeHiddenFile));
hiddenFile.toWCharArray(nativeHiddenFile);
#ifndef Q_OS_WINRT
DWORD currentAttributes = ::GetFileAttributes(nativeHiddenFile);
#else // !Q_OS_WINRT
WIN32_FILE_ATTRIBUTE_DATA attributeData;
if (!::GetFileAttributesEx(nativeHiddenFile, GetFileExInfoStandard, &attributeData))
attributeData.dwFileAttributes = 0xFFFFFFFF;
DWORD currentAttributes = attributeData.dwFileAttributes;
#endif // Q_OS_WINRT
if (currentAttributes == 0xFFFFFFFF) {
qErrnoWarning("failed to get file attributes: %s", qPrintable(hiddenFile));
return false;

View File

@ -5,5 +5,5 @@ QT += core-private gui-private
SOURCES += tst_qgraphicsitem.cpp
DEFINES += QT_NO_CAST_TO_ASCII
win32:!wince*: LIBS += -luser32
win32:!wince*:!winrt: LIBS += -luser32
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0

View File

@ -71,7 +71,7 @@ Q_DECLARE_METATYPE(QPainterPath)
#include "../../../qtest-config.h"
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#include <windows.h>
#define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \

View File

@ -4,7 +4,7 @@ QT += widgets widgets-private testlib
QT += core-private gui-private
SOURCES += tst_qgraphicsscene.cpp
RESOURCES += images.qrc
win32:!wince*: LIBS += -luser32
win32:!wince*:!winrt: LIBS += -luser32
!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\"
DEFINES += QT_NO_CAST_TO_ASCII

View File

@ -54,7 +54,7 @@
#include "../../../shared/platforminputcontext.h"
#include <private/qinputmethod_p.h>
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#include <windows.h>
#define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \

View File

@ -3,4 +3,4 @@ TARGET = tst_qitemdelegate
QT += widgets testlib
SOURCES += tst_qitemdelegate.cpp
win32:!wince*: LIBS += -luser32
win32:!wince*:!winrt: LIBS += -luser32

View File

@ -66,7 +66,7 @@
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#include <windows.h>
#define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \

View File

@ -2,4 +2,4 @@ CONFIG += testcase
TARGET = tst_qlistview
QT += widgets gui-private widgets-private core-private testlib
SOURCES += tst_qlistview.cpp
win32:!wince*: LIBS += -luser32
win32:!wince*:!winrt: LIBS += -luser32

View File

@ -1484,7 +1484,7 @@ void tst_QListView::wordWrap()
QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), true);
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
class SetCurrentIndexAfterAppendRowCrashDialog : public QDialog
{
Q_OBJECT
@ -1525,7 +1525,7 @@ private:
};
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && WINVER >= 0x0500
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && WINVER >= 0x0500
// This test only makes sense on windows 2000 and higher.
void tst_QListView::setCurrentIndexAfterAppendRowCrash()
{

View File

@ -1891,7 +1891,7 @@ void tst_QApplication::windowsCommandLine_data()
void tst_QApplication::windowsCommandLine()
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QFETCH(QString, args);
QFETCH(QString, expected);

View File

@ -20,7 +20,7 @@ x11 {
LIBS += $$QMAKE_LIBS_X11
}
!wince*:win32: LIBS += -luser32 -lgdi32
!wince*:win32:!winrt: LIBS += -luser32 -lgdi32
mac:CONFIG+=insignificant_test # QTBUG-25300, QTBUG-23695
linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC # QTBUG-30566

View File

@ -116,11 +116,13 @@ static bool qt_wince_is_platform(const QString &platformString) {
}
static inline bool qt_wince_is_smartphone() { return qt_wince_is_platform(QString::fromLatin1("Smartphone")); }
# endif // Q_OS_WINCE_WM
# else // Q_OS_WINCE
# elif !defined(Q_OS_WINRT) // Q_OS_WINCE
# define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \
QSKIP("desktop is not visible, this test would fail");
# endif // !Q_OS_WINCE
# else // !Q_OS_WINCE && !Q_OS_WINRT
# define Q_CHECK_PAINTEVENTS
# endif // Q_OS_WINRT
#else // Q_OS_WIN
# define Q_CHECK_PAINTEVENTS
#endif // else Q_OS_WIN
@ -285,7 +287,7 @@ private slots:
void subtractOpaqueSiblings();
#endif
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void setGeometry_win();
#endif
@ -355,7 +357,7 @@ private slots:
void quitOnCloseAttribute();
void moveRect();
#if defined (Q_OS_WIN)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
void gdiPainting();
void paintOnScreenPossible();
#endif
@ -572,7 +574,7 @@ void tst_QWidget::getSetCheck()
QCOMPARE(true, obj1.autoFillBackground());
var1.reset();
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
obj1.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
const HWND handle = reinterpret_cast<HWND>(obj1.winId()); // explicitly create window handle
QVERIFY(GetWindowLong(handle, GWL_STYLE) & WS_POPUP);
@ -1257,7 +1259,7 @@ void tst_QWidget::visible_setWindowOpacity()
testWidget->hide();
QVERIFY( !testWidget->isVisible() );
testWidget->setWindowOpacity(0.5);
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QVERIFY(!::IsWindowVisible(winHandleOf(testWidget)));
#endif
testWidget->setWindowOpacity(1.0);
@ -3597,7 +3599,7 @@ void tst_QWidget::optimizedResize_topLevel()
topLevel.partial = false;
topLevel.paintedRegion = QRegion();
#ifndef Q_OS_WIN
#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)
topLevel.resize(topLevel.size() + QSize(10, 10));
#else
// Static contents does not work when programmatically resizing
@ -4529,7 +4531,7 @@ void tst_QWidget::setWindowGeometry()
}
}
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void tst_QWidget::setGeometry_win()
{
QWidget widget;
@ -4548,7 +4550,7 @@ void tst_QWidget::setGeometry_win()
QEXPECT_FAIL("", "QTBUG-26424", Continue);
QVERIFY(rt.top <= 0);
}
#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE)
#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// Since X11 WindowManager operation are all async, and we have no way to know if the window
// manager has finished playing with the window geometry, this test can't be reliable on X11.
@ -8047,7 +8049,7 @@ void tst_QWidget::moveRect()
child.move(10, 10); // Don't crash.
}
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
class GDIWidget : public QDialog
{
Q_OBJECT
@ -8114,7 +8116,7 @@ void tst_QWidget::paintOnScreenPossible()
w2.setAttribute(Qt::WA_PaintOnScreen);
QVERIFY(w2.testAttribute(Qt::WA_PaintOnScreen));
}
#endif // Q_OS_WIN
#endif // Q_OS_WIN && !Q_OS_WINRT
void tst_QWidget::reparentStaticWidget()
{

View File

@ -346,7 +346,7 @@ void tst_QDateTimeEdit::cleanupTestCase()
void tst_QDateTimeEdit::init()
{
QLocale::setDefault(QLocale(QLocale::C));
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
#endif
testWidget->setDisplayFormat("dd/MM/yyyy"); // Nice default to have

View File

@ -8,4 +8,4 @@ INCLUDEPATH += ../
HEADERS +=
SOURCES += tst_qtabwidget.cpp
win32:!wince*:LIBS += -luser32
win32:!wince*:!winrt:LIBS += -luser32

View File

@ -48,7 +48,7 @@
#include <qlabel.h>
#include <QtWidgets/qboxlayout.h>
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \

View File

@ -76,7 +76,11 @@ const QString PI_PulseTestrBranch(QLS("PulseTestrBranch"));
void BaselineProtocol::sysSleep(int ms)
{
#if defined(Q_OS_WIN)
# ifndef Q_OS_WINRT
Sleep(DWORD(ms));
# else
WaitForSingleObjectEx(GetCurrentThread(), ms, false);
# endif
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
nanosleep(&ts, NULL);
@ -116,6 +120,7 @@ PlatformInfo PlatformInfo::localHostInfo()
pi.insert(PI_OSName, QLS("Other"));
#endif
#ifndef QT_NO_PROCESS
QProcess git;
QString cmd;
QStringList args;
@ -151,6 +156,7 @@ PlatformInfo PlatformInfo::localHostInfo()
pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb));
}
}
#endif // !QT_NO_PROCESS
return pi;
}

View File

@ -176,7 +176,12 @@ private slots:
wcscat(appendedPath, L"\\*");
WIN32_FIND_DATA fd;
#ifndef Q_OS_WINRT
HANDLE hSearch = FindFirstFileW(appendedPath, &fd);
#else
HANDLE hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
#endif
QVERIFY(hSearch != INVALID_HANDLE_VALUE);
QBENCHMARK {

View File

@ -106,7 +106,12 @@ static int posix_helper(const wchar_t *dirpath)
wchar_t appendedPath[MAX_PATH];
wcscpy(appendedPath, dirpath);
wcscat(appendedPath, L"\\*");
#ifndef Q_OS_WINRT
hSearch = FindFirstFile(appendedPath, &fd);
#else
hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
#endif
appendedPath[origDirPathLength] = 0;
if (hSearch == INVALID_HANDLE_VALUE) {

View File

@ -230,7 +230,12 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
wchar_t szSearchPath[MAX_PATH];
QString::fromLatin1(path).toWCharArray(szSearchPath);
wcscat(szSearchPath, L"\\*");
#ifndef Q_OS_WINRT
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
#else
HANDLE dir = FindFirstFileEx(szSearchPath, FindExInfoStandard, &m_fileSearchResult,
FindExSearchLimitToDirectories, NULL, FIND_FIRST_EX_LARGE_FETCH);
#endif
m_bFirstSearchResult = true;
#else
DIR *dir = ::opendir(path.constData());

View File

@ -310,7 +310,11 @@ void tst_qfile::readBigFile()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
#else
hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
#endif
Q_ASSERT(hndl);
wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;
@ -319,7 +323,12 @@ void tst_qfile::readBigFile()
do {
ReadFile(hndl, nativeBuffer, blockSize, &numberOfBytesRead, NULL);
} while(numberOfBytesRead != 0);
#ifndef Q_OS_WINRT
SetFilePointer(hndl, 0, NULL, FILE_BEGIN);
#else
LARGE_INTEGER offset = { 0 };
SetFilePointerEx(hndl, offset, NULL, FILE_BEGIN);
#endif
}
delete[] nativeBuffer;
CloseHandle(hndl);
@ -400,11 +409,20 @@ void tst_qfile::seek()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
#else
hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
#endif
Q_ASSERT(hndl);
QBENCHMARK {
i=(i+1)%sp_size;
#ifndef Q_OS_WINRT
SetFilePointer(hndl, seekpos[i], NULL, 0);
#else
LARGE_INTEGER offset = { seekpos[i] };
SetFilePointerEx(hndl, offset, NULL, FILE_BEGIN);
#endif
}
CloseHandle(hndl);
#else
@ -489,7 +507,11 @@ void tst_qfile::open()
wchar_t* cfilename = (wchar_t*)filename.utf16();
QBENCHMARK {
#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
#else
hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
#endif
Q_ASSERT(hndl);
CloseHandle(hndl);
}
@ -698,7 +720,11 @@ void tst_qfile::readSmallFiles()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
#else
hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
#endif
Q_ASSERT(hndl);
wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;

View File

@ -54,7 +54,7 @@ class qfileinfo : public QObject
private slots:
void existsTemporary();
void existsStatic();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void symLinkTargetPerformanceLNK();
void symLinkTargetPerformanceMounpoint();
#endif
@ -84,7 +84,7 @@ void qfileinfo::existsStatic()
QBENCHMARK { QFileInfo::exists(appPath); }
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void qfileinfo::symLinkTargetPerformanceLNK()
{
QVERIFY(QFile::link("file","link.lnk"));

View File

@ -93,7 +93,11 @@ void NativeMutexUnlock(NativeMutexType *mutex)
typedef CRITICAL_SECTION NativeMutexType;
void NativeMutexInitialize(NativeMutexType *mutex)
{
#ifndef Q_OS_WINRT
InitializeCriticalSection(mutex);
#else
InitializeCriticalSectionEx(mutex, 0, 0);
#endif
}
void NativeMutexDestroy(NativeMutexType *mutex)
{

View File

@ -92,7 +92,7 @@ public:
return file.isNull() ? qint64(-1) : file->write(relativeFileName.toUtf8());
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static void createNtfsJunction(QString target, QString linkName)
{
typedef struct {