| | 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 | |