Changeset 21 for trunk/tests/PDFDocumentTest.cxx
- Timestamp:
- 04/11/06 08:14:31 (3 years ago)
- Files:
-
- 1 moved
-
trunk/tests/PDFDocumentTest.cxx (moved) (moved from trunk/tests/DocumentTest.cxx) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/PDFDocumentTest.cxx
r19 r21 17 17 18 18 #include <epdfview.h> 19 #include " DocumentTest.h"19 #include "PDFDocumentTest.h" 20 20 21 21 using namespace ePDFView; 22 static const double equalDelta= 0.0001;22 static const double DELTA = 0.0001; 23 23 24 24 // Register the test suite into the `registry'. 25 CPPUNIT_TEST_SUITE_REGISTRATION ( DocumentTest);25 CPPUNIT_TEST_SUITE_REGISTRATION (PDFDocumentTest); 26 26 27 27 /// … … 29 29 /// 30 30 void 31 DocumentTest::setUp ()32 { 33 m_Document = new Document ();31 PDFDocumentTest::setUp () 32 { 33 m_Document = new PDFDocument (); 34 34 } 35 35 … … 38 38 /// 39 39 void 40 DocumentTest::tearDown ()40 PDFDocumentTest::tearDown () 41 41 { 42 42 delete m_Document; … … 52 52 /// 53 53 void 54 DocumentTest::emptyDocument ()54 PDFDocumentTest::emptyDocument () 55 55 { 56 56 CPPUNIT_ASSERT (!m_Document->isLoaded ()); … … 94 94 /// 95 95 void 96 DocumentTest::fileNotFound (void)96 PDFDocumentTest::fileNotFound (void) 97 97 { 98 98 GError *error = NULL; … … 101 101 CPPUNIT_ASSERT (!m_Document->isLoaded ()); 102 102 103 gchar *documentError = Document::getErrorMessage(DocumentErrorOpenFile);103 gchar *documentError = IDocument::getErrorMessage(DocumentErrorOpenFile); 104 104 gchar *errorMessage = g_strdup_printf ( 105 105 "Failed to load document '%sNoFile.pdf'.\n%s\n", … … 121 121 /// 122 122 void 123 DocumentTest::invalidFile (void)123 PDFDocumentTest::invalidFile (void) 124 124 { 125 125 GError *error = NULL; 126 CPPUNIT_ASSERT (!m_Document->loadFile (TEST_DATA_DIR " DocumentTest.cxx",126 CPPUNIT_ASSERT (!m_Document->loadFile (TEST_DATA_DIR "PDFDocumentTest.cxx", 127 127 NULL, &error)); 128 128 CPPUNIT_ASSERT (!m_Document->isLoaded ()); 129 129 130 gchar *documentError = Document::getErrorMessage(DocumentErrorDamaged);130 gchar *documentError = IDocument::getErrorMessage(DocumentErrorDamaged); 131 131 gchar *errorMessage = g_strdup_printf ( 132 "Failed to load document '%s DocumentTest.cxx'.\n%s\n",132 "Failed to load document '%sPDFDocumentTest.cxx'.\n%s\n", 133 133 TEST_DATA_DIR, documentError); 134 134 g_free(documentError); … … 150 150 /// 151 151 void 152 DocumentTest::encryptedFile (void)152 PDFDocumentTest::encryptedFile (void) 153 153 { 154 154 GError *error = NULL; … … 157 157 CPPUNIT_ASSERT (!m_Document->isLoaded ()); 158 158 159 gchar *documentError = Document::getErrorMessage(DocumentErrorEncrypted);159 gchar *documentError = IDocument::getErrorMessage(DocumentErrorEncrypted); 160 160 gchar *errorMessage = g_strdup_printf ( 161 161 "Failed to load document '%stest_encrypted.pdf'.\n%s\n", … … 175 175 CPPUNIT_ASSERT (!m_Document->isLoaded ()); 176 176 177 documentError = Document::getErrorMessage(DocumentErrorEncrypted);177 documentError = IDocument::getErrorMessage(DocumentErrorEncrypted); 178 178 errorMessage = g_strdup_printf ( 179 179 "Failed to load document '%stest_encrypted.pdf'.\n%s\n", … … 207 207 /// 208 208 void 209 DocumentTest::validFile ()209 PDFDocumentTest::validFile () 210 210 { 211 211 CPPUNIT_ASSERT (m_Document->loadFile (TEST_DATA_DIR "test2.pdf", … … 280 280 /// @brief Test changing pages. 281 281 /// 282 /// The Document class also has the information about the current page282 /// The IDocument class also has the information about the current page 283 283 /// that's shown, so we must change it through its methods. This test just 284 284 /// checks that the page is changed correctly. 285 285 /// 286 286 void 287 DocumentTest::pageChange ()287 PDFDocumentTest::pageChange () 288 288 { 289 289 // First try with a 2 page document. … … 371 371 /// 372 372 void 373 DocumentTest::pageRotate ()373 PDFDocumentTest::pageRotate () 374 374 { 375 375 CPPUNIT_ASSERT (m_Document->loadFile (TEST_DATA_DIR "test2.pdf", … … 403 403 /// @brief Test the document's zoom. 404 404 /// 405 /// The Document class is also responsible of the page's zoom level. It can405 /// The IDocument class is also responsible of the page's zoom level. It can 406 406 /// Zoom In, Zoom Out, Zoom to Width and Zoom to Fit. 407 407 /// … … 410 410 /// 411 411 void 412 DocumentTest::pageZoom ()412 PDFDocumentTest::pageZoom () 413 413 { 414 414 // On this document only try Zoom In and Zoom Out. … … 416 416 NULL, NULL)); 417 417 CPPUNIT_ASSERT (m_Document->isLoaded ()); 418 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), equalDelta);418 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), DELTA); 419 419 m_Document->zoomIn (); 420 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), equalDelta);420 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), DELTA); 421 421 m_Document->zoomIn (); 422 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.44f, m_Document->getZoom (), equalDelta);422 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.44f, m_Document->getZoom (), DELTA); 423 423 m_Document->zoomOut (); 424 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), equalDelta);424 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), DELTA); 425 425 m_Document->zoomIn (); 426 426 m_Document->zoomIn (); 427 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.728f, m_Document->getZoom (), equalDelta);427 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.728f, m_Document->getZoom (), DELTA); 428 428 429 429 // On this document we'll use the zoom to fit and zoom to width. … … 432 432 NULL, NULL)); 433 433 CPPUNIT_ASSERT (m_Document->isLoaded ()); 434 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), equalDelta);434 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), DELTA); 435 435 m_Document->zoomToWidth (200); 436 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3361f, m_Document->getZoom (), equalDelta);436 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3361f, m_Document->getZoom (), DELTA); 437 437 m_Document->zoomToFit (100, 50); 438 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0593f, m_Document->getZoom (), equalDelta);438 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0593f, m_Document->getZoom (), DELTA); 439 439 m_Document->zoomToFit (50, 100); 440 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0840f, m_Document->getZoom (), equalDelta);440 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0840f, m_Document->getZoom (), DELTA); 441 441 } 442 442 … … 455 455 /// 456 456 void 457 DocumentTest::pageRender ()457 PDFDocumentTest::pageRender () 458 458 { 459 459 CPPUNIT_ASSERT (m_Document->loadFile (TEST_DATA_DIR "test2.pdf", … … 468 468 CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); 469 469 m_Document->zoomToWidth (300); 470 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3562f, m_Document->getZoom (), equalDelta);470 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3562f, m_Document->getZoom (), DELTA); 471 471 DocumentPage *page = m_Document->renderPage (); 472 472 CPPUNIT_ASSERT_EQUAL (300, page->getWidth ());
