| 172 | | |
| 173 | | } |
| | 172 | } |
| | 173 | |
| | 174 | /// |
| | 175 | /// @brief Test a cancelled password. |
| | 176 | /// |
| | 177 | /// A cancelled password is more or less the same as cancelling the loading |
| | 178 | /// of a file. It's when the user tried to open an encrypted file, but when |
| | 179 | /// the password is prompted, then it cancels :-) |
| | 180 | /// It should happen the same as when cancelling the open file dialog. |
| | 181 | /// |
| | 182 | void |
| | 183 | MainPterTest::cancelledPassword () |
| | 184 | { |
| | 185 | m_View->setOpenFileName ("/tmp/test.pdf"); |
| | 186 | m_View->setPassword (NULL); |
| | 187 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 188 | m_MainPter->openFileActivated (); |
| | 189 | CPPUNIT_ASSERT_EQUAL (0, |
| | 190 | g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); |
| | 191 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); |
| | 192 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); |
| | 193 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); |
| | 194 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToPage ()); |
| | 195 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); |
| | 196 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomIn ()); |
| | 197 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); |
| | 198 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomFit ()); |
| | 199 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); |
| | 200 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 201 | CPPUNIT_ASSERT (!m_View->shownError ()); |
| | 202 | } |
| | 203 | |
| | 204 | /// |
| | 205 | /// @brief Test a bad password. |
| | 206 | /// |
| | 207 | /// This test is very similar to the previous, but this time the user |
| | 208 | /// enters a bad password, trying to guess which is the correct password. |
| | 209 | /// The presenter gives up after three times and shows an error message. |
| | 210 | /// |
| | 211 | void |
| | 212 | MainPterTest::badPassword () |
| | 213 | { |
| | 214 | m_View->setOpenFileName ("/tmp/test.pdf"); |
| | 215 | m_View->setPassword ("badpassword"); |
| | 216 | m_Document->setPassword ("goodpassword"); |
| | 217 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 218 | m_MainPter->openFileActivated (); |
| | 219 | CPPUNIT_ASSERT_EQUAL (0, |
| | 220 | g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); |
| | 221 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); |
| | 222 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); |
| | 223 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); |
| | 224 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToPage ()); |
| | 225 | CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); |
| | 226 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomIn ()); |
| | 227 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); |
| | 228 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomFit ()); |
| | 229 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); |
| | 230 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 231 | CPPUNIT_ASSERT (m_View->shownError ()); |
| | 232 | CPPUNIT_ASSERT_EQUAL (3, m_View->countTimesShownPasswordPrompt ()); |
| | 233 | } |