int aValue;
if (_isLocal) {
SALOMEDS::Locker lock;
- aValue = (bool)Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->Value();
+ aValue = Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->Value();
}
else aValue = SALOMEDS::AttributeLocalID::_narrow(_corba_impl)->Value();
return aValue;
}
else {
SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
- aLength = aRow->length();
+ aLength = aRow->length();
for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
}
Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
try {
- aTable->SetRowData(theColumn, aColumn);
+ aTable->SetColumnData(theColumn, aColumn);
}
catch(...) {
throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
aColumn->length(aLength);
for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
- SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
}
}
}
else {
SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
- aLength = aColumn->length();
+ aLength = aColumn->length();
for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
}
return aVector;
else {
SALOMEDS::LongSeq_var aSet =
SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
- aLength = aSet->length();
+ aLength = aSet->length();
for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
}
return aVector;
}
else {
SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
- aLength = aRow->length();
+ aLength = aRow->length();
for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
}
Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
try {
- aTable->SetRowData(theColumn, aColumn);
+ aTable->SetColumnData(theColumn, aColumn);
}
catch(...) {
throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
aColumn->length(aLength);
for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
- SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
}
}
}
else {
SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
- aLength = aColumn->length();
+ aLength = aColumn->length();
for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
}
return aVector;
}
else {
SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
- aLength = aSet->length();
+ aLength = aSet->length();
for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
}
return aVector;
}
else {
SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
+ aLength = aRow->length();
for (i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
}
Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString;
for (int i = 0; i < aLength; i++) aColumn->Append((char*)theData[i].c_str());
try {
- aTable->SetRowData(theColumn, aColumn);
+ aTable->SetColumnData(theColumn, aColumn);
}
catch(...) {
throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
aColumn->length(aLength);
for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
- SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
}
}
else {
SALOMEDS::StringSeq_var aColumn =
SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
+ aLength = aColumn->length();
for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
}
return aVector;
else {
SALOMEDS::LongSeq_var aSet =
SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+ aLength = aSet->length();
for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
}
return aVector;
else {
SALOMEDS::Study::ListOfSObject_var aSeq = SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Get();
aLength = aSeq->length();
- for (i = 0; i < aLength; i++) {
- aSO = new SALOMEDS_SObject(aSeq[i].in());
- aVector.push_back(_PTR(SObject)(aSO));
- }
+ for (i = 0; i < aLength; i++) {
+ aSO = new SALOMEDS_SObject(aSeq[i].in());
+ aVector.push_back(_PTR(SObject)(aSO));
+ }
}
return aVector;
#include "SALOMEDS.hxx"
#include <string>
+#include <stdexcept>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value)
{
+ if(!Standard_GUID::CheckGUIDFormat((char*)value.c_str())) throw invalid_argument("Invalid GUID");
+
if (_isLocal) {
CheckLocked();
SALOMEDS::Locker lock;
SALOMEDS::Locker lock;
CheckLocked();
Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_impl);
- aNode->SetTreeID(Standard_GUID(aNode->ID()));
+ aNode->SetTreeID(Standard_GUID((char*)value));
}
char* SALOMEDS_AttributeTreeNode_i::GetTreeID()
#include "SALOMEDS.hxx"
#include <string>
+#include <stdexcept>
+
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_GUID.hxx>
void SALOMEDS_AttributeUserID::SetValue(const std::string& value)
{
+ if(!Standard_GUID::CheckGUIDFormat((char*)value.c_str())) throw invalid_argument("Invalid GUID");
+
if (_isLocal) {
CheckLocked();
SALOMEDS::Locker lock;
long pid = (long)getpid();
#endif
- CORBA::LongLong addr = // mpv: fix for IPAL13534: for 64 bit platform use 8-bytes long for pointer storage
- theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
-
+ long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
if(_isLocal) {
_local_impl = ((SALOMEDSImpl_Study*)(addr));
_corba_impl = SALOMEDS::Study::_duplicate(theStudy);
SALOMEDSClient_SObject* aSO = NULL;
if (_isLocal) {
SALOMEDS::Locker lock;
- aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str()));
+ Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->CreateObjectID((char*)anObjectID.c_str());
+ if(aSO_impl.IsNull()) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
+ }
+ else {
+ SALOMEDS::SObject_var aSO_impl = _corba_impl->CreateObjectID((char*)anObjectID.c_str());
+ if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO);
+ aSO = new SALOMEDS_SObject(aSO_impl);
}
- else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str()));
return _PTR(SObject)(aSO);
}
std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO)
{
+ if(!theSO) return "";
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
std::string aPath;
if (_isLocal) {
std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject)
{
- CORBA::String_var objStr = _orb->object_to_string(theObject);
- return string( objStr.in() );
+ return _orb->object_to_string(theObject);
}
CORBA::Object_ptr SALOMEDS_Study::ConvertIORToObject(const std::string& theIOR)
#include "SALOMEDSImpl_GenericAttribute.hxx"
#include <string>
+#include <stdexcept>
#include <TCollection_AsciiString.hxx>
#include <TDF_Attribute.hxx>
void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO,
const std::string& ComponentIOR)
{
+ if(theSCO) return;
+
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO)
{
+ if(!theSCO) return;
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR)
{
+ if(!theSCO) return;
+
SALOMEDS_SComponent* aSCO = dynamic_cast<SALOMEDS_SComponent*>(theSCO.get());
CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str());
SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj);
void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
_PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO,
const std::string& aTypeOfAttribute)
-{
- SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
+{
SALOMEDSClient_GenericAttribute* anAttr = NULL;
+ if(!theSO) return _PTR(GenericAttribute)(anAttr);
+ SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
SALOMEDS::Locker lock;
const std::string& aTypeOfAttribute)
{
bool ret;
+
+ if(!theSO) return false;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
SALOMEDS::Locker lock;
void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject)
{
+ if(!me || !thereferencedObject) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
SALOMEDS_SObject* aRefSO = dynamic_cast<SALOMEDS_SObject*>(thereferencedObject.get());
if (_isLocal) {
void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me)
{
+ if(!me) return;
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(me.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
{
+ if(!theSO) return;
+ if(!Standard_GUID::CheckGUIDFormat((char*)theGUID.c_str())) throw invalid_argument("Invalid GUID");
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string& theGUID)
{
+ if(!theSO || !Standard_GUID::CheckGUIDFormat((char*)theGUID.c_str())) return false;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
bool ret;
if (_isLocal) {
void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue)
{
+ if(!theSO) return;
+
SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theSO.get());
if (_isLocal) {
CheckLocked();
#ifndef __SALOMEDS_STUDYBUILDER_I_H__
#define __SALOMEDS_STUDYBUILDER_I_H__
-#include "SALOMEDS_Defines.hxx"
-
// std C++ headers
#include <iostream>
// Cascade header
#include <TDocStd_Document.hxx>
-class SALOMEDS_EXPORT SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder,
+class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder,
public PortableServer::RefCountServantBase
{
private:
virtual void SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
virtual void SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
virtual void SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection);
+
+ Handle(SALOMEDSImpl_StudyBuilder) GetImpl() { return _impl; }
+
};
#endif
{
SALOMEDS::Locker lock;
+ if(!anObjectID || strlen(anObjectID) == 0) return SALOMEDS::SObject::_nil();
+
Handle(SALOMEDSImpl_SObject) aSO = _impl->CreateObjectID((char*)anObjectID);
if(aSO.IsNull()) return SALOMEDS::SObject::_nil();
aSO = _impl->FindObjectID(aSObj->GetID());
}
else {
- CORBA::String_var objStr = _orb->object_to_string(theObject);
- TCollection_AsciiString anAscii((char *)objStr.in());
- aSO = _impl->FindObjectIOR(anAscii);
+ aSO = _impl->FindObjectIOR(_orb->object_to_string(theObject));
}
if(aSO.IsNull()) return CORBA::string_dup(aPath.ToCString());
//============================================================================
/*! Function : GetComponentNames
* Purpose : method to get all components names
+ * SRN: Note, theContext can be any, it doesn't matter
*/
//============================================================================
SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext)
SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
- if (strlen(theContext) == 0 && !_impl->HasCurrentContext())
- throw SALOMEDS::Study::StudyInvalidContext();
-
Handle(TColStd_HSequenceOfAsciiString) aSeq =
_impl->GetComponentNames(TCollection_AsciiString((char*)theContext));
return CORBA::string_dup(script.c_str());
}
+//============================================================================
+/*! Function : EnableUseCaseAutoFilling
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled)
+{
+ _impl->EnableUseCaseAutoFilling(isEnabled);
+ Handle(SALOMEDSImpl_StudyBuilder) builder = _builder->GetImpl();
+ if(!builder.IsNull()) {
+ if(isEnabled) {
+ builder->SetOnAddSObject(_impl->GetCallback());
+ builder->SetOnRemoveSObject(_impl->GetCallback());
+ }
+ else {
+ builder->SetOnAddSObject(NULL);
+ builder->SetOnRemoveSObject(NULL);
+ }
+ }
+}
+
//===========================================================================
// PRIVATE FUNCTIONS
//===========================================================================
virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject);
- virtual SALOMEDS::AttributeStudyProperties_ptr GetProperties();
+ virtual SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties();
virtual char* GetLastModificationDate();
virtual void Close();
- void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _impl->EnableUseCaseAutoFilling(isEnabled); }
+ void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled);
// postponed destroying of CORBA object functionality
virtual void AddPostponed(const char* theIOR);
_PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SObject)& theObject)
{
SALOMEDS_UseCaseIterator* it = NULL;
- SALOMEDS_SObject* obj = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
+ SALOMEDS_SObject* obj = (theObject)?dynamic_cast<SALOMEDS_SObject*>(theObject.get()):NULL;
if (_isLocal) {
SALOMEDS::Locker lock;
- it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl()));
+ if(obj)
+ it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl()));
+ else
+ it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(NULL));
+ }
+ else {
+ if(obj)
+ it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
+ else
+ it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(SALOMEDS::SObject::_nil()));
}
- else it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl()));
return _PTR(UseCaseIterator)(it);
}
{
SALOMEDS::Locker lock;
if(_impl.IsNull() || theFirst->_is_nil() || theNext->_is_nil()) return 0;
- return _impl->AppendTo(_impl->GetSObject(theFirst->GetID()), _impl->GetSObject(theNext->GetID()));
+ return _impl->InsertBefore(_impl->GetSObject(theFirst->GetID()), _impl->GetSObject(theNext->GetID()));
}
SALOMEDS::Locker lock;
if(_impl.IsNull()) return SALOMEDS::UseCaseIterator::_nil();
- Handle(SALOMEDSImpl_UseCaseIterator) anItr = _impl->GetUseCaseIterator(_impl->GetSObject(theObject->GetID()));
+ Handle(SALOMEDSImpl_UseCaseIterator) anItr;
+ if(!CORBA::is_nil(theObject)) anItr = _impl->GetUseCaseIterator(_impl->GetSObject(theObject->GetID()));
+ else anItr = _impl->GetUseCaseIterator(NULL);
SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(anItr, _orb);
SALOMEDS::UseCaseIterator_var anIterator = SALOMEDS::UseCaseIterator::_narrow(aServant->_this());
return anIterator._retn();
-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());
+
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_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());
+
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_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());
+
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_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));
+
+ //Check visibility for 0 and -1
+ _attr->SetVisibility(0, false);
+ CPPUNIT_ASSERT(!_attr->GetVisibility(0));
+ _attr->SetVisibility(-1, true);
+ CPPUNIT_ASSERT(_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());
+
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_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);
+
+ //Try to retreive a value with invalid ID
+ bool isRaised = false;
+ CPPUNIT_ASSERT(!_attr->IsSet("invalid ID", PT_INTEGER));
+ try {
+ _attr->GetInt("invalid ID");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ //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());
+
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_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);
+
+ //Check empty PixMap assigning and retreival
+ _attr->SetPixMap("");
+ CPPUNIT_ASSERT(_attr->GetPixMap() == "");
+
+
+ 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);
+
+ //Check setting and retreival of empty object
+ _attr->SetObject("", true);
+ CPPUNIT_ASSERT(_attr->GetObject() == "" && _attr->IsScript());
+
+ 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);
+
+ //Check processing of invalid indicies
+ bool isRaised = false;
+ try {
+ _attr->Value(-1);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+ isRaised = false;
+ try {
+ _attr->ChangeValue(12, 1);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+ isRaised = false;
+ try {
+ _attr->Remove(10);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ 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);
+
+ //Check processing of invalid indicies
+ bool isRaised = false;
+ try {
+ _attr->Value(-1);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+ isRaised = false;
+ try {
+ _attr->ChangeValue(12, 1);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+ isRaised = false;
+ try {
+ _attr->Remove(10);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ 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
+ */
+#define SALOMEDS_ALL_TESTS
+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);
+
+ //Check method Label
+ CPPUNIT_ASSERT(_attr1->Label() == "0:1:2");
+
+ _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());
+
+#ifdef SALOMEDS_ALL_TESTS
+ //Check method GetFather
+ CPPUNIT_ASSERT(_attr1->GetFather()->Label() == _attr->Label());
+
+ //Check method Append
+ _attr->Append(_attr1);
+
+ //Check possibility to Append to itself
+ bool isRaised = false;
+ try {
+ _attr->Append(_attr);
+ }catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ _attr->Append(_attr2);
+
+ //Check method HasNext
+ CPPUNIT_ASSERT(_attr1->HasNext());
+
+ //Check method GetNext
+ CPPUNIT_ASSERT(_attr1->GetNext()->Label() == _attr2->Label());
+
+ //Check method HasPrevious
+ CPPUNIT_ASSERT(_attr2->HasPrevious());
+
+ //Check method GetPrevious
+ CPPUNIT_ASSERT(_attr2->GetPrevious()->Label() == _attr1->Label());
+
+ //Check method Depth
+ CPPUNIT_ASSERT(_attr->Depth() == 0 && _attr1->Depth() == 1);
+
+ //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()->Label() == _attr1->Label());
+
+ _attr2->Remove();
+
+ //Check method Prepend
+ _attr->Prepend(_attr2);
+ CPPUNIT_ASSERT(_attr->GetFirst()->Label() == _attr2->Label());
+
+ //Check possibility to Prepend to itself
+ isRaised = false;
+ try {
+ _attr->Prepend(_attr);
+ }catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ _attr1->Remove();
+
+ //Check method InsertBefore
+ _attr2->InsertBefore(_attr1);
+
+ CPPUNIT_ASSERT(_attr->GetFirst()->Label() == _attr1->Label());
+
+ //Check possibility to InsertBefore to itself
+ isRaised = false;
+ try {
+ _attr->InsertBefore(_attr);
+ }catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ _attr1->Remove();
+
+ //Check method InsertAfter
+ _attr2->InsertAfter(_attr1);
+
+ CPPUNIT_ASSERT(_attr->GetFirst()->Label() == _attr2->Label());
+
+ //Check possibility to InsertAfter to itself
+ isRaised = false;
+ try {
+ _attr->InsertAfter(_attr);
+ }catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ //Check method Remove
+ _attr2->Remove();
+
+ CPPUNIT_ASSERT(_attr->GetFirst()->Label() == _attr1->Label());
+
+ //Check method SetTreeID and GetTreeID
+ _attr2->SetTreeID(TreeNodeID);
+
+ CPPUNIT_ASSERT(_attr2->GetTreeID() == TreeNodeID);
+#else
+ cout << endl << "THE TEST IS NOT COMPLETE !!!" << endl;
+#endif
+
+
+ //Try to create the attribute with given TreeID
+ string value = "0e1c36e6-1111-4d90-ab3b-18a14310e648";
+ _PTR(AttributeTreeNode) _attr_guid = studyBuilder->FindOrCreateAttribute(so, "AttributeTreeNode"+value);
+ CPPUNIT_ASSERT(_attr_guid && _attr_guid->GetTreeID() == value);
+
+ //Try to set invalid GUID
+ isRaised = false;
+ try {
+ _attr->SetTreeID("invalid guid");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ sm->Close(study);
+}
+#undef SALOMEDS_ALL_TESTS
+
+
--- /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());
+
+ //Try to create the attribute with given UserID
+ value = "0e1c36e6-379b-4d90-ab3b-18a14310e648";
+ _PTR(AttributeUserID) _attr2 = studyBuilder->FindOrCreateAttribute(so, "AttributeUserID"+value);
+ CPPUNIT_ASSERT(_attr2 && _attr2->Value() == value);
+
+ //Try to set invalid GUID
+ bool isRaised = false;
+ try {
+ _attr->SetValue("invalid guid");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+
+ 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"));
+
+ //Try to find attribute with empty type
+ CPPUNIT_ASSERT(!so->FindAttribute(ga, ""));
+
+ //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("");
+ CPPUNIT_ASSERT(study->URL() == "");
+ 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);
+
+ //Try to create SObject with empty and invalid entries
+ CPPUNIT_ASSERT(!study->CreateObjectID(""));
+ CPPUNIT_ASSERT(!study->CreateObjectID("entry"));
+
+ //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");
+
+ //Try to find component with empty type
+ CPPUNIT_ASSERT(!study->FindComponent(""));
+
+ //Check method GetComponentNames
+ vector<string> components = study->GetComponentNames(""); //The context doesn't matter
+ CPPUNIT_ASSERT(components.size() == 1 && components[0] == "sco1");
+
+ //Check method FindComponentID
+ _PTR(SComponent) sco3 = study->FindComponentID(sco1->GetID());
+ CPPUNIT_ASSERT(sco3 && sco3->GetID() == sco1->GetID());
+
+ //Try to find component with empty id
+ CPPUNIT_ASSERT(!study->FindComponentID(""));
+
+ _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());
+
+ //Try to find SObject with empty name
+ CPPUNIT_ASSERT(!study->FindObject(""));
+
+ //Check method FindObjectID
+ _PTR(SObject) so4 = study->FindObjectID(so1->GetID());
+ CPPUNIT_ASSERT(so4 && so4->GetID() == so1->GetID());
+
+ //Try to find SObject with empty ID
+ CPPUNIT_ASSERT(!study->FindObjectID(""));
+
+ //Check method FindObjectByName
+ vector< _PTR(SObject) > v = study->FindObjectByName("so1", sco1->ComponentDataType());
+ CPPUNIT_ASSERT(v.size()==1 && v[0]->GetID() == so1->GetID());
+
+ //Try to find SObject with empty name and empty component type
+ CPPUNIT_ASSERT((study->FindObjectByName("", "")).size() == 0);
+
+ //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());
+
+ //Try to find SObject with empty IOR
+ CPPUNIT_ASSERT(!study->FindObjectIOR(""));
+
+ //Check method GetObjectPath
+ string path = study->GetObjectPath(so2);
+
+ //Try to get path of NULL SObject
+ _PTR(SObject) emptySO;
+ path = study->GetObjectPath(emptySO);
+ CPPUNIT_ASSERT(path.empty());
+
+ //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());
+
+
+ //Try to find SObject with empty path
+ _PTR(SObject) tmp = study->FindObjectByPath(""); //Must return the Context SObject
+ CPPUNIT_ASSERT(tmp && tmp->GetID() == sco1->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_so1->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
+ 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();
+ CPPUNIT_ASSERT(ub);
+
+ //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);
+
+ //Try to create and find the component with empty type
+ _PTR(SComponent) sco_empty = studyBuilder->NewComponent("");
+ CPPUNIT_ASSERT(!sco_empty);
+
+ _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);
+
+ cout << endl << "########## 1" << endl;
+
+ //Try to create attribute with invalid type
+ CPPUNIT_ASSERT(!studyBuilder->FindOrCreateAttribute(so3, "invalid type"));
+
+ cout << endl << "########## 2" << endl;
+
+ //Check method FindAttribute
+ _PTR(GenericAttribute) ga;
+ CPPUNIT_ASSERT(studyBuilder->FindAttribute(so3, ga, "AttributeName"));
+
+ cout << endl << "########## 3" << endl;
+
+ //Try to find attribute with invalid type
+ CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so3, ga, "invalid type"));
+
+ cout << endl << "########## 4" << endl;
+
+ //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());
+
+ //Try to set reference to NULL SObject
+ bool isRaised = false;
+ _PTR(SObject) empty_so;
+ try {
+ studyBuilder->Addreference(so2, empty_so);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ //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));
+
+ //Try to set invalid GUID
+ isRaised = false;
+ try {
+ studyBuilder->SetGUID(so1, "invalid GUID");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+ //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");
+
+ //Try to set empty Name
+ studyBuilder->SetName(so1, "");
+ CPPUNIT_ASSERT(so1->GetName() == "");
+
+ //Check method SetComment
+ studyBuilder->SetComment(so1, "new comment");
+ CPPUNIT_ASSERT(so1->GetComment() == "new comment");
+
+ //Check method empty Comment
+ studyBuilder->SetComment(so1, "");
+ CPPUNIT_ASSERT(so1->GetComment() == "");
+
+ //Try to set empty IOR
+ studyBuilder->SetIOR(so1, "");
+ CPPUNIT_ASSERT(so1->GetIOR() == "");
+
+ //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);
+
+ 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 GetStudyByName
+ _PTR(Study) study3 = sm->GetStudyByName("Study1");
+ CPPUNIT_ASSERT(study3->StudyId() == study1->StudyId());
+ CPPUNIT_ASSERT(study3->Name() == study1->Name());
+
+ //Check method GetStudyByName with empty name
+ CPPUNIT_ASSERT(!sm->GetStudyByName(""));
+
+ //Try to create Study with empty name
+ _PTR(Study) study_empty = sm->NewStudy("");
+ CPPUNIT_ASSERT(study_empty);
+ CPPUNIT_ASSERT(sm->GetStudyByName(""));
+ sm->Close(study_empty);
+
+ //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 method GetStudyByID for invalid ID
+ CPPUNIT_ASSERT(!sm->GetStudyByID(-1));
+
+ //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");
+ url = study1->URL();
+ 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
+ */
+
+#define SALOMEDS_ALL_TESTS
+
+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");
+
+#ifdef SALOMEDS_ALL_TESTS
+ //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());
+#else
+ cout << endl << "THE TEST IS NOT COMPLETE !!!" << endl;
+#endif
+
+ 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);
+}
+#undef SALOMEDS_ALL_TESTS
+
+
#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 "OpUtil.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);
+ char* chr_port = getenv("SALOMEDS_UNITTESTS_PORT");
+ string port;
+ if(chr_port) port = chr_port;
+ if(port.empty()) port = "2810";
+ string cfg_file = string(getenv("HOME"))+"/.omniORB_"+string(hostname)+"_"+port+".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(15);
+
+ string host; // = GetHostname();
+ char* wait_Superv = getenv("SALOMEDS_UNITTESTS_WAIT_SUPERVISOR");
+ if(wait_Superv) host = GetHostname();
+
+ SALOME_NamingService NS(orb);
+ if(host.empty())
+ NamingService_WaitForServerReadiness(&NS, "/myStudyManager");
+ else {
+ string serverName = "/Containers/"+host+"/SuperVisionContainer";
+ NamingService_WaitForServerReadiness(&NS, serverName);
+ }
+
+ 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;
+}
#include "SALOMEDSClient_definitions.hxx"
#include "SALOMEDSClient_GenericAttribute.hxx"
-class SALOMEDSClient_AttributeTreeNode
+class SALOMEDSClient_AttributeTreeNode: public virtual SALOMEDSClient_GenericAttribute
{
public:
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_ints[theID] = theValue;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_reals[theID] = theValue;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_strings[theID] = theValue;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_bools[theID] = theValue;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_realarrays[theID] = theArray;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_intarrays[theID] = theArray;
{
CheckLocked();
+ if(theID.size() == 0) return;
+
Backup();
_strarrays[theID] = theArray;
_intarrays.clear();
_strarrays.clear();
- for(map<string,int>::const_iterator p = A->_ints.begin(); p!= A->_ints.end(); p++) _ints[p->first] = p->second;
- for(map<string,double>::const_iterator p = A->_reals.begin(); p!= A->_reals.end(); p++) _reals[p->first] = p->second;
- for(map<string,bool>::const_iterator p = A->_bools.begin(); p!= A->_bools.end(); p++) _bools[p->first] = p->second;
+ for(map<string,int>::const_iterator p = A->_ints.begin(); p!= A->_ints.end(); p++)
+ if(p->first.size()) _ints[p->first] = p->second;
+ for(map<string,double>::const_iterator p = A->_reals.begin(); p!= A->_reals.end(); p++)
+ if(p->first.size()) _reals[p->first] = p->second;
+ for(map<string,bool>::const_iterator p = A->_bools.begin(); p!= A->_bools.end(); p++)
+ if(p->first.size()) _bools[p->first] = p->second;
for(map<string,string>::const_iterator p = A->_strings.begin(); p!= A->_strings.end(); p++)
- _strings[p->first] = p->second;
+ if(p->first.size()) _strings[p->first] = p->second;
for(map< string,vector<double> >::const_iterator p = A->_realarrays.begin(); p!= A->_realarrays.end(); p++)
- _realarrays[p->first] = p->second;
+ if(p->first.size()) _realarrays[p->first] = p->second;
for(map< string,vector<int> >::const_iterator p = A->_intarrays.begin(); p!= A->_intarrays.end(); p++)
- _intarrays[p->first] = p->second;
+ if(p->first.size()) _intarrays[p->first] = p->second;
for(map< string,vector<string> >::const_iterator p = A->_strarrays.begin(); p!= A->_strarrays.end(); p++)
- _strarrays[p->first] = p->second;
+ if(p->first.size()) _strarrays[p->first] = p->second;
}
//=======================================================================
{
CheckLocked();
Backup();
+
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
+
myValue->SetValue(Index, Value);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
{
CheckLocked();
Backup();
+
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
+
myValue->Remove(Index);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Value(const Standard_Integer Index)
{
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
+
return myValue->Value(Index);
}
{
CheckLocked();
Backup();
+
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
+
myValue->SetValue(Index, Value);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
{
CheckLocked();
Backup();
+
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
+
myValue->Remove(Index);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
Standard_Real SALOMEDSImpl_AttributeSequenceOfReal::Value(const Standard_Integer Index)
{
+ if(Index <= 0 || Index > myValue->Length()) Standard_Failure::Raise("Out of range");
return myValue->Value(Index);
}
if (!(TN->ID() == myTreeID) )
Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::Append : uncompatible GUID");
+ if(TN->Label() == Label())
+ Standard_Failure::Raise("Attempt of self linking");
+
Handle(SALOMEDSImpl_AttributeTreeNode) bid;
TN->SetNext(bid); // Deconnects from next.
if (!(TN->ID() == myTreeID) )
Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::Prepend : uncompatible GUID");
+ if(TN->Label() == Label())
+ Standard_Failure::Raise("Attempt of self linking");
+
Handle(SALOMEDSImpl_AttributeTreeNode) bid;
TN->SetPrevious(bid);
if (HasFirst()) {
if (!(TN->ID() == myTreeID) )
Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::InsertBefore : uncompatible GUID");
+ if(TN->Label() == Label())
+ Standard_Failure::Raise("Attempt of self linking");
+
TN->SetFather(GetFather());
TN->SetPrevious(GetPrevious());
TN->SetNext(this);
{
CheckLocked();
+ if(TN->Label() == Label())
+ Standard_Failure::Raise("Attempt of self linking");
+
if (!(TN->ID() == myTreeID) )
Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::InsertAfter : uncompatible GUID");
return aResultSeq;
}
- TDF_ChildIterator anIter (aLabel, Standard_False); // iterate all subchildren at all sublevels
+ TDF_ChildIterator anIter (aLabel, Standard_True); // iterate all subchildren at all sublevels
for (; anIter.More(); anIter.Next()) {
TDF_Label aLabel = anIter.Value();
Handle(SALOMEDSImpl_AttributeName) aName;
return aResultSeq;
}
- TDF_ChildIterator anIter (aLabel, Standard_False); // iterate first-level children at all sublevels
+ TDF_ChildIterator anIter (aLabel, Standard_True); // iterate first-level children at all sublevels
for (; anIter.More(); anIter.Next()) {
TDF_Label aLabel = anIter.Value();
Handle(SALOMEDSImpl_AttributeLocalID) anID;
return aResultSeq;
}
- TDF_ChildIterator anIter (aLabel, Standard_False); // iterate all subchildren at all sublevels
+ TDF_ChildIterator anIter (aLabel, Standard_True); // iterate all subchildren at all sublevels
for (; anIter.More(); anIter.Next()) {
TDF_Label aLabel = anIter.Value();
Handle(SALOMEDSImpl_AttributeLocalID) anID;
if(aDriver == NULL) continue;
- bool isValidScript = false;
+ bool isValidScript;
long aStreamLength = 0;
Handle(SALOMEDSImpl_TMPFile) aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength);
if ( !isValidScript )
{
return _lockers;
}
+
+//============================================================================
+/*! Function : EnableUseCaseAutoFilling
+ * Purpose :
+ */
+//============================================================================
+void SALOMEDSImpl_Study::EnableUseCaseAutoFilling(bool isEnabled)
+{
+ _errorCode = ""; _autoFill = isEnabled;
+ if(isEnabled) {
+ _builder->SetOnAddSObject(_cb);
+ _builder->SetOnRemoveSObject(_cb);
+ }
+ else {
+ _builder->SetOnAddSObject(NULL);
+ _builder->SetOnRemoveSObject(NULL);
+ }
+}
\ No newline at end of file
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
+#ifndef WNT
#include <NCollection_DataMap.hxx>
+#else
+#include <NCollection_DataMap1.hxx>
+#endif
//SALOMEDSImpl headers
#include "SALOMEDSImpl_SComponentIterator.hxx"
class SALOMEDSImpl_StudyManager;
class SALOMEDSImpl_GenericAttribute;
+#ifndef WNT
typedef NCollection_DataMap <TCollection_AsciiString, Handle_Standard_Transient> DataMapOfAsciiStringTransient;
typedef NCollection_DataMap <TCollection_AsciiString, TDF_Label> DataMapAsciiStringLabel;
+#else
+typedef NCollection_DataMap1 <TCollection_AsciiString, Handle_Standard_Transient> DataMapOfAsciiStringTransient;
+typedef NCollection_DataMap1 <TCollection_AsciiString, TDF_Label> DataMapAsciiStringLabel;
+#endif
class SALOMEDSImpl_Study : public MMgt_TShared
{
Standard_EXPORT virtual Handle(TColStd_HSequenceOfTransient) FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject);
- Standard_EXPORT virtual Handle(SALOMEDSImpl_AttributeStudyProperties) GetProperties();
+ Standard_EXPORT virtual Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties();
Standard_EXPORT virtual TCollection_AsciiString GetLastModificationDate();
Standard_EXPORT virtual void Close();
- Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled) { _errorCode = ""; _autoFill = isEnabled; }
+ Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled);
// postponed destroying of object functionality
Standard_EXPORT virtual void AddPostponed(const TCollection_AsciiString& theIOR);
//Returns an ID of the study locker
Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetLockerID();
+ //Returns a callback
+ Standard_EXPORT Handle(SALOMEDSImpl_Callback) GetCallback() { return _cb; }
+
+
public:
DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study )
{
_errorCode = "";
CheckLocked();
+
+ if(DataType.Length() == 0) return 0;
+
//Always create component under main label.
TDF_Label L = _doc->Main();
} else {
char* aGUIDString = new char[40];
char* aType = (char*)aTypeOfAttribute.ToCString();
- sprintf(aGUIDString, &(aType[21]));
+ sprintf(aGUIDString, &(aType[17]));
+ if(!Standard_GUID::CheckGUIDFormat(aGUIDString)) {
+ delete(aGUIDString);
+ return NULL;
+ }
aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
delete(aGUIDString);
}
}
if (strncmp(aTypeOfAttribute.ToCString(), "AttributeUserID",15) == 0 ) {
+ Standard_GUID aUserGUID;
+ if (strcmp(aTypeOfAttribute.ToCString(), "AttributeUserID") == 0) {
+ aUserGUID = SALOMEDSImpl_AttributeUserID::DefaultID();
+ } else {
+ char* aGUIDString = new char[40];
+ char* aType = (char*)aTypeOfAttribute.ToCString();
+ sprintf(aGUIDString, &(aType[15]));
+ if(!Standard_GUID::CheckGUIDFormat(aGUIDString)) {
+ delete(aGUIDString);
+ return NULL;
+ }
+ aUserGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
+ delete(aGUIDString);
+ }
Handle(SALOMEDSImpl_AttributeUserID) anAttr;
if (!Lab.FindAttribute(SALOMEDSImpl_AttributeUserID::DefaultID(), anAttr)) {
CheckLocked();
- anAttr = SALOMEDSImpl_AttributeUserID::Set(Lab, SALOMEDSImpl_AttributeUserID::DefaultID());
+ anAttr = SALOMEDSImpl_AttributeUserID::Set(Lab, aUserGUID);
}
return anAttr;
}
IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared )
#define USE_CASE_LABEL_ID "0:2"
-#define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
-#define AUTO_SAVE_TAG "0:8"
-#define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200
static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject);
static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* );
if (aLocked) aStudy->GetProperties()->SetLocked(false);
Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder();
- map<string, SALOMEDSImpl_Driver*> aMapTypeDriver; // IPAL13339
+ map<char*, SALOMEDSImpl_Driver*> aMapTypeDriver;
if(aStudy.IsNull()) {
_errorCode = "Study is null";
SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator();
- //SRN: Added 17 Nov, 2003
- Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG);
- //SRN: End
for (; itcomponent.More(); itcomponent.Next())
- {
+ {
Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
TCollection_AsciiString scoid = sco->GetID();
hdf_sco_group->CreateOnDisk();
TCollection_AsciiString componentDataType = sco->ComponentDataType();
-
- //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
- if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) {
-
- Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
- if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) {
- Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
- if(nbRows > 0 && aTable->GetNbColumns() > 1) {
-
- Handle(TColStd_HSequenceOfExtendedString) aRow;
- for(k=1; k<=nbRows; k++) {
- aRow = aTable->GetRowData(k);
- if (aRow->Value(1) == componentDataType) {
- TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2));
- Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry);
- if(!aCompSpecificSO.IsNull()) {
- Handle(SALOMEDSImpl_AttributeInteger) anInteger;
- if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) {
- anInteger->SetValue(-1);
- while(anInteger->Value() < 0) {
-#ifndef WNT
- sleep(2);
-#else
- Sleep(2);
-#endif
- if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS)
- break;
- }
- } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
- } // if(!CORBA::is_nil(aCompSpecificSO))
- } // if (strcmp(aRow[0], componentDataType) == 0)
- } // for
-
- } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
-
- } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
-
- } // if(SB->IsGUID(AUTO_SAVE_GUID)
-
- //SRN: End
TCollection_AsciiString IOREngine;
if (sco->ComponentIOR(IOREngine))
{
if(_root.IsNull() || theFather.IsNull() || theObject.IsNull()) return false;
TDF_Label aFatherLabel = theFather->GetLabel(), aLabel = theObject->GetLabel();
+ if(aFatherLabel == aLabel) return false;
+
Handle(SALOMEDSImpl_AttributeTreeNode) aFather, aNode;
if(aFatherLabel.IsNull()) return false;
if(_root.IsNull() || theFirst.IsNull() || theNext.IsNull()) return false;
TDF_Label aFirstLabel = theFirst->GetLabel(), aLabel= theNext->GetLabel();
+ if(aFirstLabel == aLabel) return false;
+
Handle(SALOMEDSImpl_AttributeTreeNode) aFirstNode, aNode;
if(aFirstLabel.IsNull()) return false;
{
TCollection_AsciiString aString;
if(_root.IsNull()) return aString;
-
+
Handle(SALOMEDSImpl_AttributeName) aName;
if (!_root->FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aName)) return aString;
aString = TCollection_AsciiString(aName->Value());