summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-11-02 18:39:20 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-03 02:42:56 +0100
commit65ece490a914bc56a9c92cac4ace329033832030 (patch)
treea1d951aa6a1c308002152e7ab52dbe344275ea9f /src/testlib/qtestcase.cpp
parent8cb52795f1dc0bdc06ce4fa9dc49ac9e5141ab0f (diff)
Fix getting of enviroment strings in testlib
The standard C getenv() returns NULL if the requested environment variable is not found. In Qt4 and later, qgetenv() does not return a null pointer if the requested environment string is not defined. Instead it returns a QByteArray containing an empty string. If using qgetenv(), there is no way to tell the difference between an undefined environment variable and one which is defined to be the empty string. In testlib, all calls to qgetenv() were checking whether the returned QByteArray's constData() returned a null pointer, but that would never happen. These calls must instead check whether the QByteArray contains a non-empty string. Change-Id: I342f0e8b196896c26cccce3ff169fa1b9669b5ff Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index cb039a6354..713004da4d 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -945,7 +945,7 @@ static void invokeMethod(QObject *obj, const char *methodName)
bool Q_TESTLIB_EXPORT defaultKeyVerbose()
{
if (keyVerbose == -1) {
- keyVerbose = qgetenv("QTEST_KEYEVENT_VERBOSE").constData() ? 1 : 0;
+ keyVerbose = qgetenv("QTEST_KEYEVENT_VERBOSE").isEmpty() ? 0 : 1;
}
return keyVerbose == 1;
}
@@ -953,7 +953,7 @@ bool Q_TESTLIB_EXPORT defaultKeyVerbose()
int defaultEventDelay()
{
if (eventDelay == -1) {
- if (qgetenv("QTEST_EVENT_DELAY").constData())
+ if (!qgetenv("QTEST_EVENT_DELAY").isEmpty())
eventDelay = atoi(qgetenv("QTEST_EVENT_DELAY"));
else
eventDelay = 0;
@@ -964,8 +964,8 @@ int defaultEventDelay()
int Q_TESTLIB_EXPORT defaultMouseDelay()
{
if (mouseDelay == -1) {
- if (qgetenv("QTEST_MOUSEEVENT_DELAY").constData())
- mouseDelay = atoi((qgetenv("QTEST_MOUSEEVENT_DELAY")));
+ if (!qgetenv("QTEST_MOUSEEVENT_DELAY").isEmpty())
+ mouseDelay = atoi(qgetenv("QTEST_MOUSEEVENT_DELAY"));
else
mouseDelay = defaultEventDelay();
}
@@ -975,7 +975,7 @@ int Q_TESTLIB_EXPORT defaultMouseDelay()
int Q_TESTLIB_EXPORT defaultKeyDelay()
{
if (keyDelay == -1) {
- if (qgetenv("QTEST_KEYEVENT_DELAY").constData())
+ if (!qgetenv("QTEST_KEYEVENT_DELAY").isEmpty())
keyDelay = atoi(qgetenv("QTEST_KEYEVENT_DELAY").constData());
else
keyDelay = defaultEventDelay();