Salome HOME
Merge branch 'BR_MULTI_BATHS' into HEAD
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_Entity.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <test_HYDROData_Entity.h>
20
21 #include <HYDROData_Document.h>
22 #include <HYDROData_Entity.h>
23
24 #include <QString>
25
26 void test_HYDROData_Entity::testName()
27 {
28   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
29
30   Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
31   static const QString aName("test_name");
32   anObj->SetName(aName);
33   CPPUNIT_ASSERT_EQUAL(aName.toStdString(), anObj->GetName().toStdString());
34   
35   aDoc->Close();
36 }
37
38 void test_HYDROData_Entity::testRemove()
39 {
40   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
41   
42   Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
43   CPPUNIT_ASSERT(!anObj->IsRemoved());
44   anObj->Remove();
45   CPPUNIT_ASSERT(anObj->IsRemoved());
46
47   aDoc->Close();
48 }
49
50 void test_HYDROData_Entity::testCopy()
51 {
52   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
53
54   Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
55   static const QString aName("test_name");
56   anObj->SetName(aName);
57
58   Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
59   CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
60   anObj->CopyTo(aCopy, false);
61
62   // check the copied object has same name as original
63   CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
64
65   aDoc->Close();
66 }