From: srn Date: Thu, 9 Mar 2006 12:37:15 +0000 (+0000) Subject: Cppunit tests for AttributeParameters X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0869552e79a36e89157adb7d7897ab1e3eab444;p=modules%2Fkernel.git Cppunit tests for AttributeParameters --- diff --git a/src/SALOMEDSImpl/Test/Makefile.in b/src/SALOMEDSImpl/Test/Makefile.in new file mode 100644 index 000000000..07480c055 --- /dev/null +++ b/src/SALOMEDSImpl/Test/Makefile.in @@ -0,0 +1,62 @@ +# SALOMELocalTrace : log on local machine +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Sergey RUIN +# Module : SALOME + +top_srcdir=@top_srcdir@ +top_builddir=../../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= SALOMEDSImplTest.hxx + +EXPORT_PYSCRIPTS = TestSALOMEDSImpl.py + +# Libraries targets + +LIB = libSALOMEDSImplTest.la +LIB_SRC = SALOMEDSImplTest.cxx + +# Executables targets + +BIN = TestSALOMEDSImpl +BIN_SRC = + +CXXFLAGS += $(OCC_CXXFLAGS) @CPPUNIT_INCLUDES@ +CPPFLAGS += $(OCC_INCLUDES) @CPPUNIT_INCLUDES@ + +LIBS= @LIBS@ @CPPUNIT_LIBS@ + +LDFLAGS+=$(CAS_OCAF) + +LDFLAGSFORBIN+= -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeDSImpl $(LDFLAGS) -lSALOMEDSImplTest + +UNIT_TEST_PROG = TestSALOMEDSImpl + +@CONCLUDE@ diff --git a/src/SALOMEDSImpl/Test/SALOMEDSImplTest.cxx b/src/SALOMEDSImpl/Test/SALOMEDSImplTest.cxx new file mode 100644 index 000000000..7ce2e5416 --- /dev/null +++ b/src/SALOMEDSImpl/Test/SALOMEDSImplTest.cxx @@ -0,0 +1,129 @@ +// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// + +#include "SALOMEDSImplTest.hxx" + +#include +#include +#include +#include +#include +#include "utilities.h" + +#include "SALOMEDSImpl_AttributeParameter.hxx" +#include "SALOMEDSImpl_StudyManager.hxx" +#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" + +#include + +using namespace std; + +// ============================================================================ +/*! + * Set up the environment + */ +// ============================================================================ + +void SALOMEDSImplTest::setUp() +{ + TCollection_AsciiString kernel(getenv("KERNEL_ROOT_DIR")); + TCollection_AsciiString subPath("/share/salome/resources"); + TCollection_AsciiString csf_var = (kernel+subPath); + setenv("CSF_PluginDefaults", csf_var.ToCString(), 0); + setenv("CSF_SALOMEDS_ResourcesDefaults", csf_var.ToCString(), 0); +} + +// ============================================================================ +/*! + * - delete trace classes + */ +// ============================================================================ + +void +SALOMEDSImplTest::tearDown() +{ +} + +// ============================================================================ +/*! + * Check setting int value + */ +// ============================================================================ +void SALOMEDSImplTest::testAttributeParameter() +{ + Handle(SALOMEDSImpl_StudyManager) sm = new SALOMEDSImpl_StudyManager(); + Handle(SALOMEDSImpl_Study) study = sm->NewStudy("Test"); + Handle(SALOMEDSImpl_AttributeParameter) _ap = study->GetCommonParameters("TestComp", 0); + + CPPUNIT_ASSERT(!_ap.IsNull()); + + _ap->SetInt("IntValue", 1); + CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER)); + CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1); + + _ap->SetReal("RealValue", 1.2); + CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL)); + CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2); + + _ap->SetString("StringValue", "hello"); + CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING)); + CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello"); + + _ap->SetBool("BoolValue", 0); + CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN)); + CPPUNIT_ASSERT(!_ap->GetBool("BoolValue")); + + _ap->SetBool("BoolValue", 0); + CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN)); + CPPUNIT_ASSERT(!_ap->GetBool("BoolValue")); + + vector intArray; + intArray.push_back(0); + intArray.push_back(1); + + _ap->SetIntArray("IntArray", intArray); + CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY)); + CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0); + CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1); + + vector realArray; + realArray.push_back(0.0); + realArray.push_back(1.1); + + _ap->SetRealArray("RealArray", realArray); + CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY)); + CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0); + CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1); + + vector strArray; + strArray.push_back("hello"); + strArray.push_back("world"); + + _ap->SetStrArray("StrArray", strArray); + CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY)); + CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello"); + CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world"); + +} + + + diff --git a/src/SALOMEDSImpl/Test/SALOMEDSImplTest.hxx b/src/SALOMEDSImpl/Test/SALOMEDSImplTest.hxx new file mode 100644 index 000000000..0abba8283 --- /dev/null +++ b/src/SALOMEDSImpl/Test/SALOMEDSImplTest.hxx @@ -0,0 +1,39 @@ +// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// + +#ifndef _SALOMEDSImplTEST_HXX_ +#define _SALOMEDSImplTEST_HXX_ + +#include + +class SALOMEDSImplTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( SALOMEDSImplTest ); + CPPUNIT_TEST( testAttributeParameter ); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp(); + void tearDown(); + void testAttributeParameter(); +}; + +#endif diff --git a/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.cxx b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.cxx new file mode 100644 index 000000000..2456fc6ed --- /dev/null +++ b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.cxx @@ -0,0 +1,31 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ +// + +// --- include all SALOMEDSImpl Test from basics until the present directory + +#include "SALOMEDSImplTest.hxx" + +// --- Registers the fixture into the 'registry' + +CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSImplTest ); + +// --- generic Main program from Basic/Test + +#include "BasicMainTest.hxx" diff --git a/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py new file mode 100644 index 000000000..985241ad8 --- /dev/null +++ b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py @@ -0,0 +1,29 @@ + +import sys, os,signal,string,commands +import runSalome +import orbmodule +import TestKiller + +# get SALOME environment : + +args, modules_list, modules_root_dir = runSalome.get_config() +runSalome.set_env(args, modules_list, modules_root_dir) + +# launch CORBA naming server + +clt=orbmodule.client() + +# launch CORBA logger server + +myServer=runSalome.LoggerServer(args) +myServer.run() +clt.waitLogger("Logger") + +# execute Unit Test + +command = ['TestSALOMEDSImpl'] +ret = os.spawnvp(os.P_WAIT, command[0], command) + +# kill Test process + +TestKiller.killProcess(runSalome.process_id)