1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 * Check all methods of SALOMEDS_AttributeStudyProperties
25 * Use code of SALOMEDS_AttributeStudyProperties.cxx
27 void SALOMEDSTest::testAttributeStudyProperties()
29 //Create or find the Study manager
30 _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
35 _PTR(Study) study = sm->NewStudy("Test");
37 CPPUNIT_ASSERT(study);
39 //Create Study Builder
40 _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
42 CPPUNIT_ASSERT(studyBuilder);
44 //Create a SObject with entry 0:1:1
45 _PTR(SObject) so = study->CreateObjectID("0:1:1");
49 //Create an attribute AttributeStudyProperties
50 _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
52 //Check the attribute creation
53 CPPUNIT_ASSERT(_attr);
55 //Check method SetCreationDate
56 _attr->SetCreationDate(1, 2, 3, 4, 5);
58 //Check method GetCreationDate
60 _attr->GetCreationDate(MN, H, D, MH, Y);
62 CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
64 //Check method SetUserName
65 _attr->SetUserName("srn");
67 //Check method GetUserName
68 CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
70 //Check method SetCreationMode
71 std::string value = "from scratch";
72 _attr->SetCreationMode(value);
74 //Check method GetCreationMode
75 CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
77 //Check method SetModified
78 _attr->SetModified(2);
80 //Check method IsModified
81 CPPUNIT_ASSERT(_attr->IsModified());
83 //Check method GetModified
84 CPPUNIT_ASSERT(_attr->GetModified() == 2);
86 //Check method SetLocked
87 _attr->SetLocked(true);
89 //Check method IsLocked
90 CPPUNIT_ASSERT(_attr->IsLocked());
92 _attr->SetLocked(false);
94 CPPUNIT_ASSERT(!_attr->IsLocked());
96 //Check method SetModification
97 _attr->SetModification("srn2", 6, 7, 8, 9, 10);
99 //Check method GetModificationsList
100 std::vector<std::string> vs;
101 std::vector<int> vi[5];
102 _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
103 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);
106 for(int i=0; i<5; i++) vi[i].clear();
108 _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
109 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);