Show
Ignore:
Timestamp:
04/11/06 12:15:53 (3 years ago)
Author:
jordi
Message:

The user can now open an encrypted pdf file, as the presenter will ask for the password three time before to show an error, or until the user gives the cancels out.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/MainPterTest.cxx

    r26 r27  
    170170    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
    171171    CPPUNIT_ASSERT (m_View->shownError ()); 
    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/// 
     182void 
     183MainPterTest::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/// 
     211void 
     212MainPterTest::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}