sd/CppunitTest_sd_uiimpress.mk |    1 
 sd/qa/unit/uiimpress.cxx       |  104 +++++++----------------------------------
 2 files changed, 21 insertions(+), 84 deletions(-)

New commits:
commit 7c21bc69406407988f50479ad7b00afee7e4113d
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Oct 26 10:32:56 2022 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Oct 26 11:18:49 2022 +0200

    CppunitTest_sd_uiimpress: inherit from UnoApiTest
    
    Change-Id: I31c941677b45c0a82e3fe688d40b63796a46d26a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141863
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sd/CppunitTest_sd_uiimpress.mk b/sd/CppunitTest_sd_uiimpress.mk
index 4d06c52db024..e7ee786e98ba 100644
--- a/sd/CppunitTest_sd_uiimpress.mk
+++ b/sd/CppunitTest_sd_uiimpress.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uiimpress, \
     sd \
     sfx \
     sot \
+    subsequenttest \
     svl \
     svt \
     svx \
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 627a652da622..f287a4a83f36 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "sdmodeltestbase.hxx"
+#include <test/unoapi_test.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -47,6 +47,8 @@
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 
+#include <drawdoc.hxx>
+#include <DrawDocShell.hxx>
 #include <ViewShell.hxx>
 #include <app.hrc>
 #include <sdpage.hxx>
@@ -57,40 +59,21 @@
 using namespace ::com::sun::star;
 
 /// Impress UI tests.
-class SdUiImpressTest : public test::BootstrapFixture, public 
unotest::MacrosTest
+class SdUiImpressTest : public UnoApiTest
 {
-protected:
-    uno::Reference<lang::XComponent> mxComponent;
-
 public:
-    virtual void setUp() override;
-    virtual void tearDown() override;
+    SdUiImpressTest()
+        : UnoApiTest("/sd/qa/unit/data/")
+    {
+    }
 
     void checkCurrentPageNumber(sal_uInt16 nNum);
     void typeString(SdXImpressDocument* rImpressDocument, const 
std::u16string_view& rStr);
     void typeKey(SdXImpressDocument* rImpressDocument, const sal_uInt16 nKey);
     void insertStringToObject(sal_uInt16 nObj, const std::u16string_view& 
rStr, bool bUseEscape);
     sd::slidesorter::SlideSorterViewShell* getSlideSorterViewShell();
-    FileFormat* getFormat(sal_Int32 nExportType);
-    void save(sd::DrawDocShell* pShell, FileFormat const* pFormat,
-              utl::TempFileNamed const& rTempFile);
 };
 
-void SdUiImpressTest::setUp()
-{
-    test::BootstrapFixture::setUp();
-
-    mxDesktop.set(frame::Desktop::create(mxComponentContext));
-}
-
-void SdUiImpressTest::tearDown()
-{
-    if (mxComponent.is())
-        mxComponent->dispose();
-
-    test::BootstrapFixture::tearDown();
-}
-
 void SdUiImpressTest::checkCurrentPageNumber(sal_uInt16 nNum)
 {
     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
@@ -166,46 +149,6 @@ sd::slidesorter::SlideSorterViewShell* 
SdUiImpressTest::getSlideSorterViewShell(
     return pSSVS;
 }
 
-FileFormat* SdUiImpressTest::getFormat(sal_Int32 nExportType)
-{
-    FileFormat* pFormat = &aFileFormats[0];
-    if (o3tl::make_unsigned(nExportType) < SAL_N_ELEMENTS(aFileFormats))
-        pFormat = &aFileFormats[nExportType];
-    return pFormat;
-}
-
-void SdUiImpressTest::save(sd::DrawDocShell* pShell, FileFormat const* pFormat,
-                           utl::TempFileNamed const& rTempFile)
-{
-    SfxMedium aStoreMedium(rTempFile.GetURL(), StreamMode::STD_WRITE);
-    if (std::strcmp(pFormat->pName, "odg") == 0)
-    { // Draw
-        SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
-        if (pFormat->nFormatType == ODG_FORMAT_TYPE)
-            nExportFormat = SotClipboardFormatId::STARDRAW_8;
-        auto pExportFilter = std::make_shared<SfxFilter>(
-            OUString::createFromAscii(pFormat->pFilterName), OUString(), 
pFormat->nFormatType,
-            nExportFormat, OUString::createFromAscii(pFormat->pTypeName), 
OUString(),
-            OUString::createFromAscii(pFormat->pUserData), 
"private:factory/sdraw*");
-        pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
-        aStoreMedium.SetFilter(pExportFilter);
-    }
-    else // Impress
-    {
-        SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE;
-        if (pFormat->nFormatType == ODP_FORMAT_TYPE)
-            nExportFormat = SotClipboardFormatId::STARCHART_8;
-        auto pExportFilter = std::make_shared<SfxFilter>(
-            OUString::createFromAscii(pFormat->pFilterName), OUString(), 
pFormat->nFormatType,
-            nExportFormat, OUString::createFromAscii(pFormat->pTypeName), 
OUString(),
-            OUString::createFromAscii(pFormat->pUserData), 
"private:factory/simpress*");
-        pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
-        aStoreMedium.SetFilter(pExportFilter);
-    }
-    pShell->DoSaveAs(aStoreMedium);
-    pShell->DoClose();
-}
-
 static void lcl_search(const OUString& rKey, bool bFindAll = false, bool 
bBackwards = false)
 {
     Scheduler::ProcessEventsToIdle();
@@ -224,7 +167,7 @@ static void lcl_search(const OUString& rKey, bool bFindAll 
= false, bool bBackwa
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
 {
     // Load the document and create two new windows.
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf111522.odp"));
+    loadFromURL(u"tdf111522.odp");
     auto pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
     pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_NEWWINDOW, 
SfxCallMode::SYNCHRON);
@@ -287,7 +230,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf126197)
 {
     // Load the document and create two new windows.
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf126197.odp"));
+    loadFromURL(u"tdf126197.odp");
     auto pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
     pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_NEWWINDOW, 
SfxCallMode::SYNCHRON);
@@ -318,7 +261,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf126197)
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf124708)
 {
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf124708.ppt"));
+    loadFromURL(u"tdf124708.ppt");
 
     dispatchCommand(mxComponent, ".uno:NextPage", {});
     Scheduler::ProcessEventsToIdle();
@@ -356,7 +299,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf143412)
     SdPage* pActualPage = pViewShell->GetActualPage();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pActualPage->GetObjCount());
 
-    OUString aImageURL = 
m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf143412.svg");
+    OUString aImageURL = createFileURL(u"tdf143412.svg");
     uno::Sequence<beans::PropertyValue> 
aArgs(comphelper::InitPropertySequence({
         { "FileName", uno::Any(aImageURL) },
     }));
@@ -420,8 +363,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf128651)
     // Error was, that undo and redo changes size of the shape. Affected 
actions were e.g.
     // extrusion on/off, shadow on/off, changes on line or fill attributes.
     // All these actions do not change the snap rectangle.
-    mxComponent = loadFromDesktop(
-        
m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf128651_CustomShapeUndo.odp"));
+    loadFromURL(u"tdf128651_CustomShapeUndo.odp");
     auto pXImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
     SdPage* pActualPage = pViewShell->GetActualPage();
@@ -772,7 +714,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127481)
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillColor)
 {
     // Load the document and create two new windows.
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf126197.odp"));
+    loadFromURL(u"tdf126197.odp");
     auto pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
 
@@ -798,7 +740,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillColor)
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient)
 {
     // Load the document and create two new windows.
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/tdf126197.odp"));
+    loadFromURL(u"tdf126197.odp");
     auto pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
 
@@ -829,8 +771,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient)
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
 {
     // Error was, that dashes and dots were longer than in MS Office.
-    mxComponent = loadFromDesktop(
-        
m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf134053_dashdot.pptx"));
+    loadFromURL(u"pptx/tdf134053_dashdot.pptx");
     auto pXImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
     SdPage* pActualPage = pViewShell->GetActualPage();
@@ -856,7 +797,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter)
 {
-    mxComponent = 
loadFromDesktop(m_directories.getURLFromSrc(u"sd/qa/unit/data/empty.fodp"));
+    loadFromURL(u"empty.fodp");
     auto pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     bool bSet = pImpressDocument->GetDoc()->GetOnlineSpell();
 
@@ -964,8 +905,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testSearchAllInDocumentAndNotes)
     // "find all" produces a crash when the search string exists in notes
     // and the document
 
-    mxComponent = loadFromDesktop(
-        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/search-all-notes.odp"));
+    loadFromURL(u"odp/search-all-notes.odp");
 
     auto pXImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
     sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
@@ -978,8 +918,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testSearchAllInDocumentAndNotes)
 // for some reason, the search for "second" (or "Second") didn't return page 2 
in WIN and MACOS
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf123658_SearchAfterSlideChange)
 {
-    mxComponent = loadFromDesktop(
-        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp"));
+    loadFromURL(u"odp/tdf123658_SearchAfterSlideChange.odp");
 
     auto pXImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
 
@@ -1144,10 +1083,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127696)
     dispatchCommand(mxComponent, ".uno:OutlineFont", {});
 
     // Save it as PPTX and load it again.
-    utl::TempFileNamed aTempFile;
-    save(dynamic_cast<SdXImpressDocument*>(mxComponent.get())->GetDocShell(), 
getFormat(PPTX),
-         aTempFile);
-    mxComponent = loadFromDesktop(aTempFile.GetURL());
+    saveAndReload("Impress Office Open XML");
 
     uno::Reference<drawing::XDrawPagesSupplier> 
xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
     uno::Reference<drawing::XDrawPage> 
xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(1),

Reply via email to