From 08c7bd30fc5e56901f11330687a95ad9114d7047 Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 15 Feb 2007 09:54:45 +0000 Subject: [PATCH] Merge modifications for SALOMEDS Unittests --- src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx | 2 +- .../SALOMEDS_AttributeTableOfInteger.cxx | 10 +- .../SALOMEDS_AttributeTableOfReal.cxx | 10 +- .../SALOMEDS_AttributeTableOfString.cxx | 7 +- src/SALOMEDS/SALOMEDS_AttributeTarget.cxx | 8 +- src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx | 3 + src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx | 2 +- src/SALOMEDS/SALOMEDS_AttributeUserID.cxx | 4 + src/SALOMEDS/SALOMEDS_Study.cxx | 18 +- src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 34 +- src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx | 7 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 31 +- src/SALOMEDS/SALOMEDS_Study_i.hxx | 4 +- src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx | 14 +- src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx | 6 +- src/SALOMEDS/Test/Makefile.am | 2 +- src/SALOMEDS/Test/SALOMEDSTest.cxx | 210 ++++------- src/SALOMEDS/Test/SALOMEDSTest.hxx | 149 +++++++- .../Test/SALOMEDSTest_AttributeComment.cxx | 75 ++++ .../Test/SALOMEDSTest_AttributeDrawable.cxx | 73 ++++ .../Test/SALOMEDSTest_AttributeExpandable.cxx | 71 ++++ .../SALOMEDSTest_AttributeExternalFileDef.cxx | 74 ++++ .../Test/SALOMEDSTest_AttributeFileType.cxx | 74 ++++ .../Test/SALOMEDSTest_AttributeFlags.cxx | 76 ++++ .../Test/SALOMEDSTest_AttributeGraphic.cxx | 73 ++++ .../Test/SALOMEDSTest_AttributeIOR.cxx | 69 ++++ .../Test/SALOMEDSTest_AttributeInteger.cxx | 66 ++++ .../Test/SALOMEDSTest_AttributeLocalID.cxx | 65 ++++ .../Test/SALOMEDSTest_AttributeName.cxx | 73 ++++ .../Test/SALOMEDSTest_AttributeOpened.cxx | 71 ++++ .../Test/SALOMEDSTest_AttributeParameter.cxx | 146 ++++++++ .../SALOMEDSTest_AttributePersistentRef.cxx | 73 ++++ .../Test/SALOMEDSTest_AttributePixMap.cxx | 74 ++++ .../SALOMEDSTest_AttributePythonObject.cxx | 74 ++++ .../Test/SALOMEDSTest_AttributeReal.cxx | 65 ++++ .../Test/SALOMEDSTest_AttributeSelectable.cxx | 71 ++++ ...ALOMEDSTest_AttributeSequenceOfInteger.cxx | 126 +++++++ .../SALOMEDSTest_AttributeSequenceOfReal.cxx | 121 ++++++ .../SALOMEDSTest_AttributeStudyProperties.cxx | 113 ++++++ .../SALOMEDSTest_AttributeTableOfInteger.cxx | 193 ++++++++++ .../SALOMEDSTest_AttributeTableOfReal.cxx | 190 ++++++++++ .../SALOMEDSTest_AttributeTableOfString.cxx | 190 ++++++++++ .../Test/SALOMEDSTest_AttributeTarget.cxx | 89 +++++ .../Test/SALOMEDSTest_AttributeTextColor.cxx | 74 ++++ ...LOMEDSTest_AttributeTextHighlightColor.cxx | 74 ++++ .../Test/SALOMEDSTest_AttributeTreeNode.cxx | 204 ++++++++++ .../Test/SALOMEDSTest_AttributeUserID.cxx | 81 ++++ .../Test/SALOMEDSTest_ChildIterator.cxx | 79 ++++ src/SALOMEDS/Test/SALOMEDSTest_SComponent.cxx | 70 ++++ .../Test/SALOMEDSTest_SComponentIterator.cxx | 65 ++++ src/SALOMEDS/Test/SALOMEDSTest_SObject.cxx | 124 +++++++ src/SALOMEDS/Test/SALOMEDSTest_Study.cxx | 349 ++++++++++++++++++ .../Test/SALOMEDSTest_StudyBuilder.cxx | 285 ++++++++++++++ .../Test/SALOMEDSTest_StudyManager.cxx | 164 ++++++++ src/SALOMEDS/Test/SALOMEDSTest_UseCase.cxx | 149 ++++++++ src/SALOMEDS/Test/TestSALOMEDS.cxx | 149 +++++++- .../SALOMEDSClient_AttributeTreeNode.hxx | 2 +- .../SALOMEDSImpl_AttributeParameter.cxx | 31 +- ...ALOMEDSImpl_AttributeSequenceOfInteger.cxx | 8 + .../SALOMEDSImpl_AttributeSequenceOfReal.cxx | 7 + .../SALOMEDSImpl_AttributeTreeNode.cxx | 12 + src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 26 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx | 17 +- .../SALOMEDSImpl_StudyBuilder.cxx | 25 +- .../SALOMEDSImpl_StudyManager.cxx | 50 +-- .../SALOMEDSImpl_UseCaseBuilder.cxx | 6 +- 66 files changed, 4709 insertions(+), 248 deletions(-) create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeDrawable.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeExpandable.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeExternalFileDef.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeFileType.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeFlags.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeGraphic.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeIOR.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeInteger.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeLocalID.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeName.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeOpened.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeParameter.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributePersistentRef.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributePixMap.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributePythonObject.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeReal.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeSelectable.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfInteger.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfReal.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeStudyProperties.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfInteger.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfReal.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfString.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTarget.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTextColor.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTextHighlightColor.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeTreeNode.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_AttributeUserID.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_ChildIterator.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_SComponent.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_SComponentIterator.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_SObject.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_Study.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_StudyManager.cxx create mode 100755 src/SALOMEDS/Test/SALOMEDSTest_UseCase.cxx diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx index 0be09d990..9fd941897 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx @@ -43,7 +43,7 @@ int SALOMEDS_AttributeLocalID::Value() 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx index 4bf6caea8..829dd0205 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger.cxx @@ -297,7 +297,7 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRow(int theRow) } 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]); } @@ -340,7 +340,7 @@ void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vecto 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(); @@ -350,7 +350,7 @@ void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vecto 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); } } @@ -367,7 +367,7 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn) } 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; @@ -435,7 +435,7 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow) 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx index 3443b6b52..f695ed2ad 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx @@ -296,7 +296,7 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRow(int theRow) } 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]); } @@ -339,7 +339,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vectorAppend(theData[i]); try { - aTable->SetRowData(theColumn, aColumn); + aTable->SetColumnData(theColumn, aColumn); } catch(...) { throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); @@ -349,7 +349,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vectorlength(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); } } @@ -366,7 +366,7 @@ std::vector SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn) } 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; @@ -432,7 +432,7 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow) } 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx index de544941a..b416e0691 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx @@ -296,6 +296,7 @@ std::vector SALOMEDS_AttributeTableOfString::GetRow(int theRow) } 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()); } @@ -338,7 +339,7 @@ void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector 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(); @@ -348,7 +349,7 @@ void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector 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); } } @@ -368,6 +369,7 @@ std::vector SALOMEDS_AttributeTableOfString::GetColumn(int theColum 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; @@ -435,6 +437,7 @@ std::vector SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow) 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx index 8579bbaef..fff0cb6f0 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx @@ -71,10 +71,10 @@ std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get() 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx index 59703419d..8cac2063e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx @@ -25,6 +25,7 @@ #include "SALOMEDS.hxx" #include +#include #include #include @@ -248,6 +249,8 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst() 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; diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index b4ae565ce..3574d218b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -160,7 +160,7 @@ void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value) 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() diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx index 1b73e3c5c..c20087a47 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx @@ -25,6 +25,8 @@ #include "SALOMEDS.hxx" #include +#include + #include #include #include @@ -55,6 +57,8 @@ std::string SALOMEDS_AttributeUserID::Value() 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; diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index a9b692a0f..207684032 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -83,9 +83,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) 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); @@ -246,9 +244,15 @@ _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID) 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); } @@ -290,6 +294,7 @@ _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath) std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO) { + if(!theSO) return ""; SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); std::string aPath; if (_isLocal) { @@ -693,8 +698,7 @@ vector SALOMEDS_Study::GetLockerID() 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) diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index 97fa1f884..277ceebb9 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -41,6 +41,7 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" #include +#include #include #include @@ -97,6 +98,8 @@ _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& Componen void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO, const std::string& ComponentIOR) { + if(theSCO) return; + SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); if (_isLocal) { CheckLocked(); @@ -113,6 +116,7 @@ void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& the void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO) { + if(!theSCO) return; SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); if (_isLocal) { CheckLocked(); @@ -188,6 +192,8 @@ void SALOMEDS_StudyBuilder::AddDirectory(const std::string& thePath) void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std::string& theIOR) { + if(!theSCO) return; + SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str()); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); @@ -217,6 +223,8 @@ void SALOMEDS_StudyBuilder::Load(const _PTR(SObject)& theSCO) void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); @@ -229,6 +237,8 @@ void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO) void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); @@ -241,9 +251,10 @@ void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO) _PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute) -{ - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); +{ SALOMEDSClient_GenericAttribute* anAttr = NULL; + if(!theSO) return _PTR(GenericAttribute)(anAttr); + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { SALOMEDS::Locker lock; @@ -271,6 +282,9 @@ bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute) { bool ret; + + if(!theSO) return false; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { SALOMEDS::Locker lock; @@ -290,6 +304,8 @@ bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO, void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); @@ -302,6 +318,8 @@ void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const st void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject) { + if(!me || !thereferencedObject) return; + SALOMEDS_SObject* aSO = dynamic_cast(me.get()); SALOMEDS_SObject* aRefSO = dynamic_cast(thereferencedObject.get()); if (_isLocal) { @@ -315,6 +333,7 @@ void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SOb void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me) { + if(!me) return; SALOMEDS_SObject* aSO = dynamic_cast(me.get()); if (_isLocal) { CheckLocked(); @@ -327,6 +346,9 @@ void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me) 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(theSO.get()); if (_isLocal) { CheckLocked(); @@ -339,6 +361,8 @@ void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::strin 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(theSO.get()); bool ret; if (_isLocal) { @@ -482,6 +506,8 @@ void SALOMEDS_StudyBuilder::CheckLocked() void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); @@ -494,6 +520,8 @@ void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::strin void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); @@ -506,6 +534,8 @@ void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::st void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue) { + if(!theSO) return; + SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); if (_isLocal) { CheckLocked(); diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index e5c77f217..ae6d0e5c5 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -24,8 +24,6 @@ #ifndef __SALOMEDS_STUDYBUILDER_I_H__ #define __SALOMEDS_STUDYBUILDER_I_H__ -#include "SALOMEDS_Defines.hxx" - // std C++ headers #include @@ -39,7 +37,7 @@ // Cascade header #include -class SALOMEDS_EXPORT SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder, +class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder, public PortableServer::RefCountServantBase { private: @@ -132,5 +130,8 @@ public: 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 diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 11661ab45..1bac30de6 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -194,6 +194,8 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID) { 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(); @@ -275,9 +277,7 @@ char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject) 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()); @@ -401,6 +401,7 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) //============================================================================ /*! 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) @@ -409,9 +410,6 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theCont 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)); @@ -882,6 +880,27 @@ char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* 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 //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index d1e6fae52..cabc9c648 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -247,7 +247,7 @@ public: 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(); @@ -260,7 +260,7 @@ public: 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); diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx index d429516f3..c89cb6ff3 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx @@ -200,11 +200,19 @@ _PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName) _PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SObject)& theObject) { SALOMEDS_UseCaseIterator* it = NULL; - SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); + SALOMEDS_SObject* obj = (theObject)?dynamic_cast(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); } diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx index a0da803d2..6997908eb 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -101,7 +101,7 @@ CORBA::Boolean SALOMEDS_UseCaseBuilder_i::InsertBefore(SALOMEDS::SObject_ptr the { 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())); } @@ -218,7 +218,9 @@ SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALO 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(); diff --git a/src/SALOMEDS/Test/Makefile.am b/src/SALOMEDS/Test/Makefile.am index 6b1bc5f50..be6a60647 100644 --- a/src/SALOMEDS/Test/Makefile.am +++ b/src/SALOMEDS/Test/Makefile.am @@ -57,6 +57,7 @@ COMMON_CPPFLAGS=\ -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 \ @@ -107,4 +108,3 @@ TestSALOMEDS_LDADD = \ libSALOMEDSTest.la ../libSalomeDS.la \ $(RPATH)/NamingService/Test/libNamingServiceTest.la \ $(COMMON_LIBS) - diff --git a/src/SALOMEDS/Test/SALOMEDSTest.cxx b/src/SALOMEDS/Test/SALOMEDSTest.cxx index 88443291b..0b728667b 100644 --- a/src/SALOMEDS/Test/SALOMEDSTest.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest.cxx @@ -20,81 +20,50 @@ #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 #include #include #include #include -#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 +#include 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; + char* argv[] = {""}; - // --- Get or initialize the orb - - int _argc = 1; - char* _argv[] = {""}; ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::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) ); } // ============================================================================ @@ -103,88 +72,73 @@ void SALOMEDSTest::setUp() */ // ============================================================================ -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 v = sm->GetOpenStudies(); + for(int i = 0; iGetStudyByName(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; + char* argv[] = {""}; - _ap->SetReal("RealValue", 1.2); - CPPUNIT_ASSERT(_ap->IsSet("RealValue", PT_REAL)); - CPPUNIT_ASSERT(_ap->GetReal("RealValue") == 1.2); - - _ap->SetString("StringValue", "hello"); - CPPUNIT_ASSERT(_ap->IsSet("StringValue", PT_STRING)); - CPPUNIT_ASSERT(_ap->GetString("StringValue") == "hello"); - - _ap->SetBool("BoolValue", 0); - CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN)); - CPPUNIT_ASSERT(!_ap->GetBool("BoolValue")); - - _ap->SetBool("BoolValue", 0); - CPPUNIT_ASSERT(_ap->IsSet("BoolValue", PT_BOOLEAN)); - CPPUNIT_ASSERT(!_ap->GetBool("BoolValue")); - - vector intArray; - intArray.push_back(0); - intArray.push_back(1); - - _ap->SetIntArray("IntArray", intArray); - CPPUNIT_ASSERT(_ap->IsSet("IntArray", PT_INTARRAY)); - CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[0] == 0); - CPPUNIT_ASSERT(_ap->GetIntArray("IntArray")[1] == 1); - - vector realArray; - realArray.push_back(0.0); - realArray.push_back(1.1); - - _ap->SetRealArray("RealArray", realArray); - CPPUNIT_ASSERT(_ap->IsSet("RealArray", PT_REALARRAY)); - CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[0] == 0.0); - CPPUNIT_ASSERT(_ap->GetRealArray("RealArray")[1] == 1.1); + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init(argc , argv ) ; + SALOME_NamingService NS(_orb); + CORBA::Object_var obj = NS.Resolve( "/myStudyManager_embedded" ); + _sm = SALOMEDS::StudyManager::_narrow( obj ); - vector strArray; - strArray.push_back("hello"); - strArray.push_back("world"); - - _ap->SetStrArray("StrArray", strArray); - CPPUNIT_ASSERT(_ap->IsSet("StrArray", PT_STRARRAY)); - CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[0] == "hello"); - CPPUNIT_ASSERT(_ap->GetStrArray("StrArray")[1] == "world"); + CPPUNIT_ASSERT( !CORBA::is_nil(_sm) ); } - - - diff --git a/src/SALOMEDS/Test/SALOMEDSTest.hxx b/src/SALOMEDS/Test/SALOMEDSTest.hxx index 83c4debb6..6dcaed5e5 100644 --- a/src/SALOMEDS/Test/SALOMEDSTest.hxx +++ b/src/SALOMEDS/Test/SALOMEDSTest.hxx @@ -23,26 +23,161 @@ #include -#include - #include -#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 diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx new file mode 100755 index 000000000..ce401624f --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx @@ -0,0 +1,75 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeDrawable.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeDrawable.cxx new file mode 100755 index 000000000..b1e72cf76 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeDrawable.cxx @@ -0,0 +1,73 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeExpandable.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeExpandable.cxx new file mode 100755 index 000000000..7d799d957 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeExpandable.cxx @@ -0,0 +1,71 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeExternalFileDef.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeExternalFileDef.cxx new file mode 100755 index 000000000..db6ca94a9 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeExternalFileDef.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeFileType.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeFileType.cxx new file mode 100755 index 000000000..1db238278 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeFileType.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeFlags.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeFlags.cxx new file mode 100755 index 000000000..d171576c7 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeFlags.cxx @@ -0,0 +1,76 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeGraphic.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeGraphic.cxx new file mode 100755 index 000000000..b7f6152a8 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeGraphic.cxx @@ -0,0 +1,73 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeIOR.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeIOR.cxx new file mode 100755 index 000000000..5a30c88b1 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeIOR.cxx @@ -0,0 +1,69 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeInteger.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeInteger.cxx new file mode 100755 index 000000000..1476a85be --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeInteger.cxx @@ -0,0 +1,66 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeLocalID.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeLocalID.cxx new file mode 100755 index 000000000..d8fce6079 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeLocalID.cxx @@ -0,0 +1,65 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeName.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeName.cxx new file mode 100755 index 000000000..2c5d28525 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeName.cxx @@ -0,0 +1,73 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeOpened.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeOpened.cxx new file mode 100755 index 000000000..9e41cd5bc --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeOpened.cxx @@ -0,0 +1,71 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeParameter.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeParameter.cxx new file mode 100755 index 000000000..5eb3ba31c --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeParameter.cxx @@ -0,0 +1,146 @@ +// 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 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 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 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributePersistentRef.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributePersistentRef.cxx new file mode 100755 index 000000000..acd864710 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributePersistentRef.cxx @@ -0,0 +1,73 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributePixMap.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributePixMap.cxx new file mode 100755 index 000000000..87828f007 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributePixMap.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributePythonObject.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributePythonObject.cxx new file mode 100755 index 000000000..8db63c023 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributePythonObject.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeReal.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeReal.cxx new file mode 100755 index 000000000..c04e3e70f --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeReal.cxx @@ -0,0 +1,65 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeSelectable.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSelectable.cxx new file mode 100755 index 000000000..67aaea942 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSelectable.cxx @@ -0,0 +1,71 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfInteger.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfInteger.cxx new file mode 100755 index 000000000..27371c474 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfInteger.cxx @@ -0,0 +1,126 @@ +// 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 v = _attr->CorbaSequence(); + CPPUNIT_ASSERT(v.size() == 3); + + for(int i = 0; iAssign(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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfReal.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfReal.cxx new file mode 100755 index 000000000..ed4747576 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeSequenceOfReal.cxx @@ -0,0 +1,121 @@ +// 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 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeStudyProperties.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeStudyProperties.cxx new file mode 100755 index 000000000..965773d4d --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeStudyProperties.cxx @@ -0,0 +1,113 @@ +// 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 vs; + vector 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfInteger.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfInteger.cxx new file mode 100755 index 000000000..e633bc5b3 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfInteger.cxx @@ -0,0 +1,193 @@ +// 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 rs = _attr->GetRowSetIndices(1); + + CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1); +*/ + _attr->PutValue(32, 2,2); + CPPUNIT_ASSERT(_attr->HasValue(2, 2)); +/* + vector 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 rt = _attr->GetRowTitles(); + + CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2"); + + vector 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 ct = _attr->GetColumnTitles(); + + + CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2"); +*/ + + vector 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 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 data; + data.push_back(11); + data.push_back(22); + + _attr->AddRow(data); + + CPPUNIT_ASSERT(_attr->GetNbRows() == 3); + + //Check method GetRow + vector 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfReal.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfReal.cxx new file mode 100755 index 000000000..75d1b2e40 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfReal.cxx @@ -0,0 +1,190 @@ +// 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 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 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 rt = _attr->GetRowTitles(); + + CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2"); + + + vector 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 ct = _attr->GetColumnTitles(); + + CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2"); + + vector 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 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 data; + data.push_back(11.11); + data.push_back(22.22); + + _attr->AddRow(data); + + CPPUNIT_ASSERT(_attr->GetNbRows() == 3); + + //Check method GetRow + vector 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfString.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfString.cxx new file mode 100755 index 000000000..f9de75405 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTableOfString.cxx @@ -0,0 +1,190 @@ +// 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 rs = _attr->GetRowSetIndices(1); + + CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1); + + _attr->PutValue("32", 2,2); + CPPUNIT_ASSERT(_attr->HasValue(2, 2)); + + vector 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 rt = _attr->GetRowTitles(); + + CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2"); + + + vector 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 ct = _attr->GetColumnTitles(); + + CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2"); + + vector 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 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 data; + data.push_back("11"); + data.push_back("22"); + + _attr->AddRow(data); + + CPPUNIT_ASSERT(_attr->GetNbRows() == 3); + + //Check method GetRow + vector 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTarget.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTarget.cxx new file mode 100755 index 000000000..4f2785f0d --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTarget.cxx @@ -0,0 +1,89 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextColor.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextColor.cxx new file mode 100755 index 000000000..c99bf75c6 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextColor.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextHighlightColor.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextHighlightColor.cxx new file mode 100755 index 000000000..40ec96098 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTextHighlightColor.cxx @@ -0,0 +1,74 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeTreeNode.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTreeNode.cxx new file mode 100755 index 000000000..23a7b9471 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeTreeNode.cxx @@ -0,0 +1,204 @@ +// 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 + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeUserID.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeUserID.cxx new file mode 100755 index 000000000..064b77de5 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeUserID.cxx @@ -0,0 +1,81 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_ChildIterator.cxx b/src/SALOMEDS/Test/SALOMEDSTest_ChildIterator.cxx new file mode 100755 index 000000000..bed9e9276 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_ChildIterator.cxx @@ -0,0 +1,79 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_SComponent.cxx b/src/SALOMEDS/Test/SALOMEDSTest_SComponent.cxx new file mode 100755 index 000000000..1ca79b8c4 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_SComponent.cxx @@ -0,0 +1,70 @@ +// 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_SComponentIterator.cxx b/src/SALOMEDS/Test/SALOMEDSTest_SComponentIterator.cxx new file mode 100755 index 000000000..7ca4ca72c --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_SComponentIterator.cxx @@ -0,0 +1,65 @@ +// 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 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); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_SObject.cxx b/src/SALOMEDS/Test/SALOMEDSTest_SObject.cxx new file mode 100755 index 000000000..5b4d221fe --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_SObject.cxx @@ -0,0 +1,124 @@ +// 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(so.get())->GetObject(); + CPPUNIT_ASSERT(!CORBA::is_nil(obj)); + + sm->Close(study); +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx b/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx new file mode 100755 index 000000000..aef1f9c2a --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_Study.cxx @@ -0,0 +1,349 @@ +// 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 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 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); + +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx b/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx new file mode 100755 index 000000000..4ce06a578 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_StudyBuilder.cxx @@ -0,0 +1,285 @@ +// 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); +} diff --git a/src/SALOMEDS/Test/SALOMEDSTest_StudyManager.cxx b/src/SALOMEDS/Test/SALOMEDSTest_StudyManager.cxx new file mode 100755 index 000000000..f20d68208 --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_StudyManager.cxx @@ -0,0 +1,164 @@ +// 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 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. +} + + + diff --git a/src/SALOMEDS/Test/SALOMEDSTest_UseCase.cxx b/src/SALOMEDS/Test/SALOMEDSTest_UseCase.cxx new file mode 100755 index 000000000..27c2246ce --- /dev/null +++ b/src/SALOMEDS/Test/SALOMEDSTest_UseCase.cxx @@ -0,0 +1,149 @@ +// 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 + + diff --git a/src/SALOMEDS/Test/TestSALOMEDS.cxx b/src/SALOMEDS/Test/TestSALOMEDS.cxx index 68c94b243..59f32e47d 100644 --- a/src/SALOMEDS/Test/TestSALOMEDS.cxx +++ b/src/SALOMEDS/Test/TestSALOMEDS.cxx @@ -24,12 +24,153 @@ #include "SALOMEDSImplTest.hxx" #include "SALOMEDSTest.hxx" +#include + // --- 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#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_::Instance() ; + ASSERT(SINGLETON_::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; +} diff --git a/src/SALOMEDSClient/SALOMEDSClient_AttributeTreeNode.hxx b/src/SALOMEDSClient/SALOMEDSClient_AttributeTreeNode.hxx index b3b31b94d..47383e748 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_AttributeTreeNode.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_AttributeTreeNode.hxx @@ -27,7 +27,7 @@ #include "SALOMEDSClient_definitions.hxx" #include "SALOMEDSClient_GenericAttribute.hxx" -class SALOMEDSClient_AttributeTreeNode +class SALOMEDSClient_AttributeTreeNode: public virtual SALOMEDSClient_GenericAttribute { public: diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.cxx index 1eea12dbd..820643d35 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.cxx @@ -119,6 +119,8 @@ void SALOMEDSImpl_AttributeParameter::SetInt(const string& theID, const int& the { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _ints[theID] = theValue; @@ -148,6 +150,8 @@ void SALOMEDSImpl_AttributeParameter::SetReal(const string& theID, const double& { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _reals[theID] = theValue; @@ -177,6 +181,8 @@ void SALOMEDSImpl_AttributeParameter::SetString(const string& theID, const strin { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _strings[theID] = theValue; @@ -206,6 +212,8 @@ void SALOMEDSImpl_AttributeParameter::SetBool(const string& theID, const bool& t { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _bools[theID] = theValue; @@ -235,6 +243,8 @@ void SALOMEDSImpl_AttributeParameter::SetRealArray(const string& theID, const ve { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _realarrays[theID] = theArray; @@ -265,6 +275,8 @@ void SALOMEDSImpl_AttributeParameter::SetIntArray(const string& theID, const vec { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _intarrays[theID] = theArray; @@ -295,6 +307,8 @@ void SALOMEDSImpl_AttributeParameter::SetStrArray(const string& theID, const vec { CheckLocked(); + if(theID.size() == 0) return; + Backup(); _strarrays[theID] = theArray; @@ -583,17 +597,20 @@ void SALOMEDSImpl_AttributeParameter::Restore(const Handle(TDF_Attribute)& with) _intarrays.clear(); _strarrays.clear(); - for(map::const_iterator p = A->_ints.begin(); p!= A->_ints.end(); p++) _ints[p->first] = p->second; - for(map::const_iterator p = A->_reals.begin(); p!= A->_reals.end(); p++) _reals[p->first] = p->second; - for(map::const_iterator p = A->_bools.begin(); p!= A->_bools.end(); p++) _bools[p->first] = p->second; + for(map::const_iterator p = A->_ints.begin(); p!= A->_ints.end(); p++) + if(p->first.size()) _ints[p->first] = p->second; + for(map::const_iterator p = A->_reals.begin(); p!= A->_reals.end(); p++) + if(p->first.size()) _reals[p->first] = p->second; + for(map::const_iterator p = A->_bools.begin(); p!= A->_bools.end(); p++) + if(p->first.size()) _bools[p->first] = p->second; for(map::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 >::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 >::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 >::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; } //======================================================================= diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx index 459b8b26e..8519394a9 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.cxx @@ -133,6 +133,9 @@ void SALOMEDSImpl_AttributeSequenceOfInteger::ChangeValue(const Standard_Integer { 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 @@ -151,6 +154,9 @@ void SALOMEDSImpl_AttributeSequenceOfInteger::Remove(const Standard_Integer Inde { 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 @@ -162,6 +168,8 @@ Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Length() } 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); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx index 1cad917f6..3d78ec633 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.cxx @@ -132,6 +132,9 @@ void SALOMEDSImpl_AttributeSequenceOfReal::ChangeValue(const Standard_Integer In { 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 @@ -150,6 +153,9 @@ void SALOMEDSImpl_AttributeSequenceOfReal::Remove(const Standard_Integer Index) { 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 @@ -162,6 +168,7 @@ Standard_Integer SALOMEDSImpl_AttributeSequenceOfReal::Length() 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); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx index 9a9776d30..8bc31e415 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx @@ -87,6 +87,9 @@ Standard_Boolean SALOMEDSImpl_AttributeTreeNode::Append (const Handle(SALOMEDSIm 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. @@ -122,6 +125,9 @@ Standard_Boolean SALOMEDSImpl_AttributeTreeNode::Prepend (const Handle(SALOMEDSI 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()) { @@ -151,6 +157,9 @@ Standard_Boolean SALOMEDSImpl_AttributeTreeNode::InsertBefore (const Handle(SALO 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); @@ -175,6 +184,9 @@ Standard_Boolean SALOMEDSImpl_AttributeTreeNode::InsertAfter (const Handle(SALOM { CheckLocked(); + if(TN->Label() == Label()) + Standard_Failure::Raise("Attempt of self linking"); + if (!(TN->ID() == myTreeID) ) Standard_DomainError::Raise("SALOMEDSImpl_AttributeTreeNode::InsertAfter : uncompatible GUID"); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index f6c2fa1f6..28f8a0ff2 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -590,7 +590,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetObjectNames(const 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; @@ -624,7 +624,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetDirectoryNames(con 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; @@ -665,7 +665,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetFileNames(const TC 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; @@ -1361,7 +1361,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, if(aDriver == NULL) continue; - bool isValidScript = false; + bool isValidScript; long aStreamLength = 0; Handle(SALOMEDSImpl_TMPFile) aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength); if ( !isValidScript ) @@ -1635,3 +1635,21 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetLockerID() { 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 diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index a1fe8805d..2ee5246f7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -43,7 +43,11 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) #include #include #include +#ifndef WNT #include +#else +#include +#endif //SALOMEDSImpl headers #include "SALOMEDSImpl_SComponentIterator.hxx" @@ -60,8 +64,13 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) class SALOMEDSImpl_StudyManager; class SALOMEDSImpl_GenericAttribute; +#ifndef WNT typedef NCollection_DataMap DataMapOfAsciiStringTransient; typedef NCollection_DataMap DataMapAsciiStringLabel; +#else +typedef NCollection_DataMap1 DataMapOfAsciiStringTransient; +typedef NCollection_DataMap1 DataMapAsciiStringLabel; +#endif class SALOMEDSImpl_Study : public MMgt_TShared { @@ -210,7 +219,7 @@ public: 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(); @@ -220,7 +229,7 @@ public: 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); @@ -279,6 +288,10 @@ public: //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 ) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index 05d9dec5e..f963a80c4 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -81,6 +81,9 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_StudyBuilder::NewComponent(const TC { _errorCode = ""; CheckLocked(); + + if(DataType.Length() == 0) return 0; + //Always create component under main label. TDF_Label L = _doc->Main(); @@ -482,7 +485,11 @@ Handle(TDF_Attribute) SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const Han } 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); } @@ -495,10 +502,24 @@ Handle(TDF_Attribute) SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const Han } 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; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index a4bb6e922..dd91556cd 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -56,9 +56,6 @@ IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared ) 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* ); @@ -503,7 +500,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, if (aLocked) aStudy->GetProperties()->SetLocked(false); Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder(); - map aMapTypeDriver; // IPAL13339 + map aMapTypeDriver; if(aStudy.IsNull()) { _errorCode = "Study is null"; @@ -558,11 +555,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, 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(); @@ -570,46 +564,6 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, 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)) { diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx index 6a20fec57..3f6f339ce 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.cxx @@ -165,6 +165,8 @@ bool SALOMEDSImpl_UseCaseBuilder::AppendTo(const Handle(SALOMEDSImpl_SObject)& t 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; @@ -191,6 +193,8 @@ bool SALOMEDSImpl_UseCaseBuilder::InsertBefore(const Handle(SALOMEDSImpl_SObject 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; @@ -320,7 +324,7 @@ TCollection_AsciiString SALOMEDSImpl_UseCaseBuilder::GetName() { 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()); -- 2.39.2