Changeset 26
- Timestamp:
- 04/11/06 11:40:45 (3 years ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
src/IMainView.h (modified) (1 diff)
-
src/MainPter.cxx (modified) (2 diffs)
-
tests/DumbDocument.cxx (modified) (3 diffs)
-
tests/DumbDocument.h (modified) (1 diff)
-
tests/DumbMainView.cxx (modified) (4 diffs)
-
tests/DumbMainView.h (modified) (3 diffs)
-
tests/MainPterTest.cxx (modified) (1 diff)
-
tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IMainView.h
r24 r26 41 41 virtual void sensitiveZoomWidth (gboolean sensitive) = 0; 42 42 virtual void show (void) = 0; 43 virtual void showErrorMessage (const gchar *title, 44 const gchar *body) = 0; 43 45 virtual void showPage (DocumentPage *page) = 0; 44 46 virtual void setTitle (const gchar *title) = 0; -
trunk/src/MainPter.cxx
r25 r26 147 147 if ( NULL != fileName ) 148 148 { 149 GError *error ;149 GError *error = NULL; 150 150 if ( m_Document->loadFile (fileName, NULL, &error) ) 151 151 { … … 154 154 setInitialState (); 155 155 g_free (fileName); 156 } 157 else 158 { 159 // We got an error, but also can be that the file is encrypted. 160 if ( DocumentErrorEncrypted == error->code ) 161 { 162 // TODO 163 } 164 else 165 { 166 // It was an error. Show the error message. 167 getView ().showErrorMessage (_("Error Loading File"), 168 error->message); 169 170 } 171 g_free (error); 156 172 } 157 173 } -
trunk/tests/DumbDocument.cxx
r24 r26 29 29 { 30 30 m_Loaded = FALSE; 31 m_OpenError = DocumentErrorNone; 31 32 } 32 33 … … 45 46 GError **error) 46 47 { 47 setFileName (filename); 48 m_Loaded = TRUE; 48 if ( DocumentErrorNone == m_OpenError ) 49 { 50 setFileName (filename); 51 m_Loaded = TRUE; 52 } 53 else 54 { 55 g_set_error (error, EPDFVIEW_DOCUMENT_ERROR, m_OpenError, 56 "%s", IDocument::getErrorMessage (m_OpenError)); 57 } 49 58 return m_Loaded; 50 59 } … … 62 71 return new DocumentPage (); 63 72 } 73 74 //////////////////////////////////////////////////////////////// 75 // Tests Methods 76 //////////////////////////////////////////////////////////////// 77 void 78 DumbDocument::setOpenError (DocumentError error) 79 { 80 m_OpenError = error; 81 } -
trunk/tests/DumbDocument.h
r24 r26 34 34 DocumentPage *renderPage (void); 35 35 36 // Test functions. 37 void setOpenError (DocumentError error); 38 36 39 private: 37 40 gboolean m_Loaded; 41 DocumentError m_OpenError; 38 42 }; 39 43 } -
trunk/tests/DumbMainView.cxx
r25 r26 40 40 m_SensitiveZoomWidth = TRUE; 41 41 m_Shown = FALSE; 42 m_ShownError = FALSE; 42 43 m_Title = g_strdup (""); 43 44 } … … 116 117 117 118 void 119 DumbMainView::showErrorMessage (const gchar *title, const gchar *body) 120 { 121 m_ShownError = TRUE; 122 } 123 124 void 118 125 DumbMainView::showPage (DocumentPage *page) 119 126 { … … 136 143 DumbMainView::hasImagePageView () 137 144 { 138 return NULL != m_DocumentPage; 145 gboolean shown = (NULL != m_DocumentPage); 146 // The next time, it will be FALSE unless it's shown again. 147 m_DocumentPage = NULL; 148 149 return shown; 139 150 } 140 151 … … 215 226 } 216 227 } 228 229 gboolean 230 DumbMainView::shownError () 231 { 232 gboolean shown = m_ShownError; 233 // It's like the user clicked the "OK" button. No shown anymore, until 234 // the next error. 235 m_ShownError = FALSE; 236 237 return shown; 238 } -
trunk/tests/DumbMainView.h
r24 r26 39 39 void sensitiveZoomWidth (gboolean sensitive); 40 40 void show (void); 41 void showErrorMessage (const gchar *title, const gchar *body); 41 42 void showPage (DocumentPage *page); 42 43 void setTitle (const gchar *title); … … 56 57 gboolean isSensitiveZoomWidth (void); 57 58 void setOpenFileName (const gchar *fileName); 59 gboolean shownError (void); 58 60 59 61 protected: … … 70 72 gboolean m_SensitiveZoomWidth; 71 73 gboolean m_Shown; 74 gboolean m_ShownError; 72 75 gchar *m_Title; 73 76 }; -
trunk/tests/MainPterTest.cxx
r25 r26 141 141 CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 142 142 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 143 CPPUNIT_ASSERT (!m_View->shownError ()); 143 144 } 145 146 /// 147 /// @brief Test a failed load. 148 /// 149 /// A failed load (anything but a DocumentErrorNone and DocumentErrorEncrypted) 150 /// is very similar to the load cancelled, but an error message is shown 151 /// to the user. 152 /// 153 void 154 MainPterTest::loadFailed () 155 { 156 m_View->setOpenFileName ("/tmp/test.pdf"); 157 m_Document->setOpenError (DocumentErrorDamaged); 158 m_MainPter->openFileActivated (); 159 CPPUNIT_ASSERT_EQUAL (0, 160 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); 161 CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); 162 CPPUNIT_ASSERT (!m_View->isSensitiveGoToLastPage ()); 163 CPPUNIT_ASSERT (!m_View->isSensitiveGoToNextPage ()); 164 CPPUNIT_ASSERT (!m_View->isSensitiveGoToPage ()); 165 CPPUNIT_ASSERT (!m_View->isSensitiveGoToPreviousPage ()); 166 CPPUNIT_ASSERT (!m_View->isSensitiveZoomIn ()); 167 CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); 168 CPPUNIT_ASSERT (!m_View->isSensitiveZoomFit ()); 169 CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 170 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 171 CPPUNIT_ASSERT (m_View->shownError ()); 172 173 } -
trunk/tests/MainPterTest.h
r25 r26 29 29 CPPUNIT_TEST (loadDocument); 30 30 CPPUNIT_TEST (loadCancelled); 31 CPPUNIT_TEST (loadFailed); 31 32 CPPUNIT_TEST_SUITE_END(); 32 33 … … 38 39 void loadDocument (void); 39 40 void loadCancelled (void); 41 void loadFailed (void); 40 42 41 43 private:
