Salome HOME
Update copyrights 2014.
[modules/kernel.git] / src / SALOMEDS / Test / SALOMEDSTest_AttributeStudyProperties.cxx
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 /*!
24  * Check all methods of SALOMEDS_AttributeStudyProperties
25  * Use code of SALOMEDS_AttributeStudyProperties.cxx
26  */
27 void SALOMEDSTest::testAttributeStudyProperties()
28 {
29   //Create or find the Study manager
30   _PTR(StudyManager) sm ( new SALOMEDS_StudyManager(_sm) );
31
32   CPPUNIT_ASSERT(sm);
33
34   //Create a new study
35   _PTR(Study) study = sm->NewStudy("Test");
36
37   CPPUNIT_ASSERT(study);
38
39   //Create Study Builder
40   _PTR(StudyBuilder) studyBuilder = study->NewBuilder();
41
42   CPPUNIT_ASSERT(studyBuilder);
43
44   //Create a SObject with entry 0:1:1
45   _PTR(SObject) so = study->CreateObjectID("0:1:1");
46
47   CPPUNIT_ASSERT(so);
48
49   //Create an attribute AttributeStudyProperties
50   _PTR(AttributeStudyProperties) _attr = studyBuilder->FindOrCreateAttribute(so, "AttributeStudyProperties");
51
52   //Check the attribute creation
53   CPPUNIT_ASSERT(_attr);
54
55   //Check method SetCreationDate
56   _attr->SetCreationDate(1, 2, 3, 4, 5);
57
58   //Check method GetCreationDate
59   int MN, H, D, MH, Y;
60   _attr->GetCreationDate(MN, H, D, MH, Y);
61
62   CPPUNIT_ASSERT(MN == 1 && H == 2 && D == 3 && MH == 4 && Y == 5);
63
64   //Check method SetUserName
65   _attr->SetUserName("srn");
66
67   //Check method GetUserName
68   CPPUNIT_ASSERT(_attr->GetUserName() == "srn");
69
70   //Check method SetCreationMode
71   std::string value = "from scratch";
72   _attr->SetCreationMode(value);
73
74   //Check method GetCreationMode
75   CPPUNIT_ASSERT(_attr->GetCreationMode() == value);
76
77   //Check method SetModified
78   _attr->SetModified(2);
79
80   //Check method IsModified
81   CPPUNIT_ASSERT(_attr->IsModified());
82
83   //Check method GetModified
84   CPPUNIT_ASSERT(_attr->GetModified() == 2);
85
86   //Check method SetLocked
87   _attr->SetLocked(true);
88
89   //Check method IsLocked
90   CPPUNIT_ASSERT(_attr->IsLocked());
91
92   _attr->SetLocked(false);
93
94   CPPUNIT_ASSERT(!_attr->IsLocked());
95
96   //Check method SetModification
97   _attr->SetModification("srn2", 6, 7, 8, 9, 10);
98
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);
104
105   vs.clear();
106   for(int i=0; i<5; i++) vi[i].clear();
107
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);
110
111   sm->Close(study);
112 }
113
114
115