Back to index

salome-kernel  6.5.0
Public Member Functions | Protected Attributes | Private Member Functions
SALOMEDSTest Class Reference

#include <SALOMEDSTest.hxx>

Inheritance diagram for SALOMEDSTest:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void setUp ()
 Set up the environment.
virtual void tearDown ()
void testAttributeComment ()
 Check all methods of SALOMEDS_AttributeComment Use code of SALOMEDS_AttributeComment.cxx.
void testAttributeDrawable ()
 Check all methods of SALOMEDS_AttributeDrawable Use code of SALOMEDS_AttributeDrawable.cxx.
void testAttributeExpandable ()
 Check all methods of SALOMEDS_AttributeExpandable Use code of SALOMEDS_AttributeExpandable.cxx.
void testAttributeExternalFileDef ()
 Check all methods of SALOMEDS_AttributeExternalFileDef Use code of SALOMEDS_AttributeExternalFileDef.cxx.
void testAttributeFileType ()
 Check all methods of SALOMEDS_AttributeFileType Use code of SALOMEDS_AttributeFileType.cxx.
void testAttributeFlags ()
 Check all methods of SALOMEDS_AttributeFlags Use code of SALOMEDS_AttributeFlags.cxx.
void testAttributeGraphic ()
 Check all methods of SALOMEDS_AttributeGraphic Use code of SALOMEDS_AttributeGraphic.cxx.
void testAttributeIOR ()
 Check all methods of SALOMEDS_AttributeIOR Use code of SALOMEDS_AttributeIOR.cxx.
void testAttributeInteger ()
 Check all methods of SALOMEDS_AttributeInteger Use code of SALOMEDS_AttributeInteger.cxx.
void testAttributeLocalID ()
 Check all methods of SALOMEDS_AttributeLocalID Use code of SALOMEDS_AttributeLocalID.cxx.
void testAttributeName ()
 Check all methods of SALOMEDS_AttributeName Use code of SALOMEDS_AttributeName.cxx.
void testAttributeOpened ()
 Check all methods of SALOMEDS_AttributeOpened Use code of SALOMEDS_AttributeOpened.cxx.
void testAttributeParameter ()
 Check all methods of SALOMEDS_AttributeParameter Use code of SALOMEDS_AttributeParameter.cxx.
void testAttributePersistentRef ()
 Check all methods of SALOMEDS_AttributePersistentRef Use code of SALOMEDS_AttributePersistentRef.cxx.
void testAttributePixMap ()
 Check all methods of SALOMEDS_AttributePixMap Use code of SALOMEDS_AttributePixMap.cxx.
void testAttributePythonObject ()
 Check all methods of SALOMEDS_AttributePythonObject Use code of SALOMEDS_AttributePythonObject.cxx.
void testAttributeReal ()
 Check all methods of SALOMEDS_AttributeReal Use code of SALOMEDS_AttributeReal.cxx.
void testAttributeSelectable ()
 Check all methods of SALOMEDS_AttributeSelectable Use code of SALOMEDS_AttributeSelectable.cxx.
void testAttributeSequenceOfInteger ()
 Check all methods of SALOMEDS_AttributeSequenceOfInteger Use code of SALOMEDS_AttributeSequenceOfInteger.cxx.
void testAttributeSequenceOfReal ()
 Check all methods of SALOMEDS_AttributeSequenceOfReal Use code of SALOMEDS_AttributeSequenceOfReal.cxx.
void testAttributeStudyProperties ()
 Check all methods of SALOMEDS_AttributeStudyProperties Use code of SALOMEDS_AttributeStudyProperties.cxx.
void testAttributeTableOfInteger ()
 Check all methods of SALOMEDS_AttributeTableOfInteger Use code of SALOMEDS_AttributeTableOfInteger.cxx.
void testAttributeTableOfReal ()
 Check all methods of SALOMEDS_AttributeTableOfReal Use code of SALOMEDS_AttributeTableOfReal.cxx.
void testAttributeTableOfString ()
 Check all methods of SALOMEDS_AttributeTableOfString Use code of SALOMEDS_AttributeTableOfString.cxx.
void testAttributeTarget ()
 Check all methods of SALOMEDS_AttributeTarget Use code of SALOMEDS_AttributeTarget.cxx.
void testAttributeTextColor ()
 Check all methods of SALOMEDS_AttributeTextColor Use code of SALOMEDS_AttributeTextColor.cxx.
void testAttributeTextHighlightColor ()
 Check all methods of SALOMEDS_AttributeTextHighlightColor Use code of SALOMEDS_AttributeTextHighlightColor.cxx.
void testAttributeTreeNode ()
void testAttributeUserID ()
 Check all methods of SALOMEDS_AttributeUserID Use code of SALOMEDS_AttributeUserID.cxx.
void testChildIterator ()
 Check all methods of SALOMEDS_ChildIterator Use code of SALOMEDS_ChildIterator.cxx.
void testSComponent ()
 Check all methods of SALOMEDS_SComponent Use code of SALOMEDS_SComponent.cxx.
void testSComponentIterator ()
 Check all methods of SALOMEDS_SComponentIterator Use code of SALOMEDS_SComponentIterator.cxx.
void testSObject ()
 Check all methods of SALOMEDS_SObject Use code of SALOMEDS_SObject.cxx.
void testStudy ()
 Check all methods of SALOMEDS_Study Use code of SALOMEDS_Study.cxx.
void testStudyBuilder ()
 Check all methods of SALOMEDS_StudyBuilder Use code of SALOMEDS_StudyBuilder.cxx.
void testStudyManager ()
 Check all methods of SALOMEDS_StudyManager Use code of SALOMEDS_StudyManager.cxx.
void testUseCase ()

Protected Attributes

SALOMEDS::StudyManager_var _sm
CORBA::ORB_var _orb

Private Member Functions

 CPPUNIT_TEST_SUITE (SALOMEDSTest)
 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 ()

Detailed Description

Definition at line 31 of file SALOMEDSTest.hxx.


Member Function Documentation

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

Reimplemented in SALOMEDSTest_Embedded.

void SALOMEDSTest::setUp ( ) [virtual]

Set up the environment.

Reimplemented in SALOMEDSTest_Embedded.

Definition at line 52 of file SALOMEDSTest.cxx.

{  
  int argc = 1;
  char* argv[] = {(char*)""};

  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
  _orb = init(argc , argv ) ;
  SALOME_NamingService NS(_orb);
  CORBA::Object_var obj = NS.Resolve( "/myStudyManager" );
  _sm = SALOMEDS::StudyManager::_narrow( obj );

  CPPUNIT_ASSERT( !CORBA::is_nil(_sm) ); 
}
void SALOMEDSTest::tearDown ( ) [virtual]
  • delete trace classes

Definition at line 73 of file SALOMEDSTest.cxx.

{
  _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
  std::vector<std::string> v = sm->GetOpenStudies();
  for(int i = 0; i<v.size(); i++) {
    _PTR(Study) study = sm->GetStudyByName(v[i]);
    if(study)
      sm->Close(study);
  }
}

Check all methods of SALOMEDS_AttributeComment Use code of SALOMEDS_AttributeComment.cxx.

Definition at line 28 of file SALOMEDSTest_AttributeComment.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributeDrawable Use code of SALOMEDS_AttributeDrawable.cxx.

Definition at line 28 of file SALOMEDSTest_AttributeDrawable.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeExpandable Use code of SALOMEDS_AttributeExpandable.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeExpandable.cxx.

{
  //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(false);

  CPPUNIT_ASSERT(!_attr->IsExpandable());

  _attr->SetExpandable(true);

  CPPUNIT_ASSERT(_attr->IsExpandable());

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeExternalFileDef Use code of SALOMEDS_AttributeExternalFileDef.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeExternalFileDef.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributeFileType Use code of SALOMEDS_AttributeFileType.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeFileType.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributeFlags Use code of SALOMEDS_AttributeFlags.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeFlags.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeGraphic Use code of SALOMEDS_AttributeGraphic.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeGraphic.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeInteger Use code of SALOMEDS_AttributeInteger.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeInteger.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeIOR Use code of SALOMEDS_AttributeIOR.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeIOR.cxx.

{
  //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
  std::string value = _attr->Value();

  CPPUNIT_ASSERT(value.empty());

  std::string ior = _orb->object_to_string(_sm);

  //Check method SetValue
  _attr->SetValue(ior);

  CPPUNIT_ASSERT(ior == _attr->Value());

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeLocalID Use code of SALOMEDS_AttributeLocalID.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeLocalID.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeName Use code of SALOMEDS_AttributeName.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeName.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributeOpened Use code of SALOMEDS_AttributeOpened.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeOpened.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeParameter Use code of SALOMEDS_AttributeParameter.cxx.

Definition at line 35 of file SALOMEDSTest_AttributeParameter.cxx.

{
  //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"));

  std::vector<int> intArray;
  intArray.push_back(0);
  intArray.push_back(1);

  //Check method SetIntArray and GetIntArray
  _attr->SetIntArray("IntArray", intArray);
  CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY));
  CPPUNIT_ASSERT(_attr->GetIntArray("IntArray")[0] == 0);
  CPPUNIT_ASSERT(_attr->GetIntArray("IntArray")[1] == 1); 

  std::vector<double> realArray;
  realArray.push_back(0.0);
  realArray.push_back(1.1);
  
  //Check method SetRealArray and GetRealArray
  _attr->SetRealArray("RealArray", realArray);
  CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY));
  CPPUNIT_ASSERT(_attr->GetRealArray("RealArray")[0] == 0.0);
  CPPUNIT_ASSERT(_attr->GetRealArray("RealArray")[1] == 1.1); 

  std::vector<std::string> strArray;
  strArray.push_back("hello");
  strArray.push_back("world");
  
  //Check method SetStrArray and GetStrArray
  _attr->SetStrArray("StrArray", strArray);
  CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY));
  CPPUNIT_ASSERT(_attr->GetStrArray("StrArray")[0] == "hello");
  CPPUNIT_ASSERT(_attr->GetStrArray("StrArray")[1] == "world"); 

  /*
  string saved = _attr->Save();
  _attr->Load(saved);

  CPPUNIT_ASSERT(_attr->IsSet("IntValue", PT_INTEGER) && _attr->GetInt("IntValue") == 1);
  CPPUNIT_ASSERT(_attr->IsSet("RealValue", PT_REAL) && _attr->GetReal("IntValue") == 1.2);
  CPPUNIT_ASSERT(_attr->IsSet("StringValue", PT_STRING) && _attr->GetString("StringValue") == "hello");
  CPPUNIT_ASSERT(_attr->IsSet("BoolValue", PT_BOOLEAN) && _attr->GetBool("BoolValue") == 0);
  CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY) && _attr->GetIntArray("IntArray")[0] == 0);
  CPPUNIT_ASSERT(_attr->IsSet("IntArray", PT_INTARRAY) && _attr->GetIntArray("IntArray")[1] == 1);
  CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY) && _attr->GetRealArray("RealArray")[0] == 0.0);
  CPPUNIT_ASSERT(_attr->IsSet("RealArray", PT_REALARRAY) && _attr->GetRealArray("RealArray")[1] == 1.1);
  CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY) && _attr->GetStrArray("StrArray")[0] == "hello");
  CPPUNIT_ASSERT(_attr->IsSet("StrArray", PT_STRARRAY) && _attr->GetStrArray("StrArray")[1] == "world");
  */

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributePersistentRef Use code of SALOMEDS_AttributePersistentRef.cxx.

Definition at line 27 of file SALOMEDSTest_AttributePersistentRef.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributePixMap Use code of SALOMEDS_AttributePixMap.cxx.

Definition at line 27 of file SALOMEDSTest_AttributePixMap.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributePythonObject Use code of SALOMEDS_AttributePythonObject.cxx.

Definition at line 27 of file SALOMEDSTest_AttributePythonObject.cxx.

{
  //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()); 

  std::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);
}

Check all methods of SALOMEDS_AttributeReal Use code of SALOMEDS_AttributeReal.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeReal.cxx.

{
  //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);
}

Check all methods of SALOMEDS_AttributeSelectable Use code of SALOMEDS_AttributeSelectable.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeSelectable.cxx.

{
  //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(false);

  CPPUNIT_ASSERT(!_attr->IsSelectable());

  _attr->SetSelectable(true);

  CPPUNIT_ASSERT(_attr->IsSelectable());

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeSequenceOfInteger Use code of SALOMEDS_AttributeSequenceOfInteger.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeSequenceOfInteger.cxx.

{
  //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
  std::vector<int> v = _attr->CorbaSequence();
  CPPUNIT_ASSERT(v.size() == 3);


  for(int i = 0; i<v.size(); i++) 
    CPPUNIT_ASSERT((i+1) == v[i]);

  v.push_back(5);

  //Check method Assign
  _attr->Assign(v);

  CPPUNIT_ASSERT(_attr->Length() == 4);

  CPPUNIT_ASSERT(_attr->Value(4) == 5);

  //Check processing of invalid indicies
  bool isRaised = false;
  try {
    _attr->Value(-1);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);
  isRaised = false;
  try {
    _attr->ChangeValue(12, 1);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);
  isRaised = false;
  try {
    _attr->Remove(10);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeSequenceOfReal Use code of SALOMEDS_AttributeSequenceOfReal.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeSequenceOfReal.cxx.

{
  //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
  std::vector<double> v = _attr->CorbaSequence();
  CPPUNIT_ASSERT(v.size() == 3);

  v.push_back(5.5);

  _attr->Assign(v);

  CPPUNIT_ASSERT(_attr->Length() == 4);

  CPPUNIT_ASSERT(_attr->Value(4) == 5.5);

  //Check processing of invalid indicies
  bool isRaised = false;
  try {
    _attr->Value(-1);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);
  isRaised = false;
  try {
    _attr->ChangeValue(12, 1);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);
  isRaised = false;
  try {
    _attr->Remove(10);
  }
  catch(...) {
    isRaised = true;
  }
  CPPUNIT_ASSERT(isRaised);

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeStudyProperties Use code of SALOMEDS_AttributeStudyProperties.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeStudyProperties.cxx.

{
  //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
  std::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
  std::vector<std::string> vs;
  std::vector<int> vi[5];
  _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
  CPPUNIT_ASSERT(vs[0] == "srn2" && vi[0][0] == 6 && vi[1][0] == 7 && vi[2][0] == 8 && vi[3][0] == 9 && vi[4][0] == 10);

  vs.clear();
  for(int i=0; i<5; i++) vi[i].clear();

  _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
  CPPUNIT_ASSERT(vs[0] == "srn" && vi[0][0] == 1 && vi[1][0] == 2 && vi[2][0] == 3 && vi[3][0] == 4 && vi[4][0] == 5);

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeTableOfInteger Use code of SALOMEDS_AttributeTableOfInteger.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTableOfInteger.cxx.

{
  //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
  std::vector<int> rs = _attr->GetRowSetIndices(1);

  CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);

  _attr->PutValue(32, 2,2);
  CPPUNIT_ASSERT(_attr->HasValue(2, 2));

  std::vector<std::string> rowTitles;
  rowTitles.push_back("title1");
  rowTitles.push_back("title2");

  //Check method SetRowTitles
  _attr->SetRowTitles(rowTitles);
  
  //Check method SetRowTitle
  _attr->SetRowTitle(1, "new_title");

  //Check method GetRowTitles
  std::vector<std::string> rt = _attr->GetRowTitles();

  CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");

  std::vector<std::string> colTitles;
  colTitles.push_back("title1");
  colTitles.push_back("title2");

  //Check method SetColumnTitles
  _attr->SetColumnTitles(colTitles);
 
  //Check method SetColumnTitle
  _attr->SetColumnTitle(1, "new_title");

  //Check method GetColumnTitles
  std::vector<std::string> ct = _attr->GetColumnTitles();

  CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");

  std::vector<std::string> rowUnits;
  rowUnits.push_back("unit1");
  rowUnits.push_back("unit2");

  //Check method SetRowUnits
  _attr->SetRowUnits(rowUnits);

  //Check method SetRowUnit
  _attr->SetRowUnit(1, "new_unit");

  //Check method GetRowUnits
  std::vector<std::string> ru = _attr->GetRowUnits();

  CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");

  //Check method GetNbColumns
  CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);

  //Check method AddRow
  std::vector<int> data;
  data.push_back(11);
  data.push_back(22);

  _attr->AddRow(data);

  CPPUNIT_ASSERT(_attr->GetNbRows() == 3);

  //Check method GetRow
  std::vector<int> data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 11 && data2[1] == 22);

  //Check method SetRow
  data[0] = 33;
  _attr->SetRow(3, data);

  data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 33 && data2[1] == 22);

   //Check method AddColumn
  data[0] = -11;
  data[1] = -22;
  data.push_back(-33);

  _attr->AddColumn(data);


  CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);

  //Check method GetColumn
  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == -11 && data2[1] == -22 && data2[2] == -33);

  //Check method SetColumn
  data[0] = 11;
  _attr->SetColumn(3, data);

  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == 11 && data2[1] == -22 && data2[2] == -33);

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeTableOfReal Use code of SALOMEDS_AttributeTableOfReal.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTableOfReal.cxx.

{
  //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
  std::vector<int> rs = _attr->GetRowSetIndices(1);

  CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);

  _attr->PutValue(32.32, 2,2);
  CPPUNIT_ASSERT(_attr->HasValue(2, 2));

  std::vector<std::string> rowTitles;
  rowTitles.push_back("title1");
  rowTitles.push_back("title2");

  //Check method SetRowTitles
  _attr->SetRowTitles(rowTitles);

  //Check method SetRowTitle
  _attr->SetRowTitle(1, "new_title");

  //Check method GetRowTitles
  std::vector<std::string> rt = _attr->GetRowTitles();

  CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");

  std::vector<std::string> colTitles;
  colTitles.push_back("title1");
  colTitles.push_back("title2");

  //Check method SetColumnTitles
  _attr->SetColumnTitles(colTitles);

  //Check method SetColumnTitle
  _attr->SetColumnTitle(1, "new_title");

  //Check method GetColumnTitles
  std::vector<std::string> ct = _attr->GetColumnTitles();

  CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");

  std::vector<std::string> rowUnits;
  rowUnits.push_back("unit1");
  rowUnits.push_back("unit2");

  //Check method SetRowUnits
  _attr->SetRowUnits(rowUnits);

  //Check method SetRowUnit
  _attr->SetRowUnit(1, "new_unit");

  //Check method GetRowUnits
  std::vector<std::string> ru = _attr->GetRowUnits();

  CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");

  //Check method GetNbColumns
  CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);

  //Check method AddRow
  std::vector<double> data;
  data.push_back(11.11);
  data.push_back(22.22);

  _attr->AddRow(data);

  CPPUNIT_ASSERT(_attr->GetNbRows() == 3);

  //Check method GetRow
  std::vector<double> data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 11.11 && data2[1] == 22.22);

  //Check method SetRow
  data[0] = 33.33;
  _attr->SetRow(3, data);

  data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == 33.33 && data2[1] == 22.22);

   //Check method AddColumn
  data[0] = -11.11;
  data[1] = -22.22;
  data.push_back(-33.33);

  _attr->AddColumn(data);

  CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);

  //Check method GetColumn
  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == -11.11 && data2[1] == -22.22 && data2[2] == -33.33);

  //Check method SetColumn
  data[0] = 11.11;
  _attr->SetColumn(3, data);

  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == 11.11 && data2[1] == -22.22 && data2[2] == -33.33);

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeTableOfString Use code of SALOMEDS_AttributeTableOfString.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTableOfString.cxx.

{
  //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
  std::vector<int> rs = _attr->GetRowSetIndices(1);

  CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);

  _attr->PutValue("32", 2,2);
  CPPUNIT_ASSERT(_attr->HasValue(2, 2));

  std::vector<std::string> rowTitles;
  rowTitles.push_back("title1");
  rowTitles.push_back("title2");

  //Check method SetRowTitles
  _attr->SetRowTitles(rowTitles);

  //Check method SetRowTitle
  _attr->SetRowTitle(1, "new_title");

  //Check method GetRowTitles
  std::vector<std::string> rt = _attr->GetRowTitles();

  CPPUNIT_ASSERT(rt.size() == 2 && rt[0] == "new_title" && rt[1] == "title2");


  std::vector<std::string> colTitles;
  colTitles.push_back("title1");
  colTitles.push_back("title2");

  //Check method SetColumnTitles
  _attr->SetColumnTitles(colTitles);

  //Check method SetColumnTitle
  _attr->SetColumnTitle(1, "new_title");

  //Check method GetColumnTitles
  std::vector<std::string> ct = _attr->GetColumnTitles();

  CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");

  std::vector<std::string> rowUnits;
  rowUnits.push_back("unit1");
  rowUnits.push_back("unit2");

  //Check method SetRowUnits
  _attr->SetRowUnits(rowUnits);

  //Check method SetRowUnit
  _attr->SetRowUnit(1, "new_unit");

  //Check method GetRowUnits
  std::vector<std::string> ru = _attr->GetRowUnits();

  CPPUNIT_ASSERT(ru.size() == 2 && ru[0] == "new_unit" && ru[1] == "unit2");

  //Check method GetNbColumns
  CPPUNIT_ASSERT(_attr->GetNbColumns() == 2);

  //Check method AddRow
  std::vector<std::string> data;
  data.push_back("11");
  data.push_back("22");

  _attr->AddRow(data);

  CPPUNIT_ASSERT(_attr->GetNbRows() == 3);

  //Check method GetRow
  std::vector<std::string> data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == "11" && data2[1] == "22");

  //Check method SetRow
  data[0] = "33";
  _attr->SetRow(3, data);

  data2 = _attr->GetRow(3);

  CPPUNIT_ASSERT(data2.size() == 2 && data2[0] == "33" && data2[1] == "22");

   //Check method AddColumn
  data[0] = "-11";
  data[1] = "-22";
  data.push_back("-33");

  _attr->AddColumn(data);

  CPPUNIT_ASSERT(_attr->GetNbColumns() == 3);

  //Check method GetColumn
  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == "-11" && data2[1] == "-22" && data2[2] == "-33");

  //Check method SetColumn
  data[0] = "11";
  _attr->SetColumn(3, data);

  data2 = _attr->GetColumn(3);

  CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == "11" && data2[1] == "-22" && data2[2] == "-33");

  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeTarget Use code of SALOMEDS_AttributeTarget.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTarget.cxx.

{
  //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
  std::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);
}

Check all methods of SALOMEDS_AttributeTextColor Use code of SALOMEDS_AttributeTextColor.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTextColor.cxx.

{
  //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);  
}

Check all methods of SALOMEDS_AttributeTextHighlightColor Use code of SALOMEDS_AttributeTextHighlightColor.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeTextHighlightColor.cxx.

{
  //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);
}

Definition at line 28 of file SALOMEDSTest_AttributeTreeNode.cxx.

{
  //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);

  std::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() == 1 && _attr1->Depth() == 2);

  //Check method IsRoot
  CPPUNIT_ASSERT(_attr->IsRoot());

  //Check method IsFather
  CPPUNIT_ASSERT(_attr->IsFather(_attr1));

  //Check method IsDescendant
  CPPUNIT_ASSERT(_attr2->IsDescendant(_attr));

  //Check method GetFirst
  CPPUNIT_ASSERT(_attr->GetFirst()->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
  std::cout << std::endl << "THE TEST IS NOT COMPLETE !!!" << std::endl;
#endif


  //Try to create the attribute with given TreeID
  std::string value = "0e1c36e6-1111-4d90-ab3b-18a14310e648";
  _PTR(AttributeTreeNode) _attr_guid = studyBuilder->FindOrCreateAttribute(so, "AttributeTreeNodeGUID"+value);
  CPPUNIT_ASSERT(_attr_guid && _attr_guid->GetTreeID() == value);
  
  sm->Close(study);
}

Check all methods of SALOMEDS_AttributeUserID Use code of SALOMEDS_AttributeUserID.cxx.

Definition at line 27 of file SALOMEDSTest_AttributeUserID.cxx.

{
  //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);

  std::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);
  
  sm->Close(study);
}

Check all methods of SALOMEDS_ChildIterator Use code of SALOMEDS_ChildIterator.cxx.

Definition at line 27 of file SALOMEDSTest_ChildIterator.cxx.

{
  //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);
}

Check all methods of SALOMEDS_SComponent Use code of SALOMEDS_SComponent.cxx.

Definition at line 27 of file SALOMEDSTest_SComponent.cxx.

{
  //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

  std::string ior = _orb->object_to_string(_sm);

  _attr->SetValue(ior);
  std::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);
}

Check all methods of SALOMEDS_SComponentIterator Use code of SALOMEDS_SComponentIterator.cxx.

Definition at line 27 of file SALOMEDSTest_SComponentIterator.cxx.

{
  //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");

  std::vector<std::string> v;
  v.push_back("Test1");
  v.push_back("Test2");

  _PTR(SComponentIterator) ci = study->NewComponentIterator();

  //Check the creation of the SComponentIterator
  CPPUNIT_ASSERT(ci);

  for(int i = 0; ci->More(); ci->Next(), i++) {
    //Check method Value
    CPPUNIT_ASSERT(i<2);
    CPPUNIT_ASSERT(ci->Value()->ComponentDataType() == v[i]);
  }

  sm->Close(study);
}

Check all methods of SALOMEDS_SObject Use code of SALOMEDS_SObject.cxx.

Definition at line 28 of file SALOMEDSTest_SObject.cxx.

{
  //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"); 

   std::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
  std::vector< _PTR(GenericAttribute) > v = so->GetAllAttributes();
   
  CPPUNIT_ASSERT(v.size() == 5); //+AttributeTarget +AttributeTreeNode

  //Check method GetName
  CPPUNIT_ASSERT(so->GetName() == "SO name");

  //Check method GetComment
  CPPUNIT_ASSERT(so->GetComment() == "SO comment");

  //Check method GetIOR
  CPPUNIT_ASSERT(so->GetIOR() == ior);

  //Check method Depth
  CPPUNIT_ASSERT(so->Depth() == 3);

  //Check method GetObject
  CORBA::Object_var obj = dynamic_cast<SALOMEDS_SObject*>(so.get())->GetObject();
  CPPUNIT_ASSERT(!CORBA::is_nil(obj));

  sm->Close(study);
}

Check all methods of SALOMEDS_Study Use code of SALOMEDS_Study.cxx.

Definition at line 28 of file SALOMEDSTest_Study.cxx.

{
  //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
  std::vector<std::string> components = study->GetComponentNames(""); //The context doesn't matter
  CPPUNIT_ASSERT(components.size() == 1 && components[0] == "sco1");

  //Check method FindComponentID
  _PTR(SComponent) sco3 = study->FindComponentID(sco1->GetID());
  CPPUNIT_ASSERT(sco3 && sco3->GetID() == sco1->GetID());

  //Try to find component with empty id
  CPPUNIT_ASSERT(!study->FindComponentID(""));

  _PTR(SObject) so1 = studyBuilder->NewObject(sco1);
  CPPUNIT_ASSERT(so1);
  _PTR(AttributeName) name_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
  CPPUNIT_ASSERT(name_attr_so1);
  name_attr_so1->SetValue("so1");
  
   //Create an attribute AttributeIOR
  _PTR(AttributeIOR) ior_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeIOR");
  CPPUNIT_ASSERT(ior_attr_so1);

  std::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
  std::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
  std::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
  std::vector<std::string> vs = study->GetObjectNames("/sco1");  
  CPPUNIT_ASSERT(vs.size() == 2);
    
  //Check method GetDirectoryNames
  _PTR(AttributeLocalID) locid_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributeLocalID");
  CPPUNIT_ASSERT(locid_attr_sco1);
  locid_attr_sco1->SetValue(16661); //DIRECTORYID
  _PTR(AttributeLocalID) locid_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeLocalID");
  CPPUNIT_ASSERT(locid_attr_so1);
  locid_attr_so1->SetValue(16661); //DIRECTORYID
  vs = study->GetDirectoryNames(""); //Empty context (the current is taken)
  CPPUNIT_ASSERT(vs.size() == 2);

  //Check method GetFileNames
  locid_attr_sco1->SetValue(26662); //FILELOCALID
  _PTR(AttributePersistentRef) persref_attr_sco1 = studyBuilder->FindOrCreateAttribute(sco1, "AttributePersistentRef");
  CPPUNIT_ASSERT(persref_attr_sco1);
  persref_attr_sco1->SetValue("FILE: filename1");
  locid_attr_so1->SetValue(26662); //FILELOCALID
  _PTR(AttributePersistentRef) persref_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributePersistentRef");
  CPPUNIT_ASSERT(persref_attr_so1);
  persref_attr_so1->SetValue("FILE: filename2");
  vs = study->GetFileNames("");
  CPPUNIT_ASSERT(vs.size() == 2 && vs[0] == "filename1" && vs[1] == "filename2");

  //Check method StudyId (get/set)
  int id = study->StudyId();
  study->StudyId(-1);
  CPPUNIT_ASSERT(study->StudyId() == -1);
  study->StudyId(id);

  //Check method FindDependances
  studyBuilder->Addreference(so2, so1);
  studyBuilder->Addreference(sco1, so1);
  std::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);
  std::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);
  std::vector< _PTR(GenericAttribute) > va1 = uso1->GetAllAttributes();
  CPPUNIT_ASSERT(va1.size() == 0); 

  study->EnableUseCaseAutoFilling(true);
  _PTR(SObject) uso2 = study->NewBuilder()->NewObject(sco1);
  std::vector< _PTR(GenericAttribute) > va2 = uso2->GetAllAttributes();
  CPPUNIT_ASSERT(va2.size() == 1); // +AttributeTreeNode

  //Check method DumpStudy
  study->DumpStudy(".", "SRN", false, false);

  std::fstream f("SRN.py");
  char buffer[128];
  buffer[81] = (char)0;
  f.getline(buffer, 80);
  std::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);
}

Check all methods of SALOMEDS_StudyBuilder Use code of SALOMEDS_StudyBuilder.cxx.

Definition at line 28 of file SALOMEDSTest_StudyBuilder.cxx.

{
  //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
  std::string ior = _orb->object_to_string(_sm);
  studyBuilder->DefineComponentInstance(sco1, ior);
  std::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);
  std::string id1 = so1->GetID();

  //Check method NewObjectToTag
  _PTR(SObject) so2 = studyBuilder->NewObjectToTag(so1, 2);
  CPPUNIT_ASSERT(so2 && so2->Tag() == 2);
  std::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);

  //Try to create attribute with invalid type
  CPPUNIT_ASSERT(!studyBuilder->FindOrCreateAttribute(so3, "invalid type"));

  //Check method FindAttribute
  _PTR(GenericAttribute) ga;
  CPPUNIT_ASSERT(studyBuilder->FindAttribute(so3, ga, "AttributeName"));

  //Try to find attribute with invalid type
  CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so3, ga, "invalid type"));

  //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
  std::string value = "0e1c36e6-379b-4d90-ab3b-17a14310e648";
  studyBuilder->SetGUID(so1, value);

  CPPUNIT_ASSERT(studyBuilder->IsGUID(so1, value));

/* Not implemented
  //Check method UndoLimit (set/get)
  studyBuilder->UndoLimit(10);
  CPPUNIT_ASSERT(studyBuilder->UndoLimit() == 10);
*/

  //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("FactoryServer", "SMESH");
  CPPUNIT_ASSERT(!CORBA::is_nil(obj));

  MESSAGE("Created a new SMESH 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("SMESH");
  
  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("SMESH");
  CPPUNIT_ASSERT(aComp);

  CORBA::Object_var obj2 = SALOME_LifeCycleCORBA(&NS).FindOrLoad_Component("FactoryServer", "SMESH");
  CPPUNIT_ASSERT(!CORBA::is_nil(obj2));
  SALOMEDS::Driver_var drv2 = SALOMEDS::Driver::_narrow(obj2);
  ior = _orb->object_to_string(drv2);

  isRaised = false;
  try {
    //getchar();
    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);  
}

Check all methods of SALOMEDS_StudyManager Use code of SALOMEDS_StudyManager.cxx.

Definition at line 27 of file SALOMEDSTest_StudyManager.cxx.

{
  //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
  std::vector<std::string> v = sm->GetOpenStudies();
  CPPUNIT_ASSERT(v.size() == 2);

  //Check method Close
  int id = study2->StudyId();
  sm->Close(study2);
  CPPUNIT_ASSERT(!sm->GetStudyByID(id));

  //Check method GetStudyByID for invalid ID
  CPPUNIT_ASSERT(!sm->GetStudyByID(-1));

  //Check methods CanPaste, CanCopy, Copy, Paste
  _PTR(StudyBuilder) sb1 = study1->NewBuilder();
  _PTR(SComponent) sco1 = sb1->NewComponent("Test");
  _PTR(SObject) so1 = sb1->NewObject(sco1);
  _PTR(AttributeName) na1 = sb1->FindOrCreateAttribute(so1, "AttributeName");
  CPPUNIT_ASSERT(na1);
  na1->SetValue("Some name");

  CPPUNIT_ASSERT(!sm->CanCopy(so1)); //The father component has no IOR
  
  CPPUNIT_ASSERT(sm->Copy(so1));

  CPPUNIT_ASSERT(!sm->CanPaste(so1)); //The father component has no IOR

  _PTR(SObject) so1_2 = sb1->NewObject(sco1);
  _PTR(SObject) pasted_so = sm->Paste(so1_2);
  CPPUNIT_ASSERT(pasted_so);

  _PTR(AttributeName) na2 = sb1->FindOrCreateAttribute(pasted_so, "AttributeName");
  CPPUNIT_ASSERT(na2 && na2->Value() == "Some name");


  //Check method SaveAs
  sm->SaveAs("srn_UnitTest_Save.hdf", study1, false);
  std::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);
  std::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.
}

Definition at line 30 of file SALOMEDSTest_UseCase.cxx.

{
  //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);
}

Member Data Documentation

CORBA::ORB_var SALOMEDSTest::_orb [protected]

Definition at line 127 of file SALOMEDSTest.hxx.

SALOMEDS::StudyManager_var SALOMEDSTest::_sm [protected]

Definition at line 126 of file SALOMEDSTest.hxx.


The documentation for this class was generated from the following files: