| 437 | | CPPUNIT_ASSERT_EQUAL (m_Document->getRotation (), 0); |
| 438 | | } |
| | 437 | CPPUNIT_ASSERT_EQUAL (0, m_Document->getRotation ()); |
| | 438 | } |
| | 439 | |
| | 440 | /// |
| | 441 | /// @brief Tests page's zoom. |
| | 442 | /// |
| | 443 | /// The DumbDocument has a fixed size of 100x250 pixels and the DumbMainView |
| | 444 | /// has a fixed pageView of 75x50. We will make sure that getting to the max |
| | 445 | /// ZoomIn unsensitives the ZoomIn button. The same for the ZoomOut. |
| | 446 | /// |
| | 447 | /// Then will test Zoom Fit and Zoom Width with two different rotations. |
| | 448 | /// |
| | 449 | void |
| | 450 | MainPterTest::pageZoom () |
| | 451 | { |
| | 452 | m_View->setOpenFileName ("/tmp/test.pdf"); |
| | 453 | m_MainPter->openFileActivated (); |
| | 454 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 455 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 456 | CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), 0.0001f); |
| | 457 | |
| | 458 | m_MainPter->zoomInActivated (); |
| | 459 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 460 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 461 | CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), 0.0001f); |
| | 462 | |
| | 463 | m_MainPter->zoomOutActivated (); |
| | 464 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 465 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 466 | CPPUNIT_ASSERT_EQUAL (1.0f, m_Document->getZoom ()); |
| | 467 | |
| | 468 | CPPUNIT_ASSERT (m_View->isSensitiveZoomIn ()); |
| | 469 | CPPUNIT_ASSERT (m_View->isSensitiveZoomOut ()); |
| | 470 | // Make sure we go to the last zoom level. |
| | 471 | for (int count = 0 ; count < 20 ; count++) |
| | 472 | { |
| | 473 | m_MainPter->zoomInActivated (); |
| | 474 | } |
| | 475 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomIn ()); |
| | 476 | CPPUNIT_ASSERT (m_View->isSensitiveZoomOut ()); |
| | 477 | for (int count = 0 ; count < 40 ; count ++) |
| | 478 | { |
| | 479 | m_MainPter->zoomOutActivated (); |
| | 480 | } |
| | 481 | CPPUNIT_ASSERT (m_View->isSensitiveZoomIn ()); |
| | 482 | CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); |
| | 483 | |
| | 484 | // OK, now try to zoom width. Since rotation is 0 |
| | 485 | // the zoom level should be 50/250 = 0.2 |
| | 486 | m_MainPter->zoomFitActivated (); |
| | 487 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 488 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 489 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2f, m_Document->getZoom (), 0.0001f); |
| | 490 | // For the width it should be 75/100 = 0.75 |
| | 491 | m_MainPter->zoomWidthActivated (); |
| | 492 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 493 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 494 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75f, m_Document->getZoom (), 0.0001f); |
| | 495 | |
| | 496 | // Now rotate and try again. |
| | 497 | m_MainPter->rotateRightActivated (); |
| | 498 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 499 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 500 | CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); |
| | 501 | |
| | 502 | // Since rotation is now 90 the zoom level should be 75/250 = 0.3 |
| | 503 | m_MainPter->zoomFitActivated (); |
| | 504 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3f, m_Document->getZoom (), 0.0001f); |
| | 505 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 506 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 507 | // For the width it should be 75/250 = 0.3 also. |
| | 508 | m_MainPter->zoomWidthActivated (); |
| | 509 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3f, m_Document->getZoom (), 0.0001f); |
| | 510 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 511 | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| | 512 | } |