diff options
-rw-r--r-- | svx/CppunitTest_svx_unit.mk | 1 | ||||
-rw-r--r-- | svx/qa/unit/classicshapes.cxx | 37 | ||||
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 184 | ||||
-rw-r--r-- | svx/qa/unit/sdr.cxx | 41 | ||||
-rw-r--r-- | svx/qa/unit/svdraw.cxx | 79 | ||||
-rw-r--r-- | svx/qa/unit/table.cxx | 35 | ||||
-rw-r--r-- | svx/qa/unit/unodraw.cxx | 36 | ||||
-rw-r--r-- | svx/qa/unit/xml.cxx | 29 | ||||
-rw-r--r-- | svx/qa/unit/xoutdev.cxx | 41 |
9 files changed, 131 insertions, 352 deletions
diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index 8bc66bcd4d7c..9f22c2adba11 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -41,6 +41,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ drawinglayercore \ editeng \ sal \ + subsequenttest \ sfx \ svl \ svxcore \ diff --git a/svx/qa/unit/classicshapes.cxx b/svx/qa/unit/classicshapes.cxx index 39c3dc20ce77..5f7363952061 100644 --- a/svx/qa/unit/classicshapes.cxx +++ b/svx/qa/unit/classicshapes.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <rtl/ustring.hxx> #include <editeng/unoprnms.hxx> @@ -24,30 +23,17 @@ using namespace ::com::sun::star; namespace { -constexpr OUStringLiteral sDataDirectory(u"svx/qa/unit/data/"); - /// Tests not about special features of custom shapes, but about shapes in general. -class ClassicshapesTest : public test::BootstrapFixture, public unotest::MacrosTest +class ClassicshapesTest : public UnoApiTest { -protected: - uno::Reference<lang::XComponent> mxComponent; - uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex, sal_uInt8 nPageIndex); - public: - virtual void setUp() override + ClassicshapesTest() + : UnoApiTest("svx/qa/unit/data/") { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); } - virtual void tearDown() override - { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); - } +protected: + uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex, sal_uInt8 nPageIndex); }; uno::Reference<drawing::XShape> ClassicshapesTest::getShape(sal_uInt8 nShapeIndex, @@ -73,8 +59,7 @@ CPPUNIT_TEST_FIXTURE(ClassicshapesTest, testTdf98584ShearVertical) // They are converted to rotate * shear horizontal * scale. // Besides using a wrong sign in shear angle, error was, that TRSetGeometry of SdrPathObj did // not consider the additional scaling (tdf#98565). - const OUString sURL(m_directories.getURLFromSrc(sDataDirectory) + "tdf98584_ShearVertical.odg"); - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf98584_ShearVertical.odg"); // Tests skewY for (sal_uInt8 nPageIndex = 0; nPageIndex < 3; ++nPageIndex) @@ -143,9 +128,7 @@ CPPUNIT_TEST_FIXTURE(ClassicshapesTest, testTdf98583ShearHorizontal) // LT 8000,5000 and RB 14000, 9000, which means width 6001, height 4001. // Error was, that not the mathematical matrix was used, but the API matrix, which has // wrong sign in shear angle. - const OUString sURL(m_directories.getURLFromSrc(sDataDirectory) - + "tdf98583_ShearHorizontal.odp"); - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf98583_ShearHorizontal.odp"); for (sal_uInt8 nPageIndex = 0; nPageIndex < 2; ++nPageIndex) { @@ -182,9 +165,7 @@ CPPUNIT_TEST_FIXTURE(ClassicshapesTest, testTdf130076Flip) // transformed by a matrix equivalent to a horizontal flip. Error was // that the transformation was made before the CircleKind was set, // resulting in the flip being performed incorrectly. - const OUString sURL(m_directories.getURLFromSrc(sDataDirectory) - + "tdf130076_FlipOnSectorSection.odg"); - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf130076_FlipOnSectorSection.odg"); for (sal_uInt8 nPageIndex = 0; nPageIndex < 2; ++nPageIndex) { diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 72920aab2933..7d711f67d17e 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -11,8 +11,7 @@ #include <cstdlib> -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <rtl/ustring.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -51,32 +50,19 @@ using namespace ::com::sun::star; namespace { -constexpr OUStringLiteral sDataDirectory(u"svx/qa/unit/data/"); - /// Tests for svx/source/customshapes/ code. -class CustomshapesTest : public test::BootstrapFixture, public unotest::MacrosTest +class CustomshapesTest : public UnoApiTest { -protected: - uno::Reference<lang::XComponent> mxComponent; - // get shape nShapeIndex from page 0 - uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex); - sal_uInt8 countShapes(); - public: - virtual void setUp() override + CustomshapesTest() + : UnoApiTest("svx/qa/unit/data/") { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); } - virtual void tearDown() override - { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); - } +protected: + // get shape nShapeIndex from page 0 + uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex); + sal_uInt8 countShapes(); }; uno::Reference<drawing::XShape> CustomshapesTest::getShape(sal_uInt8 nShapeIndex) @@ -135,8 +121,7 @@ void lcl_AssertRectEqualWithTolerance(std::string_view sInfo, const tools::Recta CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf147409_GeomItemHash) { - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf147409_GeomItemHash.odg"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf147409_GeomItemHash.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape* pSdrCustomShape( static_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape))); @@ -153,8 +138,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf147409_GeomItemHash) CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf146866_GeomItemHash) { - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf147409_GeomItemHash.odg"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf147409_GeomItemHash.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape* pSdrCustomShape( static_cast<SdrObjCustomShape*>(SdrObject::getSdrObjectFromXShape(xShape))); @@ -174,8 +158,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_NonUI) // The document contains first light soft, no ambient color, no second light and shininess 6. // Such settings are not available in the UI. It tests the actual color, not the geometry. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145700_3D_NonUI.doc"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145700_3D_NonUI.doc"); // Generate bitmap from shape uno::Reference<drawing::XShape> xShape = getShape(0); @@ -213,8 +196,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_FrontLightDim) { // This tests the actual color, not the geometry. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145700_3D_FrontLightDim.doc"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145700_3D_FrontLightDim.doc"); // Generate bitmap from shape uno::Reference<drawing::XShape> xShape = getShape(0); @@ -245,9 +227,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_FrontLightDim) CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145700_3D_FirstLightHarsh) { // Load document - OUString aURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf145700_3D_FirstLightHarsh.doc"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145700_3D_FirstLightHarsh.doc"); // Generate bitmap from shape uno::Reference<drawing::XShape> xShape = getShape(0); @@ -276,8 +256,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145956_Origin_Relative_BoundRect) // Error (among others) was, that the unrotated snap rectangle was used. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145956_Origin.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf145956_Origin.odp"); // The shape is extruded with 10cm. viewpoint="(0cm 0cm 25cm)", origin="0 0". uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -298,8 +277,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145904_Extrusion_CenterZ_odt) // Error (among others) was, that the value was interpreted as Twips. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145904_center_Zminus2000.odt"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145904_center_Zminus2000.odt"); // The shape is extruded and tilt left 60deg. The rotation center is at -2000Hmm on the z-axis. // That is a position behind the back face of the extruded shape. @@ -323,8 +301,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145904_Extrusion_CenterY_odt) // shape size. Error was, that the relative fraction was handled as absolute value in Hmm. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145904_center_Y0dot25.odt"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145904_center_Y0dot25.odt"); // The shape is extruded and tilt down 90deg. The rotation center is in the middle between shape // center and bottom shape edge. The bottom edge of the projected solid has roughly the @@ -349,8 +326,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145904_Extrusion_CenterY_doc) // shape size. Error was, that the relative fraction was handled as absolute value in EMU. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145904_center_Y0dot25.doc"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument"); + loadFromURL(u"tdf145904_center_Y0dot25.doc"); // The shape is extruded and tilt down 90deg. The rotation center is in the middle between shape // center and bottom shape edge. The bottom edge of the projected solid has roughly the @@ -377,8 +353,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145245_ExtrusionPosition) // depth itself is 5cm. Y-coordinate of shape is 6cm. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145245_ExtrusionPosition.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf145245_ExtrusionPosition.odp"); // The tolerance 40 is estimated and can be adjusted if required for HiDPI. { @@ -423,8 +398,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_Fontwork_rendering_font_siz // the first paragraph was too long and the second would fit. It resulted in wrong position // and height and overlapping characters. - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf144988_Fontwork_FontSize.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf144988_Fontwork_FontSize.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); @@ -447,8 +421,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) // 'Top-Left' and 'Bottom-Left'. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145111_TL_BL_Fontwork.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf145111_TL_BL_Fontwork.odp"); { // First shape has anchor set to Top-Left, which shifts Fontwork text down. @@ -484,8 +457,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145004_gap_by_ScaleX) // Load document and get shape. It is a custom shape from pptx import of a WordArt of // kind 'Follow Path'. - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145004_gap_by_ScaleX.pptx"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf145004_gap_by_ScaleX.pptx"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); @@ -503,8 +475,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141021ExtrusionNorth) // side faces were wrong calculated. // Load document and get shape. It is a custom shape in 3D mode. - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf141021_ExtrusionNorth.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf141021_ExtrusionNorth.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); @@ -533,9 +504,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testResizeRotatedShape) // Problem was, that fObjectRotation was not updated. // Load document and get shape. It is a rectangle custom shape with 45° shear and 330° rotation. - OUString aURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf138945_resizeRotatedShape.odg"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf138945_resizeRotatedShape.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); // Change height and mirror vertical @@ -583,9 +552,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testViewBoxLeftTop) { // tdf#121890 formula values "left" and "top" are wrongly calculated // Load a document with two custom shapes of type "non-primitive" - OUString aURL - = m_directories.getURLFromSrc(sDataDirectory) + "viewBox_positive_twolines_strict.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"viewBox_positive_twolines_strict.odp"); // Get the shape "leftright". Error was, that the identifier "left" was always set to zero, thus // the path was outside the frame rectangle for a viewBox having a positive "left" value. uno::Reference<drawing::XShape> xShapeLR(getShape(0)); @@ -616,9 +583,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testAccuracyCommandX) // 121761 Increase accuracy of quarter circles drawn by command X or Y // The loaded document has a quarter circle with radius 10000 (unit 1/100 mm) // which is rotated by 45deg. The test considers the segment. - OUString aURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf121761_Accuracy_command_X.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf121761_Accuracy_command_X.odp"); // Get the shape "arc_45deg_rotated". Error was, that a Bezier curve with bad parameters // was used, thus the segment height was obviously smaller than for a true circle. // Math: segment height approx 10000 * ( 1 - sqrt(0.5)) + line width @@ -638,9 +603,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testToggleCommandXY) // The loaded document has a shape with command X and two parameter placed on a diagonal. // The radius of the quarter circles are both 10000 (unit 1/100 mm). // The shape is rotated by 45deg, so you get two segments, one up and one down. - OUString aURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf121952_Toggle_direction_command_X.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf121952_Toggle_direction_command_X.odp"); // Error was, that the second segment was drawn with same direction as first one. If drawn // correctly, the bounding box height of the segments together is about twice the single // segment height. Math: segment height approx 10000 * ( 1 - sqrt(0.5)) + line width @@ -658,8 +621,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testMultipleMoveTo) { // tdf122964 Multiple moveTo has to be treated as lineTo in draw:enhanced-path // Load a document with path "M 0 0 5 10 10 0 N" - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf122964_MultipleMoveTo.odg"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf122964_MultipleMoveTo.odg"); // Error was, that the second and further parameter pairs were treated as moveTo, // and so the generated path was empty, resulting in zero width and height of the // bounding box. It has to be treated same as "M 0 0 L 5 10 10 0 N". @@ -677,9 +639,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testWidthOrientationCommandU) // tdf121845 custom shape with command U (angleellipse) is wrongly drawn // Load a document with path "M 750 0 L 750 500 250 500 250 0 U 500 0 500 500 0 180 N" // in viewBox="0 0 1000 500" and width="10cm", height="5cm". - const OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf121845_WidthOrientation_command_U.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf121845_WidthOrientation_command_U.odg"); // Error was, that the width and height of the ellipse was halved and that the ellipse // was not drawn clockwise but counter clockwise. uno::Reference<drawing::XShape> xShape(getShape(0)); @@ -700,9 +660,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testHalfEllipseVML) // tdf121845 custom shape with command U (angleellipse) is wrongly drawn // Load a document which was converted from VML to doc by Word. It had a VML // path="m750,al500,,500,500,,-11796480e" resulting in a lower half circle. - const OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf121845_HalfEllipseVML.doc"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.text.TextDocument"); + loadFromURL(u"tdf121845_HalfEllipseVML.doc"); // Error was, that a full circle instead of the half circle was draw. uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); @@ -719,9 +677,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testLargeSwingAngleVML) // tdf121845 custom shape with command U (angleellipse) is wrongly drawn // Load a document which was converted from VML to doc by Word. It had a VML // path="al50,50,45,45,2621440,31457280e" resulting in a full circle plus 120 deg segment. - const OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf121845_start40_swing480.doc"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.text.TextDocument"); + loadFromURL(u"tdf121845_start40_swing480.doc"); // Error was, that only the 120 deg segment was drawn. uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); @@ -738,8 +694,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf121845_two_commands_U) // Load a document with path "U 950 250 200 200 90 180 250 250 200 200 180 270 N" // Error was, that the second ellipse segment was interpreted as command T and // thus a line from first to second segment was drawn. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf121845_Two_commands_U.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf121845_Two_commands_U.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); // In case no line is drawn, two polygons are generated; with line only one polygon SdrObjCustomShape& rSdrObjCustomShape( @@ -759,8 +714,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124212_handle_position) // default viewBox. Load a document with svg:viewBox="10800 0 10800 21600" // Error was, that moving the controller results in a handle position that // does not reflect the movement. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf124212_handle_position.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf124212_handle_position.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); // The shape has one, horizontal adjust handle. SdrObjCustomShape& rSdrObjCustomShape( @@ -782,8 +736,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124029_arc_position) // tdf121029 MS binary custom shape mso_sptArc has wrong position // MS uses the sector for position reference. Error was, that // LibreOffice has used the underlying ellipse. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf124029_Arc_position.doc"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.text.TextDocument"); + loadFromURL(u"tdf124029_Arc_position.doc"); uno::Reference<drawing::XShape> xShape(getShape(0)); // The visual wrong position is due to a wrong shape width. uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); @@ -799,9 +752,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124740_handle_path_coordsystem) // tdf124740 OOXML shape with handle and w and h attribute on path has wrong // handle position // The handle position was scaled erroneously twice. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf124740_HandleInOOXMLUserShape.pptx"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf124740_HandleInOOXMLUserShape.pptx"); uno::Reference<drawing::XShape> xShape(getShape(0)); // The shape has one, horizontal adjust handle. It is about 1/5 of 10cm from left // shape edge, shape is 6cm from left . That results in a position @@ -824,9 +775,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf115813_OOXML_XY_handle) // Connectors are included as ordinary shapes to prevent converting. // Error was, that the handle movement and the changes to the shape did not follow // the mouse movement. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) - + "tdf115813_HandleMovementOOXMLPresetShapes.pptx"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf115813_HandleMovementOOXMLPresetShapes.pptx"); // values in vector InteractionsHandles are in 1/100 mm and refer to page for (sal_uInt8 i = 0; i < countShapes(); i++) @@ -879,9 +828,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testQuadraticCurveTo) // When converting to cubic Bezier curve, this had resulted in a wrong first control point. // The quadraticcurveto segment starts in shape center in the test file. The first control // point should produce a horizontal tangent in the start point. - const OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf125782_QuadraticCurveTo.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf125782_QuadraticCurveTo.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is()); @@ -899,9 +846,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf126512_OOXML_handle_in_ODP) // opened and exported to ODF format by LibreOffice. // Error was, that for shapes, which were originally imported from OOXML, the handles // could not be moved at all. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf126512_OOXMLHandleMovementInODF.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf126512_OOXMLHandleMovementInODF.odp"); for (sal_uInt8 i = 0; i < countShapes(); i++) { @@ -945,8 +890,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Mirror) // and therefore equals approximately the text frame. // Error was, that because of wrong calculation, the flipped shapes do not use the // text frame but the frame rectangle for their text. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf127785_Mirror.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf127785_Mirror.odp"); uno::Reference<drawing::XShape> xShapeV(getShape(0)); uno::Reference<beans::XPropertySet> xShapeVProps(xShapeV, uno::UNO_QUERY); @@ -983,8 +927,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf126060_3D_Z_Rotation) // and the text has 3D z rotation. When we open the document we // should see the text vertically and rotated from text bound center not text box. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf126060_3D_Z_Rotation.pptx"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf126060_3D_Z_Rotation.pptx"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape& rSdrObjCustomShape( @@ -1018,9 +961,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Asymmetric) // the text and therefore equals approximately the text frame. // Error was, that the 180deg text rotation was not compensated for the position of // the flipped text box. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf127785_asymmetricTextBoxFlipV.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf127785_asymmetricTextBoxFlipV.odg"); uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); @@ -1043,8 +984,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_TextRotateAngle) // surrounds the text and therefore equals approximately the text frame. // Error was, that the compensation for the 180° rotation added for vertical // flip were not made to the text box position but to the text matrix. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf127785_TextRotateAngle.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf127785_TextRotateAngle.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); @@ -1065,8 +1005,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf128413_tbrlOnOff) // The document contains a rotated shape with text. The error was, that switching // tb-rl writing-mode on, changed the shape size and position. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf128413_tbrl_OnOff.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf128413_tbrl_OnOff.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is()); @@ -1093,8 +1032,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf129532_MatrixFlipV) // attribute. That should result in mirroring on the x-axis. Error was, that the lines // which are drawn on the shape rectangle were mirrored, but not the rectangle itself. // The rectangle was only shifted. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf129532_MatrixFlipV.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf129532_MatrixFlipV.odg"); uno::Reference<drawing::XShape> xShape0(getShape(0)); uno::Reference<beans::XPropertySet> xShape0Props(xShape0, uno::UNO_QUERY); @@ -1120,9 +1058,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandT_CaseZeroHeight) // corner case where the ellipse has zero height. // Error was, that the calculation of the circle angle from the ellipse // angle results in a wrong angle for the case 180° and height zero. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf103474_commandT_CaseZeroHeight.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf103474_commandT_CaseZeroHeight.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); // The end points of the straight line segment should have the same x-coordinate of left // of shape, and different y-coordinates, one top and the other bottom of the shape. @@ -1150,9 +1086,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandT_CaseZeroHeight) CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandG_CaseZeroHeight) { // Some as above, but with shape with command G. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf103474_commandG_CaseZeroHeight.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf103474_commandG_CaseZeroHeight.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); // The end points of the straight line segment should have the same x-coordinate of left // of shape, and different y-coordinates, one top and the other bottom of the shape. @@ -1181,9 +1115,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf122323_largeSwingAngle) { // SwingAngles are clamped to [-360;360] in MS Office. Error was, that LO calculated // the end angle and used it modulo 360, no full ellipse was drawn. - OUString sURL - = m_directories.getURLFromSrc(sDataDirectory) + "tdf122323_swingAngle_larger360deg.pptx"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf122323_swingAngle_larger360deg.pptx"); uno::Reference<drawing::XShape> xShape(getShape(0)); uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); SdrObjCustomShape& rSdrObjCustomShape( @@ -1202,8 +1134,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf122323_largeSwingAngle) CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141268) { - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf141268.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument"); + loadFromURL(u"tdf141268.odp"); uno::Reference<drawing::XShape> xShape(getShape(0)); SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); @@ -1218,8 +1149,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf136176) { // Error was, that fObjectRotation was not correctly updated after shearing. // The problem becomes visible after save and reload. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf136176_rot30_flip.odg"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf136176_rot30_flip.odg"); for (sal_uInt16 i = 0; i < 3; i++) { @@ -1233,14 +1163,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf136176) } // Save and reload - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw8"); - xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - mxComponent->dispose(); - mxComponent = loadFromDesktop(aTempFile.GetURL()); + saveAndReload("draw8"); // Expected values of point 4 of the shape polygon const OString sTestCase[] = { "FlipH", "FlipV", "FlipHV" }; @@ -1271,8 +1194,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148501_OctagonBevel) // The document contains a shape "Octagon Bevel". It should use shadings 40%, 20%, -20%, -40% // from left-top to bottom-right. The test examines actual color, not the geometry. // Load document - OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf148501_OctagonBevel.odp"; - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf148501_OctagonBevel.odp"); // Generate bitmap from shape uno::Reference<drawing::XShape> xShape = getShape(0); @@ -1342,8 +1264,7 @@ bool lcl_getShapeSegments(uno::Sequence<drawing::EnhancedCustomShapeSegment>& rS CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148714_CurvedArrows) { // Error was, that the line between 1. and 2. arc was missing. - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf148714_CurvedArrows.ppt"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf148714_CurvedArrows.ppt"); for (sal_Int32 nShapeIndex = 0; nShapeIndex < 4; nShapeIndex++) { @@ -1384,8 +1305,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148707_two_commands_B_V) // between the arcs as if the second command was a A or W respectively. // The test document has a shape with path "V 0 0 50 100 0 50 25 0 50 0 100 100 75 0 100 50 N" // and a shape with path "B 0 0 50 100 0 50 25 100 50 0 100 100 75 100 100 50 N". - OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf148707_two_commands_B_V.odp"; - mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"tdf148707_two_commands_B_V.odp"); for (sal_uInt8 i = 0; i < 2; i++) { uno::Reference<drawing::XShape> xShape(getShape(i)); diff --git a/svx/qa/unit/sdr.cxx b/svx/qa/unit/sdr.cxx index d665987b1179..9aa087c56f4c 100644 --- a/svx/qa/unit/sdr.cxx +++ b/svx/qa/unit/sdr.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <test/xmltesttools.hxx> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> @@ -30,27 +29,13 @@ using namespace ::com::sun::star; namespace { /// Tests for svx/source/sdr/ code. -class SdrTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SdrTest : public UnoApiTest, public XmlTestTools { -protected: - uno::Reference<lang::XComponent> mxComponent; - public: - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); - } - - virtual void tearDown() override + SdrTest() + : UnoApiTest("svx/qa/unit/data/") { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); } - uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } drawinglayer::primitive2d::Primitive2DContainer renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage); @@ -76,10 +61,8 @@ SdrTest::renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawP CPPUNIT_TEST_FIXTURE(SdrTest, testShadowScaleOrigin) { // Load a document containing a custom shape. - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/shadow-scale-origin.pptx"); - getComponent() = loadFromDesktop(aURL); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + loadFromURL(u"shadow-scale-origin.pptx"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence @@ -102,10 +85,8 @@ CPPUNIT_TEST_FIXTURE(SdrTest, testShadowScaleOrigin) CPPUNIT_TEST_FIXTURE(SdrTest, testZeroWidthTextWrap) { // Load a document containing a 0-width shape with text. - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/0-width-text-wrap.pptx"); - getComponent() = loadFromDesktop(aURL); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + loadFromURL(u"0-width-text-wrap.pptx"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence @@ -124,10 +105,8 @@ CPPUNIT_TEST_FIXTURE(SdrTest, testZeroWidthTextWrap) CPPUNIT_TEST_FIXTURE(SdrTest, testSlideBackground) { // Given a document with a slide what has a linked background image: - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/slide-background.odp"); - getComponent() = loadFromDesktop(aURL); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + loadFromURL(u"slide-background.odp"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 90030296e1c8..0e4306f8a5f2 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <test/xmltesttools.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -48,28 +47,16 @@ using namespace ::com::sun::star; namespace { /// Tests for svx/source/svdraw/ code. -class SvdrawTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SvdrawTest : public UnoApiTest, public XmlTestTools { -protected: - uno::Reference<lang::XComponent> mxComponent; - SdrPage* getFirstDrawPageWithAssert(); - public: - virtual void setUp() override + SvdrawTest() + : UnoApiTest("svx/qa/unit/data/") { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); } - virtual void tearDown() override - { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); - } - uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } +protected: + SdrPage* getFirstDrawPageWithAssert(); }; SdrPage* SvdrawTest::getFirstDrawPageWithAssert() @@ -106,14 +93,14 @@ xmlDocUniquePtr lcl_dumpAndParseFirstObjectWithAssert(SdrPage* pSdrPage) CPPUNIT_TEST_FIXTURE(SvdrawTest, testSemiTransparentText) { // Create a new Draw document with a rectangle. - getComponent() = loadFromDesktop("private:factory/sdraw"); - uno::Reference<lang::XMultiServiceFactory> xFactory(getComponent(), uno::UNO_QUERY); + mxComponent = loadFromDesktop("private:factory/sdraw"); + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape( xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); xShape->setSize(awt::Size(10000, 10000)); xShape->setPosition(awt::Point(1000, 1000)); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); xDrawPage->add(xShape); @@ -147,8 +134,8 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testSemiTransparentText) CPPUNIT_TEST_FIXTURE(SvdrawTest, testHandlePathObjScale) { // Given a path object: - getComponent() = loadFromDesktop("private:factory/sdraw"); - uno::Reference<lang::XMultiServiceFactory> xFactory(getComponent(), uno::UNO_QUERY); + mxComponent = loadFromDesktop("private:factory/sdraw"); + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape( xFactory->createInstance("com.sun.star.drawing.ClosedBezierShape"), uno::UNO_QUERY); @@ -161,7 +148,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testHandlePathObjScale) xShapeProps->setPropertyValue("LineStyle", uno::Any(drawing::LineStyle_SOLID)); xShapeProps->setPropertyValue("FillColor", uno::Any(static_cast<sal_Int32>(0))); // Add it to the draw page. - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); xDrawPage->add(xShape); @@ -225,8 +212,8 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testHandlePathObjScale) CPPUNIT_TEST_FIXTURE(SvdrawTest, testTextEditEmptyGrabBag) { // Given a document with a groupshape, which has 2 children. - getComponent() = loadFromDesktop("private:factory/sdraw"); - uno::Reference<lang::XMultiServiceFactory> xFactory(getComponent(), uno::UNO_QUERY); + mxComponent = loadFromDesktop("private:factory/sdraw"); + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XShape> xRect1( xFactory->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY); xRect1->setPosition(awt::Point(1000, 1000)); @@ -237,7 +224,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testTextEditEmptyGrabBag) xRect2->setSize(awt::Size(10000, 10000)); uno::Reference<drawing::XShapes> xGroup( xFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShape> xGroupShape(xGroup, uno::UNO_QUERY); @@ -353,15 +340,11 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testAutoHeightMultiColShape) // Given a document containing a shape that has: // 1) automatic height (resize shape to fix text) // 2) multiple columns (2) - OUString aURL - = m_directories.getURLFromSrc(u"svx/qa/unit/data/auto-height-multi-col-shape.pptx"); - - // When loading that document: - getComponent().set(loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument")); + loadFromURL(u"auto-height-multi-col-shape.pptx"); // Make sure the in-file shape height is kept, even if nominally the shape height is // automatic: - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); @@ -378,8 +361,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testAutoHeightMultiColShape) CPPUNIT_TEST_FIXTURE(SvdrawTest, testFontWorks) { - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/FontWork.odg"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.drawing.DrawingDocument"); + loadFromURL(u"FontWork.odg"); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY_THROW); @@ -407,8 +389,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testFontWorks) CPPUNIT_TEST_FIXTURE(SvdrawTest, testSurfaceMetal) { - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/tdf140321_metal.odp"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf140321_metal.odp"); SdrPage* pSdrPage = getFirstDrawPageWithAssert(); @@ -424,8 +405,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testSurfaceMetal) CPPUNIT_TEST_FIXTURE(SvdrawTest, testExtrusionPhong) { - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/tdf140321_phong.odp"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf140321_phong.odp"); SdrPage* pSdrPage = getFirstDrawPageWithAssert(); @@ -438,8 +418,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testExtrusionPhong) CPPUNIT_TEST_FIXTURE(SvdrawTest, testSurfaceMattePPT) { - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/tdf140321_Matte_import.ppt"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf140321_Matte_import.ppt"); SdrPage* pSdrPage = getFirstDrawPageWithAssert(); @@ -463,9 +442,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testSurfaceMattePPT) CPPUNIT_TEST_FIXTURE(SvdrawTest, testMaterialSpecular) { - OUString aURL - = m_directories.getURLFromSrc(u"svx/qa/unit/data/tdf140321_material_specular.odp"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"tdf140321_material_specular.odp"); SdrPage* pSdrPage = getFirstDrawPageWithAssert(); @@ -489,8 +466,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot) { // Given a slide with a media shape, containing a 4 sec video, red-green-blue-black being the 4 // seconds: - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/video-snapshot.pptx"); - mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + loadFromURL(u"video-snapshot.pptx"); SdrPage* pSdrPage = getFirstDrawPageWithAssert(); auto pSdrMediaObj = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0)); @@ -516,15 +492,10 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot) CPPUNIT_TEST_FIXTURE(SvdrawTest, testPageViewDrawLayerClip) { // Given a document with 2 pages, first page footer has an off-page line shape: - OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/page-view-draw-layer-clip.docx"); - mxComponent = loadFromDesktop(aURL); + loadFromURL(u"page-view-draw-layer-clip.docx"); // When saving that document to PDF: - utl::TempFileNamed aTempFile; - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); - xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + utl::TempFileNamed aTempFile = save("writer_pdf_Export"); // Then make sure that line shape gets clipped: SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ); diff --git a/svx/qa/unit/table.cxx b/svx/qa/unit/table.cxx index c68abe18beea..c91344c24b6d 100644 --- a/svx/qa/unit/table.cxx +++ b/svx/qa/unit/table.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <test/xmltesttools.hxx> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> @@ -35,27 +34,13 @@ using namespace ::com::sun::star; namespace { /// Tests for svx/source/table/ code. -class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class Test : public UnoApiTest, public XmlTestTools { -protected: - uno::Reference<lang::XComponent> mxComponent; - public: - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); - } - - virtual void tearDown() override + Test() + : UnoApiTest("svx/qa/unit/data/") { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); } - uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } drawinglayer::primitive2d::Primitive2DContainer renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage); @@ -81,12 +66,10 @@ Test::renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage CPPUNIT_TEST_FIXTURE(Test, testTableShadowBlur) { // Given a document containing a table with a blurry shadow: - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/table-shadow-blur.pptx"); - getComponent() = loadFromDesktop(aURL); + loadFromURL(u"table-shadow-blur.pptx"); // When rendering the table shadow to primitives: - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence @@ -108,13 +91,13 @@ CPPUNIT_TEST_FIXTURE(Test, testTableShadowBlur) CPPUNIT_TEST_FIXTURE(Test, testSvxTableControllerSetAttrToSelectedShape) { // Given a document with a table shape, editing cell text: - getComponent() = loadFromDesktop("private:factory/simpress", - "com.sun.star.presentation.PresentationDocument"); + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue("Rows", sal_Int32(2)), comphelper::makePropertyValue("Columns", sal_Int32(2)) }; dispatchCommand(mxComponent, ".uno:InsertTable", aArgs); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get()); diff --git a/svx/qa/unit/unodraw.cxx b/svx/qa/unit/unodraw.cxx index a1c8fd9d6249..51dae19dba00 100644 --- a/svx/qa/unit/unodraw.cxx +++ b/svx/qa/unit/unodraw.cxx @@ -23,8 +23,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <unotools/tempfile.hxx> #include <svx/unopage.hxx> #include <vcl/virdev.hxx> @@ -43,39 +42,20 @@ using namespace ::com::sun::star; namespace { -constexpr OUStringLiteral DATA_DIRECTORY = u"/svx/qa/unit/data/"; - /// Tests for svx/source/unodraw/ code. -class UnodrawTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class UnodrawTest : public UnoApiTest, public XmlTestTools { -protected: - uno::Reference<lang::XComponent> mxComponent; - public: - void setUp() override; - void tearDown() override; + UnodrawTest() + : UnoApiTest("svx/qa/unit/data/") + { + } }; -void UnodrawTest::setUp() -{ - test::BootstrapFixture::setUp(); - - mxDesktop.set(frame::Desktop::create(mxComponentContext)); -} - -void UnodrawTest::tearDown() -{ - if (mxComponent.is()) - mxComponent->dispose(); - - test::BootstrapFixture::tearDown(); -} - CPPUNIT_TEST_FIXTURE(UnodrawTest, testWriterGraphicExport) { // Load a document with a Writer picture in it. - OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "unodraw-writer-image.odt"; - mxComponent = loadFromDesktop(aURL); + loadFromURL(u"unodraw-writer-image.odt"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); uno::Reference<lang::XComponent> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); @@ -97,7 +77,7 @@ CPPUNIT_TEST_FIXTURE(UnodrawTest, testWriterGraphicExport) CPPUNIT_TEST_FIXTURE(UnodrawTest, testTdf93998) { - mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf93998.odp"); + loadFromURL(u"tdf93998.odp"); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); CPPUNIT_ASSERT(xDrawPagesSupplier.is()); diff --git a/svx/qa/unit/xml.cxx b/svx/qa/unit/xml.cxx index de16b39be5a3..4771ca16c289 100644 --- a/svx/qa/unit/xml.cxx +++ b/svx/qa/unit/xml.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> @@ -23,36 +22,20 @@ using namespace ::com::sun::star; namespace { /// Tests for svx/source/xml/ code. -class Test : public test::BootstrapFixture, public unotest::MacrosTest +class Test : public UnoApiTest { -protected: - uno::Reference<lang::XComponent> mxComponent; - public: - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - mxDesktop.set(frame::Desktop::create(m_xContext)); - } - - virtual void tearDown() override + Test() + : UnoApiTest("svx/qa/unit/data/") { - if (mxComponent.is()) - { - mxComponent->dispose(); - } - test::BootstrapFixture::tearDown(); } - uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } }; CPPUNIT_TEST_FIXTURE(Test, test3DObjectFallback) { // Load a document which has a 3D model we don't understand, but has a fallback PNG. - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/3d-object-fallback.odp"); - getComponent() = loadFromDesktop(aURL); - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + loadFromURL(u"3d-object-fallback.odp"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx index 83f7c2801b06..52eb64ed7b1f 100644 --- a/svx/qa/unit/xoutdev.cxx +++ b/svx/qa/unit/xoutdev.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include <test/unoapi_test.hxx> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> @@ -25,31 +24,15 @@ using namespace com::sun::star; -class XOutdevTest : public test::BootstrapFixture, public unotest::MacrosTest +class XOutdevTest : public UnoApiTest { - uno::Reference<lang::XComponent> mxComponent; - public: - virtual void setUp() override; - void tearDown() override; - uno::Reference<lang::XComponent>& getComponent() { return mxComponent; } + XOutdevTest() + : UnoApiTest("svx/qa/unit/data/") + { + } }; -void XOutdevTest::setUp() -{ - test::BootstrapFixture::setUp(); - - mxDesktop.set(frame::Desktop::create(mxComponentContext)); -} - -void XOutdevTest::tearDown() -{ - if (mxComponent.is()) - mxComponent->dispose(); - - test::BootstrapFixture::tearDown(); -} - CPPUNIT_TEST_FIXTURE(XOutdevTest, testPdfGraphicExport) { auto pPdfium = vcl::pdf::PDFiumLibrary::get(); @@ -60,8 +43,7 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testPdfGraphicExport) // Import the graphic. Graphic aGraphic; - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/graphic.pdf"); + OUString aURL = createFileURL(u"graphic.pdf"); SvFileStream aStream(aURL, StreamMode::READ); CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURL, aStream)); @@ -89,8 +71,7 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testPdfGraphicExport) CPPUNIT_TEST_FIXTURE(XOutdevTest, testTdf60684) { Graphic aGraphic; - test::Directories aDirectories; - OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/tdf60684.jpg"); + OUString aURL = createFileURL(u"tdf60684.jpg"); SvFileStream aStream(aURL, StreamMode::READ); CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURL, aStream)); @@ -117,11 +98,11 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, testTdf60684) CPPUNIT_TEST_FIXTURE(XOutdevTest, testFillColorThemeUnoApi) { // Given an empty Impress document with a (title) shape: - getComponent() = loadFromDesktop("private:factory/simpress", - "com.sun.star.presentation.PresentationDocument"); + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); // When setting the theme index of the shape's fill color: - uno::Reference<drawing::XDrawPagesSupplier> xPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPagesSupplier> xPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xPage(xPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY); |