Salome HOME
merge from branch BR_V5_DEV
[modules/kernel.git] / src / SALOMEDS / Test / SALOMEDSTest_AttributeStudyProperties.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 /*!
23  * Check all methods of SALOMEDS_AttributeStudyProperties
24  * Use code of SALOMEDS_AttributeStudyProperties.cxx
25  */
26 void SALOMEDSTest::testAttributeStudyProperties()
27 {
28   //Create or find the Study manager
29   _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
30
31   CPPUNIT_ASSERT(sm);
32
33   //Create a new study
34   _PTR(Study) study = sm->NewStudy("Test");
35
36   CPPUNIT_ASSERT(study);
37
38   //Create Study Builder
39   _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
40
41   CPPUNIT_ASSERT(studyBuilder);
42
43   //Create a SObject with entry 0:1:1
44   _PTR(SObject) so = study->CreateObjectID("0:1:1");
45
46   CPPUNIT_ASSERT(so);
47
48   //Create an attribute AttributeStudyProperties
49   _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
50
51   //Check the attribute creation
52   CPPUNIT_ASSERT(_attr);
53
54   //Check method SetCreationDate
55   _attr->SetCreationDate(1, 2, 3, 4, 5);
56
57   //Check method GetCreationDate
58   int MN, H, D, MH, Y;
59   _attr->GetCreationDate(MN, H, D, MH, Y);
60
61   CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
62
63   //Check method SetUserName
64   _attr->SetUserName("srn");
65
66   //Check method GetUserName
67   CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
68
69   //Check method SetCreationMode
70   string value = "from scratch";
71   _attr->SetCreationMode(value);
72
73   //Check method GetCreationMode
74   CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
75
76   //Check method SetModified
77   _attr->SetModified(2);
78
79   //Check method IsModified
80   CPPUNIT_ASSERT(_attr->IsModified());
81
82   //Check method GetModified
83   CPPUNIT_ASSERT(_attr->GetModified() == 2);
84
85   //Check method SetLocked
86   _attr->SetLocked(true);
87
88   //Check method IsLocked
89   CPPUNIT_ASSERT(_attr->IsLocked());
90
91   _attr->SetLocked(false);
92
93   CPPUNIT_ASSERT(!_attr->IsLocked());
94
95   //Check method SetModification
96   _attr->SetModification("srn2", 6, 7, 8, 9, 10);
97
98   //Check method GetModificationsList
99   vector<string> vs;
100   vector<int> vi[5];
101   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], false);
102   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);
103
104   vs.clear();
105   for(int i=0; i<5; i++) vi[i].clear();
106
107   _attr->GetModificationsList(vs, vi[0], vi[1], vi[2], vi[3], vi[4], true);
108   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);
109
110   sm->Close(study);
111 }
112
113
114