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 <gzjjgod@gmail.com> Reviewed-by: Liang Qi <liang.qi@digia.com>
This commit is contained in:
parent
e0fc088c0c
commit
698ae963e4
@ -82,10 +82,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <Carbon/Carbon.h> // for SetFrontProcess
|
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
#undef verify
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -2080,7 +2078,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
|||||||
int callgrindChildExitCode = 0;
|
int callgrindChildExitCode = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
|
bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
|
||||||
IOPMAssertionID powerID;
|
IOPMAssertionID powerID;
|
||||||
#endif
|
#endif
|
||||||
@ -2095,14 +2093,11 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
|||||||
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
|
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_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.
|
|
||||||
if (macNeedsActivate) {
|
if (macNeedsActivate) {
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
CFStringRef reasonForActivity= CFSTR("No Display Sleep");
|
||||||
SetFrontProcess(&psn);
|
IOReturn ok = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &powerID);
|
||||||
IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
|
|
||||||
if (ok != kIOReturnSuccess)
|
if (ok != kIOReturnSuccess)
|
||||||
macNeedsActivate = false; // no need to release the assertion on exit.
|
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();
|
QTestLog::stopLogging();
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
if (macNeedsActivate) {
|
if (macNeedsActivate) {
|
||||||
IOPMAssertionRelease(powerID);
|
IOPMAssertionRelease(powerID);
|
||||||
}
|
}
|
||||||
@ -2168,7 +2163,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
|||||||
|
|
||||||
QSignalDumper::endDump();
|
QSignalDumper::endDump();
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
if (macNeedsActivate) {
|
if (macNeedsActivate) {
|
||||||
IOPMAssertionRelease(powerID);
|
IOPMAssertionRelease(powerID);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,7 @@ wince*::LIBS += libcmt.lib \
|
|||||||
mac {
|
mac {
|
||||||
LIBS += -framework IOKit -framework Security
|
LIBS += -framework IOKit -framework Security
|
||||||
!ios {
|
!ios {
|
||||||
LIBS_PRIVATE += -framework CoreServices
|
|
||||||
LIBS += -framework ApplicationServices
|
LIBS += -framework ApplicationServices
|
||||||
} else {
|
|
||||||
LIBS_PRIVATE += -framework CoreFoundation
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user