Changeset 210
- Timestamp:
- 06/10/06 09:02:37 (2 years ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
src/JobSave.cxx (modified) (1 diff)
-
tests/DumbDocument.cxx (modified) (4 diffs)
-
tests/DumbDocument.h (modified) (2 diffs)
-
tests/DumbMainView.cxx (modified) (5 diffs)
-
tests/DumbMainView.h (modified) (3 diffs)
-
tests/MainPterTest.cxx (modified) (4 diffs)
-
tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/JobSave.cxx
r200 r210 112 112 { 113 113 g_assert ( NULL != document && "Tried to set a NULL document."); 114 114 115 115 m_Document = document; 116 116 } -
trunk/tests/DumbDocument.cxx
r205 r210 30 30 m_Loaded = FALSE; 31 31 m_OpenError = DocumentErrorNone; 32 m_TestPassword = NULL; 32 m_SavedFileName = g_strdup (""); 33 m_TestPassword = NULL; 33 34 setNumPages (2); 34 35 } … … 37 38 { 38 39 clearCache (); 40 g_free (m_SavedFileName); 39 41 g_free (m_TestPassword); 40 42 } … … 101 103 102 104 gboolean 103 DumbDocument::saveFile (const gchar *file name, GError **error)105 DumbDocument::saveFile (const gchar *fileName, GError **error) 104 106 { 105 // Do nothing. 107 g_free (m_SavedFileName); 108 m_SavedFileName = g_strdup (fileName); 106 109 return TRUE; 107 110 } … … 110 113 // Tests Methods 111 114 //////////////////////////////////////////////////////////////// 115 116 const gchar * 117 DumbDocument::getSavedFileName () 118 { 119 return m_SavedFileName; 120 } 121 112 122 void 113 123 DumbDocument::setOpenError (DocumentError error) -
trunk/tests/DumbDocument.h
r205 r210 32 32 gboolean loadFile (const gchar *filename, const gchar *password, 33 33 GError **error); 34 void getPageSizeForPage (gint pageNum, gdouble *width, 34 void getPageSizeForPage (gint pageNum, gdouble *width, 35 35 gdouble *height); 36 36 DocumentPage *renderPage (gint pageNum); 37 gboolean saveFile (const gchar *file name, GError **error);37 gboolean saveFile (const gchar *fileName, GError **error); 38 38 39 39 // Test functions. 40 const gchar *getSavedFileName (void); 40 41 void setOpenError (DocumentError error); 41 42 void setOutline (DocumentOutline *outline); … … 46 47 DocumentError m_OpenError; 47 48 gchar *m_TestPassword; 49 gchar *m_SavedFileName; 48 50 }; 49 51 } -
trunk/tests/DumbMainView.cxx
r207 r210 35 35 m_OpenFileName = g_strdup (""); 36 36 m_LastOpenFileFolder = NULL; 37 m_LastSaveFileFolder = NULL; 37 38 m_Outline = NULL; 38 m_PageView = new DumbPageView (); 39 m_PageView = new DumbPageView (); 39 40 m_Password = NULL; 41 m_SaveFileName = g_strdup (""); 40 42 m_SensitiveFind = TRUE; 41 43 m_SensitiveGoToFirstPage = TRUE; … … 72 74 g_free (m_GoToPageText); 73 75 g_free (m_LastOpenFileFolder); 76 g_free (m_LastSaveFileFolder); 74 77 g_free (m_OpenFileName); 75 78 g_free (m_Password); 79 g_free (m_SaveFileName); 76 80 g_free (m_Title); 77 81 g_free (m_ZoomText); … … 126 130 DumbMainView::saveFileDialog (const gchar *lastFolder) 127 131 { 128 // Do nothing. 129 return g_strdup (""); 132 g_free (m_LastSaveFileFolder); 133 m_LastSaveFileFolder = g_strdup (lastFolder); 134 return g_strdup (m_SaveFileName); 130 135 } 131 136 … … 333 338 } 334 339 340 const gchar * 341 DumbMainView::getLastSaveFileFolder () 342 { 343 return m_LastSaveFileFolder; 344 } 345 335 346 336 347 DocumentOutline * … … 491 502 m_Password = g_strdup (password); 492 503 m_TimesShownPassword = 0; 504 } 505 506 void 507 DumbMainView::setSaveFileName (const gchar *fileName) 508 { 509 g_free (m_SaveFileName); 510 m_SaveFileName = g_strdup (fileName); 493 511 } 494 512 -
trunk/tests/DumbMainView.h
r207 r210 75 75 gint getCurrentPage (void); 76 76 const gchar *getLastOpenFileFolder (void); 77 const gchar *getLastSaveFileFolder (void); 77 78 DocumentOutline *getOutline (void); 78 79 const gchar *getTitle (void); … … 101 102 void setOpenFileName (const gchar *fileName); 102 103 void setPassword (const gchar *password); 104 void setSaveFileName (const gchar *fileName); 103 105 gboolean shownError (void); 104 106 … … 108 110 gchar *m_GoToPageText; 109 111 gchar *m_LastOpenFileFolder; 112 gchar *m_LastSaveFileFolder; 110 113 gchar *m_OpenFileName; 111 114 DocumentOutline *m_Outline; 112 115 DumbPageView *m_PageView; 113 116 gchar *m_Password; 117 gchar *m_SaveFileName; 114 118 gboolean m_SensitiveFind; 115 119 gboolean m_SensitiveGoToFirstPage; -
trunk/tests/MainPterTest.cxx
r207 r210 191 191 void 192 192 MainPterTest::loadFailed () 193 { 193 { 194 194 m_View->setOpenFileName ("/tmp/test.pdf"); 195 195 m_Document->setOpenError (DocumentErrorDamaged); … … 231 231 m_MainPter->openFileActivated (); 232 232 m_MainPter->waitForFileLoaded (); 233 CPPUNIT_ASSERT_EQUAL (0, 233 CPPUNIT_ASSERT_EQUAL (0, 234 234 g_ascii_strcasecmp ("PDF Viewer", m_View->getTitle ())); 235 235 CPPUNIT_ASSERT (!m_View->isSensitiveGoToFirstPage ()); … … 329 329 /// 330 330 void 331 MainPterTest:: lastFolder ()331 MainPterTest::openLastFolder () 332 332 { 333 333 m_View->setOpenFileName ("/tmp/test.pdf"); … … 348 348 m_View->getLastOpenFileFolder ())); 349 349 } 350 351 /// 352 /// @brief Test saving a document. 353 /// 354 /// Saving a document will call the saveFile() function of the document's class. 355 /// 356 void 357 MainPterTest::saveDocument () 358 { 359 m_View->setOpenFileName ("/tmp/test.pdf"); 360 m_MainPter->openFileActivated (); 361 m_MainPter->waitForFileLoaded (); 362 m_View->setSaveFileName ("/tmp/copy.pdf"); 363 m_MainPter->saveFileActivated (); 364 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/tmp/copy.pdf", 365 m_Document->getSavedFileName ())); 366 } 367 368 /// 369 /// @brief Tests a canceled save file. 370 /// 371 /// When the user cancels the save dialog, then nothing should be saved. 372 /// 373 void 374 MainPterTest::saveCanceled () 375 { 376 m_View->setOpenFileName ("/tmp/test.pdf"); 377 m_MainPter->openFileActivated (); 378 m_MainPter->waitForFileLoaded (); 379 // returning a NULL file name is what will happen when cancel. 380 m_View->setSaveFileName (NULL); 381 m_MainPter->saveFileActivated (); 382 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("", 383 m_Document->getSavedFileName ())); 384 } 385 386 /// 387 /// @brief Test the last folder used to save a file. 388 /// 389 /// When the presenter wants to save a file, it should pass to the 390 /// view the last folder that was used to save a file, so the 391 /// view can show it up when saving the dialog. 392 /// 393 void 394 MainPterTest::saveLastFolder () 395 { 396 m_View->setOpenFileName ("/tmp/test.pdf"); 397 m_MainPter->openFileActivated (); 398 m_MainPter->waitForFileLoaded (); 399 m_View->setSaveFileName ("/tmp/copy.pdf"); 400 m_MainPter->saveFileActivated (); 401 m_MainPter->waitForFileSaved (); 402 CPPUNIT_ASSERT (NULL == m_View->getLastSaveFileFolder ()); 403 404 405 m_View->setSaveFileName ("/usr/copy.pdf"); 406 m_MainPter->saveFileActivated (); 407 m_MainPter->waitForFileSaved (); 408 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/tmp", 409 m_View->getLastSaveFileFolder ())); 410 411 m_MainPter->saveFileActivated (); 412 m_MainPter->waitForFileSaved (); 413 CPPUNIT_ASSERT (0 == g_ascii_strcasecmp ("/usr", 414 m_View->getLastSaveFileFolder ())); 415 416 } 417 350 418 351 419 /// -
trunk/tests/MainPterTest.h
r207 r210 33 33 CPPUNIT_TEST (badPassword); 34 34 CPPUNIT_TEST (goodPassword); 35 CPPUNIT_TEST (lastFolder); 35 CPPUNIT_TEST (openLastFolder); 36 CPPUNIT_TEST (saveDocument); 37 CPPUNIT_TEST (saveCanceled); 38 CPPUNIT_TEST (saveLastFolder); 36 39 CPPUNIT_TEST (pageNavigation); 37 40 CPPUNIT_TEST (pageNavigationEntry); … … 60 63 void badPassword (void); 61 64 void goodPassword (void); 62 void lastFolder (void); 65 void openLastFolder (void); 66 void saveDocument (void); 67 void saveCanceled (void); 68 void saveLastFolder (void); 63 69 void pageNavigation (void); 64 70 void pageNavigationEntry (void);
