1 // Copyright (C) 2007-2015 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
23 #include<test_HYDROData_Document.h>
25 #include <HYDROData_Document.h>
28 void test_HYDROData_Document::testSaveOpen()
30 // temporarly created file name (in the current directory)
31 const char* aTestFile = "TestDoc.cbf";
33 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
34 CPPUNIT_ASSERT(!aDoc.IsNull());
35 // keep some saved information to check after retreive
37 int anID = aDoc->NewID();
38 Data_DocError aStatus = aDoc->Save(aTestFile);
39 CPPUNIT_ASSERT(aStatus == DocError_OK);
41 CPPUNIT_ASSERT(!HYDROData_Document::HasDocument(1));
44 aStatus = HYDROData_Document::Load(aTestFile, 2);
45 CPPUNIT_ASSERT(aStatus == DocError_OK);
46 CPPUNIT_ASSERT(HYDROData_Document::HasDocument(2));
47 aDoc = HYDROData_Document::Document(2);
48 CPPUNIT_ASSERT(!aDoc.IsNull());
49 // check that retreived correctly
50 CPPUNIT_ASSERT(aDoc->NewID() == anID + 1);
52 // remove the created file using Qt functionality
53 QFile aFile(aTestFile);
59 void test_HYDROData_Document::testOperations()
61 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
62 CPPUNIT_ASSERT(!aDoc.IsNull());
63 CPPUNIT_ASSERT(!aDoc->IsOperation());
64 CPPUNIT_ASSERT(!aDoc->IsModified());
66 aDoc->StartOperation();
67 CPPUNIT_ASSERT(aDoc->IsOperation());
68 int anID = aDoc->NewID();
69 aDoc->CommitOperation();
70 CPPUNIT_ASSERT(!aDoc->IsOperation());
71 CPPUNIT_ASSERT(aDoc->IsModified());
73 aDoc->StartOperation();
74 CPPUNIT_ASSERT(aDoc->IsOperation());
75 int anIDAborted = aDoc->NewID();
76 aDoc->AbortOperation();
77 CPPUNIT_ASSERT(!aDoc->IsOperation());
78 CPPUNIT_ASSERT(aDoc->IsModified());
80 CPPUNIT_ASSERT(anID + 1 == aDoc->NewID());
85 void test_HYDROData_Document::testUndoRedo()
87 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
88 CPPUNIT_ASSERT(!aDoc.IsNull());
89 CPPUNIT_ASSERT(!aDoc->CanUndo());
90 CPPUNIT_ASSERT(!aDoc->CanRedo());
92 aDoc->StartOperation();
93 CPPUNIT_ASSERT(aDoc->IsOperation());
94 int anID = aDoc->NewID();
95 aDoc->CommitOperation();
96 CPPUNIT_ASSERT(aDoc->CanUndo());
97 CPPUNIT_ASSERT(!aDoc->CanRedo());
98 CPPUNIT_ASSERT(aDoc->IsModified());
101 CPPUNIT_ASSERT(!aDoc->CanUndo());
102 CPPUNIT_ASSERT(aDoc->CanRedo());
103 CPPUNIT_ASSERT(anID == aDoc->NewID());
104 CPPUNIT_ASSERT(!aDoc->IsModified());
107 CPPUNIT_ASSERT(aDoc->CanUndo());
108 CPPUNIT_ASSERT(!aDoc->CanRedo());
109 CPPUNIT_ASSERT(aDoc->IsModified());