diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-09-14 19:06:55 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-09-14 19:06:55 +0200 |
commit | 8d7922aa5299d1bd75a78066e19e96b46b6b380a (patch) | |
tree | 9b11c03dd3cc0f06902c29793228e4e8fa7b424e /sal/qa/osl/pipe | |
parent | 0ed88426b5a379c0c5dbeffd70bc0c63e7c3641f (diff) |
#i103496#: split cppunit in a pure external lib and a lib depending on sal -> testshl2
Diffstat (limited to 'sal/qa/osl/pipe')
-rw-r--r-- | sal/qa/osl/pipe/makefile.mk | 15 | ||||
-rw-r--r-- | sal/qa/osl/pipe/osl_Pipe.cxx | 440 |
2 files changed, 223 insertions, 232 deletions
diff --git a/sal/qa/osl/pipe/makefile.mk b/sal/qa/osl/pipe/makefile.mk index 636bdde7d..3d0df14bb 100644 --- a/sal/qa/osl/pipe/makefile.mk +++ b/sal/qa/osl/pipe/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -44,21 +44,12 @@ CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) # BEGIN ---------------------------------------------------------------- -# auto generated Target:Pipe by codegen.pl +# auto generated Target:Pipe by codegen.pl SHL1OBJS= \ $(SLO)$/osl_Pipe.obj SHL1TARGET= osl_Pipe -SHL1STDLIBS=\ - $(SALLIB) \ - $(CPPUNITLIB) - -#.IF "$(GUI)" == "WNT" -#SHL1STDLIBS+= $(SOLARLIBDIR)$/cppunit.lib -#.ENDIF -#.IF "$(GUI)" == "UNX" -#SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a -#.ENDIF +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx index a9c5abbfb..cdae8380e 100644 --- a/sal/qa/osl/pipe/osl_Pipe.cxx +++ b/sal/qa/osl/pipe/osl_Pipe.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -30,12 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sal.hxx" - + //------------------------------------------------------------------------ // include files //------------------------------------------------------------------------ -#include <cppunit/simpleheader.hxx> +#include <testshl/simpleheader.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> @@ -68,14 +68,14 @@ using namespace rtl; inline void printBool( sal_Bool bOk ) { t_print("#printBool# " ); - ( sal_True == bOk ) ? t_print("YES!\n" ): t_print("NO!\n" ); + ( sal_True == bOk ) ? t_print("YES!\n" ): t_print("NO!\n" ); } /** print a UNI_CODE String. */ inline void printUString( const ::rtl::OUString & str ) { - rtl::OString aString; + rtl::OString aString; t_print("#printUString_u# " ); aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); @@ -89,7 +89,7 @@ inline void printPipeError( ::osl::Pipe aPipe ) oslPipeError nError = aPipe.getError( ); t_print("#printPipeError# " ); switch ( nError ) { - case osl_Pipe_E_None: + case osl_Pipe_E_None: t_print("Success!\n" ); break; case osl_Pipe_E_NotFound: @@ -148,7 +148,7 @@ namespace osl_Pipe { //------------------------------------------------------------------------ -// most return value -1 denote a fail of operation. +// most return value -1 denote a fail of operation. //------------------------------------------------------------------------ #define OSL_PIPE_FAIL -1 @@ -164,102 +164,102 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void setUp( ) { } - + void tearDown( ) { } - + void ctors_none( ) { ::osl::Pipe aPipe; bRes = aPipe.is( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, yet no case to test.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, yet no case to test.", sal_False == bRes ); } - + void ctors_name_option( ) { - /// create a named pipe. + /// create a named pipe. ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); ::osl::Pipe aAssignPipe( aTestPipeName, osl_Pipe_OPEN ); - + bRes = aPipe.is( ) && aAssignPipe.is( ); - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name and option.", sal_True == bRes ); } - + void ctors_name_option_security( ) { - /// create a security pipe. + /// create a security pipe. const ::osl::Security rSecurity; ::osl::Pipe aSecurityPipe( aTestPipeName, osl_Pipe_CREATE, rSecurity ); - + bRes = aSecurityPipe.is( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.", sal_True == bRes ); } - + void ctors_copy( ) { - /// create a pipe. + /// create a pipe. ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - /// create a pipe using copy constructor. + /// create a pipe using copy constructor. ::osl::Pipe aCopyPipe( aPipe ); - + bRes = aCopyPipe.is( ) && aCopyPipe == aPipe; - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.", sal_True == bRes ); } - + /** tester comment: - - When test the following two constructors, don't know how to test the + + When test the following two constructors, don't know how to test the acquire and no acquire action. possible plans: - 1.release one handle and check the other( did not success since the - other still exist and valid. ) - 2. release one handle twice to see getLastError( )(the getLastError - always returns invalidError(LINUX)). + 1.release one handle and check the other( did not success since the + other still exist and valid. ) + 2. release one handle twice to see getLastError( )(the getLastError + always returns invalidError(LINUX)). */ void ctors_no_acquire( ) { - /// create a pipe. + /// create a pipe. ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - /// constructs a pipe reference without acquiring the handle. + /// constructs a pipe reference without acquiring the handle. ::osl::Pipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE ); - + bRes = aNoAcquirePipe.is( ); ///aPipe.clear( ); ///bRes1 = aNoAcquirePipe.is( ); - - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no aquire of handle, only validation test, do not know how to test no acquire.", + + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no aquire of handle, only validation test, do not know how to test no acquire.", sal_True == bRes ); } - + void ctors_acquire( ) { - /// create a base pipe. + /// create a base pipe. ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - /// constructs two pipes without acquiring the handle on the base pipe. + /// constructs two pipes without acquiring the handle on the base pipe. ::osl::Pipe aAcquirePipe( aPipe.getHandle( ) ); ::osl::Pipe aAcquirePipe1( NULL ); - + bRes = aAcquirePipe.is( ); bRes1 = aAcquirePipe1.is( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no aquire of handle.only validation test, do not know how to test no acquire.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no aquire of handle.only validation test, do not know how to test no acquire.", sal_True == bRes && sal_False == bRes1 ); } - + CPPUNIT_TEST_SUITE( ctors ); CPPUNIT_TEST( ctors_none ); CPPUNIT_TEST( ctors_name_option ); @@ -267,10 +267,10 @@ namespace osl_Pipe CPPUNIT_TEST( ctors_copy ); CPPUNIT_TEST( ctors_no_acquire ); CPPUNIT_TEST( ctors_acquire ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class ctors - + /** testing the method: inline sal_Bool SAL_CALL is() const; */ @@ -280,58 +280,58 @@ namespace osl_Pipe void is_001( ) { ::osl::Pipe aPipe; - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), check if the pipe is a valid one.", sal_False == aPipe.is( ) ); } - + void is_002( ) { ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), a normal pipe creation.", sal_True == aPipe.is( ) ); } - + void is_003( ) { ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); aPipe.clear( ); - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), an invalid case.", sal_False == aPipe.is( ) ); } - + void is_004( ) { ::osl::Pipe aPipe( NULL ); - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), an invalid constructor.", sal_False == aPipe.is( ) ); } - + CPPUNIT_TEST_SUITE( is ); CPPUNIT_TEST( is_001 ); CPPUNIT_TEST( is_002 ); CPPUNIT_TEST( is_003 ); CPPUNIT_TEST( is_004 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class is - + /** testing the methods: inline sal_Bool create( const ::rtl::OUString & strName, oslPipeOptions Options, const Security &rSec ); - nline sal_Bool create( const ::rtl::OUString & strName, + nline sal_Bool create( const ::rtl::OUString & strName, oslPipeOptions Options = osl_Pipe_OPEN ); */ class create : public CppUnit::TestFixture { public: sal_Bool bRes, bRes1; - + /** tester comment: - - security create only be tested creation, security section is - untested yet. + + security create only be tested creation, security section is + untested yet. */ - + void create_named_security_001( ) { const Security rSec; @@ -339,11 +339,11 @@ namespace osl_Pipe bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); bRes1 = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); aPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", sal_True == bRes && sal_False == bRes1); } - + void create_named_security_002( ) { const Security rSec; @@ -351,53 +351,53 @@ namespace osl_Pipe bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); bRes1 = aPipe1.create( aTestPipeName, osl_Pipe_OPEN, rSec ); aPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", sal_True == bRes && sal_True == bRes1); } - + void create_named_001( ) { ::osl::Pipe aPipe; bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); bRes1 = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); aPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", sal_True == bRes && sal_False == bRes1); } - + void create_named_002( ) { ::osl::Pipe aPipe, aPipe1; bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); bRes1 = aPipe1.create( aTestPipeName, osl_Pipe_OPEN ); aPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", sal_True == bRes && sal_True == bRes1); } - + void create_named_003( ) { ::osl::Pipe aPipe; bRes = aPipe.create( aTestPipeName ); aPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test default option is open.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test default option is open.", sal_False == bRes ); } - + CPPUNIT_TEST_SUITE( create ); CPPUNIT_TEST( create_named_security_001 ); CPPUNIT_TEST( create_named_security_002 ); CPPUNIT_TEST( create_named_001 ); CPPUNIT_TEST( create_named_002 ); CPPUNIT_TEST( create_named_003 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class create - - + + /** testing the method: inline void SAL_CALL clear(); */ @@ -405,24 +405,24 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void clear_001( ) { ::osl::Pipe aPipe; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); aPipe.clear( ); - bRes = aPipe.is( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test clear.", + bRes = aPipe.is( ); + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test clear.", sal_False == bRes ); } - + CPPUNIT_TEST_SUITE( clear ); CPPUNIT_TEST( clear_001 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class clear - + /** testing the methods: inline Pipe& SAL_CALL operator= (const Pipe& pipe); inline Pipe& SAL_CALL operator= (const oslPipe pipe ); @@ -431,42 +431,42 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void assign_ref( ) { ::osl::Pipe aPipe, aPipe1; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); aPipe1 = aPipe; bRes = aPipe1.is( ); - bRes1 = aPipe == aPipe1; + bRes1 = aPipe == aPipe1; aPipe.close( ); - aPipe1.close( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", + aPipe1.close( ); + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", sal_True == bRes && sal_True == bRes1 ); } - + void assign_handle( ) { ::osl::Pipe aPipe, aPipe1; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); aPipe1 = aPipe.getHandle( ); bRes = aPipe1.is( ); - bRes1 = aPipe == aPipe1; + bRes1 = aPipe == aPipe1; aPipe.close( ); - aPipe1.close( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.", + aPipe1.close( ); + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.", sal_True == bRes && sal_True == bRes1 ); } - + CPPUNIT_TEST_SUITE( assign ); CPPUNIT_TEST( assign_ref ); CPPUNIT_TEST( assign_handle ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class assign - + /** testing the method: inline sal_Bool SAL_CALL isValid() const; isValid( ) has not been implemented under the following platforms, please refer to osl/pipe.hxx @@ -475,19 +475,19 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void isValid_001( ) { - CPPUNIT_ASSERT_MESSAGE( "#test comment#: isValid() has not been implemented on all platforms.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: isValid() has not been implemented on all platforms.", sal_False ); } - + CPPUNIT_TEST_SUITE( isValid ); CPPUNIT_TEST( isValid_001 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); };*/ // class isValid - + /** testing the method: inline sal_Bool SAL_CALL operator==( const Pipe& rPipe ) const; */ @@ -500,38 +500,38 @@ namespace osl_Pipe { ::osl::Pipe aPipe; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); - bRes = aPipe == aPipe; + bRes = aPipe == aPipe; aPipe.close( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(), compare its self.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(), compare its self.", sal_True == bRes ); } - + void isEqual_002( ) { ::osl::Pipe aPipe, aPipe1, aPipe2; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); - + aPipe1 = aPipe; aPipe2.create( aTestPipeName, osl_Pipe_CREATE ); - - bRes = aPipe == aPipe1; - bRes1 = aPipe == aPipe2; + + bRes = aPipe == aPipe1; + bRes1 = aPipe == aPipe2; aPipe.close( ); - aPipe1.close( ); - aPipe2.close( ); + aPipe1.close( ); + aPipe2.close( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.", sal_True == bRes && sal_False == bRes1 ); } - + CPPUNIT_TEST_SUITE( isEqual ); CPPUNIT_TEST( isEqual_001 ); CPPUNIT_TEST( isEqual_002 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class isEqual - - + + /** testing the method: inline void SAL_CALL close(); */ @@ -539,37 +539,37 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void close_001( ) { ::osl::Pipe aPipe( aTestPipe1, osl_Pipe_CREATE ); aPipe.close( ); bRes = aPipe.is( ); - + aPipe.clear( ); bRes1 = aPipe.is( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.", sal_True == bRes && sal_False == bRes1); } - + void close_002( ) { ::osl::StreamPipe aPipe( aTestPipe1, osl_Pipe_CREATE ); aPipe.close( ); int nRet = aPipe.send( m_pTestString1.getStr(), 3 ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: use after close.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: use after close.", OSL_PIPE_FAIL == nRet ); } - + CPPUNIT_TEST_SUITE( close ); CPPUNIT_TEST( close_001 ); CPPUNIT_TEST( close_002 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class close - + /** testing the method: inline oslPipeError SAL_CALL accept(StreamPipe& Connection); please refer to StreamPipe::recv @@ -578,7 +578,7 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void accept_001( ) { @@ -588,10 +588,10 @@ namespace osl_Pipe CPPUNIT_TEST_SUITE( accept ); CPPUNIT_TEST( accept_001 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); };*/ // class accept - + /** testing the method: inline oslPipeError SAL_CALL getError() const; */ @@ -601,26 +601,26 @@ namespace osl_Pipe sal_Bool bRes, bRes1; /* PipeError[]= { - { 0, osl_Pipe_E_None }, // no error - { EPROTOTYPE, osl_Pipe_E_NoProtocol }, // Protocol wrong type for socket - { ENOPROTOOPT, osl_Pipe_E_NoProtocol }, // Protocol not available - { EPROTONOSUPPORT, osl_Pipe_E_NoProtocol }, // Protocol not supported - { ESOCKTNOSUPPORT, osl_Pipe_E_NoProtocol }, // Socket type not supported - { EPFNOSUPPORT, osl_Pipe_E_NoProtocol }, // Protocol family not supported + { 0, osl_Pipe_E_None }, // no error + { EPROTOTYPE, osl_Pipe_E_NoProtocol }, // Protocol wrong type for socket + { ENOPROTOOPT, osl_Pipe_E_NoProtocol }, // Protocol not available + { EPROTONOSUPPORT, osl_Pipe_E_NoProtocol }, // Protocol not supported + { ESOCKTNOSUPPORT, osl_Pipe_E_NoProtocol }, // Socket type not supported + { EPFNOSUPPORT, osl_Pipe_E_NoProtocol }, // Protocol family not supported { EAFNOSUPPORT, osl_Pipe_E_NoProtocol }, // Address family not supported by - // protocol family + // protocol family { ENETRESET, osl_Pipe_E_NetworkReset }, // Network dropped connection because - // of reset - { ECONNABORTED, osl_Pipe_E_ConnectionAbort }, // Software caused connection abort - { ECONNRESET, osl_Pipe_E_ConnectionReset }, // Connection reset by peer - { ENOBUFS, osl_Pipe_E_NoBufferSpace }, // No buffer space available - { ETIMEDOUT, osl_Pipe_E_TimedOut }, // Connection timed out - { ECONNREFUSED, osl_Pipe_E_ConnectionRefused }, // Connection refused + // of reset + { ECONNABORTED, osl_Pipe_E_ConnectionAbort }, // Software caused connection abort + { ECONNRESET, osl_Pipe_E_ConnectionReset }, // Connection reset by peer + { ENOBUFS, osl_Pipe_E_NoBufferSpace }, // No buffer space available + { ETIMEDOUT, osl_Pipe_E_TimedOut }, // Connection timed out + { ECONNREFUSED, osl_Pipe_E_ConnectionRefused }, // Connection refused { -1, osl_Pipe_E_invalidError } }; did not define osl_Pipe_E_NotFound, osl_Pipe_E_AlreadyExists */ - + void getError_001( ) { ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_OPEN ); @@ -628,7 +628,7 @@ namespace osl_Pipe printPipeError( aPipe ); aPipe.clear( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: open a non-exist pipe. not passed in (W32)(LINUX)(UNX).", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: open a non-exist pipe. not passed in (W32)(LINUX)(UNX).", osl_Pipe_E_invalidError == nError ); } @@ -641,17 +641,17 @@ namespace osl_Pipe aPipe.clear( ); aPipe1.clear( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: create an already exist pipe.not passed in (W32)(LINUX)(UNX).", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: create an already exist pipe.not passed in (W32)(LINUX)(UNX).", osl_Pipe_E_invalidError == nError ); } CPPUNIT_TEST_SUITE( getError ); CPPUNIT_TEST( getError_001 ); CPPUNIT_TEST( getError_002 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class getError - + /** testing the method: inline oslPipe SAL_CALL getHandle() const; */ @@ -659,14 +659,14 @@ namespace osl_Pipe { public: sal_Bool bRes, bRes1; - + void getHandle_001( ) { ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_OPEN ); bRes = aPipe == aPipe.getHandle( ); aPipe.clear( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe should equal to its handle.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe should equal to its handle.", sal_True == bRes ); } @@ -678,17 +678,17 @@ namespace osl_Pipe aPipe.clear( ); aPipe1.clear( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe derived from another pipe's handle.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe derived from another pipe's handle.", sal_True == bRes ); } CPPUNIT_TEST_SUITE( getHandle ); CPPUNIT_TEST( getHandle_001 ); CPPUNIT_TEST( getHandle_002 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class getHandle - + // ----------------------------------------------------------------------------- CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Pipe::ctors, "osl_Pipe"); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Pipe::is, "osl_Pipe"); @@ -702,7 +702,7 @@ namespace osl_Pipe CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Pipe::getError, "osl_Pipe"); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Pipe::getHandle, "osl_Pipe"); // ----------------------------------------------------------------------------- - + } // namespace osl_Pipe @@ -721,7 +721,7 @@ namespace osl_StreamPipe { public: sal_Bool bRes, bRes1; - + void ctors_none( ) { // create a pipe. @@ -729,14 +729,14 @@ namespace osl_StreamPipe // create an unattached pipe. ::osl::StreamPipe aStreamPipe1; bRes = aStreamPipe1.is( ); - - // assign it and check. + + // assign it and check. aStreamPipe1 = aStreamPipe; bRes1 = aStreamPipe1.is( ); aStreamPipe.clear( ); aStreamPipe1.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.", sal_False == bRes && sal_True == bRes1 ); } @@ -750,10 +750,10 @@ namespace osl_StreamPipe aStreamPipe.clear( ); aStreamPipe1.clear( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with other's handle.", + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with other's handle.", sal_True == bRes ); } - + void ctors_copy( ) { // create a pipe. @@ -763,11 +763,11 @@ namespace osl_StreamPipe bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1; aStreamPipe.clear( ); aStreamPipe1.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.", sal_True == bRes ); } - + void ctors_name_option( ) { // create a pipe. @@ -784,42 +784,42 @@ namespace osl_StreamPipe void ctors_name_option_security( ) { - /// create a security pipe. + /// create a security pipe. const ::osl::Security rSecurity; ::osl::StreamPipe aSecurityPipe( aTestPipeName, osl_Pipe_CREATE, rSecurity ); - + bRes = aSecurityPipe.is( ); aSecurityPipe.clear( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.", sal_True == bRes ); } - + /** tester comment: - - When test the following constructor, don't know how to test the + + When test the following constructor, don't know how to test the acquire and no acquire action. possible plans: - 1.release one handle and check the other( did not success since the - other still exist and valid. ) - 2. release one handle twice to see getLastError( )(the getLastError - always returns invalidError(LINUX)). + 1.release one handle and check the other( did not success since the + other still exist and valid. ) + 2. release one handle twice to see getLastError( )(the getLastError + always returns invalidError(LINUX)). */ void ctors_no_acquire( ) { - // create a pipe. + // create a pipe. ::osl::StreamPipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - // constructs a pipe reference without acquiring the handle. + // constructs a pipe reference without acquiring the handle. ::osl::StreamPipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE ); - + bRes = aNoAcquirePipe.is( ); aPipe.clear( ); // bRes1 = aNoAcquirePipe.is( ); - + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no aquire of handle, only validation test, do not know how to test no acquire.", sal_True == bRes ); } - + CPPUNIT_TEST_SUITE( ctors ); CPPUNIT_TEST( ctors_none ); CPPUNIT_TEST( ctors_handle ); @@ -827,7 +827,7 @@ namespace osl_StreamPipe CPPUNIT_TEST( ctors_name_option ); CPPUNIT_TEST( ctors_name_option_security ); CPPUNIT_TEST( ctors_no_acquire ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class ctors @@ -836,46 +836,46 @@ namespace osl_StreamPipe inline StreamPipe& SAL_CALL operator=(const Pipe& pipe); mindy: not implementated in osl/pipe.hxx, so remove the cases */ - /* + /* class assign : public CppUnit::TestFixture { public: sal_Bool bRes, bRes1; - + void assign_ref( ) { ::osl::StreamPipe aPipe, aPipe1; aPipe.create( aTestPipeName, osl_Pipe_CREATE ); aPipe1 = aPipe; bRes = aPipe1.is( ); - bRes1 = aPipe == aPipe1; + bRes1 = aPipe == aPipe1; aPipe.close( ); - aPipe1.close( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", + aPipe1.close( ); + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", sal_True == bRes && sal_True == bRes1 ); } - + void assign_handle( ) { ::osl::StreamPipe * pPipe = new ::osl::StreamPipe( aTestPipeName, osl_Pipe_CREATE ); ::osl::StreamPipe * pAssignPipe = new ::osl::StreamPipe; *pAssignPipe = pPipe->getHandle( ); - + bRes = pAssignPipe->is( ); - bRes1 = ( *pPipe == *pAssignPipe ); + bRes1 = ( *pPipe == *pAssignPipe ); pPipe->close( ); - + delete pAssignPipe; - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle., seems not implemented under (LINUX)(W32)", + + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle., seems not implemented under (LINUX)(W32)", sal_True == bRes && sal_True == bRes1 ); } - + CPPUNIT_TEST_SUITE( assign ); CPPUNIT_TEST( assign_ref ); CPPUNIT_TEST( assign_handle ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); };*/ // class assign @@ -886,16 +886,16 @@ namespace osl_StreamPipe /// print statement in thread process must use fflush() to force display. // t_print("wait %d seconds. ", _nSec ); fflush(stdout); - + #ifdef WNT //Windows Sleep( _nSec * 1000 ); #endif #if ( defined UNX ) || ( defined OS2 ) //Unix sleep( _nSec ); #endif - // t_print("done\n" ); + // t_print("done\n" ); } - // test read/write & send/recv data to pipe + // test read/write & send/recv data to pipe // ----------------------------------------------------------------------------- class Pipe_DataSink_Thread : public Thread @@ -903,13 +903,13 @@ namespace osl_StreamPipe public: sal_Char buf[256]; Pipe_DataSink_Thread( ) { } - + ~Pipe_DataSink_Thread( ) { - } + } protected: void SAL_CALL run( ) - { + { sal_Int32 nChars = 0; t_print("open pipe\n"); @@ -937,9 +937,9 @@ namespace osl_StreamPipe } } } - + }; - + // ----------------------------------------------------------------------------- class Pipe_DataSource_Thread : public Thread @@ -947,7 +947,7 @@ namespace osl_StreamPipe public: sal_Char buf[256]; //::osl::StreamPipe aListenPipe; //( aTestPipeName, osl_Pipe_CREATE ); - ::osl::Pipe aListenPipe; + ::osl::Pipe aListenPipe; ::osl::StreamPipe aConnectionPipe; Pipe_DataSource_Thread( ) { @@ -970,9 +970,9 @@ namespace osl_StreamPipe t_print("pipe create failed! \n"); } else - { + { //::osl::StreamPipe aConnectionPipe; - + //start server and wait for connection. t_print("accept\n"); if ( osl_Pipe_E_None != aListenPipe.accept( aConnectionPipe ) ) @@ -981,7 +981,7 @@ namespace osl_StreamPipe return; } t_print("write\n"); - // write to pipe + // write to pipe nChars = aConnectionPipe.write( m_pTestString1.getStr(), m_pTestString1.getLength() + 1 ); if ( nChars < 0) { @@ -990,26 +990,26 @@ namespace osl_StreamPipe } t_print("recv\n"); nChars = aConnectionPipe.recv( buf, 256 ); - + if ( nChars < 0) { t_print("server receive failed! \n"); return; } - //thread_sleep( 2 ); + //thread_sleep( 2 ); t_print("received message is: %s\n", buf ); - //aConnectionPipe.close(); + //aConnectionPipe.close(); } } }; - + /** testing the method: read/write/send/recv and Pipe::accept */ class recv : public CppUnit::TestFixture { public: sal_Bool bRes, bRes1; - + void recv_001( ) { //launch threads. @@ -1022,7 +1022,7 @@ namespace osl_StreamPipe //wait until the thread terminate myDataSinkThread.join( ); myDataSourceThread.join( ); - + int nCompare1 = strcmp( myDataSinkThread.buf, m_pTestString1.getStr() ); int nCompare2 = strcmp( myDataSourceThread.buf, m_pTestString2.getStr() ); CPPUNIT_ASSERT_MESSAGE( "test send/recv/write/read.", nCompare1 == 0 && nCompare2 == 0 ); @@ -1040,11 +1040,11 @@ namespace osl_StreamPipe myDataSourceThread.join( ); //no condition judgement here, if the case could finish excuting within 1 or 2 seconds, it passes. } - + CPPUNIT_TEST_SUITE( recv ); CPPUNIT_TEST( recv_001 ); CPPUNIT_TEST( recv_002 ); - CPPUNIT_TEST_SUITE_END( ); + CPPUNIT_TEST_SUITE_END( ); }; // class recv // ----------------------------------------------------------------------------- @@ -1052,7 +1052,7 @@ namespace osl_StreamPipe //CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_StreamPipe::assign, "osl_StreamPipe"); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_StreamPipe::recv, "osl_StreamPipe"); // ----------------------------------------------------------------------------- - + } // namespace osl_StreamPipe |