| 1 | // ePDFView - Preferences Presenter Test Fixture. |
|---|
| 2 | // Copyright (C) 2006 Emma's Software. |
|---|
| 3 | // |
|---|
| 4 | // This program is free software; you can redistribute it and/or modify |
|---|
| 5 | // it under the terms of the GNU General Public License as published by |
|---|
| 6 | // the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | // (at your option) any later version. |
|---|
| 8 | // |
|---|
| 9 | // This program is distributed in the hope that it will be useful, |
|---|
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | // GNU General Public License for more details. |
|---|
| 13 | // |
|---|
| 14 | // You should have received a copy of the GNU General Public License |
|---|
| 15 | // along with this program; if not, write to the Free Software |
|---|
| 16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 | |
|---|
| 18 | #include <epdfview.h> |
|---|
| 19 | #include "DumbDocument.h" |
|---|
| 20 | #include "DumbPrintView.h" |
|---|
| 21 | #include "PrintPterTest.h" |
|---|
| 22 | |
|---|
| 23 | using namespace ePDFView; |
|---|
| 24 | |
|---|
| 25 | // Register the test suite into the `registry'. |
|---|
| 26 | CPPUNIT_TEST_SUITE_REGISTRATION (PrintPterTest); |
|---|
| 27 | |
|---|
| 28 | /// |
|---|
| 29 | /// @brief Sets up the environment for each test. |
|---|
| 30 | /// |
|---|
| 31 | void |
|---|
| 32 | PrintPterTest::setUp () |
|---|
| 33 | { |
|---|
| 34 | Config::loadFile (FALSE); |
|---|
| 35 | m_Document = new DumbDocument (); |
|---|
| 36 | m_PrintPter = new PrintPter (m_Document); |
|---|
| 37 | m_View = new DumbPrintView (); |
|---|
| 38 | m_PrintPter->setView (m_View); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | /// |
|---|
| 42 | /// @brief Cleans up after each test. |
|---|
| 43 | /// |
|---|
| 44 | void |
|---|
| 45 | PrintPterTest::tearDown () |
|---|
| 46 | { |
|---|
| 47 | Config::destroy (); |
|---|
| 48 | // Telling the presenter to cancel will delete the view and the |
|---|
| 49 | // presenter. |
|---|
| 50 | if ( NULL != m_PrintPter ) |
|---|
| 51 | { |
|---|
| 52 | m_PrintPter->cancelActivated (); |
|---|
| 53 | m_PrintPter = NULL; |
|---|
| 54 | m_View = NULL; |
|---|
| 55 | } |
|---|
| 56 | delete m_Document; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /// |
|---|
| 60 | /// @brief Check the initial's dialog sensitivity. |
|---|
| 61 | /// |
|---|
| 62 | void |
|---|
| 63 | PrintPterTest::initialSensitivity () |
|---|
| 64 | { |
|---|
| 65 | // By default "All Pages" range is selected, so the |
|---|
| 66 | // custom page ranges is insensitive. |
|---|
| 67 | CPPUNIT_ASSERT ( !m_View->isSensitivePageRange ()); |
|---|
| 68 | // By default the number of copies is 1, so the collate |
|---|
| 69 | // option is insensitive. |
|---|
| 70 | CPPUNIT_ASSERT ( !m_View->isSensitiveCollate ()); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /// |
|---|
| 74 | /// @brief Check "Collate"'s sensitivity. |
|---|
| 75 | /// |
|---|
| 76 | /// The collate option is always sensitive unless the number |
|---|
| 77 | /// of copies is 1. |
|---|
| 78 | /// |
|---|
| 79 | void |
|---|
| 80 | PrintPterTest::collateSensitivity () |
|---|
| 81 | { |
|---|
| 82 | m_View->setNumberOfCopies (1); |
|---|
| 83 | m_PrintPter->numberOfCopiesChanged (); |
|---|
| 84 | CPPUNIT_ASSERT ( !m_View->isSensitiveCollate ()); |
|---|
| 85 | |
|---|
| 86 | m_View->setNumberOfCopies (10); |
|---|
| 87 | m_PrintPter->numberOfCopiesChanged (); |
|---|
| 88 | CPPUNIT_ASSERT ( m_View->isSensitiveCollate ()); |
|---|
| 89 | |
|---|
| 90 | m_View->setNumberOfCopies (234); |
|---|
| 91 | m_PrintPter->numberOfCopiesChanged (); |
|---|
| 92 | CPPUNIT_ASSERT ( m_View->isSensitiveCollate ()); |
|---|
| 93 | |
|---|
| 94 | m_View->setNumberOfCopies (1); |
|---|
| 95 | m_PrintPter->numberOfCopiesChanged (); |
|---|
| 96 | CPPUNIT_ASSERT ( !m_View->isSensitiveCollate ()); |
|---|
| 97 | |
|---|
| 98 | m_View->setNumberOfCopies (32); |
|---|
| 99 | m_PrintPter->numberOfCopiesChanged (); |
|---|
| 100 | CPPUNIT_ASSERT ( m_View->isSensitiveCollate ()); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | /// |
|---|
| 104 | /// @brief Check "Page Range"'s sensitivity. |
|---|
| 105 | /// |
|---|
| 106 | /// The page range entry is only sensitive when the "Range:" radio |
|---|
| 107 | /// button is selected. |
|---|
| 108 | /// |
|---|
| 109 | void |
|---|
| 110 | PrintPterTest::pageRangeSensitivity () |
|---|
| 111 | { |
|---|
| 112 | m_View->selectAllPagesRangeOption (); |
|---|
| 113 | m_PrintPter->pageRangeOptionChanged (); |
|---|
| 114 | CPPUNIT_ASSERT ( !m_View->isSensitivePageRange ()); |
|---|
| 115 | |
|---|
| 116 | m_View->selectCustomPagesRangeOption (); |
|---|
| 117 | m_PrintPter->pageRangeOptionChanged (); |
|---|
| 118 | CPPUNIT_ASSERT ( m_View->isSensitivePageRange ()); |
|---|
| 119 | |
|---|
| 120 | m_View->selectAllPagesRangeOption (); |
|---|
| 121 | m_PrintPter->pageRangeOptionChanged (); |
|---|
| 122 | CPPUNIT_ASSERT ( !m_View->isSensitivePageRange ()); |
|---|
| 123 | |
|---|
| 124 | m_View->selectCustomPagesRangeOption (); |
|---|
| 125 | m_PrintPter->pageRangeOptionChanged (); |
|---|
| 126 | CPPUNIT_ASSERT ( m_View->isSensitivePageRange ()); |
|---|
| 127 | } |
|---|