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

Divided the pageZoom function from the MainPter? test to ZoomInAndOut?, ZoomWidth? and ZoomFit?, because I'm planning to make ZoomToWith? and ZoomToHeigh? toggle action that deserved separate test cases.

Also added the ZoomToFit? and ZoomToWidth? options to the configuration class. Also the test case was added.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/MainPterTest.cxx

    r97 r98  
    513513/// ZoomIn insensitives the ZoomIn button. The same for the ZoomOut. 
    514514/// 
    515 /// Then will test Zoom Fit and Zoom Width with two different rotations. 
    516 /// 
    517 void 
    518 MainPterTest::pageZoom () 
     515/// 
     516void 
     517MainPterTest::pageZoomInAndOut () 
    519518{ 
    520519    m_View->setOpenFileName ("/tmp/test.pdf"); 
     
    549548    CPPUNIT_ASSERT (m_View->isSensitiveZoomIn ()); 
    550549    CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); 
     550} 
     551 
     552/// 
     553/// @brief Tests page's zoom to width 
     554/// 
     555void 
     556MainPterTest::pageZoomWidth () 
     557{ 
     558    m_View->setOpenFileName ("/tmp/test.pdf"); 
     559    m_MainPter->openFileActivated (); 
     560    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     561    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     562    CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); 
    551563 
    552564    // OK, now try to zoom width. Since rotation is 0 
     565    // the zoom level should be 75/100 = 0.75 
     566    m_MainPter->zoomWidthActivated (); 
     567    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     568    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     569    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 
     570 
     571    // Now rotate and try again. 
     572    m_MainPter->rotateRightActivated ();  
     573    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     574    CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); 
     575     
     576    // Since rotation is now 90 the zoom level should be 75/250 = 0.3 
     577    m_MainPter->zoomWidthActivated (); 
     578    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
     579    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     580} 
     581 
     582/// 
     583/// @brief Tests page's zoom to fit 
     584/// 
     585void 
     586MainPterTest::pageZoomFit () 
     587{ 
     588    m_View->setOpenFileName ("/tmp/test.pdf"); 
     589    m_MainPter->openFileActivated (); 
     590    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
     591    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
     592    CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); 
     593 
     594    // OK, now try to zoom to fit. Since rotation is 0 
    553595    // the zoom level should be 50/250 = 0.2 
    554596    m_MainPter->zoomFitActivated (); 
     
    556598    CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
    557599    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 
    558     // For the width it should be 75/100 = 0.75 
    559     m_MainPter->zoomWidthActivated (); 
    560     CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
    561     CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 
    562     CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 
    563600 
    564601    // Now rotate and try again. 
     
    571608    CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
    572609    CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
    573     // For the width it should be 75/250 = 0.3 also. 
    574     m_MainPter->zoomWidthActivated (); 
    575     CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 
    576     CPPUNIT_ASSERT (m_View->hasImagePageView ()); 
    577 } 
     610} 
     611 
    578612 
    579613///