From 698ae963e4cbb6c5d9239d0a10efc0cb910fa310 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 9 Jul 2012 13:00:45 +0200 Subject: Update mac-specific code in qtestlib for Qt5 1. Remove the code for activate application, due to Qt 5 already has this feature 2. Update the code for power setting Task-number: QTBUG-23267 Change-Id: Id257c2e10e8e750a4b68cd2995c2ac4b70f8910c Reviewed-by: Jiang Jiang Reviewed-by: Liang Qi --- src/testlib/qtestcase.cpp | 21 ++++++++------------- src/testlib/testlib.pro | 3 --- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 6ff449fbcb..025710b3b7 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -82,10 +82,8 @@ #include #endif -#ifdef Q_WS_MAC -#include // for SetFrontProcess +#ifdef Q_OS_MAC #include -#undef verify #endif QT_BEGIN_NAMESPACE @@ -2080,7 +2078,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) int callgrindChildExitCode = 0; #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0); IOPMAssertionID powerID; #endif @@ -2095,14 +2093,11 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); #endif -#ifdef Q_WS_MAC - // Starting with Qt 4.4, applications launched from the command line - // no longer get focus automatically. Since some tests might depend - // on this, call SetFrontProcess here to get the pre 4.4 behavior. +#ifdef Q_OS_MAC if (macNeedsActivate) { - ProcessSerialNumber psn = { 0, kCurrentProcess }; - SetFrontProcess(&psn); - IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID); + CFStringRef reasonForActivity= CFSTR("No Display Sleep"); + IOReturn ok = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &powerID); + if (ok != kIOReturnSuccess) macNeedsActivate = false; // no need to release the assertion on exit. } @@ -2151,7 +2146,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) } QTestLog::stopLogging(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (macNeedsActivate) { IOPMAssertionRelease(powerID); } @@ -2168,7 +2163,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) QSignalDumper::endDump(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (macNeedsActivate) { IOPMAssertionRelease(powerID); } diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 06d7612185..6d29e8e86a 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -68,10 +68,7 @@ wince*::LIBS += libcmt.lib \ mac { LIBS += -framework IOKit -framework Security !ios { - LIBS_PRIVATE += -framework CoreServices LIBS += -framework ApplicationServices - } else { - LIBS_PRIVATE += -framework CoreFoundation } } -- cgit v1.2.3