-I$(srcdir)/$(RPATH)/Utils -I$(srcdir)/$(RPATH)/Utils/Test \
-I$(srcdir)/$(RPATH)/ResourcesManager \
-I$(srcdir)/$(RPATH)/LifeCycleCORBA \
+ -I$(srcdir)/$(RPATH)/SALOMEDS \
-I$(srcdir)/$(RPATH)/SALOMEDSClient \
-I$(srcdir)/$(RPATH)/SALOMEDSImpl -I$(srcdir)/$(RPATH)/SALOMEDSImpl/Test \
-I$(top_builddir)/salome_adm/unix \
libSALOMEDSTest.la ../libSalomeDS.la \
$(RPATH)/NamingService/Test/libNamingServiceTest.la \
$(COMMON_LIBS)
-
#include "SALOMEDSTest.hxx"
+
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "utilities.h"
+#include "Utils_SINGLETON.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
-#include "utilities.h"
-#include "Utils_SALOME_Exception.hxx"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
-#include "OpUtil.hxx"
#include "SALOMEDSClient.hxx"
-#include "SALOMEDSClient_ClientFactory.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "SALOMEDS_StudyManager.hxx"
+#include "SALOMEDS_SObject.hxx"
+
#include <TCollection_AsciiString.hxx>
+#include <Standard_GUID.hxx>
using namespace std;
-#define PT_INTEGER 0
-#define PT_REAL 1
-#define PT_BOOLEAN 2
-#define PT_STRING 3
-#define PT_REALARRAY 4
-#define PT_INTARRAY 5
-#define PT_STRARRAY 6
-
-
-#define TRACEFILE "/tmp/traceUnitTest.log"
-
// ============================================================================
/*!
* Set up the environment
*/
// ============================================================================
-
+
void SALOMEDSTest::setUp()
-{
- TCollection_AsciiString kernel(getenv("KERNEL_ROOT_DIR"));
- TCollection_AsciiString subPath("/share/salome/resources/kernel");
- TCollection_AsciiString csf_var = (kernel+subPath);
- setenv("CSF_PluginDefaults", csf_var.ToCString(), 0);
- setenv("CSF_SALOMEDS_ResourcesDefaults", csf_var.ToCString(), 0);
-
- // --- trace on file
- char *theFileName = TRACEFILE;
-
- string s = "file:";
- s += theFileName;
- CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
-
- ofstream traceFile;
- traceFile.open(theFileName, ios::out | ios::app);
- CPPUNIT_ASSERT(traceFile); // file created empty, then closed
- traceFile.close();
-
- LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
- CPPUNIT_ASSERT(bp1);
+{
+ int argc = 1;\r
+ char* argv[] = {""};\r
- // --- Get or initialize the orb
-
- int _argc = 1;
- char* _argv[] = {""};
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
- _orb = init(_argc , _argv ) ;
-
- sleep(2);
-
- // --- Create a SALOME_NamingService instance
+ _orb = init(argc , argv ) ;
+ SALOME_NamingService NS(_orb);
+ CORBA::Object_var obj = NS.Resolve( "/myStudyManager" );
+ _sm = SALOMEDS::StudyManager::_narrow( obj );
- _NS = new SALOME_NamingService;
-
- sleep(2);
-
- _NS->init_orb(_orb) ;
+ CPPUNIT_ASSERT( !CORBA::is_nil(_sm) );
}
// ============================================================================
*/
// ============================================================================
-void
-SALOMEDSTest::tearDown()
+void SALOMEDSTest::tearDown()
{
- LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
- CPPUNIT_ASSERT(bp1);
- bp1->deleteInstance(bp1);
-
- delete _NS;
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+ vector<string> v = sm->GetOpenStudies();
+ for(int i = 0; i<v.size(); i++) {
+ _PTR(Study) study = sm->GetStudyByName(v[i]);
+ if(study)
+ sm->Close(study);
+ }
}
+#include "SALOMEDSTest_AttributeComment.cxx"
+#include "SALOMEDSTest_AttributeDrawable.cxx"
+#include "SALOMEDSTest_AttributeExpandable.cxx"
+#include "SALOMEDSTest_AttributeExternalFileDef.cxx"
+#include "SALOMEDSTest_AttributeFileType.cxx"
+#include "SALOMEDSTest_AttributeFlags.cxx"
+#include "SALOMEDSTest_AttributeGraphic.cxx"
+#include "SALOMEDSTest_AttributeIOR.cxx"
+#include "SALOMEDSTest_AttributeInteger.cxx"
+#include "SALOMEDSTest_AttributeLocalID.cxx"
+#include "SALOMEDSTest_AttributeName.cxx"
+#include "SALOMEDSTest_AttributeOpened.cxx"
+#include "SALOMEDSTest_AttributeParameter.cxx"
+#include "SALOMEDSTest_AttributePersistentRef.cxx"
+#include "SALOMEDSTest_AttributePixMap.cxx"
+#include "SALOMEDSTest_AttributePythonObject.cxx"
+#include "SALOMEDSTest_AttributeReal.cxx"
+#include "SALOMEDSTest_AttributeSelectable.cxx"
+#include "SALOMEDSTest_AttributeSequenceOfInteger.cxx"
+#include "SALOMEDSTest_AttributeSequenceOfReal.cxx"
+#include "SALOMEDSTest_AttributeStudyProperties.cxx"
+#include "SALOMEDSTest_AttributeTableOfInteger.cxx"
+#include "SALOMEDSTest_AttributeTableOfReal.cxx"
+#include "SALOMEDSTest_AttributeTableOfString.cxx"
+#include "SALOMEDSTest_AttributeTarget.cxx"
+#include "SALOMEDSTest_AttributeTextColor.cxx"
+#include "SALOMEDSTest_AttributeTextHighlightColor.cxx"
+#include "SALOMEDSTest_AttributeTreeNode.cxx"
+#include "SALOMEDSTest_AttributeUserID.cxx"
+#include "SALOMEDSTest_ChildIterator.cxx"
+#include "SALOMEDSTest_SComponent.cxx"
+#include "SALOMEDSTest_SComponentIterator.cxx"
+#include "SALOMEDSTest_SObject.cxx"
+#include "SALOMEDSTest_Study.cxx"
+#include "SALOMEDSTest_StudyBuilder.cxx"
+#include "SALOMEDSTest_StudyManager.cxx"
+#include "SALOMEDSTest_UseCase.cxx"
+
+
// ============================================================================
/*!
- * Check AttributeParameter
+ * Set up the environment
*/
// ============================================================================
-void SALOMEDSTest::testAttributeParameter()
-{
- CORBA::Object_var obj = _orb->resolve_initial_references( "RootPOA" );
- PortableServer::POA_var poa = PortableServer::POA::_narrow( obj );
-
- PortableServer::POAManager_var pman = poa->the_POAManager();
- pman->activate() ;
-
- _PTR(StudyManager) sm = ClientFactory::createStudyManager(_orb, poa);
-
- CPPUNIT_ASSERT(sm);
-
- _PTR(Study) study = sm->NewStudy("Test");
-
- CPPUNIT_ASSERT(study);
-
- _PTR(AttributeParameter) _ap = study->GetCommonParameters("TestComp", 0);
-
- CPPUNIT_ASSERT(_ap);
-
- _ap->SetInt("IntValue", 1);
- CPPUNIT_ASSERT(_ap->IsSet("IntValue", PT_INTEGER));
- CPPUNIT_ASSERT(_ap->GetInt("IntValue") == 1);
+
+void SALOMEDSTest_Embedded::setUp()
+{
+ int argc = 1;\r
+ char* argv[] = {""};\r
- _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<int> 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<double> 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);
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(argc , argv ) ;
+ SALOME_NamingService NS(_orb);
+ CORBA::Object_var obj = NS.Resolve( "/myStudyManager_embedded" );
+ _sm = SALOMEDS::StudyManager::_narrow( obj );
- vector<string> 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");
+ CPPUNIT_ASSERT( !CORBA::is_nil(_sm) );
}
-
-
-
#include <cppunit/extensions/HelperMacros.h>
-#include <CORBA.h>
-
#include <SALOMEconfig.h>
-#include "SALOME_NamingService.hxx"
+#include CORBA_SERVER_HEADER(SALOMEDS)
class SALOMEDSTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( SALOMEDSTest );
+
+ //Attributes' tests
+
+ CPPUNIT_TEST( testAttributeComment );
+ CPPUNIT_TEST( testAttributeDrawable );
+ CPPUNIT_TEST( testAttributeExpandable );
+ CPPUNIT_TEST( testAttributeExternalFileDef );
+ CPPUNIT_TEST( testAttributeFileType );
+ CPPUNIT_TEST( testAttributeFlags );
+ CPPUNIT_TEST( testAttributeGraphic );
+ CPPUNIT_TEST( testAttributeIOR );
+ CPPUNIT_TEST( testAttributeInteger );
+ CPPUNIT_TEST( testAttributeLocalID );
+ CPPUNIT_TEST( testAttributeName );
+ CPPUNIT_TEST( testAttributeOpened );
CPPUNIT_TEST( testAttributeParameter );
+ CPPUNIT_TEST( testAttributePersistentRef );
+ CPPUNIT_TEST( testAttributePixMap );
+ CPPUNIT_TEST( testAttributePythonObject );
+ CPPUNIT_TEST( testAttributeReal );
+ CPPUNIT_TEST( testAttributeSelectable );
+ CPPUNIT_TEST( testAttributeSequenceOfInteger );
+ CPPUNIT_TEST( testAttributeSequenceOfReal );
+ CPPUNIT_TEST( testAttributeStudyProperties );
+ CPPUNIT_TEST( testAttributeTableOfInteger );
+ CPPUNIT_TEST( testAttributeTableOfReal );
+ CPPUNIT_TEST( testAttributeTableOfString );
+ CPPUNIT_TEST( testAttributeTarget );
+ CPPUNIT_TEST( testAttributeTextColor );
+ CPPUNIT_TEST( testAttributeTextHighlightColor );
+ CPPUNIT_TEST( testAttributeTreeNode );
+ CPPUNIT_TEST( testAttributeUserID );
+ CPPUNIT_TEST( testChildIterator );
+ CPPUNIT_TEST( testSComponent );
+ CPPUNIT_TEST( testSComponentIterator );
+ CPPUNIT_TEST( testSObject );
+ CPPUNIT_TEST( testStudy );
+ CPPUNIT_TEST( testStudyBuilder );
+ CPPUNIT_TEST( testStudyManager );
+ CPPUNIT_TEST( testUseCase );
+
+
CPPUNIT_TEST_SUITE_END();
public:
- void setUp();
- void tearDown();
+ virtual void setUp();
+ virtual void tearDown();
+
+ //Attributes
+ void testAttributeComment();
+ void testAttributeDrawable();
+ void testAttributeExpandable();
+ void testAttributeExternalFileDef();
+ void testAttributeFileType();
+ void testAttributeFlags();
+ void testAttributeGraphic();
+ void testAttributeIOR();
+ void testAttributeInteger();
+ void testAttributeLocalID();
+ void testAttributeName();
+ void testAttributeOpened();
void testAttributeParameter();
+ void testAttributePersistentRef();
+ void testAttributePixMap();
+ void testAttributePythonObject();
+ void testAttributeReal();
+ void testAttributeSelectable();
+ void testAttributeSequenceOfInteger();
+ void testAttributeSequenceOfReal();
+ void testAttributeStudyProperties();
+ void testAttributeTableOfInteger();
+ void testAttributeTableOfReal();
+ void testAttributeTableOfString();
+ void testAttributeTarget();
+ void testAttributeTextColor();
+ void testAttributeTextHighlightColor();
+ void testAttributeTreeNode();
+ void testAttributeUserID();
+
+ //Objects
+ void testChildIterator();
+ void testSComponent();
+ void testSComponentIterator();
+ void testSObject();
+ void testStudy();
+ void testStudyBuilder();
+ void testStudyManager();
+ void testUseCase();
protected:
- CORBA::ORB_var _orb;
- SALOME_NamingService* _NS;
+
+SALOMEDS::StudyManager_var _sm;
+CORBA::ORB_var _orb;
+
+};
+
+
+
+class SALOMEDSTest_Embedded : public SALOMEDSTest
+{
+ CPPUNIT_TEST_SUITE( SALOMEDSTest_Embedded );
+
+ //Attributes' tests
+
+ CPPUNIT_TEST( testAttributeComment );
+ CPPUNIT_TEST( testAttributeDrawable );
+ CPPUNIT_TEST( testAttributeExpandable );
+ CPPUNIT_TEST( testAttributeExternalFileDef );
+ CPPUNIT_TEST( testAttributeFileType );
+ CPPUNIT_TEST( testAttributeFlags );
+ CPPUNIT_TEST( testAttributeGraphic );
+ CPPUNIT_TEST( testAttributeIOR );
+ CPPUNIT_TEST( testAttributeInteger );
+ CPPUNIT_TEST( testAttributeLocalID );
+ CPPUNIT_TEST( testAttributeName );
+ CPPUNIT_TEST( testAttributeOpened );
+ CPPUNIT_TEST( testAttributeParameter );
+ CPPUNIT_TEST( testAttributePersistentRef );
+ CPPUNIT_TEST( testAttributePixMap );
+ CPPUNIT_TEST( testAttributePythonObject );
+ CPPUNIT_TEST( testAttributeReal );
+ CPPUNIT_TEST( testAttributeSelectable );
+ CPPUNIT_TEST( testAttributeSequenceOfInteger );
+ CPPUNIT_TEST( testAttributeSequenceOfReal );
+ CPPUNIT_TEST( testAttributeStudyProperties );
+ CPPUNIT_TEST( testAttributeTableOfInteger );
+ CPPUNIT_TEST( testAttributeTableOfReal );
+ CPPUNIT_TEST( testAttributeTableOfString );
+ CPPUNIT_TEST( testAttributeTarget );
+ CPPUNIT_TEST( testAttributeTextColor );
+ CPPUNIT_TEST( testAttributeTextHighlightColor );
+ CPPUNIT_TEST( testAttributeTreeNode );
+ CPPUNIT_TEST( testAttributeUserID );
+ CPPUNIT_TEST( testChildIterator );
+ CPPUNIT_TEST( testSComponent );
+ CPPUNIT_TEST( testSComponentIterator );
+ CPPUNIT_TEST( testSObject );
+ CPPUNIT_TEST( testStudy );
+ CPPUNIT_TEST( testStudyBuilder );
+ CPPUNIT_TEST( testStudyManager );
+ CPPUNIT_TEST( testUseCase );
+
+
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+ virtual void setUp();
};
#endif
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+
+/*!
+ * Check all methods of SALOMEDS_AttributeComment
+ * Use code of SALOMEDS_AttributeComment.cxx
+ */
+
+void SALOMEDSTest::testAttributeComment()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm(new SALOMEDS_StudyManager(_sm));
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeComment
+ _PTR(AttributeComment) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeComment");
+
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ value = "Test string!";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+
+/*!
+ * Check all methods of SALOMEDS_AttributeDrawable
+ * Use code of SALOMEDS_AttributeDrawable.cxx
+ */
+
+void SALOMEDSTest::testAttributeDrawable()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm(new SALOMEDS_StudyManager(_sm));
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeDrawable
+ _PTR(AttributeDrawable) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeDrawable");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method IsDrawable
+ bool isDrawable = _attr->IsDrawable();
+
+ CPPUNIT_ASSERT(!isDrawable);
+
+ //Check method SetDrawable
+ _attr->SetDrawable(true);
+
+ CPPUNIT_ASSERT(_attr->IsDrawable());
+
+ _attr->SetDrawable(false);
+
+ CPPUNIT_ASSERT(!_attr->IsDrawable());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeExpandable
+ * Use code of SALOMEDS_AttributeExpandable.cxx
+ */
+void SALOMEDSTest::testAttributeExpandable()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeExpandable
+ _PTR(AttributeExpandable) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeExpandable");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method IsExpandable
+ bool isExpandable = _attr->IsExpandable();
+
+ CPPUNIT_ASSERT(!isExpandable);
+
+ //Check method SetExpandable
+ _attr->SetExpandable(true);
+
+ CPPUNIT_ASSERT(_attr->IsExpandable());
+
+ _attr->SetExpandable(false);
+
+ CPPUNIT_ASSERT(!_attr->IsExpandable());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeExternalFileDef
+ * Use code of SALOMEDS_AttributeExternalFileDef.cxx
+ */
+void SALOMEDSTest::testAttributeExternalFileDef()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeExternalFileDef
+ _PTR(AttributeExternalFileDef) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeExternalFileDef");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ value = "Test string!";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeFileType
+ * Use code of SALOMEDS_AttributeFileType.cxx
+ */
+void SALOMEDSTest::testAttributeFileType()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeFileType
+ _PTR(AttributeFileType) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeFileType");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ value = "Test string!";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeFlags
+ * Use code of SALOMEDS_AttributeFlags.cxx
+ */
+void SALOMEDSTest::testAttributeFlags()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeFlags
+ _PTR(AttributeFlags) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeFlags");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Set
+ _attr->Set(2, true);
+
+ CPPUNIT_ASSERT(_attr->Get(2));
+
+ _attr->Set(4, false);
+
+ //Check method Get
+ CPPUNIT_ASSERT(!_attr->Get(4));
+
+ //Check method GetFlags
+ int flags = _attr->GetFlags();
+
+ _attr->SetFlags(flags);
+
+ CPPUNIT_ASSERT(_attr->Get(2));
+
+ CPPUNIT_ASSERT(!_attr->Get(4));
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeGraphic
+ * Use code of SALOMEDS_AttributeGraphic.cxx
+ */
+void SALOMEDSTest::testAttributeGraphic()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeGraphic
+ _PTR(AttributeGraphic) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeGraphic");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method SetVisibility
+ _attr->SetVisibility(1, true);
+
+ //Check method GetVisibility
+ CPPUNIT_ASSERT(_attr->GetVisibility(1));
+
+ _attr->SetVisibility(2, false);
+
+ CPPUNIT_ASSERT(!_attr->GetVisibility(2) && _attr->GetVisibility(1));
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeIOR
+ * Use code of SALOMEDS_AttributeIOR.cxx
+ */
+void SALOMEDSTest::testAttributeIOR()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeIOR
+ _PTR(AttributeIOR) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeIOR");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ string ior = _orb->object_to_string(_sm);
+
+ //Check method SetValue
+ _attr->SetValue(ior);
+
+ CPPUNIT_ASSERT(ior == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+
+/*!
+ * Check all methods of SALOMEDS_AttributeInteger
+ * Use code of SALOMEDS_AttributeInteger.cxx
+ */
+void SALOMEDSTest::testAttributeInteger()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeInteger
+ _PTR(AttributeInteger) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeInteger");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ int value = 10;
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ //Check method Value
+ CPPUNIT_ASSERT(_attr->Value() == value);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeLocalID
+ * Use code of SALOMEDS_AttributeLocalID.cxx
+ */
+void SALOMEDSTest::testAttributeLocalID()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeLocalID
+ _PTR(AttributeLocalID) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeLocalID");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ int value = 10;
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ //Check method Value
+ CPPUNIT_ASSERT(_attr->Value() == value);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeName
+ * Use code of SALOMEDS_AttributeName.cxx
+ */
+void SALOMEDSTest::testAttributeName()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeName
+ _PTR(AttributeName) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeName");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ value = "Test string!";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeOpened
+ * Use code of SALOMEDS_AttributeOpened.cxx
+ */
+void SALOMEDSTest::testAttributeOpened()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeOpened
+ _PTR(AttributeOpened) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeOpened");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method IsOpened
+ bool isOpened = _attr->IsOpened();
+
+ CPPUNIT_ASSERT(!isOpened);
+
+ //Check method SetOpened
+ _attr->SetOpened(true);
+
+ CPPUNIT_ASSERT(_attr->IsOpened());
+
+ _attr->SetOpened(false);
+
+ CPPUNIT_ASSERT(!_attr->IsOpened());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+#define PT_INTEGER 0
+#define PT_REAL 1
+#define PT_BOOLEAN 2
+#define PT_STRING 3
+#define PT_REALARRAY 4
+#define PT_INTARRAY 5
+#define PT_STRARRAY 6
+
+/*!
+ * Check all methods of SALOMEDS_AttributeParameter
+ * Use code of SALOMEDS_AttributeParameter.cxx
+ */
+void SALOMEDSTest::testAttributeParameter()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeParameter
+ _PTR(AttributeParameter) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeParameter");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method SetInt and GetInt
+ _attr->SetInt("IntValue", 1);
+ CPPUNIT_ASSERT(_attr->IsSet("IntValue", PT_INTEGER));
+ CPPUNIT_ASSERT(_attr->GetInt("IntValue") == 1);
+
+ //Check method SetReal an GetReal
+ _attr->SetReal("RealValue", 1.2);
+ CPPUNIT_ASSERT(_attr->IsSet("RealValue", PT_REAL));
+ CPPUNIT_ASSERT(_attr->GetReal("RealValue") == 1.2);
+
+ //Check method SetString and GetString
+ _attr->SetString("StringValue", "hello");
+ CPPUNIT_ASSERT(_attr->IsSet("StringValue", PT_STRING));
+ CPPUNIT_ASSERT(_attr->GetString("StringValue") == "hello");
+
+ //Check method SetBool and GetBool
+ _attr->SetBool("BoolValue", 0);
+ CPPUNIT_ASSERT(_attr->IsSet("BoolValue", PT_BOOLEAN));
+ CPPUNIT_ASSERT(!_attr->GetBool("BoolValue"));
+
+ _attr->SetBool("BoolValue", 0);
+ CPPUNIT_ASSERT(_attr->IsSet("BoolValue", PT_BOOLEAN));
+ CPPUNIT_ASSERT(!_attr->GetBool("BoolValue"));
+
+ vector<int> intArray;
+ intArray.push_back(0);
+ intArray.push_back(1);
+
+ //Check method SetIntArray and GetIntArray
+ _attr->SetIntArray("IntArray", intArray);
+ CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY));
+ CPPUNIT_ASSERT(_attr->GetIntArray("IntArray")[0] == 0);
+ CPPUNIT_ASSERT(_attr->GetIntArray("IntArray")[1] == 1);
+
+ vector<double> realArray;
+ realArray.push_back(0.0);
+ realArray.push_back(1.1);
+
+ //Check method SetRealArray and GetRealArray
+ _attr->SetRealArray("RealArray", realArray);
+ CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY));
+ CPPUNIT_ASSERT(_attr->GetRealArray("RealArray")[0] == 0.0);
+ CPPUNIT_ASSERT(_attr->GetRealArray("RealArray")[1] == 1.1);
+
+ vector<string> strArray;
+ strArray.push_back("hello");
+ strArray.push_back("world");
+
+ //Check method SetStrArray and GetStrArray
+ _attr->SetStrArray("StrArray", strArray);
+ CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY));
+ CPPUNIT_ASSERT(_attr->GetStrArray("StrArray")[0] == "hello");
+ CPPUNIT_ASSERT(_attr->GetStrArray("StrArray")[1] == "world");
+
+ /*
+ string saved = _attr->Save();
+ _attr->Load(saved);
+
+ CPPUNIT_ASSERT(_attr->IsSet("IntValue", PT_INTEGER) && _attr->GetInt("IntValue") == 1);
+ CPPUNIT_ASSERT(_attr->IsSet("RealValue", PT_REAL) && _attr->GetReal("IntValue") == 1.2);
+ CPPUNIT_ASSERT(_attr->IsSet("StringValue", PT_STRING) && _attr->GetString("StringValue") == "hello");
+ CPPUNIT_ASSERT(_attr->IsSet("BoolValue", PT_BOOLEAN) && _attr->GetBool("BoolValue") == 0);
+ CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY) && _attr->GetIntArray("IntArray")[0] == 0);
+ CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY) && _attr->GetIntArray("IntArray")[1] == 1);
+ CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY) && _attr->GetRealArray("RealArray")[0] == 0.0);
+ CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY) && _attr->GetRealArray("RealArray")[1] == 1.1);
+ CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY) && _attr->GetStrArray("StrArray")[0] == "hello");
+ CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY) && _attr->GetStrArray("StrArray")[1] == "world");
+ */
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributePersistentRef
+ * Use code of SALOMEDS_AttributePersistentRef.cxx
+ */
+void SALOMEDSTest::testAttributePersistentRef()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributePersistentRef
+ _PTR(AttributePersistentRef) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributePersistentRef");
+
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Value
+ string value = _attr->Value();
+
+ CPPUNIT_ASSERT(value.empty());
+
+ value = "Test string!";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributePixMap
+ * Use code of SALOMEDS_AttributePixMap.cxx
+ */
+void SALOMEDSTest::testAttributePixMap()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributePixMap
+ _PTR(AttributePixMap) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributePixMap");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method HasPixMap
+ CPPUNIT_ASSERT(!_attr->HasPixMap());
+
+ //Check method SetPixMap
+ string pixmap = "something";
+ _attr->SetPixMap(pixmap);
+
+ CPPUNIT_ASSERT(_attr->HasPixMap());
+
+ //Check method GetPixMap
+ CPPUNIT_ASSERT(_attr->GetPixMap() == pixmap);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributePythonObject
+ * Use code of SALOMEDS_AttributePythonObject.cxx
+ */
+void SALOMEDSTest::testAttributePythonObject()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributePythonObject
+ _PTR(AttributePythonObject) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributePythonObject");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method IsScript
+ CPPUNIT_ASSERT(!_attr->IsScript());
+
+ string pyobj = "some object!";
+
+ //Check method SetObject
+ _attr->SetObject(pyobj, true);
+
+ CPPUNIT_ASSERT(_attr->IsScript());
+
+ //Check method GetObject
+ CPPUNIT_ASSERT(_attr->GetObject() == pyobj);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeReal
+ * Use code of SALOMEDS_AttributeReal.cxx
+ */
+void SALOMEDSTest::testAttributeReal()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeReal
+ _PTR(AttributeReal) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeReal");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ double value = 10.12;
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ //Check method Value
+ CPPUNIT_ASSERT(_attr->Value() == value);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeSelectable
+ * Use code of SALOMEDS_AttributeSelectable.cxx
+ */
+void SALOMEDSTest::testAttributeSelectable()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeSelectable
+ _PTR(AttributeSelectable) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeSelectable");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method IsSelectable
+ bool isSelectable = _attr->IsSelectable();
+
+ CPPUNIT_ASSERT(!isSelectable);
+
+ //Check method SetSelectable
+ _attr->SetSelectable(true);
+
+ CPPUNIT_ASSERT(_attr->IsSelectable());
+
+ _attr->SetSelectable(false);
+
+ CPPUNIT_ASSERT(!_attr->IsSelectable());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeSequenceOfInteger
+ * Use code of SALOMEDS_AttributeSequenceOfInteger.cxx
+ */
+void SALOMEDSTest::testAttributeSequenceOfInteger()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeSequenceOfInteger
+ _PTR(AttributeSequenceOfInteger) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeSequenceOfInteger");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Length
+ CPPUNIT_ASSERT(_attr->Length() == 0);
+
+ //Check method Add
+ _attr->Add(1);
+
+ _attr->Add(2);
+
+ _attr->Add(3);
+
+ _attr->Add(4);
+
+ CPPUNIT_ASSERT(_attr->Length() == 4);
+
+ CPPUNIT_ASSERT(_attr->Value(2) == 2);
+
+ //Check method Remove
+ _attr->Remove(3);
+
+ //Check method Value
+ CPPUNIT_ASSERT(_attr->Value(3) == 4);
+
+ //Check method ChangeValue
+ _attr->ChangeValue(3, 3);
+
+ CPPUNIT_ASSERT(_attr->Value(3) == 3);
+
+ //Check method CorbaSequence
+ vector<int> v = _attr->CorbaSequence();
+ CPPUNIT_ASSERT(v.size() == 3);
+
+ for(int i = 0; i<v.size(); i++)
+ CPPUNIT_ASSERT((i+1) == v[i]);
+
+ v.push_back(5);
+
+ //Check method Assign
+ _attr->Assign(v);
+
+ CPPUNIT_ASSERT(_attr->Length() == 4);
+
+ CPPUNIT_ASSERT(_attr->Value(4) == 5);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeSequenceOfReal
+ * Use code of SALOMEDS_AttributeSequenceOfReal.cxx
+ */
+void SALOMEDSTest::testAttributeSequenceOfReal()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeSequenceOfReal
+ _PTR(AttributeSequenceOfReal) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeSequenceOfReal");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Length
+ CPPUNIT_ASSERT(_attr->Length() == 0);
+
+ //Check method Add
+ _attr->Add(1.1);
+
+ _attr->Add(2.2);
+
+ _attr->Add(3.3);
+
+ _attr->Add(4.4);
+
+ CPPUNIT_ASSERT(_attr->Length() == 4);
+
+ CPPUNIT_ASSERT(_attr->Value(2) == 2.2);
+
+ //Check method Remove
+ _attr->Remove(3);
+
+ CPPUNIT_ASSERT(_attr->Value(3) == 4.4);
+
+ //Check method ChangeValue
+ _attr->ChangeValue(3, 3.3);
+
+ CPPUNIT_ASSERT(_attr->Value(3) == 3.3);
+
+ //Check method CorbaSequence
+ vector<double> v = _attr->CorbaSequence();
+ CPPUNIT_ASSERT(v.size() == 3);
+
+ v.push_back(5.5);
+
+ _attr->Assign(v);
+
+ CPPUNIT_ASSERT(_attr->Length() == 4);
+
+ CPPUNIT_ASSERT(_attr->Value(4) == 5.5);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeStudyProperties
+ * Use code of SALOMEDS_AttributeStudyProperties.cxx
+ */
+void SALOMEDSTest::testAttributeStudyProperties()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeStudyProperties
+ _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method SetCreationDate
+ _attr->SetCreationDate(1, 2, 3, 4, 5);
+
+ //Check method GetCreationDate
+ int MN, H, D, MH, Y;
+ _attr->GetCreationDate(MN, H, D, MH, Y);
+
+ CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
+
+ //Check method SetUserName
+ _attr->SetUserName("srn");
+
+ //Check method GetUserName
+ CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
+
+ //Check method SetCreationMode
+ string value = "from scratch";
+ _attr->SetCreationMode(value);
+
+ //Check method GetCreationMode
+ CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
+
+ //Check method SetModified
+ _attr->SetModified(2);
+
+ //Check method IsModified
+ CPPUNIT_ASSERT(_attr->IsModified());
+
+ //Check method GetModified
+ CPPUNIT_ASSERT(_attr->GetModified() == 2);
+
+ //Check method SetLocked
+ _attr->SetLocked(true);
+
+ //Check method IsLocked
+ CPPUNIT_ASSERT(_attr->IsLocked());
+
+ _attr->SetLocked(false);
+
+ CPPUNIT_ASSERT(!_attr->IsLocked());
+
+ //Check method SetModification
+ _attr->SetModification("srn2", 6, 7, 8, 9, 10);
+
+ //Check method GetModificationsList
+ vector<string> vs;
+ vector<int> vi[5];
+ _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
+ CPPUNIT_ASSERT(vs[0] == "srn2" && vi[0][0] == 6 && vi[1][0] == 7 && vi[2][0] == 8 && vi[3][0] == 9 && vi[4][0] == 10);
+
+ vs.clear();
+ for(int i=0; i<5; i++) vi[i].clear();
+
+ _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
+ CPPUNIT_ASSERT(vs[0] == "srn" && vi[0][0] == 1 && vi[1][0] == 2 && vi[2][0] == 3 && vi[3][0] == 4 && vi[4][0] == 5);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTableOfInteger
+ * Use code of SALOMEDS_AttributeTableOfInteger.cxx
+ */
+void SALOMEDSTest::testAttributeTableOfInteger()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTableOfInteger
+ _PTR(AttributeTableOfInteger) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTableOfInteger");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method SetTitle
+ _attr->SetTitle("Table_1");
+
+ //Check method GetTitle
+ CPPUNIT_ASSERT(_attr->GetTitle() == "Table_1");
+
+ //Check method SetNbColumns
+ _attr->SetNbColumns(2);
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method HasValue
+ CPPUNIT_ASSERT(!_attr->HasValue(1, 1));
+
+ bool isCaught = false;
+ try {
+ _attr->GetValue(1, 1);
+ }
+ catch(...) {
+ isCaught = true;
+ }
+ CPPUNIT_ASSERT(isCaught);
+
+ //Check method PutValue
+ _attr->PutValue(23, 1,1);
+
+ CPPUNIT_ASSERT(_attr->HasValue(1, 1));
+
+ //Check method GetValue
+ CPPUNIT_ASSERT(_attr->GetValue(1, 1) == 23);
+
+ //Check method GetRowSetIndices
+ vector<int> rs = _attr->GetRowSetIndices(1);
+
+ CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);
+
+ _attr->PutValue(32, 2,2);
+ CPPUNIT_ASSERT(_attr->HasValue(2, 2));
+
+ vector<string> rowTitles;
+ rowTitles.push_back("title1");
+ rowTitles.push_back("title2");
+
+ //Check method SetRowTitles
+ _attr->SetRowTitles(rowTitles);
+
+ //Check method SetRowTitle
+ _attr->SetRowTitle(1, "new_title");
+
+ //Check method GetRowTitles
+ vector<string> rt = _attr->GetRowTitles();
+
+ CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");
+
+ vector<string> colTitles;
+ colTitles.push_back("title1");
+ colTitles.push_back("title2");
+
+ //Check method SetColumnTitles
+ _attr->SetColumnTitles(colTitles);
+
+ //Check method SetColumnTitle
+ _attr->SetColumnTitle(1, "new_title");
+
+ //Check method GetColumnTitles
+ vector<string> ct = _attr->GetColumnTitles();
+
+ CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");
+
+ vector<string> rowUnits;
+ rowUnits.push_back("unit1");
+ rowUnits.push_back("unit2");
+
+ //Check method SetRowUnits
+ _attr->SetRowUnits(rowUnits);
+
+ //Check method SetRowUnit
+ _attr->SetRowUnit(1, "new_unit");
+
+ //Check method GetRowUnits
+ vector<string> ru = _attr->GetRowUnits();
+
+ CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method AddRow
+ vector<int> data;
+ data.push_back(11);
+ data.push_back(22);
+
+ _attr->AddRow(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbRows() == 3);
+
+ //Check method GetRow
+ vector<int> data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 11 && data2[1] == 22);
+
+ //Check method SetRow
+ data[0] = 33;
+ _attr->SetRow(3, data);
+
+ data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 33 && data2[1] == 22);
+
+ //Check method AddColumn
+ data[0] = -11;
+ data[1] = -22;
+ data.push_back(-33);
+
+ _attr->AddColumn(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);
+
+ //Check method GetColumn
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == -11 && data2[1] == -22 && data2[2] == -33);
+
+ //Check method SetColumn
+ data[0] = 11;
+ _attr->SetColumn(3, data);
+
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == 11 && data2[1] == -22 && data2[2] == -33);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTableOfReal
+ * Use code of SALOMEDS_AttributeTableOfReal.cxx
+ */
+void SALOMEDSTest::testAttributeTableOfReal()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTableOfReal
+ _PTR(AttributeTableOfReal) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTableOfReal");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method SetTitle
+ _attr->SetTitle("Table_1");
+
+ //Check method GetTitle
+ CPPUNIT_ASSERT(_attr->GetTitle() == "Table_1");
+
+ //Check method SetNbColumns
+ _attr->SetNbColumns(2);
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method HasValue
+ CPPUNIT_ASSERT(!_attr->HasValue(1, 1));
+
+ bool isCaught = false;
+ try {
+ _attr->GetValue(1, 1);
+ }
+ catch(...) {
+ isCaught = true;
+ }
+ CPPUNIT_ASSERT(isCaught);
+
+ //Check method PutValue
+ _attr->PutValue(23.23, 1,1);
+
+ CPPUNIT_ASSERT(_attr->HasValue(1, 1));
+
+ //Check method GetValue
+ CPPUNIT_ASSERT(_attr->GetValue(1, 1) == 23.23);
+
+ //Check method GetRowSetIndices
+ vector<int> rs = _attr->GetRowSetIndices(1);
+
+ CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);
+
+ _attr->PutValue(32.32, 2,2);
+ CPPUNIT_ASSERT(_attr->HasValue(2, 2));
+
+ vector<string> rowTitles;
+ rowTitles.push_back("title1");
+ rowTitles.push_back("title2");
+
+ //Check method SetRowTitles
+ _attr->SetRowTitles(rowTitles);
+
+ //Check method SetRowTitle
+ _attr->SetRowTitle(1, "new_title");
+
+ //Check method GetRowTitles
+ vector<string> rt = _attr->GetRowTitles();
+
+ CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");
+
+
+ vector<string> colTitles;
+ colTitles.push_back("title1");
+ colTitles.push_back("title2");
+
+ //Check method SetColumnTitles
+ _attr->SetColumnTitles(colTitles);
+
+ //Check method SetColumnTitle
+ _attr->SetColumnTitle(1, "new_title");
+
+ //Check method GetColumnTitles
+ vector<string> ct = _attr->GetColumnTitles();
+
+ CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");
+
+ vector<string> rowUnits;
+ rowUnits.push_back("unit1");
+ rowUnits.push_back("unit2");
+
+ //Check method SetRowUnits
+ _attr->SetRowUnits(rowUnits);
+
+ //Check method SetRowUnit
+ _attr->SetRowUnit(1, "new_unit");
+
+ //Check method GetRowUnits
+ vector<string> ru = _attr->GetRowUnits();
+
+ CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method AddRow
+ vector<double> data;
+ data.push_back(11.11);
+ data.push_back(22.22);
+
+ _attr->AddRow(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbRows() == 3);
+
+ //Check method GetRow
+ vector<double> data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 11.11 && data2[1] == 22.22);
+
+ //Check method SetRow
+ data[0] = 33.33;
+ _attr->SetRow(3, data);
+
+ data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 33.33 && data2[1] == 22.22);
+
+ //Check method AddColumn
+ data[0] = -11.11;
+ data[1] = -22.22;
+ data.push_back(-33.33);
+
+ _attr->AddColumn(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);
+
+ //Check method GetColumn
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == -11.11 && data2[1] == -22.22 && data2[2] == -33.33);
+
+ //Check method SetColumn
+ data[0] = 11.11;
+ _attr->SetColumn(3, data);
+
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == 11.11 && data2[1] == -22.22 && data2[2] == -33.33);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTableOfString
+ * Use code of SALOMEDS_AttributeTableOfString.cxx
+ */
+void SALOMEDSTest::testAttributeTableOfString()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTableOfString
+ _PTR(AttributeTableOfString) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTableOfString");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+ //Check method SetTitle
+ _attr->SetTitle("Table_1");
+
+ //Check method GetTitle
+ CPPUNIT_ASSERT(_attr->GetTitle() == "Table_1");
+
+ //Check method SetNbColumns
+ _attr->SetNbColumns(2);
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method HasValue
+ CPPUNIT_ASSERT(!_attr->HasValue(1, 1));
+
+ bool isCaught = false;
+ try {
+ _attr->GetValue(1, 1);
+ }
+ catch(...) {
+ isCaught = true;
+ }
+ CPPUNIT_ASSERT(isCaught);
+
+
+ //Check method PutValue
+ _attr->PutValue("23", 1,1);
+
+ CPPUNIT_ASSERT(_attr->HasValue(1, 1));
+
+ //Check method GetValue
+ CPPUNIT_ASSERT(_attr->GetValue(1, 1) == "23");
+
+ //Check method GetRowSetIndices
+ vector<int> rs = _attr->GetRowSetIndices(1);
+
+ CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);
+
+ _attr->PutValue("32", 2,2);
+ CPPUNIT_ASSERT(_attr->HasValue(2, 2));
+
+ vector<string> rowTitles;
+ rowTitles.push_back("title1");
+ rowTitles.push_back("title2");
+
+ //Check method SetRowTitles
+ _attr->SetRowTitles(rowTitles);
+
+ //Check method SetRowTitle
+ _attr->SetRowTitle(1, "new_title");
+
+ //Check method GetRowTitles
+ vector<string> rt = _attr->GetRowTitles();
+
+ CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");
+
+
+ vector<string> colTitles;
+ colTitles.push_back("title1");
+ colTitles.push_back("title2");
+
+ //Check method SetColumnTitles
+ _attr->SetColumnTitles(colTitles);
+
+ //Check method SetColumnTitle
+ _attr->SetColumnTitle(1, "new_title");
+
+ //Check method GetColumnTitles
+ vector<string> ct = _attr->GetColumnTitles();
+
+ CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");
+
+ vector<string> rowUnits;
+ rowUnits.push_back("unit1");
+ rowUnits.push_back("unit2");
+
+ //Check method SetRowUnits
+ _attr->SetRowUnits(rowUnits);
+
+ //Check method SetRowUnit
+ _attr->SetRowUnit(1, "new_unit");
+
+ //Check method GetRowUnits
+ vector<string> ru = _attr->GetRowUnits();
+
+ CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");
+
+ //Check method GetNbColumns
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);
+
+ //Check method AddRow
+ vector<string> data;
+ data.push_back("11");
+ data.push_back("22");
+
+ _attr->AddRow(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbRows() == 3);
+
+ //Check method GetRow
+ vector<string> data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == "11" && data2[1] == "22");
+
+ //Check method SetRow
+ data[0] = "33";
+ _attr->SetRow(3, data);
+
+ data2 = _attr->GetRow(3);
+
+ CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == "33" && data2[1] == "22");
+
+ //Check method AddColumn
+ data[0] = "-11";
+ data[1] = "-22";
+ data.push_back("-33");
+
+ _attr->AddColumn(data);
+
+ CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);
+
+ //Check method GetColumn
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == "-11" && data2[1] == "-22" && data2[2] == "-33");
+
+ //Check method SetColumn
+ data[0] = "11";
+ _attr->SetColumn(3, data);
+
+ data2 = _attr->GetColumn(3);
+
+ CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == "11" && data2[1] == "-22" && data2[2] == "-33");
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTarget
+ * Use code of SALOMEDS_AttributeTarget.cxx
+ */
+void SALOMEDSTest::testAttributeTarget()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTarget
+ _PTR(AttributeTarget) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTarget");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method Get
+ CPPUNIT_ASSERT(_attr->Get().size() == 0);
+
+ _PTR(SObject) so1 = study->CreateObjectID("0:1:2");
+ studyBuilder->Addreference(so1, so);
+
+ _PTR(SObject) so2 = study->CreateObjectID("0:1:3");
+ studyBuilder->Addreference(so2, so1);
+
+ //Check method Add
+ _attr->Add(so1);
+
+ _attr->Add(so2);
+
+ //Check method Get
+ vector< _PTR(SObject) > v = _attr->Get();
+
+
+
+ CPPUNIT_ASSERT(v.size() == 2);
+
+ CPPUNIT_ASSERT(v[0]->GetID() == "0:1:2");
+
+ CPPUNIT_ASSERT(v[1]->GetID() == "0:1:3");
+
+ //Check method Remove
+ _attr->Remove(so1);
+
+ v = _attr->Get();
+
+ CPPUNIT_ASSERT(v.size() == 1);
+
+ CPPUNIT_ASSERT(v[0]->GetID() == "0:1:3");
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTextColor
+ * Use code of SALOMEDS_AttributeTextColor.cxx
+ */
+void SALOMEDSTest::testAttributeTextColor()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTextColor
+ _PTR(AttributeTextColor) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTextColor");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ STextColor color;
+ color.R = 0;
+ color.G = 1;
+ color.B = 2;
+
+ //Check method SetTextColor
+ _attr->SetTextColor(color);
+
+ //Check method TextColor
+ STextColor color2 = _attr->TextColor();
+
+ CPPUNIT_ASSERT(color.R == color2.R);
+
+ CPPUNIT_ASSERT(color.G == color2.G);
+
+ CPPUNIT_ASSERT(color.B == color2.B);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTextHighlightColor
+ * Use code of SALOMEDS_AttributeTextHighlightColor.cxx
+ */
+void SALOMEDSTest::testAttributeTextHighlightColor()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTextHighlightColor
+ _PTR(AttributeTextHighlightColor) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTextHighlightColor");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ STextColor color;
+ color.R = 0;
+ color.G = 1;
+ color.B = 2;
+
+ //Check method SetTextHighlightColor
+ _attr->SetTextHighlightColor(color);
+
+ //Check method TextHighlightColor
+ STextColor color2 = _attr->TextHighlightColor();
+
+ CPPUNIT_ASSERT(color.R == color2.R);
+
+ CPPUNIT_ASSERT(color.G == color2.G);
+
+ CPPUNIT_ASSERT(color.B == color2.B);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeTreeNode
+ * Use code of SALOMEDS_AttributeTreeNode.cxx
+ */
+void SALOMEDSTest::testAttributeTreeNode()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeTreeNode
+ _PTR(AttributeTreeNode) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeTreeNode");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ string TreeNodeID = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
+
+ _PTR(SObject) so1 = study->CreateObjectID("0:1:2");
+
+ _PTR(AttributeTreeNode) _attr1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeTreeNode");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr1);
+
+ _PTR(SObject) so2 = study->CreateObjectID("0:1:3");
+
+ _PTR(AttributeTreeNode) _attr2 = studyBuilder->FindOrCreateAttribute(so2, "AttributeTreeNode");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr2);
+
+ //Check method SetFather
+ _attr1->SetFather(_attr);
+
+ //Check method HasFather
+ CPPUNIT_ASSERT(_attr1->HasFather());
+
+ cout << endl << "THE TEST IS NOT COMPLETE !!!" << endl;
+
+ //Check method GetFather
+ /*
+ CPPUNIT_ASSERT(_attr1->GetFather() == _attr);
+
+ //Check method Append
+ _attr->Append(_attr1);
+
+ _attr->Append(_attr2);
+
+ //Check method HasNext
+ CPPUNIT_ASSERT(_attr1->HasNext());
+
+ //Check method GetNext
+ CPPUNIT_ASSERT(_attr1->GetNext() == _attr2);
+
+ //Check method GetPrevious
+ CPPUNIT_ASSERT(_attr2->GetPrevious());
+
+ CPPUNIT_ASSERT(_attr2->GetPrevious() == _attr1);
+
+ //Check method Depth
+ CPPUNIT_ASSERT(_attr->Depth() == 2);
+
+ //Check method IsRoot
+ CPPUNIT_ASSERT(_attr->IsRoot());
+
+ //Check method IsFather
+ CPPUNIT_ASSERT(_attr->IsFather(_attr1));
+
+ //Check method IsDescendant
+ CPPUNIT_ASSERT(_attr2->IsDescendant(_attr));
+
+ //Check method GetFirst
+ CPPUNIT_ASSERT(_attr->GetFirst() == _attr1);
+
+ //Check method Prepend
+ _attr->Prepend(_attr2);
+
+ CPPUNIT_ASSERT(_attr->GetFirst() == _attr2);
+
+ //Check method InsertBefore
+ _attr2->InsertBefore(_attr1);
+
+ CPPUNIT_ASSERT(_attr->GetFirst() == _attr1);
+
+ //Check method InsertAfter
+ _attr2->InsertAfter(_attr1);
+
+ CPPUNIT_ASSERT(_attr->GetFirst() == _attr2);
+
+ //Check method Label
+ CPPUNIT_ASSERT(_attr1->Label() == "0:1:2");
+
+ //Check method Remove
+ _attr2->Remove();
+
+ CPPUNIT_ASSERT(_attr->GetFirst() == _attr1);
+
+ //Check method SetTreeID and GetTreeID
+ _attr2->SetTreeID(TreeNodeID);
+
+ CPPUNIT_ASSERT(_attr2->GetTreeID() == TreeNodeID);
+ */
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_AttributeUserID
+ * Use code of SALOMEDS_AttributeUserID.cxx
+ */
+void SALOMEDSTest::testAttributeUserID()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ //Create an attribute AttributeUserID
+ _PTR(AttributeUserID) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeUserID");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ string value = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
+
+ //Check method SetValue
+ _attr->SetValue(value);
+
+ //Check method Value
+ CPPUNIT_ASSERT(value == _attr->Value());
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_ChildIterator
+ * Use code of SALOMEDS_ChildIterator.cxx
+ */
+void SALOMEDSTest::testChildIterator()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a SObject with entry 0:1:1
+ _PTR(SObject) so = study->CreateObjectID("0:1:1");
+
+ CPPUNIT_ASSERT(so);
+
+ _PTR(SObject) so1 = studyBuilder->NewObjectToTag(so, 1);
+ studyBuilder->NewObjectToTag(so1, 2);
+
+ _PTR(ChildIterator) ci = study->NewChildIterator(so);
+
+ //Check the creation of the ChildIterator
+ CPPUNIT_ASSERT(ci);
+
+ int count = 0;
+ for(; ci->More(); ci->Next()) {
+ //Check method Value
+ CPPUNIT_ASSERT(ci->Value()->Tag() == 1);
+ count++;
+ }
+
+ //Check that there is only one SObject on the first level of so
+ CPPUNIT_ASSERT(count == 1);
+
+ count = 0;
+ int i = 1;
+ for(ci->InitEx(true); ci->More(); ci->Next(), i++) {
+ CPPUNIT_ASSERT(ci->Value()->Tag() == i);
+ count++;
+ }
+
+ //Check that there are two SObject under so
+ CPPUNIT_ASSERT(count == 2);
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_SComponent
+ * Use code of SALOMEDS_SComponent.cxx
+ */
+void SALOMEDSTest::testSComponent()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ _PTR(SComponent) sco = studyBuilder->NewComponent("Test");
+
+ //Check the creation of the SComponent
+ CPPUNIT_ASSERT(sco);
+
+ //Create an attribute AttributeIOR
+ _PTR(AttributeIOR) _attr = studyBuilder->FindOrCreateAttribute(sco, "AttributeIOR");
+
+ //Check the attribute creation
+ CPPUNIT_ASSERT(_attr);
+
+ //Check method ComponentIOR
+
+ string ior = _orb->object_to_string(_sm);
+
+ _attr->SetValue(ior);
+ string new_ior;
+ CPPUNIT_ASSERT(sco->ComponentIOR(new_ior));
+
+ CPPUNIT_ASSERT(new_ior == ior);
+
+ //Check method ComponentDataType
+ CPPUNIT_ASSERT(sco->ComponentDataType() == "Test");
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_SComponentIterator
+ * Use code of SALOMEDS_SComponentIterator.cxx
+ */
+void SALOMEDSTest::testSComponentIterator()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create two SComponents
+ studyBuilder->NewComponent("Test1");
+ studyBuilder->NewComponent("Test2");
+
+ vector<string> v;
+ v.push_back("Test1");
+ v.push_back("Test2");
+
+ _PTR(SComponentIterator) ci = study->NewComponentIterator();
+
+ //Check the creation of the SComponentIterator
+ CPPUNIT_ASSERT(ci);
+
+ for(int i = 0; ci->More(); ci->Next(), i++) {
+ //Check method Value
+ CPPUNIT_ASSERT(i<2);
+ CPPUNIT_ASSERT(ci->Value()->ComponentDataType() == v[i]);
+ }
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_SObject
+ * Use code of SALOMEDS_SObject.cxx
+ */
+
+void SALOMEDSTest::testSObject()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("TestSObject");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a new SComponent
+ _PTR(SComponent) sco = studyBuilder->NewComponent("Test");
+
+ //Create new SObject
+ _PTR(SObject) so = studyBuilder->NewObjectToTag(sco, 2);
+
+ //Check the creation of the SObject
+ CPPUNIT_ASSERT(so);
+
+ //Check method GetID
+ CPPUNIT_ASSERT(so->GetID() == "0:1:1:2");
+
+ //Check method Tag
+ CPPUNIT_ASSERT(so->Tag() == 2);
+
+ //Check method GetFatherComponent
+ _PTR(SComponent) father = so->GetFatherComponent();
+ CPPUNIT_ASSERT(father->GetID() == sco->GetID());
+
+ //Check method GetFather
+ _PTR(SObject) so1 = studyBuilder->NewObject(so);
+ CPPUNIT_ASSERT(so1->GetFather()->GetID() == so->GetID());
+
+ //Check method FindAttribute
+
+ _PTR(AttributeIOR) _attrIOR = studyBuilder->FindOrCreateAttribute(so, "AttributeIOR");
+ _PTR(AttributeName) _attrName = studyBuilder->FindOrCreateAttribute(so, "AttributeName");
+ _PTR(AttributeComment) _attrComment = studyBuilder->FindOrCreateAttribute(so, "AttributeComment");
+
+ string ior = _orb->object_to_string(_sm);
+ _attrIOR->SetValue(ior);
+ _attrName->SetValue("SO name");
+ _attrComment->SetValue("SO comment");
+
+ _PTR(GenericAttribute) ga;
+ CPPUNIT_ASSERT(so->FindAttribute(ga, "AttributeIOR"));
+
+ //Check method ReferencedObject
+
+ studyBuilder->Addreference(so1, so);
+ _PTR(SObject) so2;
+ CPPUNIT_ASSERT(so1->ReferencedObject(so2));
+ CPPUNIT_ASSERT(so2->GetID() == so->GetID());
+
+ //Check method FindSubObject
+ CPPUNIT_ASSERT(so->FindSubObject(1, so2));
+ CPPUNIT_ASSERT(so2->GetID() == so1->GetID());
+
+ //Check method GetStudy
+ CPPUNIT_ASSERT(so->GetStudy()->StudyId() == study->StudyId());
+
+ //Check methods Name
+ so->Name("test");
+ CPPUNIT_ASSERT(so->Name() == "test");
+
+ //Check method GetAllAttributes
+ vector< _PTR(GenericAttribute) > v = so->GetAllAttributes();
+ CPPUNIT_ASSERT(v.size() == 5); //+AttributeTarget +AttributeTreeNode
+
+ //Check method GetName
+ CPPUNIT_ASSERT(so->GetName() == "SO name");
+
+ //Check method GetComment
+ CPPUNIT_ASSERT(so->GetComment() == "SO comment");
+
+ //Check method GetIOR
+ CPPUNIT_ASSERT(so->GetIOR() == ior);
+
+ //Check method Depth
+ CPPUNIT_ASSERT(so->Depth() == 3);
+
+ //Check method GetObject
+ CORBA::Object_var obj = dynamic_cast<SALOMEDS_SObject*>(so.get())->GetObject();
+ CPPUNIT_ASSERT(!CORBA::is_nil(obj));
+
+ sm->Close(study);
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_Study
+ * Use code of SALOMEDS_Study.cxx
+ */
+
+void SALOMEDSTest::testStudy()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("Test");
+
+ //Check the creation of the study
+ CPPUNIT_ASSERT(study);
+
+ //Check method NewBuilder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Check method NewComponentIterator
+ _PTR(SComponentIterator) componentIterator = study->NewComponentIterator();
+ CPPUNIT_ASSERT(componentIterator);
+
+ //Check method GetTransientReference
+ CPPUNIT_ASSERT(!study->GetTransientReference().empty());
+
+ //Check method StudyId
+ CPPUNIT_ASSERT(study->StudyId() > 0);
+
+ //Check method Name (get/set)
+ CPPUNIT_ASSERT(study->Name() == "Test");
+ study->Name("New name");
+ CPPUNIT_ASSERT(study->Name() == "New name");
+ study->Name("Test");
+
+ //Check method URL (get/set)
+ study->URL("some url");
+ CPPUNIT_ASSERT(study->URL() == "some url");
+
+ //Check method GetPersistentReference == URL
+ CPPUNIT_ASSERT(study->GetPersistentReference() == "some url");
+
+ //Check method IsSaved (get/set)
+ study->IsSaved(true);
+ CPPUNIT_ASSERT(study->IsSaved());
+ study->IsSaved(false);
+ CPPUNIT_ASSERT(!study->IsSaved());
+
+ //Check method CreateObjectID
+ _PTR(SObject) so = study->CreateObjectID("0:2:1:3");
+ CPPUNIT_ASSERT(so);
+
+ //Check method NewChildIterator
+ _PTR(ChildIterator) childIterator = study->NewChildIterator(so);
+ CPPUNIT_ASSERT(childIterator);
+
+ //Check method IsEmpty
+ CPPUNIT_ASSERT(!study->IsEmpty());
+
+ //Check method FindComponent
+ _PTR(SComponent) sco1 = studyBuilder->NewComponent("test1");
+ _PTR(SComponent) sco2 = study->FindComponent("test1");
+ CPPUNIT_ASSERT(sco1 && sco2);
+ CPPUNIT_ASSERT(sco1->GetID() == sco2->GetID());
+ _PTR(AttributeName) name_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributeName");
+ CPPUNIT_ASSERT(name_attr_sco1);
+ name_attr_sco1->SetValue("sco1");
+
+ //Check method FindComponentID
+ _PTR(SComponent) sco3 = study->FindComponentID(sco1->GetID());
+ CPPUNIT_ASSERT(sco3 && sco3->GetID() == sco1->GetID());
+
+ _PTR(SObject) so1 = studyBuilder->NewObject(sco1);
+ CPPUNIT_ASSERT(so1);
+ _PTR(AttributeName) name_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
+ CPPUNIT_ASSERT(name_attr_so1);
+ name_attr_so1->SetValue("so1");
+
+ //Create an attribute AttributeIOR
+ _PTR(AttributeIOR) ior_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeIOR");
+ CPPUNIT_ASSERT(ior_attr_so1);
+
+ string ior = _orb->object_to_string(_sm);
+ ior_attr_so1->SetValue(ior);
+
+ _PTR(SObject) so2 = studyBuilder->NewObject(so1);
+ CPPUNIT_ASSERT(so2);
+ _PTR(AttributeName) name_attr_so2 = studyBuilder->FindOrCreateAttribute(so2, "AttributeName");
+ CPPUNIT_ASSERT(name_attr_so2);
+ name_attr_so2->SetValue("so2");
+
+ //Check method FindObject
+ _PTR(SObject) so3 = study->FindObject("so1");
+ CPPUNIT_ASSERT(so3 && so3->GetID() == so1->GetID());
+
+ //Check method FindObjectID
+ _PTR(SObject) so4 = study->FindObjectID(so1->GetID());
+ CPPUNIT_ASSERT(so4 && so4->GetID() == so1->GetID());
+
+ //Check method FindObjectByName
+ vector< _PTR(SObject) > v = study->FindObjectByName("so1", sco1->ComponentDataType());
+ CPPUNIT_ASSERT(v.size()==1 && v[0]->GetID() == so1->GetID());
+
+ //Check method FindObjectByPath
+ _PTR(SObject) path_so = study->FindObjectByPath("/"+sco1->GetName()+"/"+so1->GetName());
+ CPPUNIT_ASSERT(path_so && path_so->GetID() == so1->GetID());
+
+ //Check method FindObjectIOR
+ _PTR(SObject) so5 = study->FindObjectIOR(ior);
+ CPPUNIT_ASSERT(so5 && so5->GetID() == so1->GetID());
+
+ //Check method GetObjectPath
+ string path = study->GetObjectPath(so2);
+
+ //Check method SetContext
+ study->SetContext("/sco1");
+ CPPUNIT_ASSERT(study->GetContext() == "/sco1");
+
+ //Check method FindObjectByPath
+ _PTR(SObject) so6 = study->FindObjectByPath("so1");
+ CPPUNIT_ASSERT(so6 && so6->GetID() == so1->GetID());
+
+ study->SetContext("/"); //Root
+
+ //Check method GetObjectNames
+ vector<string> vs = study->GetObjectNames("/sco1");
+ CPPUNIT_ASSERT(vs.size() == 2);
+
+ //Check method GetDirectoryNames
+ _PTR(AttributeLocalID) locid_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributeLocalID");
+ CPPUNIT_ASSERT(locid_attr_sco1);
+ locid_attr_sco1->SetValue(16661); //DIRECTORYID
+ _PTR(AttributeLocalID) locid_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeLocalID");
+ CPPUNIT_ASSERT(locid_attr_so1);
+ locid_attr_sco1->SetValue(16661); //DIRECTORYID
+ vs = study->GetDirectoryNames(""); //Empty context (the current is taken)
+ CPPUNIT_ASSERT(vs.size() == 2);
+
+ //Check method GetFileNames
+ locid_attr_sco1->SetValue(26662); //FILELOCALID
+ _PTR(AttributePersistentRef) persref_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributePersistentRef");
+ CPPUNIT_ASSERT(persref_attr_sco1);
+ persref_attr_sco1->SetValue("FILE: filename1");
+ locid_attr_so1->SetValue(26662); //FILELOCALID
+ _PTR(AttributePersistentRef) persref_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributePersistentRef");
+ CPPUNIT_ASSERT(persref_attr_so1);
+ persref_attr_so1->SetValue("FILE: filename2");
+ vs = study->GetFileNames("");
+ CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "filename1" && vs[1] == "filename2");
+
+ //Check method StudyId (get/set)
+ int id = study->StudyId();
+ study->StudyId(-1);
+ CPPUNIT_ASSERT(study->StudyId() == -1);
+ study->StudyId(id);
+
+ //Check method FindDependances
+ studyBuilder->Addreference(so2, so1);
+ studyBuilder->Addreference(sco1, so1);
+ vector< _PTR(SObject) > vso = study->FindDependances(so1);
+ CPPUNIT_ASSERT(vso.size() == 2 && vso[0]->GetID() == so2->GetID() && vso[1]->GetID() == sco1->GetID());
+
+ //Check method GetProperties
+ _PTR(AttributeStudyProperties) sp = study->GetProperties();
+ CPPUNIT_ASSERT(sp);
+
+ //Check Lock functionality
+ //_PTR(AttributeName) name_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
+ sp->SetLocked(true);
+ bool isLockRaised = false;
+ try {
+ name_attr_so1->SetValue("test");
+ }
+ catch(...) {
+ isLockRaised = true;
+ }
+ CPPUNIT_ASSERT(isLockRaised);
+
+ sp->SetLocked(false);
+ isLockRaised = false;
+ try {
+ name_attr_so1->SetValue("test");
+ }
+ catch(...) {
+ isLockRaised = true;
+ }
+ CPPUNIT_ASSERT(!isLockRaised);
+
+ //Check method GetLastModificationDate
+ sp->SetModification("srn", 1, 2, 3, 4, 5);
+ sp->SetModification("srn", 6, 7, 8, 9, 10);
+ string date = study->GetLastModificationDate();
+
+ CPPUNIT_ASSERT(date == "08/09/0010 07:06");
+
+ //Check method GetModificationsDate
+ vs = study->GetModificationsDate();
+ CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "03/04/0005 02:01" && vs[1] == "08/09/0010 07:06");
+
+ //Check method GetCommonParameters
+ _PTR(AttributeParameter) cp = study->GetCommonParameters("id", 1); //Save point = 1
+ CPPUNIT_ASSERT(cp);
+ cp->SetBool("test_true", true);
+ cp->SetBool("test_false", false);
+ _PTR(AttributeParameter) cp2 = study->GetCommonParameters("id", 1); //Save point = 1
+ CPPUNIT_ASSERT(cp2);
+ CPPUNIT_ASSERT(cp2->GetBool("test_true") && !cp2->GetBool("test_false"));
+ _PTR(AttributeParameter) cp21 = study->GetCommonParameters("id", 2); //Save point = 2
+ CPPUNIT_ASSERT(cp21);
+ CPPUNIT_ASSERT(!cp21->IsSet("test_true", PT_BOOLEAN) && !cp21->IsSet("test_false", PT_BOOLEAN));
+
+ //Check method GetModuleParameters
+ _PTR(AttributeParameter) cp3 = study->GetModuleParameters("id", "module name", 1); //Save point = 1, name = "module name"
+ CPPUNIT_ASSERT(cp3);
+ cp3->SetBool("test_true", true);
+ cp3->SetBool("test_false", false);
+ _PTR(AttributeParameter) cp4 = study->GetModuleParameters("id", "module name", 1); //Save point = 1, name = "module name"
+ CPPUNIT_ASSERT(cp4);
+ CPPUNIT_ASSERT(cp4->GetBool("test_true") && !cp4->GetBool("test_false"));
+ _PTR(AttributeParameter) cp5 = study->GetModuleParameters("id", "module name 2", 1); //Save point = 1, name = "module name 2"
+ CPPUNIT_ASSERT(cp5);
+ CPPUNIT_ASSERT(!cp5->IsSet("test_true", PT_BOOLEAN) && !cp5->IsSet("test_false", PT_BOOLEAN));
+ _PTR(AttributeParameter) cp6 = study->GetModuleParameters("id", "module name", 2); //Save point = 2, name = "module name"
+ CPPUNIT_ASSERT(cp6);
+ CPPUNIT_ASSERT(!cp6->IsSet("test_true", PT_BOOLEAN) && !cp6->IsSet("test_false", PT_BOOLEAN));
+
+ //Check method GetUseCaseBuilder
+ _PTR(UseCaseBuilder) ub = study->GetUseCaseBuilder();
+
+ //Check method SetStudyLock
+ study->SetStudyLock("locker1");
+
+ //Check method IsStudyLocked
+ CPPUNIT_ASSERT(study->IsStudyLocked());
+
+ //Check method GetLockerID
+ study->SetStudyLock("locker2");
+ vs = study->GetLockerID();
+ CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "locker1" && vs[1] == "locker2");
+
+ //Check method UnLockStudy
+ study->UnLockStudy("locker1");
+ CPPUNIT_ASSERT(study->IsStudyLocked());
+ vs = study->GetLockerID();
+ CPPUNIT_ASSERT(vs.size() == 1 && vs[0] == "locker2");
+ study->UnLockStudy("locker2");
+ CPPUNIT_ASSERT(!study->IsStudyLocked());
+ vs = study->GetLockerID();
+ CPPUNIT_ASSERT(vs.size() == 0);
+
+ //Check method EnableUseCaseAutoFilling
+ study->EnableUseCaseAutoFilling(false);
+ _PTR(SObject) uso1 = study->NewBuilder()->NewObject(sco1);
+ vector< _PTR(GenericAttribute) > va1 = uso1->GetAllAttributes();
+ CPPUNIT_ASSERT(va1.size() == 0);
+
+ study->EnableUseCaseAutoFilling(true);
+ _PTR(SObject) uso2 = study->NewBuilder()->NewObject(sco1);
+ vector< _PTR(GenericAttribute) > va2 = uso2->GetAllAttributes();
+ CPPUNIT_ASSERT(va2.size() == 1); // +AttributeTreeNode
+
+ //Check method DumpStudy
+ study->DumpStudy(".", "SRN", false);
+
+ fstream f("SRN.py");
+ char buffer[128];
+ buffer[81] = (char)0;
+ f.getline(buffer, 80);
+ string line(buffer);
+
+ f.close();
+ system("rm -f SRN.py");
+ CPPUNIT_ASSERT(line == "### This file is generated by SALOME automatically by dump python functionality");
+
+ //Check method Close
+ bool isException = false;
+ try {
+ sm->Close(study); //Close is called inside StudyManager::Close
+ }
+ catch(...) {
+ isException = true;
+ }
+ CPPUNIT_ASSERT(!isException);
+
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_StudyBuilder
+ * Use code of SALOMEDS_StudyBuilder.cxx
+ */
+
+void SALOMEDSTest::testStudyBuilder()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("TestStudyBuilder");
+
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+
+ //Check the StudyBuilder creation
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Check method NewComponent
+ _PTR(SComponent) sco1 = studyBuilder->NewComponent("Test");
+ CPPUNIT_ASSERT(sco1 && sco1->ComponentDataType() == "Test");
+
+ //Check method DefineComponentInstance
+ string ior = _orb->object_to_string(_sm);
+ studyBuilder->DefineComponentInstance(sco1, ior);
+ string newior;
+ sco1->ComponentIOR(newior);
+ CPPUNIT_ASSERT(newior == ior);
+
+ //Check method RemoveComponent
+ studyBuilder->RemoveComponent(sco1);
+ _PTR(SComponent) sco2 = study->FindComponent("Test");
+ CPPUNIT_ASSERT(!sco2);
+
+
+ _PTR(SComponent) sco3 = studyBuilder->NewComponent("NewComp");
+ CPPUNIT_ASSERT(sco3);
+
+ //Check method NewObject
+ _PTR(SObject) so1 = studyBuilder->NewObject(sco3);
+ CPPUNIT_ASSERT(so1);
+ string id1 = so1->GetID();
+
+ //Check method NewObjectToTag
+ _PTR(SObject) so2 = studyBuilder->NewObjectToTag(so1, 2);
+ CPPUNIT_ASSERT(so2 && so2->Tag() == 2);
+ string id2 = so2->GetID();
+
+ //Check method FindOrCreateAttribute
+ _PTR(SObject) so3 = studyBuilder->NewObject(sco3);
+ CPPUNIT_ASSERT(so3);
+ _PTR(AttributeName) an3 = studyBuilder->FindOrCreateAttribute(so3, "AttributeName");
+ CPPUNIT_ASSERT(an3);
+
+ //Check method FindAttribute
+ _PTR(GenericAttribute) ga;
+ CPPUNIT_ASSERT(studyBuilder->FindAttribute(so3, ga, "AttributeName"));
+
+ //Check method RemoveObject
+ studyBuilder->RemoveObject(so3);
+ CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so3, ga, "AttributeName"));
+
+ //Check method RemoveObjectWithChildren
+ _PTR(AttributeName) an2 = studyBuilder->FindOrCreateAttribute(so2, "AttributeName");
+ CPPUNIT_ASSERT(an2);
+ studyBuilder->RemoveObjectWithChildren(so1);
+ CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so2, ga, "AttributeName"));
+
+ //Check method RemoveAttribute
+ _PTR(AttributeName) an1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
+ CPPUNIT_ASSERT(an1);
+ CPPUNIT_ASSERT(studyBuilder->FindAttribute(so1, ga, "AttributeName"));
+ studyBuilder->RemoveAttribute(so1, "AttributeName");
+ CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so1, ga, "AttributeName"));
+
+ //Check method Addreference
+ studyBuilder->Addreference(so2, so1);
+ _PTR(SObject) refSO;
+ CPPUNIT_ASSERT(so2->ReferencedObject(refSO) && refSO->GetID() == so1->GetID());
+
+ //Check method RemoveReference
+ studyBuilder->RemoveReference(so2);
+ CPPUNIT_ASSERT(!so2->ReferencedObject(refSO));
+
+ //Check method SetGUID and IsGUID
+ string value = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
+ studyBuilder->SetGUID(so1, value);
+ CPPUNIT_ASSERT(studyBuilder->IsGUID(so1, value));
+
+ //Check method UndoLimit (set/get)
+ studyBuilder->UndoLimit(10);
+ CPPUNIT_ASSERT(studyBuilder->UndoLimit() == 10);
+
+ //Check transactions methods: NewCommand, CommitCommand, AbortCommand,
+ //HasOpenedCommand, Undo, Redo, GetAvailableUndos, GetAvailableRedos
+ _PTR(SObject) so4 = studyBuilder->NewObject(sco3);
+ CPPUNIT_ASSERT(so4);
+ studyBuilder->NewCommand();
+ CPPUNIT_ASSERT(studyBuilder->HasOpenCommand());
+ _PTR(AttributeName) an4 = studyBuilder->FindOrCreateAttribute(so4, "AttributeName");
+ CPPUNIT_ASSERT(an4);
+ an4->SetValue("command1");
+ studyBuilder->CommitCommand();
+ CPPUNIT_ASSERT(!studyBuilder->HasOpenCommand());
+ studyBuilder->NewCommand();
+ an4->SetValue("command2");
+ studyBuilder->AbortCommand();
+ CPPUNIT_ASSERT(an4->Value() == "command1");
+ studyBuilder->NewCommand();
+ an4->SetValue("command2");
+ studyBuilder->CommitCommand();
+ studyBuilder->Undo();
+ CPPUNIT_ASSERT(an4->Value() == "command1");
+ CPPUNIT_ASSERT(studyBuilder->GetAvailableRedos());
+ studyBuilder->Redo();
+ CPPUNIT_ASSERT(an4->Value() == "command2");
+ CPPUNIT_ASSERT(studyBuilder->GetAvailableUndos());
+
+ //Check method SetName
+ studyBuilder->SetName(so1, "new name");
+ CPPUNIT_ASSERT(so1->GetName() == "new name");
+
+ //Check method SetComment
+ studyBuilder->SetComment(so1, "new comment");
+ CPPUNIT_ASSERT(so1->GetComment() == "new comment");
+
+ //Check method SetIOR
+ studyBuilder->SetIOR(so1, ior);
+ CPPUNIT_ASSERT(so1->GetIOR() == ior);
+
+ sm->Close(study);
+
+ //Check method LoadWith
+ _PTR(Study) study2 = sm->NewStudy("Study2");
+
+ SALOME_NamingService NS(_orb);
+ CORBA::Object_var obj = SALOME_LifeCycleCORBA(&NS).FindOrLoad_Component("SuperVisionContainer", "SUPERV");
+ CPPUNIT_ASSERT(!CORBA::is_nil(obj));
+
+ MESSAGE("Created a new GEOM component");
+
+ SALOMEDS::Driver_var drv = SALOMEDS::Driver::_narrow(obj);
+ CPPUNIT_ASSERT(!CORBA::is_nil(drv));
+ _PTR(StudyBuilder) sb2 = study2->NewBuilder();
+ _PTR(SComponent) sco = sb2->NewComponent("SUPERV");
+ ior = _orb->object_to_string(drv);
+ sb2->DefineComponentInstance(sco, ior);
+
+ sm->SaveAs("srn_SALOMEDS_UnitTests.hdf", study2, false);
+ sm->Close(study2);
+
+ _PTR(Study) study3 = sm->Open("srn_SALOMEDS_UnitTests.hdf");
+ _PTR(StudyBuilder) sb3 = study3->NewBuilder();
+ _PTR(SComponent) aComp = study3->FindComponent("SUPERV");
+ CPPUNIT_ASSERT(aComp);
+
+ CORBA::Object_var obj2 = SALOME_LifeCycleCORBA(&NS).FindOrLoad_Component("SuperVisionContainer", "SUPERV");
+ CPPUNIT_ASSERT(!CORBA::is_nil(obj2));
+ SALOMEDS::Driver_var drv2 = SALOMEDS::Driver::_narrow(obj2);
+ ior = _orb->object_to_string(drv2);
+
+ bool isRaised = false;
+ try {
+ sb3->LoadWith(aComp, ior);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+
+ CPPUNIT_ASSERT(!isRaised);
+
+ ior = "";
+ aComp->ComponentIOR(ior);
+ CPPUNIT_ASSERT(!ior.empty());
+
+ system("rm -f srn_SALOMEDS_UnitTests.hdf");
+
+ //Check method AddDirectory
+ _PTR(AttributeName) na1 = sb3->FindOrCreateAttribute(aComp, "AttributeName");
+ na1->SetValue("Component");
+
+ isRaised = false;
+ try {
+ sb3->AddDirectory("/Component/Dir1");
+ } catch(...) {
+ isRaised = true;
+ }
+
+ CPPUNIT_ASSERT(!isRaised);
+ _PTR(SObject) so5 = study3->FindObjectByPath("/Component/Dir1");
+ CPPUNIT_ASSERT(so5);
+
+ isRaised = false;
+ try {
+ sb3->AddDirectory("/Component/Dir1"); //Attempt to create the same directory
+ } catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ isRaised = false;
+ try {
+ sb3->AddDirectory("/MyComponent/Dir1"); //Attempt to create the invalid directory
+ } catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ sm->Close(study3);
+}
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_StudyManager
+ * Use code of SALOMEDS_StudyManager.cxx
+ */
+void SALOMEDSTest::testStudyManager()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+
+ CPPUNIT_ASSERT(sm);
+
+ //Check method NewStudy
+ _PTR(Study) study1 = sm->NewStudy("Study1");
+ CPPUNIT_ASSERT(study1);
+
+ _PTR(Study) study2 = sm->NewStudy("Study2");
+ CPPUNIT_ASSERT(study2);
+
+ //Check method FindStudyByName
+ _PTR(Study) study3 = sm->GetStudyByName("Study1");
+ CPPUNIT_ASSERT(study3->StudyId() == study1->StudyId());
+ CPPUNIT_ASSERT(study3->Name() == study1->Name());
+
+ //Check method FindStudyByID
+ _PTR(Study) study4 = sm->GetStudyByID(study2->StudyId());
+ CPPUNIT_ASSERT(study4->StudyId() == study2->StudyId());
+ CPPUNIT_ASSERT(study4->Name() == study2->Name());
+
+ //Check method GetOpenStudies
+ vector<string> v = sm->GetOpenStudies();
+ CPPUNIT_ASSERT(v.size() == 2);
+
+ //Check method Close
+ int id = study2->StudyId();
+ sm->Close(study2);
+ CPPUNIT_ASSERT(!sm->GetStudyByID(id));
+
+ //Check methods CanPaste, CanCopy, Copy, Paste
+ _PTR(StudyBuilder) sb1 = study1->NewBuilder();
+ _PTR(SComponent) sco1 = sb1->NewComponent("Test");
+ _PTR(SObject) so1 = sb1->NewObject(sco1);
+ _PTR(AttributeName) na1 = sb1->FindOrCreateAttribute(so1, "AttributeName");
+ CPPUNIT_ASSERT(na1);
+ na1->SetValue("Some name");
+
+ CPPUNIT_ASSERT(!sm->CanCopy(so1)); //The father component has no IOR
+
+ CPPUNIT_ASSERT(sm->Copy(so1));
+
+
+ CPPUNIT_ASSERT(!sm->CanPaste(so1)); //The father component has no IOR
+
+ _PTR(SObject) so1_2 = sb1->NewObject(sco1);
+ _PTR(SObject) pasted_so = sm->Paste(so1_2);
+ CPPUNIT_ASSERT(pasted_so);
+
+ _PTR(AttributeName) na2 = sb1->FindOrCreateAttribute(pasted_so, "AttributeName");
+ CPPUNIT_ASSERT(na2 && na2->Value() == "Some name");
+
+
+
+ //Check method SaveAs
+ sm->SaveAs("srn_UnitTest_Save.hdf", study1, false);
+ string url = study1->URL();
+ sm->Close(study1);
+
+ //Check method Open
+ _PTR(Study) study1_opened = sm->Open("srn_UnitTest_Save.hdf"); //Contains Test component
+ system("rm -f srn_UnitTest_Save.hdf");
+ CPPUNIT_ASSERT(study1_opened);
+ CPPUNIT_ASSERT(url == "srn_UnitTest_Save.hdf");
+
+ //Check method Save
+ _PTR(StudyBuilder) sb3 = study1_opened->NewBuilder();
+ _PTR(SComponent) sco3 = study1_opened->FindComponent("Test");
+ CPPUNIT_ASSERT(sco3);
+ // Add a new SObject with AttributeName that contains "Saved study" string
+ _PTR(SObject) so3 = sb3->NewObject(sco3);
+ string soID = so3->GetID();
+ _PTR(AttributeName) na3 = sb3->FindOrCreateAttribute(so3, "AttributeName");
+ CPPUNIT_ASSERT(na3);
+ na3->SetValue("Saved study");
+ // Save and close the study
+ sm->Save(study1_opened, false);
+ sm->Close(study1_opened);
+
+ // Open saved study and find the created SObject with AttributeName, then compare the stored string
+ _PTR(Study) study2_opened = sm->Open("srn_UnitTest_Save.hdf");
+ system("rm -f srn_UnitTest_Save.hdf");
+ CPPUNIT_ASSERT(study2_opened);
+ _PTR(SObject) so4 = study2_opened->CreateObjectID(soID);
+ _PTR(StudyBuilder) sb4 = study2_opened->NewBuilder();
+ _PTR(AttributeName) na4 = sb4->FindOrCreateAttribute(so4, "AttributeName");
+ CPPUNIT_ASSERT(na4 && na4->Value() == "Saved study"); //Compare the value of restored attribute with string that has to be saved.
+
+
+ //Check method SaveAsASCII
+ sm->SaveAsASCII("srn_UnitTest_SaveASCII.hdf", study2_opened, false);
+ url = study2_opened->URL();
+ sm->Close(study2_opened);
+ _PTR(Study) study3_opened = sm->Open("srn_UnitTest_SaveASCII.hdf"); //Contains Test component
+ system("rm -f srn_UnitTest_SaveASCII.hdf");
+ CPPUNIT_ASSERT(study3_opened);
+ CPPUNIT_ASSERT(url == "srn_UnitTest_SaveASCII.hdf");
+
+ //Check method SaveASCII
+ _PTR(StudyBuilder) sb5 = study3_opened->NewBuilder();
+ _PTR(SComponent) sco5 = study3_opened->FindComponent("Test");
+ CPPUNIT_ASSERT(sco5);
+ // Add a new SObject with AttributeName that contains "Saved study" string
+ _PTR(SObject) so5 = sb5->NewObject(sco5);
+ soID = so5->GetID();
+ _PTR(AttributeName) na5 = sb5->FindOrCreateAttribute(so5, "AttributeName");
+ CPPUNIT_ASSERT(na5);
+ na5->SetValue("Saved study ASCII");
+ // Save and close the study
+ sm->Save(study3_opened, false);
+ sm->Close(study3_opened);
+
+ // Open saved study and find the created SObject with AttributeName, then compare the stored string
+ _PTR(Study) study4_opened = sm->Open("srn_UnitTest_SaveASCII.hdf");
+ system("rm -f srn_UnitTest_SaveASCII.hdf");
+ CPPUNIT_ASSERT(study4_opened);
+ _PTR(SObject) so6 = study4_opened->CreateObjectID(soID);
+ _PTR(StudyBuilder) sb6 = study4_opened->NewBuilder();
+ _PTR(AttributeName) na6 = sb6->FindOrCreateAttribute(so6, "AttributeName");
+ CPPUNIT_ASSERT(na6 && na6->Value() == "Saved study ASCII"); //Compare the value of restored attribute with string that has to be saved.
+
+}
+
+
+
--- /dev/null
+// 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/ or email : webmaster.salome@opencascade.com
+//
+
+/*!
+ * Check all methods of SALOMEDS_UseCaseBuilder and UseCaseIterator
+ * Use code of SALOMEDS_UseCaseBuilder.cxx and SALOMEDS_UseCaseIterator.cxx
+ */
+
+void SALOMEDSTest::testUseCase()
+{
+ //Create or find the Study manager
+ _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
+ CPPUNIT_ASSERT(sm);
+
+ //Create a new study
+ _PTR(Study) study = sm->NewStudy("TestSObject");
+ CPPUNIT_ASSERT(study);
+
+ //Create Study Builder
+ _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
+ CPPUNIT_ASSERT(studyBuilder);
+
+ //Create a new UseCaseBuilder
+ _PTR(UseCaseBuilder) builder = study->GetUseCaseBuilder();
+ CPPUNIT_ASSERT(builder);
+
+ //Check method AddUseCase
+ _PTR(SObject) root1 = builder->AddUseCase("UseCase_1");
+ _PTR(SObject) root2 = builder->AddUseCase("UseCase_2");
+ CPPUNIT_ASSERT(root1 && root2);
+
+ //Check method SetCurrentObject
+ builder->SetCurrentObject(root1);
+
+ //Check method GetCurrentObject
+ CPPUNIT_ASSERT(builder->GetCurrentObject() && builder->GetCurrentObject()->GetID() == root1->GetID());
+
+ //Check method SetRootCurrent
+ CPPUNIT_ASSERT(builder->SetRootCurrent());
+ CPPUNIT_ASSERT(builder->GetCurrentObject()->GetID() == "0:2"); //Root in UseCases is always placed at label 0:2
+
+ //Check method IsUseCase
+ CPPUNIT_ASSERT(builder->IsUseCase(root1) && builder->IsUseCase(root2));
+
+ //Check method SetName
+ builder->SetName("A root use case");
+
+ //Check method GetName
+ CPPUNIT_ASSERT(builder->GetName() == "A root use case");
+
+ cout << endl << "THE TEST IS NOT COMPLETE !!!" << endl;
+
+ //Check method GetUseCaseIterator
+ /*
+ builder->SetRootCurrent();
+ _PTR(SObject) nullObject;
+ _PTR(UseCaseIterator) root_it = builder->GetUseCaseIterator(nullObject); //The iterator on all UseCases
+ root_it->Init(false); //Only the first level
+ CPPUNIT_ASSERT(root_it->More());
+ CPPUNIT_ASSERT(root_it->Value()->GetID() == root1->GetID());
+ root_it->Next();
+ CPPUNIT_ASSERT(root_it->More());
+ CPPUNIT_ASSERT(root_it->Value()->GetID() == root2->GetID());
+ root_it->Next();
+ CPPUNIT_ASSERT(!root_it->More());
+ */
+
+ builder->SetCurrentObject(root1);
+ _PTR(UseCaseIterator) it = builder->GetUseCaseIterator(root1); //The iterator on the given UseCase
+
+ //Check method Append
+ _PTR(SObject) so1 = study->CreateObjectID("0:1:1");
+ _PTR(SObject) so2 = study->CreateObjectID("0:1:2");
+ CPPUNIT_ASSERT(builder->Append(so1));
+
+ //Check methods Init, More, Next and Value of UseCaseIterator
+ it->Init(false);
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so1->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(!it->More());
+
+ //Check method AppendTo
+ CPPUNIT_ASSERT(builder->AppendTo(so1, so2));
+
+ //Check method HasChildren
+ CPPUNIT_ASSERT(builder->HasChildren(so1));
+ CPPUNIT_ASSERT(!builder->HasChildren(so2));
+
+ //Check method Init of UseCaseIterator
+ it->Init(false); //Only the first level
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so1->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(!it->More());
+
+ it->Init(true); //All levels
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so1->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so2->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(!it->More());
+
+ //Check method Remove
+ CPPUNIT_ASSERT(builder->Remove(so2));
+ it->Init(true);
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so1->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(!it->More());
+
+ CPPUNIT_ASSERT(builder->Append(so2));
+
+ //Check method InsertBefore
+ CPPUNIT_ASSERT(builder->InsertBefore(so2, so1));
+ it->Init(false);
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so2->GetID());
+ it->Next();
+ CPPUNIT_ASSERT(it->More());
+ CPPUNIT_ASSERT(it->Value()->GetID() == so1->GetID());
+
+ sm->Close(study);
+}
+
+
+
#include "SALOMEDSImplTest.hxx"
#include "SALOMEDSTest.hxx"
+#include <TCollection_AsciiString.hxx>
+
// --- Registers the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
-CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSImplTest );
CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded );
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestRunner.h>
+#include <stdexcept>
+
+#include <iostream>
+#include <fstream>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include "utilities.h"
+#include "Utils_SINGLETON.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "SALOME_NamingService.hxx"
+#include "NamingService_WaitForServerReadiness.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
+
+// ============================================================================
+/*!
+ * Main program source for Unit Tests with cppunit package does not depend
+ * on actual tests, so we use the same for all partial unit tests.
+ */
+// ============================================================================
+
+int main(int argc, char* argv[])
+{
+ // --- Run Salome without GUI
+
+ setenv("SALOME_trace", "file:./traceUnitTest.log", 1); // 1: overwrite
+
+ system("runSalome -t &");
+
+ // --- Wait till SALOMEDS server is launched
+
+ char hostname[511];
+ int size;
+ gethostname(hostname, size);
+ string cfg_file = string(getenv("HOME"))+"/.omniORB_"+string(hostname)+"_2810.cfg";
+ setenv("OMNIORB_CONFIG", cfg_file.c_str(), 1);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ CORBA::ORB_var orb = init(argc , argv ) ;
+
+ sleep(10);
+
+ SALOME_NamingService NS(orb);
+ NamingService_WaitForServerReadiness(&NS, "/myStudyManager");
+
+ CORBA::Object_var obj = NS.Resolve( "/myStudyManager" );
+ if(CORBA::is_nil(obj)) {
+ system("killSalome.py");
+ return 1;
+ }
+
+ //Set up the environement for Embedded case
+ string kernel_root = getenv("KERNEL_ROOT_DIR");
+ CPPUNIT_ASSERT(!kernel_root.empty());
+ kernel_root+="/share/salome/resources/kernel";
+ setenv("CSF_PluginDefaults", kernel_root.c_str(), 1);
+ setenv("CSF_SALOMEDS_ResourcesDefaults", kernel_root.c_str(), 1);
+
+ CORBA::Object_var poaObj = orb->resolve_initial_references("RootPOA");
+ if(!CORBA::is_nil(poaObj)) {
+ PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj);
+
+ SALOMEDS_StudyManager_i * aStudyManager_i = new SALOMEDS_StudyManager_i(orb, poa);
+ // Activate the objects. This tells the POA that the objects are ready to accept requests.
+ PortableServer::ObjectId_var aStudyManager_iid = poa->activate_object(aStudyManager_i);
+ aStudyManager_i->register_name("/myStudyManager_embedded");
+
+ // Obtain a POAManager, and tell the POA to start accepting
+ // requests on its objects.
+ PortableServer::POAManager_var pman = poa->the_POAManager();
+ pman->activate();
+ }
+
+
+ // --- Create the event manager and test controller
+ CPPUNIT_NS::TestResult controller;
+
+ // --- Add a listener that colllects test result
+ CPPUNIT_NS::TestResultCollector result;
+ controller.addListener( &result );
+
+ // --- Add a listener that print dots as test run.
+#ifdef WIN32
+ CPPUNIT_NS::TextTestProgressListener progress;
+#else
+ CPPUNIT_NS::BriefTestProgressListener progress;
+#endif
+ controller.addListener( &progress );
+
+ // --- Get the top level suite from the registry
+
+ CPPUNIT_NS::Test *suite =
+ CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
+
+ // --- Adds the test to the list of test to run
+
+ CPPUNIT_NS::TestRunner runner;
+ runner.addTest( suite );
+ runner.run( controller);
+
+ // --- Print test in a compiler compatible format.
+
+ std::ofstream testFile;
+ testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc);
+ //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
+ CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
+ outputter.write();
+
+ // --- Run the tests.
+
+ bool wasSucessful = result.wasSuccessful();
+ testFile.close();
+
+ // --- Kill all created Salome process
+
+ system("killSalome.py");
-// --- generic Main program from Basic/Test
+ // --- Return error code 1 if the one of test failed.
-#include "BasicMainTest.hxx"
+ return wasSucessful ? 0 : 1;
+}