CPPUNIT_ASSERT(value == _attr->Value());
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_attr->Value() == "");
+
+
sm->Close(study);
}
CPPUNIT_ASSERT(value == _attr->Value());
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_attr->Value() == "");
+
+
sm->Close(study);
}
CPPUNIT_ASSERT(value == _attr->Value());
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_attr->Value() == "");
+
+
sm->Close(study);
}
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);
}
CPPUNIT_ASSERT(value == _attr->Value());
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_attr->Value() == "");
+
sm->Close(study);
}
//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(value == _attr->Value());
+ //Try to set empty string
+ _attr->SetValue("");
+ CPPUNIT_ASSERT(_attr->Value() == "");
+
sm->Close(study);
}
//Check method GetPixMap
CPPUNIT_ASSERT(_attr->GetPixMap() == pixmap);
+ //Check empty PixMap assigning and retreival
+ _attr->SetPixMap("");
+ CPPUNIT_ASSERT(_attr->GetPixMap() == "");
+
+
sm->Close(study);
}
//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);
}
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);
}
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 the attribute creation
CPPUNIT_ASSERT(_attr);
-
+/*
//Check method SetTitle
_attr->SetTitle("Table_1");
vector<int> rs = _attr->GetRowSetIndices(1);
CPPUNIT_ASSERT(rs.size() == 1 && rs[0] == 1);
-
+*/
_attr->PutValue(32, 2,2);
CPPUNIT_ASSERT(_attr->HasValue(2, 2));
-
+/*
vector<string> rowTitles;
rowTitles.push_back("title1");
rowTitles.push_back("title2");
//Check method SetColumnTitles
_attr->SetColumnTitles(colTitles);
-
+
//Check method SetColumnTitle
_attr->SetColumnTitle(1, "new_title");
//Check method GetColumnTitles
vector<string> ct = _attr->GetColumnTitles();
+
CPPUNIT_ASSERT(ct.size() == 2 && ct[0] == "new_title" && ct[1] == "title2");
+*/
vector<string> rowUnits;
rowUnits.push_back("unit1");
//Check method SetRowUnits
_attr->SetRowUnits(rowUnits);
+/*
+
//Check method SetRowUnit
_attr->SetRowUnit(1, "new_unit");
data2 = _attr->GetColumn(3);
CPPUNIT_ASSERT(data2.size() == 3 && data2[0] == 11 && data2[1] == -22 && data2[2] == -33);
-
+*/
sm->Close(study);
}
//Check method Get
vector< _PTR(SObject) > v = _attr->Get();
-
-
CPPUNIT_ASSERT(v.size() == 2);
CPPUNIT_ASSERT(v[0]->GetID() == "0:1:2");
* Check all methods of SALOMEDS_AttributeTreeNode
* Use code of SALOMEDS_AttributeTreeNode.cxx
*/
+#define SALOMEDS_ALL_TESTS
void SALOMEDSTest::testAttributeTreeNode()
{
//Create or find the Study manager
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
//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
//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
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
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();
cout << endl << "THE TEST IS NOT COMPLETE !!!" << endl;
#endif
+
+ //Try to create the attribute with given TreeID
+ string value = "0e1c36e6-1111-4d90-ab3b-18a14310e648";
+ _PTR(AttributeTreeNode) _attr_guid = studyBuilder->FindOrCreateAttribute(so, "AttributeTreeNode"+value);
+ CPPUNIT_ASSERT(_attr_guid && _attr_guid->GetTreeID() == value);
+
+ //Try to set invalid GUID
+ isRaised = false;
+ try {
+ _attr->SetTreeID("invalid guid");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
sm->Close(study);
}
-
+#undef SALOMEDS_ALL_TESTS
//Check method Value
CPPUNIT_ASSERT(value == _attr->Value());
+ //Try to create the attribute with given UserID
+ value = "0e1c36e6-379b-4d90-ab3b-18a14310e648";
+ _PTR(AttributeUserID) _attr2 = studyBuilder->FindOrCreateAttribute(so, "AttributeUserID"+value);
+ CPPUNIT_ASSERT(_attr2 && _attr2->Value() == value);
+
+ //Try to set invalid GUID
+ bool isRaised = false;
+ try {
+ _attr->SetValue("invalid guid");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
+
sm->Close(study);
}
* Use code of SALOMEDS_UseCaseBuilder.cxx and SALOMEDS_UseCaseIterator.cxx
*/
+#define SALOMEDS_ALL_TESTS
+
void SALOMEDSTest::testUseCase()
{
//Create or find the Study manager
//Check method InsertBefore
CPPUNIT_ASSERT(builder->InsertBefore(so2, so1));
+
it->Init(false);
CPPUNIT_ASSERT(it->More());
CPPUNIT_ASSERT(it->Value()->GetID() == so2->GetID());
sm->Close(study);
}
-
+#undef SALOMEDS_ALL_TESTS
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
CORBA::ORB_var orb = init(argc , argv ) ;
- sleep(10);
+ sleep(15);
- string host = GetHostname();
+ string host; // = GetHostname();
+ char* wait_Superv = getenv("SALOMEDS_UNITTESTS_WAIT_SUPERVISOR");
+ if(wait_Superv) host = GetHostname();
SALOME_NamingService NS(orb);
if(host.empty())