xref: /aoo41x/main/io/test/stm/pumptest.cxx (revision 3716f815)
1*3716f815SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3716f815SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3716f815SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3716f815SAndrew Rist  * distributed with this work for additional information
6*3716f815SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3716f815SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3716f815SAndrew Rist  * "License"); you may not use this file except in compliance
9*3716f815SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3716f815SAndrew Rist  *
11*3716f815SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3716f815SAndrew Rist  *
13*3716f815SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3716f815SAndrew Rist  * software distributed under the License is distributed on an
15*3716f815SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3716f815SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3716f815SAndrew Rist  * specific language governing permissions and limitations
18*3716f815SAndrew Rist  * under the License.
19*3716f815SAndrew Rist  *
20*3716f815SAndrew Rist  *************************************************************/
21*3716f815SAndrew Rist 
22*3716f815SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_io.hxx"
26cdf0e10cSrcweir #include <stdio.h>
27cdf0e10cSrcweir #include <osl/time.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <osl/diagnose.h>
30cdf0e10cSrcweir #include <com/sun/star/test/XSimpleTest.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp>
33cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSink.hpp>
34cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataControl.hpp>
35cdf0e10cSrcweir #include <com/sun/star/io/XConnectable.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <uno/dispatcher.h>
42cdf0e10cSrcweir #include <uno/mapping.hxx>
43cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
44cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
45cdf0e10cSrcweir #include <osl/mutex.hxx>
46cdf0e10cSrcweir #include <osl/thread.h>
47cdf0e10cSrcweir #include <list>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace ::rtl;
53cdf0e10cSrcweir using namespace ::osl;
54cdf0e10cSrcweir using namespace ::cppu;
55cdf0e10cSrcweir using namespace ::com::sun::star::uno;
56cdf0e10cSrcweir using namespace ::com::sun::star::io;
57cdf0e10cSrcweir using namespace ::com::sun::star::lang;
58cdf0e10cSrcweir using namespace ::com::sun::star::test;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #include "testfactreg.hxx"
61cdf0e10cSrcweir 
mywait()62cdf0e10cSrcweir static void mywait()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir     TimeValue a = { 0, 10000 };
65cdf0e10cSrcweir     osl_waitThread( &a );
66cdf0e10cSrcweir     osl_yieldThread();
67cdf0e10cSrcweir     osl_yieldThread();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir class OPumpTest : public WeakImplHelper1 < XSimpleTest >
71cdf0e10cSrcweir {
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir 	OPumpTest( const Reference< XMultiServiceFactory >  & rFactory );
74cdf0e10cSrcweir 	~OPumpTest();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir public: // implementation names
77cdf0e10cSrcweir     static Sequence< OUString > 	getSupportedServiceNames_Static(void) throw();
78cdf0e10cSrcweir 	static OUString 				getImplementationName_Static() throw();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir     virtual void SAL_CALL testInvariant(const OUString& TestName, const Reference < XInterface >& TestObject)
82cdf0e10cSrcweir 		throw  ( IllegalArgumentException, RuntimeException) ;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL test(	const OUString& TestName,
85cdf0e10cSrcweir 										const Reference < XInterface >& TestObject,
86cdf0e10cSrcweir 										sal_Int32 hTestHandle)
87cdf0e10cSrcweir 		throw  (	IllegalArgumentException,
88cdf0e10cSrcweir 					RuntimeException);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     virtual sal_Bool SAL_CALL testPassed(void) 								throw  (	RuntimeException) ;
91cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getErrors(void) 				throw  (RuntimeException) ;
92cdf0e10cSrcweir     virtual Sequence< Any > SAL_CALL getErrorExceptions(void) 		throw  (RuntimeException);
93cdf0e10cSrcweir 	virtual Sequence< OUString > SAL_CALL getWarnings(void) 				throw  (RuntimeException);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir private:
96cdf0e10cSrcweir 	void testSimple( const Reference < XInterface > & );
97cdf0e10cSrcweir 	void testWrongUsage( const Reference < XInterface > & );
98cdf0e10cSrcweir     void testClose( const Reference< XInterface >& );
99cdf0e10cSrcweir     void testTerminate( const Reference< XInterface >& );
100cdf0e10cSrcweir     void testFunction( const Reference< XInterface >& );
101cdf0e10cSrcweir private:
102cdf0e10cSrcweir 	Sequence<Any>  m_seqExceptions;
103cdf0e10cSrcweir 	Sequence<OUString> m_seqErrors;
104cdf0e10cSrcweir 	Sequence<OUString> m_seqWarnings;
105cdf0e10cSrcweir 	Reference< XMultiServiceFactory > m_rSmgr;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
OPumpTest(const Reference<XMultiServiceFactory> & rFactory)109cdf0e10cSrcweir OPumpTest::OPumpTest( const Reference< XMultiServiceFactory > &rFactory ) :
110cdf0e10cSrcweir 	m_rSmgr( rFactory )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
~OPumpTest()115cdf0e10cSrcweir OPumpTest::~OPumpTest()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
testInvariant(const OUString & TestName,const Reference<XInterface> & TestObject)122cdf0e10cSrcweir void OPumpTest::testInvariant( const OUString& TestName, const Reference < XInterface >& TestObject )
123cdf0e10cSrcweir 	throw  (	IllegalArgumentException,
124cdf0e10cSrcweir 				RuntimeException)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	Reference< XServiceInfo > info( TestObject, UNO_QUERY );
127cdf0e10cSrcweir   	ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
128cdf0e10cSrcweir 	if( info.is() )
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir   		ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
131cdf0e10cSrcweir 		ERROR_ASSERT( ! info->supportsService(
132cdf0e10cSrcweir 			OUString( RTL_CONSTASCII_USTRINGPARAM("bla bluzb") ) ), "XServiceInfo test failed" );
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	Reference < XActiveDataSource > xActiveDataSource( TestObject, UNO_QUERY );
136cdf0e10cSrcweir 	Reference < XActiveDataSink > xActiveDataSink( TestObject, UNO_QUERY );
137cdf0e10cSrcweir 	Reference < XActiveDataControl > xActiveDataControl( TestObject , UNO_QUERY );
138cdf0e10cSrcweir 	Reference < XConnectable > xConnectable( TestObject , UNO_QUERY );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	ERROR_ASSERT( xActiveDataSource.is() && xActiveDataSink.is() && xActiveDataControl.is () &&
141cdf0e10cSrcweir 				  xConnectable.is(), "specified interface not supported" );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
test(const OUString & TestName,const Reference<XInterface> & TestObject,sal_Int32 hTestHandle)145cdf0e10cSrcweir sal_Int32 OPumpTest::test(
146cdf0e10cSrcweir 	const OUString& TestName,
147cdf0e10cSrcweir 	const Reference < XInterface >& TestObject,
148cdf0e10cSrcweir 	sal_Int32 hTestHandle)
149cdf0e10cSrcweir 	throw  (	IllegalArgumentException, RuntimeException)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	if( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.Pump") ) == TestName )  {
152cdf0e10cSrcweir 		try
153cdf0e10cSrcweir 		{
154cdf0e10cSrcweir 			if( 0 == hTestHandle ) {
155cdf0e10cSrcweir 				testInvariant( TestName , TestObject );
156cdf0e10cSrcweir 			}
157cdf0e10cSrcweir 			else if ( 1 == hTestHandle )
158cdf0e10cSrcweir 			{
159cdf0e10cSrcweir 				testWrongUsage( TestObject);
160cdf0e10cSrcweir 			}
161cdf0e10cSrcweir 			else if ( 2 == hTestHandle )
162cdf0e10cSrcweir 			{
163cdf0e10cSrcweir 				testClose( TestObject);
164cdf0e10cSrcweir 			}
165cdf0e10cSrcweir 			else if ( 3 == hTestHandle )
166cdf0e10cSrcweir 			{
167cdf0e10cSrcweir 				testTerminate( TestObject );
168cdf0e10cSrcweir 			}
169cdf0e10cSrcweir 			else if ( 4 == hTestHandle )
170cdf0e10cSrcweir 			{
171cdf0e10cSrcweir 				testFunction( TestObject );
172cdf0e10cSrcweir 			}
173cdf0e10cSrcweir 		}
174cdf0e10cSrcweir 		catch( Exception & e )
175cdf0e10cSrcweir 		{
176cdf0e10cSrcweir 			OString s = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
177cdf0e10cSrcweir 			BUILD_ERROR( 0 , s.getStr() );
178cdf0e10cSrcweir 		}
179cdf0e10cSrcweir 		catch( ... )
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir 			BUILD_ERROR( 0 , "unknown exception (Exception is  not base class)" );
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 		hTestHandle ++;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 		if( 5 == hTestHandle )
187cdf0e10cSrcweir 		{
188cdf0e10cSrcweir 			// all tests finished.
189cdf0e10cSrcweir 			hTestHandle = -1;
190cdf0e10cSrcweir 		}
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir 	else {
193cdf0e10cSrcweir 		throw IllegalArgumentException();
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir 	return hTestHandle;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
testPassed(void)200cdf0e10cSrcweir sal_Bool OPumpTest::testPassed(void) 		throw  (RuntimeException)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	return m_seqErrors.getLength() == 0;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
getErrors(void)206cdf0e10cSrcweir Sequence< OUString > OPumpTest::getErrors(void)		throw  (RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	return m_seqErrors;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 
getErrorExceptions(void)212cdf0e10cSrcweir Sequence< Any > OPumpTest::getErrorExceptions(void) 					throw  (RuntimeException)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	return m_seqExceptions;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
getWarnings(void)218cdf0e10cSrcweir Sequence< OUString > OPumpTest::getWarnings(void) 						throw  (RuntimeException)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir 	return m_seqWarnings;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 
224cdf0e10cSrcweir /***
225cdf0e10cSrcweir * the test methods
226cdf0e10cSrcweir *
227cdf0e10cSrcweir ****/
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 
testSimple(const Reference<XInterface> & r)230cdf0e10cSrcweir void OPumpTest::testSimple( const Reference < XInterface > &r )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir 	// jbu todo: add sensible test
233cdf0e10cSrcweir 
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir class TestListener: public WeakImplHelper1< XStreamListener >
237cdf0e10cSrcweir {
238cdf0e10cSrcweir public:
239cdf0e10cSrcweir     sal_Bool m_bStarted;
240cdf0e10cSrcweir     sal_Bool m_bClosed;
241cdf0e10cSrcweir     sal_Bool m_bTerminated;
242cdf0e10cSrcweir     sal_Bool m_bError;
243cdf0e10cSrcweir     sal_Bool m_bDisposed;
TestListener()244cdf0e10cSrcweir     TestListener() : m_bStarted (sal_False),
245cdf0e10cSrcweir                      m_bClosed (sal_False),
246cdf0e10cSrcweir                      m_bTerminated ( sal_False ),
247cdf0e10cSrcweir                      m_bError( sal_False ),
248cdf0e10cSrcweir                      m_bDisposed( sal_False )
249cdf0e10cSrcweir     {}
250cdf0e10cSrcweir 
disposing(const EventObject & obj)251cdf0e10cSrcweir     virtual void SAL_CALL disposing( const EventObject &obj  ) throw (::com::sun::star::uno::RuntimeException)
252cdf0e10cSrcweir     {
253cdf0e10cSrcweir         m_bDisposed = sal_True;
254cdf0e10cSrcweir //         printf( "disposing called\n");
255cdf0e10cSrcweir     }
256cdf0e10cSrcweir 
started()257cdf0e10cSrcweir     virtual void SAL_CALL started(  ) throw (::com::sun::star::uno::RuntimeException)
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         m_bStarted = sal_True;
260cdf0e10cSrcweir //         printf( "started called\n");
261cdf0e10cSrcweir     }
closed()262cdf0e10cSrcweir     virtual void SAL_CALL closed(  ) throw (::com::sun::star::uno::RuntimeException)
263cdf0e10cSrcweir     {
264cdf0e10cSrcweir         m_bClosed = sal_True;
265cdf0e10cSrcweir //         printf( "closed called\n");
266cdf0e10cSrcweir     }
terminated()267cdf0e10cSrcweir     virtual void SAL_CALL terminated(  ) throw (::com::sun::star::uno::RuntimeException)
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         m_bTerminated = sal_True;
270cdf0e10cSrcweir //         printf( "terminated called\n");
271cdf0e10cSrcweir     }
error(const::com::sun::star::uno::Any & aException)272cdf0e10cSrcweir     virtual void SAL_CALL error( const ::com::sun::star::uno::Any& aException )
273cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException)
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         m_bError = sal_True;
276cdf0e10cSrcweir         Exception e;
277cdf0e10cSrcweir         aException >>= e;
278cdf0e10cSrcweir //         printf( "error called %s\n", OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US).getStr() );
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir };
281cdf0e10cSrcweir 
282cdf0e10cSrcweir class TestCase
283cdf0e10cSrcweir {
284cdf0e10cSrcweir public:
TestCase(const Reference<XMultiServiceFactory> & rSMgr,const Reference<XInterface> & r)285cdf0e10cSrcweir     TestCase( const Reference< XMultiServiceFactory > & rSMgr,
286cdf0e10cSrcweir               const Reference< XInterface > &r ) : m_rSmgr( rSMgr ), m_pTestListener( 0 )
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir         m_rControl = Reference<XActiveDataControl>( r, UNO_QUERY );
289cdf0e10cSrcweir 
290cdf0e10cSrcweir         Reference< XActiveDataSource > rSource ( r, UNO_QUERY );
291cdf0e10cSrcweir         Reference< XActiveDataSink > rSink( r , UNO_QUERY );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir         m_rOutSource = Reference< XOutputStream > ( createPipe() );
294cdf0e10cSrcweir         rSink->setInputStream(Reference< XInputStream> (m_rOutSource,UNO_QUERY));
295cdf0e10cSrcweir 
296cdf0e10cSrcweir         Reference< XOutputStream > rOutSink( createPipe() );
297cdf0e10cSrcweir         m_rInSink = Reference< XInputStream > ( rOutSink, UNO_QUERY );
298cdf0e10cSrcweir         rSource->setOutputStream( rOutSink );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir         m_pTestListener = new TestListener();
301cdf0e10cSrcweir         m_pTestListener->acquire();
302cdf0e10cSrcweir         m_rControl->addListener( m_pTestListener );
303cdf0e10cSrcweir     }
304cdf0e10cSrcweir 
~TestCase()305cdf0e10cSrcweir     ~TestCase()
306cdf0e10cSrcweir     {
307cdf0e10cSrcweir         if( m_pTestListener )
308cdf0e10cSrcweir             m_pTestListener->release();
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     TestListener *m_pTestListener;
312cdf0e10cSrcweir     Reference< XActiveDataControl > m_rControl;
313cdf0e10cSrcweir     Reference< XOutputStream > m_rOutSource;
314cdf0e10cSrcweir     Reference< XInputStream > m_rInSink;
315cdf0e10cSrcweir     Reference< XMultiServiceFactory > m_rSmgr;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir private:
createPipe()318cdf0e10cSrcweir     Reference< XOutputStream > createPipe()
319cdf0e10cSrcweir     {
320cdf0e10cSrcweir         Reference< XOutputStream > rOut( m_rSmgr->createInstance(
321cdf0e10cSrcweir              OUString::createFromAscii( "com.sun.star.io.Pipe" )),UNO_QUERY);
322cdf0e10cSrcweir         return rOut;
323cdf0e10cSrcweir     }
324cdf0e10cSrcweir };
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 
testClose(const Reference<XInterface> & r)328cdf0e10cSrcweir void OPumpTest::testClose( const Reference< XInterface > &r )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir     TestCase t( m_rSmgr, r );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bStarted , "started too early" );
333cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" );
334cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
335cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" );
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     t.m_rControl->start();
338cdf0e10cSrcweir     mywait();
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" );
341cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" );
342cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
343cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     Reference< XStreamListener > rListener( new TestListener() );
346cdf0e10cSrcweir     t.m_rControl->addListener( rListener );
347cdf0e10cSrcweir     t.m_rControl->removeListener( rListener );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     t.m_rOutSource->closeOutput();
350cdf0e10cSrcweir     mywait();
351cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" );
352cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "should be terminiated already" );
353cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
354cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
testTerminate(const Reference<XInterface> & r)357cdf0e10cSrcweir void OPumpTest::testTerminate( const Reference< XInterface > &r )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir     TestCase t( m_rSmgr, r );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bStarted , "started too early" );
362cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" );
363cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
364cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     t.m_rControl->start();
367cdf0e10cSrcweir     mywait();
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" );
370cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "terminiation unexpected" );
371cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
372cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bClosed, "unexpected clase" );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     t.m_rControl->terminate();
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     mywait();
377cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" );
378cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bTerminated , "should be terminiated already" );
379cdf0e10cSrcweir     // terminte leads to an error, that is no surprise, in fact
380cdf0e10cSrcweir     // one can't tell wether the error occurs because of the terminate
381cdf0e10cSrcweir     // call or for some other reason !
382cdf0e10cSrcweir //     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
383cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
testFunction(const Reference<XInterface> & r)386cdf0e10cSrcweir void OPumpTest::testFunction( const Reference< XInterface > &r )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     TestCase t( m_rSmgr, r );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     t.m_rControl->start();
391cdf0e10cSrcweir 
392cdf0e10cSrcweir     t.m_rOutSource->writeBytes( Sequence< sal_Int8 > ( 5 ) );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     Sequence< sal_Int8 > dummy;
395cdf0e10cSrcweir     ERROR_ASSERT( 5 == t.m_rInSink->readBytes( dummy , 5 ), "couldn't read the expected number of bytes" );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     t.m_rOutSource->closeOutput();
398cdf0e10cSrcweir     mywait();
399cdf0e10cSrcweir 
400cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bStarted , "should have been started already" );
401cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bTerminated , "should be terminiated already" );
402cdf0e10cSrcweir     ERROR_ASSERT( ! t.m_pTestListener->m_bError, "unexpected error" );
403cdf0e10cSrcweir     ERROR_ASSERT( t.m_pTestListener->m_bClosed, "should be closed already" );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
testWrongUsage(const Reference<XInterface> & r)406cdf0e10cSrcweir void OPumpTest::testWrongUsage( const Reference< XInterface > &r )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir 	Reference< XActiveDataSource > rSource ( r, UNO_QUERY );
409cdf0e10cSrcweir 	Reference< XActiveDataSink > rSink( r , UNO_QUERY );
410cdf0e10cSrcweir 	Reference< XActiveDataControl > rControl( r, UNO_QUERY );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	Reference< XInputStream > rIn( m_rSmgr->createInstance(
413cdf0e10cSrcweir 		OUString::createFromAscii( "com.sun.star.io.DataInputStream" )),UNO_QUERY);
414cdf0e10cSrcweir 	Reference< XOutputStream > rOut( m_rSmgr->createInstance(
415cdf0e10cSrcweir 		OUString::createFromAscii( "com.sun.star.io.DataOutputStream" )),UNO_QUERY);
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	rSink->setInputStream( rIn );
418cdf0e10cSrcweir 	rSource->setOutputStream( rOut );
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 	rControl->start();
421cdf0e10cSrcweir 
422cdf0e10cSrcweir     mywait();
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
OPumpTest_CreateInstance(const Reference<XMultiServiceFactory> & rSMgr)425cdf0e10cSrcweir Reference< XInterface > SAL_CALL OPumpTest_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception )
426cdf0e10cSrcweir {
427cdf0e10cSrcweir 	return *new OPumpTest( rSMgr );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
OPumpTest_getSupportedServiceNames(void)430cdf0e10cSrcweir Sequence<OUString> OPumpTest_getSupportedServiceNames(void) throw()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	OUString s = OPumpTest_getServiceName();
433cdf0e10cSrcweir 	Sequence< OUString > seq( &s , 1 );
434cdf0e10cSrcweir 	return seq;
435cdf0e10cSrcweir 
436cdf0e10cSrcweir }
OPumpTest_getServiceName()437cdf0e10cSrcweir OUString     OPumpTest_getServiceName() throw()
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "test.com.sun.star.io.Pump" ) );
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
OPumpTest_getImplementationName()442cdf0e10cSrcweir OUString 	OPumpTest_getImplementationName() throw()
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "test.com.sun.star.comp.io.Pump") );
445cdf0e10cSrcweir }
446