Kaydet (Commit) c09b966f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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

üst daff51e1
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "cppunit/plugin/TestPlugIn.h" #include "cppunit/plugin/TestPlugIn.h"
#include "osl/conditn.hxx" #include "osl/conditn.hxx"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "osl/time.h"
#include "rtl/ustring.h" #include "rtl/ustring.h"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "test/gettestargument.hxx" #include "test/gettestargument.hxx"
...@@ -197,9 +198,16 @@ void Test::test() { ...@@ -197,9 +198,16 @@ void Test::test() {
disp, url, css::uno::Sequence< css::beans::PropertyValue >(), disp, url, css::uno::Sequence< css::beans::PropertyValue >(),
new Listener(&result)), new Listener(&result)),
css::uno::Any()); css::uno::Any());
TimeValue t; // Wait for result.condition or connection_ going stale:
t.Seconds = 30; t.Nanosec = 0; for (;;) {
result.condition.wait(&t); 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(result.success);
CPPUNIT_ASSERT_EQUAL(rtl::OUString(), result.result); CPPUNIT_ASSERT_EQUAL(rtl::OUString(), result.result);
} }
......
...@@ -55,6 +55,9 @@ public: ...@@ -55,6 +55,9 @@ public:
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
getComponentContext() const; getComponentContext() const;
// Must not be called before setUp or after tearDown:
bool isStillAlive() const;
private: private:
oslProcess process_; oslProcess process_;
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
......
...@@ -170,6 +170,7 @@ void OfficeConnection::tearDown() { ...@@ -170,6 +170,7 @@ void OfficeConnection::tearDown() {
osl_getProcessInfo(process_, osl_Process_EXITCODE, &info)); osl_getProcessInfo(process_, osl_Process_EXITCODE, &info));
CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code); CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code);
osl_freeProcessHandle(process_); osl_freeProcessHandle(process_);
process_ = 0; // guard against subsequent calls to isStillAlive
} }
} }
...@@ -178,6 +179,14 @@ OfficeConnection::getComponentContext() const { ...@@ -178,6 +179,14 @@ OfficeConnection::getComponentContext() const {
return context_; 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment