| 578 | | CPPUNIT_ASSERT (!m_View->hasImagePageView ()); |
| 579 | | } |
| | 577 | } |
| | 578 | |
| | 579 | /// |
| | 580 | /// @brief Tries to reload an encrypted file. |
| | 581 | /// |
| | 582 | /// Reloading an encrypted file won't ask for the password unless it changed, |
| | 583 | /// but here we assume that don't |
| | 584 | /// |
| | 585 | void |
| | 586 | MainPterTest::reloadEncrypted () |
| | 587 | { |
| | 588 | m_View->setOpenFileName ("/tmp/test.pdf"); |
| | 589 | m_View->setPassword ("goodpassword"); |
| | 590 | m_Document->setTestPassword ("goodpassword"); |
| | 591 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 592 | m_MainPter->openFileActivated (); |
| | 593 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 594 | CPPUNIT_ASSERT_EQUAL (0, |
| | 595 | g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); |
| | 596 | |
| | 597 | m_MainPter->goToNextPageActivated (); |
| | 598 | m_MainPter->rotateRightActivated (); |
| | 599 | m_MainPter->zoomWidthActivated (); |
| | 600 | CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ()); |
| | 601 | CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); |
| | 602 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); |
| | 603 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 604 | |
| | 605 | // Reload the document. |
| | 606 | m_View->setPassword ("badpassword"); |
| | 607 | m_Document->setTestPassword ("goodpassword"); |
| | 608 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 609 | m_MainPter->reloadActivated (); |
| | 610 | CPPUNIT_ASSERT_EQUAL (0, |
| | 611 | g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); |
| | 612 | CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ()); |
| | 613 | CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); |
| | 614 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); |
| | 615 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 616 | CPPUNIT_ASSERT (!m_View->shownError ()); |
| | 617 | CPPUNIT_ASSERT_EQUAL (0, m_View->countTimesShownPasswordPrompt ()); |
| | 618 | } |
| | 619 | |
| | 620 | /// |
| | 621 | /// @brief Tries to reload an encrypted file whose password changed. |
| | 622 | /// |
| | 623 | /// Reloading an encrypted file won't ask for the password unless it changed. |
| | 624 | /// |
| | 625 | void |
| | 626 | MainPterTest::reloadChangedPassword () |
| | 627 | { |
| | 628 | m_View->setOpenFileName ("/tmp/test.pdf"); |
| | 629 | m_View->setPassword ("goodpassword"); |
| | 630 | m_Document->setTestPassword ("goodpassword"); |
| | 631 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 632 | m_MainPter->openFileActivated (); |
| | 633 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 634 | CPPUNIT_ASSERT_EQUAL (0, |
| | 635 | g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); |
| | 636 | |
| | 637 | m_MainPter->goToNextPageActivated (); |
| | 638 | m_MainPter->rotateRightActivated (); |
| | 639 | m_MainPter->zoomWidthActivated (); |
| | 640 | CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ()); |
| | 641 | CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); |
| | 642 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); |
| | 643 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 644 | |
| | 645 | // Reload the document. |
| | 646 | m_View->setPassword ("newpassword"); |
| | 647 | m_Document->setTestPassword ("newpassword"); |
| | 648 | CPPUNIT_ASSERT_EQUAL (0, |
| | 649 | g_ascii_strcasecmp("goodpassword", m_Document->getPassword ())); |
| | 650 | m_Document->setOpenError (DocumentErrorEncrypted); |
| | 651 | m_MainPter->reloadActivated (); |
| | 652 | CPPUNIT_ASSERT_EQUAL (0, |
| | 653 | g_ascii_strcasecmp("newpassword", m_Document->getPassword ())); |
| | 654 | CPPUNIT_ASSERT_EQUAL (0, |
| | 655 | g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); |
| | 656 | CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ()); |
| | 657 | CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); |
| | 658 | CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); |
| | 659 | CPPUNIT_ASSERT (m_View->hasImagePageView ()); |
| | 660 | CPPUNIT_ASSERT (!m_View->shownError ()); |
| | 661 | CPPUNIT_ASSERT_EQUAL (1, m_View->countTimesShownPasswordPrompt ()); |
| | 662 | } |