Back to index

salome-kernel  6.5.0
SALOMEDSTest_AttributeStudyProperties.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00027 void SALOMEDSTest::testAttributeStudyProperties()
00028 {
00029   //Create or find the Study manager
00030   _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
00031 
00032   CPPUNIT_ASSERT(sm);
00033 
00034   //Create a new study
00035   _PTR(Study) study = sm->NewStudy("Test");
00036 
00037   CPPUNIT_ASSERT(study);
00038 
00039   //Create Study Builder
00040   _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
00041 
00042   CPPUNIT_ASSERT(studyBuilder);
00043 
00044   //Create a SObject with entry 0:1:1
00045   _PTR(SObject) so = study->CreateObjectID("0:1:1");
00046 
00047   CPPUNIT_ASSERT(so);
00048 
00049   //Create an attribute AttributeStudyProperties
00050   _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
00051 
00052   //Check the attribute creation
00053   CPPUNIT_ASSERT(_attr);
00054 
00055   //Check method SetCreationDate
00056   _attr->SetCreationDate(1, 2, 3, 4, 5);
00057 
00058   //Check method GetCreationDate
00059   int MN, H, D, MH, Y;
00060   _attr->GetCreationDate(MN, H, D, MH, Y);
00061 
00062   CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
00063 
00064   //Check method SetUserName
00065   _attr->SetUserName("srn");
00066 
00067   //Check method GetUserName
00068   CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
00069 
00070   //Check method SetCreationMode
00071   std::string value = "from scratch";
00072   _attr->SetCreationMode(value);
00073 
00074   //Check method GetCreationMode
00075   CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
00076 
00077   //Check method SetModified
00078   _attr->SetModified(2);
00079 
00080   //Check method IsModified
00081   CPPUNIT_ASSERT(_attr->IsModified());
00082 
00083   //Check method GetModified
00084   CPPUNIT_ASSERT(_attr->GetModified() == 2);
00085 
00086   //Check method SetLocked
00087   _attr->SetLocked(true);
00088 
00089   //Check method IsLocked
00090   CPPUNIT_ASSERT(_attr->IsLocked());
00091 
00092   _attr->SetLocked(false);
00093 
00094   CPPUNIT_ASSERT(!_attr->IsLocked());
00095 
00096   //Check method SetModification
00097   _attr->SetModification("srn2", 6, 7, 8, 9, 10);
00098 
00099   //Check method GetModificationsList
00100   std::vector<std::string> vs;
00101   std::vector<int> vi[5];
00102   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
00103   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);
00104 
00105   vs.clear();
00106   for(int i=0; i<5; i++) vi[i].clear();
00107 
00108   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
00109   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);
00110 
00111   sm->Close(study);
00112 }
00113 
00114 
00115