Show
Ignore:
Timestamp:
04/14/06 12:08:30 (3 years ago)
Author:
jordi
Message:

The document's outlines are now loaded correctly, although I don't like the way is set up now...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/DocumentOutlineTest.cxx

    r59 r60  
    5151{ 
    5252    CPPUNIT_ASSERT ( !m_Document->isLoaded ()); 
    53     DocumentOutline *outline = m_Document->getOutline (); 
    54     // The initial state of the outline is no outline at all. 
    55     CPPUNIT_ASSERT_EQUAL (0, outline->getNumChildren ()); 
    56     CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("", outline->getTitle ())); 
    57     CPPUNIT_ASSERT_EQUAL (1, outline->getDestinationPage ()); 
    58     CPPUNIT_ASSERT (NULL == outline->getFirstChild ()); 
     53    CPPUNIT_ASSERT ( NULL == m_Document->getOutline ()); 
    5954} 
    6055 
     
    6358/// 
    6459/// When a loaded document doesn't have an outline, the DocumentOutline's 
    65 /// behaviour is exactly the same as the initial status. 
     60/// is empty. 
    6661/// 
    6762void 
     
    7267    CPPUNIT_ASSERT (m_Document->isLoaded ()); 
    7368    DocumentOutline *outline = m_Document->getOutline (); 
     69    CPPUNIT_ASSERT ( NULL != outline ); 
    7470    CPPUNIT_ASSERT_EQUAL (0, outline->getNumChildren ()); 
    7571    CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("", outline->getTitle ())); 
    7672    CPPUNIT_ASSERT_EQUAL (1, outline->getDestinationPage ()); 
    7773    CPPUNIT_ASSERT (NULL == outline->getFirstChild ()); 
     74    CPPUNIT_ASSERT (NULL == outline->getNextChild ()); 
    7875} 
     76 
     77/// 
     78/// @brief Test a file that has outline. 
     79/// 
     80/// The document I've gone test has the following outline: 
     81/// 
     82///  * 
     83///  | 
     84///  +- Test PDF 1 / page 3 
     85///  | 
     86///  +- Table of Contents / page 4 
     87///  | 
     88///  +- Chapter 1. First Chapter / page 5 
     89///     | 
     90///     + First Section / page 5 
     91/// 
     92void 
     93DocumentOutlineTest::hasOutline () 
     94{ 
     95    CPPUNIT_ASSERT (m_Document->loadFile (TEST_DATA_DIR "test1.pdf", 
     96                                          NULL, NULL)); 
     97    CPPUNIT_ASSERT (m_Document->isLoaded ()); 
     98    DocumentOutline *outline = m_Document->getOutline (); 
     99    CPPUNIT_ASSERT ( NULL != outline ); 
     100    // The root outline must be the same empy one, except it has children. 
     101    CPPUNIT_ASSERT_EQUAL (3, outline->getNumChildren ()); 
     102    CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("", outline->getTitle ())); 
     103    CPPUNIT_ASSERT_EQUAL (1, outline->getDestinationPage ()); 
     104 
     105    { 
     106        DocumentOutline *child = outline->getFirstChild(); 
     107        CPPUNIT_ASSERT ( NULL != child ); 
     108        CPPUNIT_ASSERT_EQUAL (0, child->getNumChildren ()); 
     109        CPPUNIT_ASSERT_EQUAL (0, g_ascii_strcasecmp ("Test PDF 1",  
     110                                                     child->getTitle ())); 
     111        CPPUNIT_ASSERT_EQUAL (3, child->getDestinationPage ()); 
     112    } 
     113     
     114    { 
     115        DocumentOutline *child = outline->getNextChild(); 
     116        CPPUNIT_ASSERT ( NULL != child ); 
     117        CPPUNIT_ASSERT_EQUAL (0, child->getNumChildren ()); 
     118        CPPUNIT_ASSERT_EQUAL (0, g_ascii_strcasecmp ("Table of Contents",  
     119                                                     child->getTitle ())); 
     120        CPPUNIT_ASSERT_EQUAL (4, child->getDestinationPage ()); 
     121    } 
     122 
     123    { 
     124        DocumentOutline *child = outline->getNextChild(); 
     125        CPPUNIT_ASSERT ( NULL != child ); 
     126        CPPUNIT_ASSERT_EQUAL (1, child->getNumChildren ()); 
     127        CPPUNIT_ASSERT_EQUAL (0, 
     128                              g_ascii_strcasecmp ("Chapter 1. First Chapter", 
     129                                                  child->getTitle ())); 
     130        CPPUNIT_ASSERT_EQUAL (5, child->getDestinationPage ()); 
     131 
     132        DocumentOutline *greatChild = child->getFirstChild (); 
     133        CPPUNIT_ASSERT ( NULL != greatChild ); 
     134        CPPUNIT_ASSERT_EQUAL (0, greatChild->getNumChildren ()); 
     135        CPPUNIT_ASSERT_EQUAL (0, g_ascii_strcasecmp ("First Section", 
     136                                                     greatChild->getTitle ())); 
     137        CPPUNIT_ASSERT_EQUAL (5, greatChild->getDestinationPage ()); 
     138    } 
     139 
     140    // After the last child, it should return NULL. 
     141    CPPUNIT_ASSERT (NULL == outline->getNextChild ()); 
     142 
     143    // Try again the "no outlined" file. 
     144    noOutline (); 
     145}