sd/qa/unit/export-tests.cxx |   49 +++++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 14 deletions(-)

New commits:
commit c2a4b16ebfde78c6180465c938475f67c4e8e7b7
Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
Date:   Thu Feb 8 05:08:17 2018 +0900

    extend testLinkedGraphicRT if state after import is as expected
    
    Change-Id: Ia3452d7946148db20f8a876c92f945cb4e68ddb5
    Reviewed-on: https://gerrit.libreoffice.org/49552
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 73d8bb5c49c6..8994f0d8883c 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -549,8 +549,7 @@ void SdExportTest::testLinkedGraphicRT()
     for( size_t nExportFormat = 0; nExportFormat < SAL_N_ELEMENTS(vFormats); 
++nExportFormat )
     {
         // Load the original file with one image
-        ::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/document_with_linked_graphic.odp"),
 ODP);
-        const OString sFailedMessage = OString("Failed on filter: ") + 
OString(aFileFormats[vFormats[nExportFormat]].pFilterName);
+        sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/document_with_linked_graphic.odp"),
 ODP);
 
         // Export the document and import again for a check
         uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), 
uno::UNO_QUERY);
@@ -558,6 +557,24 @@ void SdExportTest::testLinkedGraphicRT()
         utl::MediaDescriptor aMediaDescriptor;
         aMediaDescriptor["FilterName"] <<= 
OStringToOUString(OString(aFileFormats[vFormats[nExportFormat]].pFilterName), 
RTL_TEXTENCODING_UTF8);
 
+        // Check if the graphic has been imported correctly (before doing the 
export/import run)
+        {
+            const OString sFailedImportMessage = "Failed to correctly import 
the document";
+            SdDrawDocument* pDoc = xDocShRef->GetDoc();
+            CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != 
nullptr);
+            const SdrPage* pPage = pDoc->GetPage(1);
+            CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != 
nullptr);
+            SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
+            CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != 
nullptr );
+            CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), 
pObject->IsLinkedGraphic() );
+
+            const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
+            CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), 
!rGraphicObj.IsSwappedOut());
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), 
int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+            CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), 
sal_uLong(864900), rGraphicObj.GetSizeBytes());
+        }
+
+        // Save and reload
         utl::TempFile aTempFile;
         aTempFile.EnableKillingFile();
         xStorable->storeToURL(aTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
@@ -566,18 +583,22 @@ void SdExportTest::testLinkedGraphicRT()
         xDocShRef = loadURL(aTempFile.GetURL(), nExportFormat);
 
         // Check whether graphic imported well after export
-        SdDrawDocument *pDoc = xDocShRef->GetDoc();
-        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDoc != nullptr );
-        const SdrPage *pPage = pDoc->GetPage(1);
-        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != nullptr );
-        SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
-        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject != nullptr );
-        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), 
pObject->IsLinkedGraphic() );
-
-        const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
-        CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), 
!rGraphicObj.IsSwappedOut());
-        CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), 
int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
-        CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), 
sal_uLong(864900), rGraphicObj.GetSizeBytes());
+        {
+            const OString sFailedMessage = OString("Failed on filter: ") + 
OString(aFileFormats[vFormats[nExportFormat]].pFilterName);
+
+            SdDrawDocument *pDoc = xDocShRef->GetDoc();
+            CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDoc != nullptr );
+            const SdrPage *pPage = pDoc->GetPage(1);
+            CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != nullptr 
);
+            SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
+            CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pObject != 
nullptr );
+            CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), 
pObject->IsLinkedGraphic() );
+
+            const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
+            CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), 
!rGraphicObj.IsSwappedOut());
+            CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), 
int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType()));
+            CPPUNIT_ASSERT_EQUAL_MESSAGE( sFailedMessage.getStr(), 
sal_uLong(864900), rGraphicObj.GetSizeBytes());
+        }
 
         xDocShRef->DoClose();
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to