QtTestLib: use new qEnvironmentVariableIsEmpty()

Except where using the contents of the variable, in which case
collapse two calls to qgetenv() for the same variable into one
that stores the result in a temporary QByteArray and continues
working with that one instead.

Change-Id: I6c09a20ae946327ccb85e4833a60a373a8a07355
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2012-08-07 00:18:45 +02:00 committed by Qt by Nokia
parent bdd682ea4c
commit a2fbe8056c

View File

@ -1084,7 +1084,7 @@ QT_BEGIN_NAMESPACE
static bool installCoverageTool(const char * appname, const char * testname) static bool installCoverageTool(const char * appname, const char * testname)
{ {
#ifdef __COVERAGESCANNER__ #ifdef __COVERAGESCANNER__
if (!qgetenv("QT_TESTCOCOON_ACTIVE").isEmpty()) if (!qEnvironmentVariableIsEmpty("QT_TESTCOCOON_ACTIVE"))
return false; return false;
// Set environment variable QT_TESTCOCOON_ACTIVE to prevent an eventual subtest from // Set environment variable QT_TESTCOCOON_ACTIVE to prevent an eventual subtest from
// being considered as a stand-alone test regarding the coverage analysis. // being considered as a stand-alone test regarding the coverage analysis.
@ -1162,8 +1162,9 @@ static void invokeMethod(QObject *obj, const char *methodName)
int defaultEventDelay() int defaultEventDelay()
{ {
if (eventDelay == -1) { if (eventDelay == -1) {
if (!qgetenv("QTEST_EVENT_DELAY").isEmpty()) const QByteArray env = qgetenv("QTEST_EVENT_DELAY");
eventDelay = atoi(qgetenv("QTEST_EVENT_DELAY")); if (!env.isEmpty())
eventDelay = atoi(env.constData());
else else
eventDelay = 0; eventDelay = 0;
} }
@ -1173,8 +1174,9 @@ int defaultEventDelay()
int Q_TESTLIB_EXPORT defaultMouseDelay() int Q_TESTLIB_EXPORT defaultMouseDelay()
{ {
if (mouseDelay == -1) { if (mouseDelay == -1) {
if (!qgetenv("QTEST_MOUSEEVENT_DELAY").isEmpty()) const QByteArray env = qgetenv("QTEST_MOUSEEVENT_DELAY");
mouseDelay = atoi(qgetenv("QTEST_MOUSEEVENT_DELAY")); if (!env.isEmpty())
mouseDelay = atoi(env.constData());
else else
mouseDelay = defaultEventDelay(); mouseDelay = defaultEventDelay();
} }
@ -1184,8 +1186,9 @@ int Q_TESTLIB_EXPORT defaultMouseDelay()
int Q_TESTLIB_EXPORT defaultKeyDelay() int Q_TESTLIB_EXPORT defaultKeyDelay()
{ {
if (keyDelay == -1) { if (keyDelay == -1) {
if (!qgetenv("QTEST_KEYEVENT_DELAY").isEmpty()) const QByteArray env = qgetenv("QTEST_KEYEVENT_DELAY");
keyDelay = atoi(qgetenv("QTEST_KEYEVENT_DELAY").constData()); if (!env.isEmpty())
keyDelay = atoi(env.constData());
else else
keyDelay = defaultEventDelay(); keyDelay = defaultEventDelay();
} }