Show
Ignore:
Timestamp:
04/11/06 13:58:09 (3 years ago)
Author:
jordi
Message:

The page navigation toolbar works as expected, setting the sensitiveness of its controls correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/MainPterTest.cxx

    r28 r29  
    262262    CPPUNIT_ASSERT_EQUAL (1, m_View->countTimesShownPasswordPrompt ()); 
    263263} 
     264 
     265/// 
     266/// @brief Test page navigation. 
     267/// 
     268/// I'll load a 4-pages document and will try to go to the first, last, next,  
     269/// previous and also on a page using the entry on the toolbar. 
     270/// 
     271void 
     272MainPterTest::pageNavigation () 
     273{ 
     274    m_View->setOpenFileName ("/tmp/test.pdf"); 
     275    m_Document->setNumPages (4); 
     276    m_MainPter->openFileActivated (); 
     277    // Check that sets the correct number of pages and the current page. 
     278    CPPUNIT_ASSERT_EQUAL (4, m_View->getTotalPages ()); 
     279    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ()); 
     280    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     281    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     282    // Going to the next page should make all actions sensitive. 
     283    m_MainPter->goToNextPageActivated (); 
     284    CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ());  
     285    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     286    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     287    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     288    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     289    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     290    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     291    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     292    // Going to the last will make some unsensitive. 
     293    m_MainPter->goToLastPageActivated (); 
     294    CPPUNIT_ASSERT_EQUAL (4, m_View->getCurrentPage ());  
     295    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     296    CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); 
     297    CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); 
     298    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     299    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     300    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     301    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     302    // Again to the last won't harm (just in case...) nor going next. 
     303    m_MainPter->goToLastPageActivated (); 
     304    m_MainPter->goToNextPageActivated (); 
     305    CPPUNIT_ASSERT_EQUAL (4, m_View->getCurrentPage ());  
     306    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     307    CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); 
     308    CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); 
     309    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     310    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     311    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     312    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     313    // But going to the previous will change something. 
     314    m_MainPter->goToPreviousPageActivated (); 
     315    CPPUNIT_ASSERT_EQUAL (3, m_View->getCurrentPage ());  
     316    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     317    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     318    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     319    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     320    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     321    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     322    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     323    // Now, to the first again. 
     324    m_MainPter->goToFirstPageActivated (); 
     325    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ());  
     326    CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 
     327    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     328    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     329    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     330    CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 
     331    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     332    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     333    // Check sane behaviour. 
     334    m_MainPter->goToFirstPageActivated (); 
     335    m_MainPter->goToPreviousPageActivated (); 
     336    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ());  
     337    CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 
     338    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     339    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     340    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     341    CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 
     342    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     343    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     344 
     345    // Now try again using the page entry on toolbar. 
     346    m_View->setGoToPageText ("2"); 
     347    m_MainPter->goToPageActivated (); 
     348    CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ());  
     349    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     350    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     351    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     352    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     353    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     354    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     355    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     356 
     357    m_View->setGoToPageText ("4"); 
     358    m_MainPter->goToPageActivated (); 
     359    CPPUNIT_ASSERT_EQUAL (4, m_View->getCurrentPage ());  
     360    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     361    CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); 
     362    CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); 
     363    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     364    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     365    CPPUNIT_ASSERT (m_View->hasImagePageView ());     
     366    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     367 
     368    m_View->setGoToPageText ("1"); 
     369    m_MainPter->goToPageActivated (); 
     370    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ());  
     371    CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 
     372    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     373    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     374    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     375    CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 
     376    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     377    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     378 
     379    // Invalid values. 
     380    m_View->setGoToPageText ("123123"); 
     381    m_MainPter->goToPageActivated (); 
     382    CPPUNIT_ASSERT_EQUAL (4, m_View->getCurrentPage ());  
     383    CPPUNIT_ASSERT (m_View->isSensitiveGoToFirstPage ()); 
     384    CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); 
     385    CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); 
     386    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     387    CPPUNIT_ASSERT (m_View->isSensitiveGoToPreviousPage ()); 
     388    CPPUNIT_ASSERT (m_View->hasImagePageView ());     
     389    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     390 
     391    m_View->setGoToPageText ("0"); 
     392    m_MainPter->goToPageActivated (); 
     393    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ());  
     394    CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 
     395    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     396    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     397    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     398    CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 
     399    CPPUNIT_ASSERT (m_View->hasImagePageView ());     
     400    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     401 
     402    m_MainPter->goToNextPageActivated (); 
     403    m_View->setGoToPageText ("Jejej"); 
     404    m_MainPter->goToPageActivated (); 
     405    CPPUNIT_ASSERT_EQUAL (1, m_View->getCurrentPage ());  
     406    CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 
     407    CPPUNIT_ASSERT (m_View->isSensitiveGoToLastPage ()); 
     408    CPPUNIT_ASSERT (m_View->isSensitiveGoToNextPage ()); 
     409    CPPUNIT_ASSERT (m_View->isSensitiveGoToPage ()); 
     410    CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 
     411    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     412    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     413}