1 #include<test_HYDROData_Document.h>
3 #include <HYDROData_Document.h>
6 void test_HYDROData_Document::testSaveOpen()
8 // temporarly created file name (in the current directory)
9 const char* aTestFile = "TestDoc.cbf";
11 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
12 CPPUNIT_ASSERT(!aDoc.IsNull());
13 // keep some saved information to check after retreive
15 int anID = aDoc->NewID();
16 Data_DocError aStatus = aDoc->Save(aTestFile);
17 CPPUNIT_ASSERT(aStatus == DocError_OK);
19 CPPUNIT_ASSERT(!HYDROData_Document::HasDocument(1));
22 aStatus = HYDROData_Document::Load(aTestFile, 2);
23 CPPUNIT_ASSERT(aStatus == DocError_OK);
24 CPPUNIT_ASSERT(HYDROData_Document::HasDocument(2));
25 aDoc = HYDROData_Document::Document(2);
26 CPPUNIT_ASSERT(!aDoc.IsNull());
27 // check that retreived correctly
28 CPPUNIT_ASSERT(aDoc->NewID() == anID + 1);
30 // remove the created file using Qt functionality
31 QFile aFile(aTestFile);
37 void test_HYDROData_Document::testOperations()
39 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
40 CPPUNIT_ASSERT(!aDoc.IsNull());
41 CPPUNIT_ASSERT(!aDoc->IsOperation());
42 CPPUNIT_ASSERT(!aDoc->IsModified());
44 aDoc->StartOperation();
45 CPPUNIT_ASSERT(aDoc->IsOperation());
46 int anID = aDoc->NewID();
47 aDoc->CommitOperation();
48 CPPUNIT_ASSERT(!aDoc->IsOperation());
49 CPPUNIT_ASSERT(aDoc->IsModified());
51 aDoc->StartOperation();
52 CPPUNIT_ASSERT(aDoc->IsOperation());
53 int anIDAborted = aDoc->NewID();
54 aDoc->AbortOperation();
55 CPPUNIT_ASSERT(!aDoc->IsOperation());
56 CPPUNIT_ASSERT(aDoc->IsModified());
58 CPPUNIT_ASSERT(anID + 1 == aDoc->NewID());
63 void test_HYDROData_Document::testUndoRedo()
65 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
66 CPPUNIT_ASSERT(!aDoc.IsNull());
67 CPPUNIT_ASSERT(!aDoc->CanUndo());
68 CPPUNIT_ASSERT(!aDoc->CanRedo());
70 aDoc->StartOperation();
71 CPPUNIT_ASSERT(aDoc->IsOperation());
72 int anID = aDoc->NewID();
73 aDoc->CommitOperation();
74 CPPUNIT_ASSERT(aDoc->CanUndo());
75 CPPUNIT_ASSERT(!aDoc->CanRedo());
76 CPPUNIT_ASSERT(aDoc->IsModified());
79 CPPUNIT_ASSERT(!aDoc->CanUndo());
80 CPPUNIT_ASSERT(aDoc->CanRedo());
81 CPPUNIT_ASSERT(anID == aDoc->NewID());
82 CPPUNIT_ASSERT(!aDoc->IsModified());
85 CPPUNIT_ASSERT(aDoc->CanUndo());
86 CPPUNIT_ASSERT(!aDoc->CanRedo());
87 CPPUNIT_ASSERT(aDoc->IsModified());