Fix unit confusion in ccf3b9e48b2d773999a9a88e249f79380618cde6
authorDavid Faure <faure@kde.org>
Wed, 2 May 2012 20:36:40 +0000 (22:36 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 2 May 2012 20:49:26 +0000 (22:49 +0200)
I wrote nonsense in that commit. The older methods that take a timeout
all take milliseconds, and the comments in the unit test really meant
milliseconds, not seconds. 1s is not shorter than 100ms....

Change-Id: Ic18899bb0462d89575dc5a9a311478adc4dea1cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/dbus/qdbusabstractinterface.cpp
tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp

index 76089f2..c45097d 100644 (file)
@@ -385,7 +385,7 @@ QDBusError QDBusAbstractInterface::lastError() const
 }
 
 /*!
-    Sets the timeout in seconds for all future DBus calls to \a timeout.
+    Sets the timeout in milliseconds for all future DBus calls to \a timeout.
     -1 means the default DBus timeout (usually 25 seconds).
 
     \since 4.8
@@ -396,7 +396,7 @@ void QDBusAbstractInterface::setTimeout(int timeout)
 }
 
 /*!
-    Returns the current value of the timeout in seconds.
+    Returns the current value of the timeout in milliseconds.
     -1 means the default DBus timeout (usually 25 seconds).
 
     \since 4.8
index 48ea1e4..fcc2a32 100644 (file)
@@ -495,7 +495,7 @@ void tst_QDBusAbstractInterface::callWithTimeout()
 
     QDBusMessage msg = QDBusMessage::createMethodCall(server_serviceName,
                                                       server_objectPath, server_interfaceName, "sleepMethod");
-    msg << 100;
+    msg << 100; // sleep 100 ms
 
     {
        // Call with no timeout -> works
@@ -505,7 +505,7 @@ void tst_QDBusAbstractInterface::callWithTimeout()
     }
 
     {
-        // Call with 1 sec timeout -> fails
+        // Call with 1 msec timeout -> fails
         QDBusMessage reply = con.call(msg, QDBus::Block, 1);
         QCOMPARE(reply.type(), QDBusMessage::ErrorMessage);
     }
@@ -520,11 +520,17 @@ void tst_QDBusAbstractInterface::callWithTimeout()
         QCOMPARE(reply.arguments().at(0).toInt(), 42);
     }
     {
-        // Call with 1 sec timeout -> fails
+        // Call with 1 msec timeout -> fails
         iface.setTimeout(1);
         QDBusMessage reply = iface.call("sleepMethod", 100);
         QCOMPARE(reply.type(), QDBusMessage::ErrorMessage);
     }
+    {
+        // Call with 300 msec timeout -> works
+        iface.setTimeout(300);
+        QDBusMessage reply = iface.call("sleepMethod", 100);
+        QCOMPARE(reply.arguments().at(0).toInt(), 42);
+    }
 
     // Now using generated code
     com::trolltech::QtDBus::Pinger p(server_serviceName, server_objectPath, QDBusConnection::sessionBus());
@@ -535,7 +541,7 @@ void tst_QDBusAbstractInterface::callWithTimeout()
         QCOMPARE(int(reply), 42);
     }
     {
-        // Call with 1 sec timeout -> fails
+        // Call with 1 msec timeout -> fails
         p.setTimeout(1);
         QDBusReply<int> reply = p.sleepMethod(100);
         QVERIFY(!reply.isValid());