| | 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 | /// |
| | 92 | void |
| | 93 | DocumentOutlineTest::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 | } |