summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-11-10 22:34:07 +0100
committerRegina Henschel <rb.henschel@t-online.de>2021-11-12 15:55:52 +0100
commit87e5caca7d3133a32d92503bfa8e5a1409545187 (patch)
tree293112c748ab5886317241509df47af8a8e9664e /svx
parent9fdb9c5fd71e61ae673c79064e3249ce7207031a (diff)
tdf#143021 unit test enable 'matte' extrusion surface
This adds the missing unit test for commmit 70a4cb766ed356bc17433ac1673e977bb0bf3d2f. Thanks to Tomaž for extending the test framework to 3D. Change-Id: Iffaa163c3d453318bc0ed7f8703af15bd20c8966 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125013 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/qa/unit/data/tdf140321_Matte_import.pptbin0 -> 13312 bytes
-rw-r--r--svx/qa/unit/data/tdf140321_material_specular.odpbin0 -> 12939 bytes
-rw-r--r--svx/qa/unit/data/tdf140321_metal.odpbin0 -> 16876 bytes
-rw-r--r--svx/qa/unit/data/tdf140321_phong.odpbin0 -> 14088 bytes
-rw-r--r--svx/qa/unit/svdraw.cxx101
5 files changed, 101 insertions, 0 deletions
diff --git a/svx/qa/unit/data/tdf140321_Matte_import.ppt b/svx/qa/unit/data/tdf140321_Matte_import.ppt
new file mode 100644
index 000000000000..83e790fd414f
--- /dev/null
+++ b/svx/qa/unit/data/tdf140321_Matte_import.ppt
Binary files differ
diff --git a/svx/qa/unit/data/tdf140321_material_specular.odp b/svx/qa/unit/data/tdf140321_material_specular.odp
new file mode 100644
index 000000000000..03869914f54d
--- /dev/null
+++ b/svx/qa/unit/data/tdf140321_material_specular.odp
Binary files differ
diff --git a/svx/qa/unit/data/tdf140321_metal.odp b/svx/qa/unit/data/tdf140321_metal.odp
new file mode 100644
index 000000000000..a81ee0dfbcd1
--- /dev/null
+++ b/svx/qa/unit/data/tdf140321_metal.odp
Binary files differ
diff --git a/svx/qa/unit/data/tdf140321_phong.odp b/svx/qa/unit/data/tdf140321_phong.odp
new file mode 100644
index 000000000000..989a0848532c
--- /dev/null
+++ b/svx/qa/unit/data/tdf140321_phong.odp
Binary files differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 5050136991bf..f213af12f7de 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -48,6 +48,7 @@ class SvdrawTest : public test::BootstrapFixture, public unotest::MacrosTest, pu
{
protected:
uno::Reference<lang::XComponent> mxComponent;
+ SdrPage* getFirstDrawPageWithAssert();
public:
virtual void setUp() override
@@ -67,6 +68,37 @@ public:
uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
};
+SdrPage* SvdrawTest::getFirstDrawPageWithAssert()
+{
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
+ uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDrawPagesSupplier.is());
+ uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDrawPage.is());
+
+ auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get());
+ CPPUNIT_ASSERT(pDrawPage);
+ return pDrawPage->GetSdrPage();
+}
+
+xmlDocUniquePtr lcl_dumpAndParseFirstObjectWithAssert(SdrPage* pSdrPage)
+{
+ ScopedVclPtrInstance<VirtualDevice> aVirtualDevice;
+ sdr::contact::ObjectContactOfObjListPainter aObjectContact(*aVirtualDevice,
+ { pSdrPage->GetObj(0) }, nullptr);
+ const auto& rDrawPageVOContact
+ = pSdrPage->GetViewContact().GetViewObjectContact(aObjectContact);
+ sdr::contact::DisplayInfo aDisplayInfo;
+ drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence;
+ rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo, xPrimitiveSequence);
+
+ drawinglayer::Primitive2dXmlDump aDumper;
+ xmlDocUniquePtr pXmlDoc = aDumper.dumpAndParse(xPrimitiveSequence);
+ CPPUNIT_ASSERT(pXmlDoc);
+ return pXmlDoc;
+}
+
CPPUNIT_TEST_FIXTURE(SvdrawTest, testSemiTransparentText)
{
// Create a new Draw document with a rectangle.
@@ -391,6 +423,75 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testFontWorks)
assertXPath(pXmlDoc, "//scene/extrude3D[1]/object3Dattributes/material", "specularIntensity",
"20");
}
+
+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");
+
+ SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+
+ xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
+
+ // ODF specifies specular color as rgb(200,200,200) and adding 15 to specularity for metal=true
+ // without patch the specular color was #ffffff
+ assertXPath(pXmlDoc, "(//material)[1]", "specular", "#c8c8c8");
+ // specularIntensity = 100 - (80 + 15), with nominal value 80 in the file
+ // without patch specularIntensity was 15
+ assertXPath(pXmlDoc, "(//material)[1]", "specularIntensity", "5");
+}
+
+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");
+
+ SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+
+ xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
+
+ // The rendering method and normals kind were always 'Flat' without the patch.
+ assertXPath(pXmlDoc, "//scene", "shadeMode", "Phong");
+ assertXPath(pXmlDoc, "//object3Dattributes", "normalsKind", "Specific");
+}
+
+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");
+
+ SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+
+ xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
+
+ // The preset 'matte' in the PPT user interface sets the specularity of material to 0. To get the
+ // same effect in LO, specular of the lights need to be false in addition. Without patch the
+ // lights 1, 2, 3 are used, with patch lights 2, 3, 4. Thereby light 4 has the same color and
+ // direction as light 1, but without being specular. The dump has in both cases three lights, but
+ // without number. So we test as ersatz, that the third of them has the color of light 1. Being
+ // not light 1, it is never specular in LO, so no need to test.
+ // 'color' was "#464646" without patch.
+ assertXPath(pXmlDoc, "(//light)[3]", "color", "#aaaaaa");
+ // 'specularIntensity' was "15" without patch. specularIntensity = 100 - specularity of material.
+ assertXPath(pXmlDoc, "(//material)[1]", "specularIntensity", "100");
+}
+
+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");
+
+ SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+
+ xmlDocUniquePtr pXmlDoc = lcl_dumpAndParseFirstObjectWithAssert(pSdrPage);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // The material property 'draw:extrusion-specularity' was not applied to the object but to the
+ // scene. Without patch the object has always a default value 15 of specularIntensity. The file
+ // has specularity=77%. It should be specularIntensity = 100-77=23 with patch.
+ assertXPath(pXmlDoc, "(//material)[1]", "specularIntensity", "23");
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */