[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 3 commits - sal/prj sal/qa
Jürgen Schmidt
jsc at apache.org
Tue Jun 3 07:08:16 PDT 2014
sal/prj/build.lst | 2
sal/qa/osl/pipe/makefile.mk | 39 -
sal/qa/osl/pipe/osl_Pipe.cxx | 1180 +++++++++++++++++--------------------------
3 files changed, 489 insertions(+), 732 deletions(-)
New commits:
commit 2a9414bc50d9c0618513ccbd82a30e2591db1159
Author: Jürgen Schmidt <jsc at apache.org>
Date: Tue Jun 3 13:59:55 2014 +0000
#125038# add header for Sleep under windows
diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx
index cda89d3..dd0bed9 100644
--- a/sal/qa/osl/pipe/osl_Pipe.cxx
+++ b/sal/qa/osl/pipe/osl_Pipe.cxx
@@ -28,6 +28,10 @@
// include files
//------------------------------------------------------------------------
+#ifdef WNT
+#include <Windows.h>
+#endif
+
#include <sal/types.h>
#include <rtl/ustring.hxx>
commit 61e546c4943bfe20d1ed5e75c62ff905bf933b6b
Author: Jürgen Schmidt <jsc at apache.org>
Date: Tue Jun 3 13:42:15 2014 +0000
#125038# remove double entry for sal/qa/osl/pipe
diff --git a/sal/prj/build.lst b/sal/prj/build.lst
index 710f21e..24f7ca9 100644
--- a/sal/prj/build.lst
+++ b/sal/prj/build.lst
@@ -22,7 +22,6 @@ sa sal\cppunittester nmake - all sa_cppunittester sa_cpprt.u sa_util NULL
sa sal\qa\ByteSequence nmake - all sa_qa_ByteSequence sa_cppunittester sa_util NULL
sa sal\qa\OStringBuffer nmake - all sa_qa_OStringBuffer sa_cppunittester sa_util NULL
sa sal\qa\osl\mutex nmake - all sa_qa_osl_mutex sa_cppunittester sa_util NULL
-sa sal\qa\osl\pipe nmake - all sa_qa_osl_pipe sa_cppunittester sa_util NULL
sa sal\qa\osl\profile nmake - all sa_qa_osl_profile sa_cppunittester sa_util NULL
sa sal\qa\osl\setthreadname nmake - all sa_qa_osl_setthreadname sa_cppunittester sa_util NULL
sa sal\qa\rtl\math nmake - all sa_qa_rtl_math sa_cppunittester sa_util NULL
commit 5300cdf1769a633166b630815ce8e1431a315bf8
Author: Jürgen Schmidt <jsc at apache.org>
Date: Tue Jun 3 13:33:59 2014 +0000
#125038# migrate sal/qa/osl/pipe tests to gtest
diff --git a/sal/prj/build.lst b/sal/prj/build.lst
index f02c578..710f21e 100644
--- a/sal/prj/build.lst
+++ b/sal/prj/build.lst
@@ -16,6 +16,7 @@ sa sal\osl\all nmake - all sa_oslall sa_tc.u sa_inc NULL
sa sal\util nmake - all sa_util sa_tc.u sa_oslall sa_uwinapi.n sa_kill.n sa_onlineupdate.n sa_osln.n sa_oslp.p sa_oslu.u sa_rtl sa_textenc NULL
sa sal\qa\sal nmake - all sa_qa_sal sa_util NULL
sa sal\qa\osl\condition nmake - all sa_qa_osl_condition sa_util NULL
+sa sal\qa\osl\pipe nmake - all sa_qa_osl_pipe sa_util NULL
sa sal\cppunittester nmake - all sa_cppunittester sa_cpprt.u sa_util NULL
sa sal\qa\ByteSequence nmake - all sa_qa_ByteSequence sa_cppunittester sa_util NULL
diff --git a/sal/qa/osl/pipe/makefile.mk b/sal/qa/osl/pipe/makefile.mk
index 4378a51..776470c 100644
--- a/sal/qa/osl/pipe/makefile.mk
+++ b/sal/qa/osl/pipe/makefile.mk
@@ -20,15 +20,10 @@
#**************************************************************
-
-.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
-nothing .PHONY:
-.ELSE
-
PRJ=..$/..$/..
PRJNAME=sal
-TARGET=qa_osl_pipe
+TARGET=sal_ut_osl_pipe
ENABLE_EXCEPTIONS=TRUE
@@ -39,28 +34,20 @@ ENABLE_EXCEPTIONS=TRUE
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
-# BEGIN ----------------------------------------------------------------
-# auto generated Target:Pipe by codegen.pl
-SHL1OBJS= \
- $(SLO)$/osl_Pipe.obj
-
-SHL1TARGET= osl_Pipe
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTLIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+.ELSE
-DEF1NAME =$(SHL1TARGET)
-SHL1VERSIONMAP = $(PRJ)$/qa$/export.map
-SHL1RPATH = NONE
-# auto generated Target:Pipe
-# END ------------------------------------------------------------------
+APP1OBJS = $(OBJ)/osl_Pipe.obj
+APP1RPATH = NONE
+APP1STDLIBS = $(GTESTLIB) $(SALLIB)
+APP1TARGET = sal_ut_osl_pipe
+APP1TEST = enabled
+#APP1TEST = disabled
-# --- Targets ------------------------------------------------------
+.INCLUDE: target.mk
-.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+.ENDIF
-.END
diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx
index ffb2e5b..cda89d3 100644
--- a/sal/qa/osl/pipe/osl_Pipe.cxx
+++ b/sal/qa/osl/pipe/osl_Pipe.cxx
@@ -28,11 +28,6 @@
// include files
//------------------------------------------------------------------------
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
-#include "test/uniquepipename.hxx"
#include <sal/types.h>
#include <rtl/ustring.hxx>
@@ -48,12 +43,15 @@
#include <osl/pipe.hxx>
#endif
#include <osl/time.h>
+#include <osl/process.h>
#ifdef UNX
#include <unistd.h>
#endif
#include <string.h>
+#include "gtest/gtest.h"
+
using namespace osl;
using namespace rtl;
@@ -61,6 +59,16 @@ using namespace rtl;
// helper functions
//------------------------------------------------------------------------
+
+/** helper function for unique pipe names
+ */
+OUString uniquePipeName(OUString const & name) {
+ oslProcessInfo info;
+ info.Size = sizeof info;
+ EXPECT_TRUE( osl_Process_E_None == osl_getProcessInfo(0, osl_Process_IDENTIFIER, &info) );
+ return name + OUString::valueOf((sal_Int32)info.Ident);
+}
+
/** print Boolean value.
*/
inline void printBool( sal_Bool bOk )
@@ -133,9 +141,9 @@ inline void printPipeError( ::osl::Pipe aPipe )
//------------------------------------------------------------------------
const rtl::OUString aTestPipeName = rtl::OUString::createFromAscii( "testpipe2" );
const rtl::OUString aTestPipe1 = rtl::OUString::createFromAscii( "testpipe1" );
-const rtl::OUString aTestString = rtl::OUString::createFromAscii( "Sun Microsystems" );
+const rtl::OUString aTestString = rtl::OUString::createFromAscii( "Apache Software Foundation" );
-const OString m_pTestString1("Sun Microsystems");
+const OString m_pTestString1("Apache Software Foundation");
const OString m_pTestString2("test pipe PASS/OK");
//------------------------------------------------------------------------
@@ -158,159 +166,119 @@ namespace osl_Pipe
inline Pipe(oslPipe pipe, __sal_NoAcquire noacquire );
inline Pipe(oslPipe Pipe);
*/
- class ctors : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void setUp( )
- {
- }
-
- void tearDown( )
- {
- }
+ TEST(Sal_Test_Pipe, ctors_none) {
+ ::osl::Pipe aPipe;
+ sal_Bool bRes = aPipe.is( );
- void ctors_none( )
- {
- ::osl::Pipe aPipe;
- bRes = aPipe.is( );
-
- 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.
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- ::osl::Pipe aAssignPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ // #test comment#: test constructor with no parameter, yet no case to test.
+ ASSERT_TRUE( !bRes );
+ }
- bRes = aPipe.is( ) && aAssignPipe.is( );
+ TEST(Sal_Test_Pipe, ctors_name_option) {
+ /// create a named pipe.
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ ::osl::Pipe aAssignPipe( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name and option.",
- sal_True == bRes );
- }
+ sal_Bool bRes = aPipe.is( ) && aAssignPipe.is( );
- void ctors_name_option_security( )
- {
- /// create a security pipe.
- const ::osl::Security rSecurity;
- ::osl::Pipe aSecurityPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity );
+ // #test comment#: test constructor with name and option.
+ ASSERT_TRUE( bRes );
+ }
- bRes = aSecurityPipe.is( );
+ TEST(Sal_Test_Pipe, ctors_name_option_security) {
+ /// create a security pipe.
+ const ::osl::Security rSecurity;
+ ::osl::Pipe aSecurityPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.",
- sal_True == bRes );
- }
+ sal_Bool bRes = aSecurityPipe.is( );
- void ctors_copy( )
- {
- /// create a pipe.
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- /// create a pipe using copy constructor.
- ::osl::Pipe aCopyPipe( aPipe );
+ // #test comment#: test constructor with name, option and security, the test of security is not implemented yet.
+ ASSERT_TRUE( bRes );
+ }
- bRes = aCopyPipe.is( ) && aCopyPipe == aPipe;
+ TEST(Sal_Test_Pipe, ctors_copy) {
+ /// create a pipe.
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ /// create a pipe using copy constructor.
+ ::osl::Pipe aCopyPipe( aPipe );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.",
- sal_True == bRes );
- }
+ sal_Bool bRes = aCopyPipe.is( ) && aCopyPipe == aPipe;
- /** tester comment:
+ // #test comment#: test copy constructor.
+ ASSERT_TRUE( bRes );
+ }
- 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)).
- */
- void ctors_no_acquire( )
- {
- /// create a pipe.
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- /// constructs a pipe reference without acquiring the handle.
- ::osl::Pipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE );
+ /** tester comment:
- bRes = aNoAcquirePipe.is( );
- ///aPipe.clear( );
- ///bRes1 = aNoAcquirePipe.is( );
+ 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)).
+ */
+ TEST(Sal_Test_Pipe, ctors_no_acquire) {
+ /// create a pipe.
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ /// constructs a pipe reference without acquiring the handle.
+ ::osl::Pipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE );
+ sal_Bool bRes = aNoAcquirePipe.is( );
+ ///aPipe.clear( );
+ ///bRes1 = aNoAcquirePipe.is( );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle, only validation test, do not know how to test no acquire.",
- sal_True == bRes );
- }
- void ctors_acquire( )
- {
- /// create a base pipe.
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- /// constructs two pipes without acquiring the handle on the base pipe.
- ::osl::Pipe aAcquirePipe( aPipe.getHandle( ) );
- ::osl::Pipe aAcquirePipe1( NULL );
+ // #test comment#: test constructor with no acquire of handle, only validation test, do not know how to test no acquire.
+ ASSERT_TRUE( bRes );
+ }
- bRes = aAcquirePipe.is( );
- bRes1 = aAcquirePipe1.is( );
+ TEST(Sal_Test_Pipe, ctors_acquire) {
+ /// create a base pipe.
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ /// constructs two pipes without acquiring the handle on the base pipe.
+ ::osl::Pipe aAcquirePipe( aPipe.getHandle( ) );
+ ::osl::Pipe aAcquirePipe1( NULL );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle.only validation test, do not know how to test no acquire.",
- sal_True == bRes && sal_False == bRes1 );
- }
+ sal_Bool bRes = aAcquirePipe.is( );
+ sal_Bool bRes1 = aAcquirePipe1.is( );
- CPPUNIT_TEST_SUITE( ctors );
- CPPUNIT_TEST( ctors_none );
- CPPUNIT_TEST( ctors_name_option );
- CPPUNIT_TEST( ctors_name_option_security );
- CPPUNIT_TEST( ctors_copy );
- CPPUNIT_TEST( ctors_no_acquire );
- CPPUNIT_TEST( ctors_acquire );
- CPPUNIT_TEST_SUITE_END( );
- }; // class ctors
+ // #test comment#: test constructor with no acquire of handle.only validation test, do not know how to test no acquire.
+ ASSERT_TRUE( bRes && !bRes1 );
+ }
/** testing the method:
inline sal_Bool SAL_CALL is() const;
*/
- class is : public CppUnit::TestFixture
- {
- public:
- void is_001( )
- {
- ::osl::Pipe aPipe;
+ TEST(Sal_Test_Pipe, 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( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // #test comment#: test is(), check if the pipe is a valid one.
+ ASSERT_TRUE( !aPipe.is( ) );
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), a normal pipe creation.", sal_True == aPipe.is( ) );
- }
+ TEST(Sal_Test_Pipe, is_002) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- void is_003( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe.clear( );
+ // #test comment#: test is(), a normal pipe creation.
+ ASSERT_TRUE( aPipe.is( ) );
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), an invalid case.", sal_False == aPipe.is( ) );
- }
+ TEST(Sal_Test_Pipe, is_003) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe.clear( );
- void is_004( )
- {
- ::osl::Pipe aPipe( NULL );
+ // #test comment#: test is(), an invalid case
+ ASSERT_TRUE( !aPipe.is( ) );
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), an invalid constructor.", sal_False == aPipe.is( ) );
- }
+ TEST(Sal_Test_Pipe, is_004) {
+ ::osl::Pipe aPipe( NULL );
- CPPUNIT_TEST_SUITE( is );
- CPPUNIT_TEST( is_001 );
- CPPUNIT_TEST( is_002 );
- CPPUNIT_TEST( is_003 );
- CPPUNIT_TEST( is_004 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class is
+ // #test comment#: test is(), an invalid constructor.
+ ASSERT_TRUE( !aPipe.is( ) );
+ }
/** testing the methods:
@@ -319,387 +287,244 @@ namespace osl_Pipe
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:
+ TEST(Sal_Test_Pipe, create_named_security_001) {
+ const Security rSec;
+ ::osl::Pipe aPipe;
+ sal_Bool bRes = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
+ sal_Bool bRes1 = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
+ aPipe.clear( );
+
+ // #test comment#: test creation.
+ ASSERT_TRUE( bRes && !bRes1 );
+ }
- security create only be tested creation, security section is
- untested yet.
- */
+ TEST(Sal_Test_Pipe, create_named_security_002) {
+ const Security rSec;
+ ::osl::Pipe aPipe, aPipe1;
+ sal_Bool bRes = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
+ sal_Bool bRes1 = aPipe1.create( uniquePipeName(aTestPipeName), osl_Pipe_OPEN, rSec );
+ aPipe.clear( );
- void create_named_security_001( )
- {
- const Security rSec;
- ::osl::Pipe aPipe;
- bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
- bRes1 = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
- aPipe.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.",
- sal_True == bRes && sal_False == bRes1);
- }
-
- void create_named_security_002( )
- {
- const Security rSec;
- ::osl::Pipe aPipe, aPipe1;
- bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec );
- bRes1 = aPipe1.create( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN, rSec );
- aPipe.clear( );
-
- 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( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- bRes1 = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe.clear( );
+ // #test comment#: test creation and open.
+ ASSERT_TRUE( bRes && bRes1 );
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.",
- sal_True == bRes && sal_False == bRes1);
- }
+ TEST(Sal_Test_Pipe, create_named_001) {
+ ::osl::Pipe aPipe;
+ sal_Bool bRes = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ sal_Bool bRes1 = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe.clear( );
- void create_named_002( )
- {
- ::osl::Pipe aPipe, aPipe1;
- bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- bRes1 = aPipe1.create( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
- aPipe.clear( );
+ // #test comment#: test creation.
+ ASSERT_TRUE( bRes && !bRes1);
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.",
- sal_True == bRes && sal_True == bRes1);
- }
+ TEST(Sal_Test_Pipe, create_named_002) {
+ ::osl::Pipe aPipe, aPipe1;
+ sal_Bool bRes = aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ sal_Bool bRes1 = aPipe1.create( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ aPipe.clear( );
- void create_named_003( )
- {
- ::osl::Pipe aPipe;
- bRes = aPipe.create( test::uniquePipeName(aTestPipeName) );
- aPipe.clear( );
+ // #test comment#: test creation and open.
+ ASSERT_TRUE( bRes && bRes1);
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test default option is open.",
- sal_False == bRes );
- }
+ TEST(Sal_Test_Pipe, create_named_003) {
+ ::osl::Pipe aPipe;
+ sal_Bool bRes = aPipe.create( uniquePipeName(aTestPipeName) );
+ aPipe.clear( );
- 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( );
- }; // class create
+ // #test comment#: test default option is open.
+ ASSERT_TRUE( !bRes );
+ }
/** testing the method:
inline void SAL_CALL clear();
*/
- class clear : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void clear_001( )
- {
- ::osl::Pipe aPipe;
- aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe.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( );
- }; // class clear
+ TEST(Sal_Test_Pipe, clear_001) {
+ ::osl::Pipe aPipe;
+ aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe.clear( );
+ sal_Bool bRes = aPipe.is( );
+
+ // #test comment#: test clear.
+ ASSERT_TRUE( !bRes );
+ }
/** testing the methods:
inline Pipe& SAL_CALL operator= (const Pipe& pipe);
inline Pipe& SAL_CALL operator= (const oslPipe pipe );
*/
- class assign : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void assign_ref( )
- {
- ::osl::Pipe aPipe, aPipe1;
- aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe1 = aPipe;
- bRes = aPipe1.is( );
- bRes1 = aPipe == aPipe1;
- aPipe.close( );
- 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( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe1 = aPipe.getHandle( );
- bRes = aPipe1.is( );
- bRes1 = aPipe == aPipe1;
- aPipe.close( );
- aPipe1.close( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.",
- sal_True == bRes && sal_True == bRes1 );
- }
+ TEST(Sal_Test_Pipe, assign_ref) {
+ ::osl::Pipe aPipe, aPipe1;
+ aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe1 = aPipe;
+ sal_Bool bRes = aPipe1.is( );
+ sal_Bool bRes1 = aPipe == aPipe1;
+ aPipe.close( );
+ aPipe1.close( );
+
+ // #test comment#: test assign with reference.
+ ASSERT_TRUE( bRes && bRes1 );
+ }
- CPPUNIT_TEST_SUITE( assign );
- CPPUNIT_TEST( assign_ref );
- CPPUNIT_TEST( assign_handle );
- CPPUNIT_TEST_SUITE_END( );
- }; // class assign
+ TEST(Sal_Test_Pipe, assign_handle) {
+ ::osl::Pipe aPipe, aPipe1;
+ aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe1 = aPipe.getHandle( );
+ sal_Bool bRes = aPipe1.is( );
+ sal_Bool bRes1 = aPipe == aPipe1;
+ aPipe.close( );
+ aPipe1.close( );
+
+ // #test comment#: test assign with handle.
+ ASSERT_TRUE( bRes && bRes1 );
+ }
/** 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
*/
- /*class isValid : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void isValid_001( )
- {
- 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( );
- };*/ // class isValid
+ // TEST(Sal_Test_Pipe, isValid_001) {
+ // ...
+ // // #test comment#: isValid() has not been implemented on all platforms.
+ // ASSERT_TRUE( ... );
+ // }
/** testing the method:
inline sal_Bool SAL_CALL operator==( const Pipe& rPipe ) const;
*/
- class isEqual : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void isEqual_001( )
- {
- ::osl::Pipe aPipe;
- aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- bRes = aPipe == aPipe;
- aPipe.close( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(), compare its self.",
- sal_True == bRes );
- }
-
- void isEqual_002( )
- {
- ::osl::Pipe aPipe, aPipe1, aPipe2;
- aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ TEST(Sal_Test_Pipe, isEqual_001) {
+ ::osl::Pipe aPipe;
+ aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ sal_Bool bRes = aPipe == aPipe;
+ aPipe.close( );
+
+ // #test comment#: test isEqual(), compare its self.
+ ASSERT_TRUE( bRes );
+ }
- aPipe1 = aPipe;
- aPipe2.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ TEST(Sal_Test_Pipe, isEqual_002) {
+ ::osl::Pipe aPipe, aPipe1, aPipe2;
+ aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ aPipe1 = aPipe;
+ aPipe2.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- bRes = aPipe == aPipe1;
- bRes1 = aPipe == aPipe2;
- aPipe.close( );
- aPipe1.close( );
- aPipe2.close( );
+ sal_Bool bRes = aPipe == aPipe1;
+ sal_Bool bRes1 = aPipe == aPipe2;
+ aPipe.close( );
+ aPipe1.close( );
+ aPipe2.close( );
- 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( );
- }; // class isEqual
+ // #test comment#: test isEqual(),create one copy instance, and compare.
+ ASSERT_TRUE( bRes && !bRes1 );
+ }
/** testing the method:
inline void SAL_CALL close();
*/
- class close : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
+ TEST(Sal_Test_Pipe, close_001) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipe1), osl_Pipe_CREATE );
+ aPipe.close( );
+ sal_Bool bRes = aPipe.is( );
- void close_001( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipe1), osl_Pipe_CREATE );
- aPipe.close( );
- bRes = aPipe.is( );
-
- aPipe.clear( );
- bRes1 = aPipe.is( );
+ aPipe.clear( );
+ sal_Bool bRes1 = aPipe.is( );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.",
- sal_True == bRes && sal_False == bRes1);
- }
-
- void close_002( )
- {
- ::osl::StreamPipe aPipe( test::uniquePipeName(aTestPipe1), osl_Pipe_CREATE );
- aPipe.close( );
- int nRet = aPipe.send( m_pTestString1.getStr(), 3 );
+ // #test comment#: difference between close and clear.
+ ASSERT_TRUE( bRes && !bRes1);
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: use after close.",
- OSL_PIPE_FAIL == nRet );
- }
+ TEST(Sal_Test_Pipe, close_002) {
+ ::osl::StreamPipe aPipe( uniquePipeName(aTestPipe1), osl_Pipe_CREATE );
+ aPipe.close( );
+ int nRet = aPipe.send( m_pTestString1.getStr(), 3 );
- CPPUNIT_TEST_SUITE( close );
- CPPUNIT_TEST( close_001 );
- CPPUNIT_TEST( close_002 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class close
+ // #test comment#: use after close.
+ ASSERT_EQ( nRet, OSL_PIPE_FAIL );
+ }
/** testing the method:
inline oslPipeError SAL_CALL accept(StreamPipe& Connection);
please refer to StreamPipe::recv
*/
- /* class accept : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void accept_001( )
- {
-
- // CPPUNIT_ASSERT_MESSAGE( "#test comment#: accept, untested.", 1 == 1 );
- //CPPUNIT_ASSERT_STUB();
- }
-
- CPPUNIT_TEST_SUITE( accept );
- CPPUNIT_TEST( accept_001 );
- CPPUNIT_TEST_SUITE_END( );
- };*/ // class accept
/** testing the method:
inline oslPipeError SAL_CALL getError() const;
*/
- class getError : public CppUnit::TestFixture
- {
- public:
- 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
- { EAFNOSUPPORT, osl_Pipe_E_NoProtocol }, // Address family not supported by
- // 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
- { -1, osl_Pipe_E_invalidError }
- };
- did not define osl_Pipe_E_NotFound, osl_Pipe_E_AlreadyExists
- */
-
- void getError_001( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
- oslPipeError nError = aPipe.getError( );
- printPipeError( aPipe );
- aPipe.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: open a non-exist pipe.",
- nError != osl_Pipe_E_None );
- }
+ /*
+ 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
+ { EAFNOSUPPORT, osl_Pipe_E_NoProtocol }, // Address family not supported by
+ // 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
+ { -1, osl_Pipe_E_invalidError }
+ };
+ did not define osl_Pipe_E_NotFound, osl_Pipe_E_AlreadyExists
+ */
+ TEST(Sal_Test_Pipe, getError_001) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ oslPipeError nError = aPipe.getError( );
+ printPipeError( aPipe );
+ aPipe.clear( );
+
+ // #test comment#: open a non-exist pipe.
+ ASSERT_NE( nError, osl_Pipe_E_None );
+ }
- void getError_002( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- ::osl::Pipe aPipe1( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- oslPipeError nError = aPipe.getError( );
- printPipeError( aPipe );
- aPipe.clear( );
- aPipe1.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: create an already exist pipe.",
- nError != osl_Pipe_E_None );
- }
+ TEST(Sal_Test_Pipe, getError_002) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ ::osl::Pipe aPipe1( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ oslPipeError nError = aPipe.getError( );
+ printPipeError( aPipe );
+ aPipe.clear( );
+ aPipe1.clear( );
- CPPUNIT_TEST_SUITE( getError );
- CPPUNIT_TEST( getError_001 );
- CPPUNIT_TEST( getError_002 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getError
+ // #test comment#: create an already exist pipe.
+ ASSERT_NE( nError, osl_Pipe_E_None );
+ }
/** testing the method:
inline oslPipe SAL_CALL getHandle() const;
*/
- class getHandle : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void getHandle_001( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
- bRes = aPipe == aPipe.getHandle( );
- aPipe.clear( );
+ TEST(Sal_Test_Pipe, getHandle_001) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ sal_Bool bRes = aPipe == aPipe.getHandle( );
+ aPipe.clear( );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe should equal to its handle.",
- sal_True == bRes );
- }
+ // #test comment#: one pipe should equal to its handle.
+ ASSERT_TRUE( bRes );
+ }
- void getHandle_002( )
- {
- ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- ::osl::Pipe aPipe1( aPipe.getHandle( ) );
- bRes = aPipe == aPipe1;
- aPipe.clear( );
- aPipe1.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: one pipe derived from another pipe's handle.",
- sal_True == bRes );
- }
+ TEST(Sal_Test_Pipe, getHandle_002) {
+ ::osl::Pipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ ::osl::Pipe aPipe1( aPipe.getHandle( ) );
+ sal_Bool bRes = aPipe == aPipe1;
+ aPipe.clear( );
+ aPipe1.clear( );
- CPPUNIT_TEST_SUITE( getHandle );
- CPPUNIT_TEST( getHandle_001 );
- CPPUNIT_TEST( getHandle_002 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class getHandle
-
-
-// -----------------------------------------------------------------------------
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::ctors);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::is);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::create);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::clear);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::assign);
-//CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::isValid);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::isEqual);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::close);
- //CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::accept);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::getError);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_Pipe::getHandle);
-// -----------------------------------------------------------------------------
+ // #test comment#: one pipe derived from another pipe's handle.
+ ASSERT_TRUE( bRes );
+ }
} // namespace osl_Pipe
@@ -715,166 +540,130 @@ namespace osl_StreamPipe
inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec );
inline StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire );
*/
- class ctors : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
-
- void ctors_none( )
- {
- // create a pipe.
- ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- // create an unattached pipe.
- ::osl::StreamPipe aStreamPipe1;
- bRes = aStreamPipe1.is( );
-
- // 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.",
- sal_False == bRes && sal_True == bRes1 );
- }
-
- void ctors_handle( )
- {
- // create a pipe.
- ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- // create a pipe with last handle.
- ::osl::StreamPipe aStreamPipe1( aStreamPipe.getHandle( ) );
- bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1;
- aStreamPipe.clear( );
- aStreamPipe1.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with other's handle.",
- sal_True == bRes );
- }
-
- void ctors_copy( )
- {
- // create a pipe.
- ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- // create an unattached pipe.
- ::osl::StreamPipe aStreamPipe1( aStreamPipe );
- bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1;
- aStreamPipe.clear( );
- aStreamPipe1.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.",
- sal_True == bRes );
- }
-
- void ctors_name_option( )
- {
- // create a pipe.
- ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- // create an unattached pipe.
- ::osl::StreamPipe aStreamPipe1( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
- bRes = aStreamPipe1.is( ) && aStreamPipe.is( );
- aStreamPipe.clear( );
- aStreamPipe1.clear( );
-
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name and option.",
- sal_True == bRes );
- }
- void ctors_name_option_security( )
- {
- /// create a security pipe.
- const ::osl::Security rSecurity;
- ::osl::StreamPipe aSecurityPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity );
-
- bRes = aSecurityPipe.is( );
- aSecurityPipe.clear( );
+ TEST(Sal_Test_StreamPipe, ctors_none) {
+ // create a pipe.
+ ::osl::StreamPipe aStreamPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // create an unattached pipe.
+ ::osl::StreamPipe aStreamPipe1;
+ sal_Bool bRes = aStreamPipe1.is( );
+
+ // assign it and check.
+ aStreamPipe1 = aStreamPipe;
+ sal_Bool bRes1 = aStreamPipe1.is( );
+ aStreamPipe.clear( );
+ aStreamPipe1.clear( );
+
+ // #test comment#: test constructor with no parameter, before and after assign.
+ ASSERT_TRUE( !bRes && bRes1 );
+ }
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.",
- sal_True == bRes );
- }
+ TEST(Sal_Test_StreamPipe, ctors_handle) {
+ // create a pipe.
+ ::osl::StreamPipe aStreamPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // create a pipe with last handle.
+ ::osl::StreamPipe aStreamPipe1( aStreamPipe.getHandle( ) );
+ sal_Bool bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1;
+ aStreamPipe.clear( );
+ aStreamPipe1.clear( );
+
+ // #test comment#: test constructor with other's handle.
+ ASSERT_TRUE( bRes );
+ }
- /** tester comment:
+ TEST(Sal_Test_StreamPipe, ctors_copy) {
+ // create a pipe.
+ ::osl::StreamPipe aStreamPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // create an unattached pipe.
+ ::osl::StreamPipe aStreamPipe1( aStreamPipe );
+ sal_Bool bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1;
+ aStreamPipe.clear( );
+ aStreamPipe1.clear( );
+
+ // #test comment#: test copy constructor.
+ ASSERT_TRUE( bRes );
+ }
- 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)).
- */
+ TEST(Sal_Test_StreamPipe, ctors_name_option) {
+ // create a pipe.
+ ::osl::StreamPipe aStreamPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // create an unattached pipe.
+ ::osl::StreamPipe aStreamPipe1( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ sal_Bool bRes = aStreamPipe1.is( ) && aStreamPipe.is( );
+ aStreamPipe.clear( );
+ aStreamPipe1.clear( );
+
+ // #test comment#: test constructor with name and option.
+ ASSERT_TRUE( bRes );
+ }
- void ctors_no_acquire( )
- {
- // create a pipe.
- ::osl::StreamPipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- // constructs a pipe reference without acquiring the handle.
- ::osl::StreamPipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE );
+ TEST(Sal_Test_StreamPipe, ctors_name_option_security) {
+ // create a security pipe.
+ const ::osl::Security rSecurity;
+ ::osl::StreamPipe aSecurityPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity );
- bRes = aNoAcquirePipe.is( );
- aPipe.clear( );
- // bRes1 = aNoAcquirePipe.is( );
+ sal_Bool bRes = aSecurityPipe.is( );
+ aSecurityPipe.clear( );
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle, only validation test, do not know how to test no acquire.",
- sal_True == bRes );
- }
+ // #test comment#: test constructor with name, option and security, the test of security is not implemented yet.
+ ASSERT_TRUE( bRes );
+ }
- CPPUNIT_TEST_SUITE( ctors );
- CPPUNIT_TEST( ctors_none );
- CPPUNIT_TEST( ctors_handle );
- CPPUNIT_TEST( ctors_copy );
- CPPUNIT_TEST( ctors_name_option );
- CPPUNIT_TEST( ctors_name_option_security );
- CPPUNIT_TEST( ctors_no_acquire );
- CPPUNIT_TEST_SUITE_END( );
- }; // class ctors
+ /** tester comment:
+ 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)).
+ */
+ TEST(Sal_Test_StreamPipe, ctors_no_acquire) {
+ // create a pipe.
+ ::osl::StreamPipe aPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // constructs a pipe reference without acquiring the handle.
+ ::osl::StreamPipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE );
+
+ sal_Bool bRes = aNoAcquirePipe.is( );
+ aPipe.clear( );
+ // bRes1 = aNoAcquirePipe.is( );
+
+ // #test comment#: test constructor with no acquire of handle, only validation test, do not know how to test no acquire.
+ ASSERT_TRUE( bRes );
+ }
/** testing the methods:
inline StreamPipe & SAL_CALL operator=(oslPipe Pipe);
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( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- aPipe1 = aPipe;
- bRes = aPipe1.is( );
- bRes1 = aPipe == aPipe1;
- aPipe.close( );
- 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( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- ::osl::StreamPipe * pAssignPipe = new ::osl::StreamPipe;
- *pAssignPipe = pPipe->getHandle( );
-
- bRes = pAssignPipe->is( );
- bRes1 = ( *pPipe == *pAssignPipe );
- pPipe->close( );
-
- delete pAssignPipe;
-
- 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( );
- };*/ // class assign
+ // TEST(Sal_Test_StreamPipe, assign_ref) {
+ // ::osl::StreamPipe aPipe, aPipe1;
+ // aPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // aPipe1 = aPipe;
+ // sal_Bool bRes = aPipe1.is( );
+ // sal_Bool bRes1 = aPipe == aPipe1;
+ // aPipe.close( );
+ // aPipe1.close( );
+
+ // // #test comment#: test assign with reference.
+ // ASSERT_TRUE( bRes && bRes1 );
+ // }
+
+ // TEST(Sal_Test_StreamPipe, assign_ref) {
+ // ::osl::StreamPipe * pPipe = new ::osl::StreamPipe( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ // ::osl::StreamPipe * pAssignPipe = new ::osl::StreamPipe;
+ // *pAssignPipe = pPipe->getHandle( );
+
+ // bRes = pAssignPipe->is( );
+ // bRes1 = ( *pPipe == *pAssignPipe );
+ // pPipe->close( );
+
+ // delete pAssignPipe;
+
+ // // #test comment#: test assign with handle., seems not implemented under (LINUX)(W32)
+ // ASSERT_TRUE( bRes && bRes1 );
+ // }
/** wait _nSec seconds.
@@ -893,7 +682,8 @@ namespace osl_StreamPipe
#endif
// printf("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,39 +693,39 @@ namespace osl_StreamPipe
Pipe_DataSink_Thread( ) { }
~Pipe_DataSink_Thread( )
- {
- }
+ {
+ }
protected:
void SAL_CALL run( )
- {
- sal_Int32 nChars = 0;
+ {
+ sal_Int32 nChars = 0;
- printf("open pipe\n");
- ::osl::StreamPipe aSenderPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); // test::uniquePipeName(aTestPipeName) is a string = "TestPipe"
- if ( aSenderPipe.is() == sal_False )
+ printf("open pipe\n");
+ // uniquePipeName(aTestPipeName) is a string = "TestPipe"
+ ::osl::StreamPipe aSenderPipe( uniquePipeName(aTestPipeName), osl_Pipe_OPEN );
+ if ( aSenderPipe.is() == sal_False )
+ {
+ printf("pipe open failed! \n");
+ }
+ else
+ {
+ printf("read\n");
+ nChars = aSenderPipe.read( buf, m_pTestString1.getLength() + 1 );
+ if ( nChars < 0 )
{
- printf("pipe open failed! \n");
+ printf("read failed! \n");
+ return;
}
- else
+ printf("buffer is %s \n", buf);
+ printf("send\n");
+ nChars = aSenderPipe.send( m_pTestString2.getStr(), m_pTestString2.getLength() + 1 );
+ if ( nChars < 0 )
{
- printf("read\n");
- nChars = aSenderPipe.read( buf, m_pTestString1.getLength() + 1 );
- if ( nChars < 0 )
- {
- printf("read failed! \n");
- return;
- }
- printf("buffer is %s \n", buf);
- printf("send\n");
- nChars = aSenderPipe.send( m_pTestString2.getStr(), m_pTestString2.getLength() + 1 );
- if ( nChars < 0 )
- {
- printf("client send failed! \n");
- return;
- }
+ printf("client send failed! \n");
+ return;
}
}
-
+ }
};
// -----------------------------------------------------------------------------
@@ -944,113 +734,89 @@ namespace osl_StreamPipe
{
public:
sal_Char buf[256];
- //::osl::StreamPipe aListenPipe; //( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ //::osl::StreamPipe aListenPipe; //( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
::osl::Pipe aListenPipe;
::osl::StreamPipe aConnectionPipe;
Pipe_DataSource_Thread( )
- {
- printf("create pipe\n");
- aListenPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- }
+ {
+ printf("create pipe\n");
+ aListenPipe.create( uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ }
~Pipe_DataSource_Thread( )
- {
- aListenPipe.close();
- }
+ {
+ aListenPipe.close();
+ }
protected:
void SAL_CALL run( )
+ {
+ //create pipe.
+ sal_Int32 nChars;
+ //::osl::StreamPipe aListenPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
+ printf("listen\n");
+ if ( aListenPipe.is() == sal_False )
{
- //create pipe.
- sal_Int32 nChars;
- //::osl::StreamPipe aListenPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
- printf("listen\n");
- if ( aListenPipe.is() == sal_False )
+ printf("pipe create failed! \n");
+ }
+ else
+ {
+ //::osl::StreamPipe aConnectionPipe;
+
+ //start server and wait for connection.
+ printf("accept\n");
+ if ( osl_Pipe_E_None != aListenPipe.accept( aConnectionPipe ) )
{
- printf("pipe create failed! \n");
+ printf("pipe accept failed!");
+ return;
}
- else
+ printf("write\n");
+ // write to pipe
+ nChars = aConnectionPipe.write( m_pTestString1.getStr(), m_pTestString1.getLength() + 1 );
+ if ( nChars < 0)
{
- //::osl::StreamPipe aConnectionPipe;
-
- //start server and wait for connection.
- printf("accept\n");
- if ( osl_Pipe_E_None != aListenPipe.accept( aConnectionPipe ) )
- {
- printf("pipe accept failed!");
- return;
- }
- printf("write\n");
- // write to pipe
- nChars = aConnectionPipe.write( m_pTestString1.getStr(), m_pTestString1.getLength() + 1 );
- if ( nChars < 0)
- {
- printf("server write failed! \n");
- return;
- }
- printf("recv\n");
- nChars = aConnectionPipe.recv( buf, 256 );
-
- if ( nChars < 0)
- {
- printf("server receive failed! \n");
- return;
- }
- //thread_sleep( 2 );
- printf("received message is: %s\n", buf );
- //aConnectionPipe.close();
+ printf("server write failed! \n");
+ return;
}
+ printf("recv\n");
+ nChars = aConnectionPipe.recv( buf, 256 );
+
+ if ( nChars < 0)
+ {
+ printf("server receive failed! \n");
+ return;
+ }
+ //thread_sleep( 2 );
+ printf("received message is: %s\n", buf );
+ //aConnectionPipe.close();
}
+ }
};
+
/** testing the method: read/write/send/recv and Pipe::accept
*/
- class recv : public CppUnit::TestFixture
- {
- public:
- sal_Bool bRes, bRes1;
+ TEST(Sal_Test_StreamPipe, recv_001) {
+ //launch threads.
+ Pipe_DataSource_Thread myDataSourceThread;
+ Pipe_DataSink_Thread myDataSinkThread;
+ myDataSourceThread.create( );
+ thread_sleep( 1 );
+ myDataSinkThread.create( );
- void recv_001( )
- {
- //launch threads.
- Pipe_DataSource_Thread myDataSourceThread;
- Pipe_DataSink_Thread myDataSinkThread;
- myDataSourceThread.create( );
- thread_sleep( 1 );
- myDataSinkThread.create( );
-
- //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 );
- }
- //close pipe when accept
- void recv_002()
- {
- thread_sleep( 1 );
-
- Pipe_DataSource_Thread myDataSourceThread;
- Pipe_DataSink_Thread myDataSinkThread;
- myDataSourceThread.create( );
- thread_sleep( 1 );
- myDataSourceThread.aListenPipe.close();
- myDataSourceThread.join( );
- //no condition judgement here, if the case could finish excuting within 1 or 2 seconds, it passes.
- }
+ //wait until the thread terminate
+ myDataSinkThread.join( );
+ myDataSourceThread.join( );
- CPPUNIT_TEST_SUITE( recv );
- CPPUNIT_TEST( recv_001 );
- CPPUNIT_TEST( recv_002 );
- CPPUNIT_TEST_SUITE_END( );
- }; // class recv
+ int nCompare1 = strcmp( myDataSinkThread.buf, m_pTestString1.getStr() );
+ int nCompare2 = strcmp( myDataSourceThread.buf, m_pTestString2.getStr() );
-// -----------------------------------------------------------------------------
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_StreamPipe::ctors);
-//CPPUNIT_TEST_SUITE_REGISTRATION(osl_StreamPipe::assign);
- CPPUNIT_TEST_SUITE_REGISTRATION(osl_StreamPipe::recv);
-// -----------------------------------------------------------------------------
+ // test send/recv/write/read.
+ ASSERT_TRUE( nCompare1 == 0 && nCompare2 == 0 );
+ }
} // namespace osl_StreamPipe
-CPPUNIT_PLUGIN_IMPLEMENT();
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
More information about the Libreoffice-commits
mailing list