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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include<test_HYDROData_Document.h>
21 #include <HYDROData_Document.h>
24 void test_HYDROData_Document::testSaveOpen()
26 // temporarly created file name (in the current directory)
27 const char* aTestFile = "TestDoc.cbf";
29 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
30 CPPUNIT_ASSERT(!aDoc.IsNull());
31 // keep some saved information to check after retreive
33 int anID = aDoc->NewID();
34 Data_DocError aStatus = aDoc->Save(aTestFile);
35 CPPUNIT_ASSERT(aStatus == DocError_OK);
37 CPPUNIT_ASSERT(!HYDROData_Document::HasDocument(1));
40 aStatus = HYDROData_Document::Load(aTestFile, 2);
41 CPPUNIT_ASSERT(aStatus == DocError_OK);
42 CPPUNIT_ASSERT(HYDROData_Document::HasDocument(2));
43 aDoc = HYDROData_Document::Document(2);
44 CPPUNIT_ASSERT(!aDoc.IsNull());
45 // check that retreived correctly
46 CPPUNIT_ASSERT(aDoc->NewID() == anID + 1);
48 // remove the created file using Qt functionality
49 QFile aFile(aTestFile);
55 void test_HYDROData_Document::testOperations()
57 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
58 CPPUNIT_ASSERT(!aDoc.IsNull());
59 CPPUNIT_ASSERT(!aDoc->IsOperation());
60 CPPUNIT_ASSERT(!aDoc->IsModified());
62 aDoc->StartOperation();
63 CPPUNIT_ASSERT(aDoc->IsOperation());
64 int anID = aDoc->NewID();
65 aDoc->CommitOperation();
66 CPPUNIT_ASSERT(!aDoc->IsOperation());
67 CPPUNIT_ASSERT(aDoc->IsModified());
69 aDoc->StartOperation();
70 CPPUNIT_ASSERT(aDoc->IsOperation());
71 int anIDAborted = aDoc->NewID();
72 aDoc->AbortOperation();
73 CPPUNIT_ASSERT(!aDoc->IsOperation());
74 CPPUNIT_ASSERT(aDoc->IsModified());
76 CPPUNIT_ASSERT(anID + 1 == aDoc->NewID());
81 void test_HYDROData_Document::testUndoRedo()
83 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
84 CPPUNIT_ASSERT(!aDoc.IsNull());
85 CPPUNIT_ASSERT(!aDoc->CanUndo());
86 CPPUNIT_ASSERT(!aDoc->CanRedo());
88 aDoc->StartOperation();
89 CPPUNIT_ASSERT(aDoc->IsOperation());
90 int anID = aDoc->NewID();
91 aDoc->CommitOperation();
92 CPPUNIT_ASSERT(aDoc->CanUndo());
93 CPPUNIT_ASSERT(!aDoc->CanRedo());
94 CPPUNIT_ASSERT(aDoc->IsModified());
97 CPPUNIT_ASSERT(!aDoc->CanUndo());
98 CPPUNIT_ASSERT(aDoc->CanRedo());
99 CPPUNIT_ASSERT(anID == aDoc->NewID());
100 CPPUNIT_ASSERT(!aDoc->IsModified());
103 CPPUNIT_ASSERT(aDoc->CanUndo());
104 CPPUNIT_ASSERT(!aDoc->CanRedo());
105 CPPUNIT_ASSERT(aDoc->IsModified());