[Libreoffice-commits] .: smoketestoo_native/smoketest.cxx test/inc test/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Mon Sep 26 08:25:10 PDT 2011


 smoketestoo_native/smoketest.cxx     |   14 +++++++++++---
 test/inc/test/officeconnection.hxx   |    3 +++
 test/source/cpp/officeconnection.cxx |    9 +++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit c09b966f94f5a50fe537916398451339f008947d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 26 17:23:52 2011 +0200

    In smoketest.cxx, also wait for connection_ going stale while waiting for result.condition.

diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx
index bb47b26..f422ebc 100644
--- a/smoketestoo_native/smoketest.cxx
+++ b/smoketestoo_native/smoketest.cxx
@@ -56,6 +56,7 @@
 #include "cppunit/plugin/TestPlugIn.h"
 #include "osl/conditn.hxx"
 #include "osl/diagnose.h"
+#include "osl/time.h"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 #include "test/gettestargument.hxx"
@@ -197,9 +198,16 @@ void Test::test() {
                 disp, url, css::uno::Sequence< css::beans::PropertyValue >(),
                 new Listener(&result)),
             css::uno::Any());
-    TimeValue t;
-    t.Seconds = 30; t.Nanosec = 0;
-    result.condition.wait(&t);
+    // Wait for result.condition or connection_ going stale:
+    for (;;) {
+        TimeValue delay = { 1, 0 }; // 1 sec
+        osl::Condition::Result res = result.condition.wait(&delay);
+        if (res == osl::Condition::result_ok) {
+            break;
+        }
+        CPPUNIT_ASSERT_EQUAL(osl::Condition::result_timeout, res);
+        CPPUNIT_ASSERT(connection_.isStillAlive());
+    }
     CPPUNIT_ASSERT(result.success);
     CPPUNIT_ASSERT_EQUAL(rtl::OUString(), result.result);
 }
diff --git a/test/inc/test/officeconnection.hxx b/test/inc/test/officeconnection.hxx
index 4c764b1..e5250ce 100644
--- a/test/inc/test/officeconnection.hxx
+++ b/test/inc/test/officeconnection.hxx
@@ -55,6 +55,9 @@ public:
     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
     getComponentContext() const;
 
+    // Must not be called before setUp or after tearDown:
+    bool isStillAlive() const;
+
 private:
     oslProcess process_;
     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx
index a40451e..9c8d4d5 100644
--- a/test/source/cpp/officeconnection.cxx
+++ b/test/source/cpp/officeconnection.cxx
@@ -170,6 +170,7 @@ void OfficeConnection::tearDown() {
             osl_getProcessInfo(process_, osl_Process_EXITCODE, &info));
         CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code);
         osl_freeProcessHandle(process_);
+        process_ = 0; // guard against subsequent calls to isStillAlive
     }
 }
 
@@ -178,6 +179,14 @@ OfficeConnection::getComponentContext() const {
     return context_;
 }
 
+bool OfficeConnection::isStillAlive() const {
+    OSL_ASSERT(process_ != 0);
+    TimeValue delay = { 0, 0 }; // 0 sec
+    oslProcessError e = osl_joinProcessWithTimeout(process_, &delay);
+    CPPUNIT_ASSERT(e == osl_Process_E_None || e == osl_Process_E_TimedOut);
+    return e == osl_Process_E_TimedOut;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list