vcl/CppunitTest_vcl_animation.mk |   43 +++++++++++++
 vcl/Module_vcl.mk                |    1 
 vcl/inc/impanmvw.hxx             |    6 -
 vcl/qa/cppunit/implanimview.cxx  |  121 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 168 insertions(+), 3 deletions(-)

New commits:
commit f4e2d7b006aa86732b30bb7e2f219360481fc724
Author:     Chris Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Sun Jul 28 19:16:53 2019 +1000
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri May 6 16:06:48 2022 +0200

    vcl: test ImplAnimView
    
    Change-Id: I1f17dce097810e4507a9feae1675ff486260657a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121698
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/CppunitTest_vcl_animation.mk b/vcl/CppunitTest_vcl_animation.mk
new file mode 100644
index 000000000000..3ff256daa7b2
--- /dev/null
+++ b/vcl/CppunitTest_vcl_animation.mk
@@ -0,0 +1,43 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_animation))
+
+$(eval $(call gb_CppunitTest_set_include,vcl_animation,\
+    -I$(SRCDIR)/vcl/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_animation, \
+       vcl/qa/cppunit/implanimview \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_animation, \
+       test \
+       unotest \
+       vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_animation, \
+       boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,vcl_animation))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_animation))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_animation))
+
+$(eval $(call gb_CppunitTest_use_components,vcl_animation,\
+       configmgr/source/configmgr \
+       i18npool/util/i18npool \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,vcl_animation))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 33485fefa52a..62660b718ec1 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -218,6 +218,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\
     CppunitTest_vcl_backend_test \
     CppunitTest_vcl_blocklistparser_test \
     CppunitTest_vcl_type_serializer_test \
+    CppunitTest_vcl_animation \
     $(call gb_Helper_optional, PDFIUM, \
         CppunitTest_vcl_pdfium_library_test) \
     $(if $(filter SKIA,$(BUILD_TYPE)), \
diff --git a/vcl/inc/impanmvw.hxx b/vcl/inc/impanmvw.hxx
index 99bd7cd5dff2..be48421f5abd 100644
--- a/vcl/inc/impanmvw.hxx
+++ b/vcl/inc/impanmvw.hxx
@@ -20,6 +20,7 @@
 #ifndef INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX
 #define INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX
 
+#include <vcl/dllapi.h>
 #include <vcl/animate/Animation.hxx>
 #include <vcl/vclptr.hxx>
 
@@ -41,7 +42,7 @@ struct AInfo
 };
 
 
-class ImplAnimView
+class VCL_DLLPUBLIC ImplAnimView
 {
 private:
 
@@ -68,11 +69,10 @@ private:
     bool            mbIsMirroredVertically;
 
 public:
-                    ~ImplAnimView();
-private:
                     ImplAnimView( Animation* pParent, OutputDevice* pOut,
                                   const Point& rPt, const Size& rSz, sal_uLong 
nExtraData,
                                   OutputDevice* pFirstFrameOutDev = nullptr );
+                    ~ImplAnimView();
 
     bool            matches(const OutputDevice* pOut, tools::Long nExtraData) 
const;
     void            drawToPos( sal_uLong nPos );
diff --git a/vcl/qa/cppunit/implanimview.cxx b/vcl/qa/cppunit/implanimview.cxx
new file mode 100644
index 000000000000..01386fac048d
--- /dev/null
+++ b/vcl/qa/cppunit/implanimview.cxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/TestAssert.h>
+
+#include <vcl/animate/Animation.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/virdev.hxx>
+
+#include <impanmvw.hxx>
+
+namespace
+{
+class TestRenderingContext : public OutputDevice
+{
+public:
+    TestRenderingContext()
+        : OutputDevice(OutDevType::OUTDEV_VIRDEV)
+    {
+    }
+
+    void SaveBackground(VirtualDevice&, const Point&, const Size&, const 
Size&) const override {}
+    bool AcquireGraphics() const override { return true; }
+    void ReleaseGraphics(bool) override {}
+    bool UsePolyPolygonForComplexGradient() override { return false; }
+};
+}
+
+class VclImplAnimViewTest : public test::BootstrapFixture
+{
+public:
+    VclImplAnimViewTest()
+        : BootstrapFixture(true, false)
+    {
+    }
+
+    void testMatching();
+    void testDrawToPos();
+    void testGetPosSizeWindow();
+
+    CPPUNIT_TEST_SUITE(VclImplAnimViewTest);
+    CPPUNIT_TEST(testMatching);
+    CPPUNIT_TEST(testDrawToPos);
+    CPPUNIT_TEST(testGetPosSizeWindow);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    Animation createAnimation();
+};
+
+void VclImplAnimViewTest::testMatching()
+{
+    Animation aTestAnim = createAnimation();
+    ScopedVclPtrInstance<TestRenderingContext> pTestRC;
+
+    ImplAnimView* pImplAnimView
+        = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
+    CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 5));
+    CPPUNIT_ASSERT(!pImplAnimView->matches(pTestRC, 10));
+
+    // caller ID of 0 only matches the OutputDevice
+    CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 0));
+}
+
+void VclImplAnimViewTest::testDrawToPos()
+{
+    Animation aTestAnim = createAnimation();
+    ScopedVclPtrInstance<VirtualDevice> pTestRC;
+
+    ImplAnimView* pImplAnimView
+        = new ImplAnimView(&aTestAnim, pTestRC.get(), Point(0, 0), Size(10, 
10), 5);
+    pImplAnimView->drawToPos(0);
+    pImplAnimView->drawToPos(1);
+    pImplAnimView->drawToPos(2);
+    pImplAnimView->drawToPos(10);
+
+    CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel());
+}
+
+void VclImplAnimViewTest::testGetPosSizeWindow()
+{
+    Animation aTestAnim = createAnimation();
+    ScopedVclPtrInstance<TestRenderingContext> pTestRC;
+
+    ImplAnimView* pImplAnimView
+        = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
+    AnimationBitmap aAnimBmp(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), 
Point(0, 0),
+                             Size(10, 10));
+    Point aPos;
+    Size aSize;
+
+    pImplAnimView->getPosSize(aAnimBmp, aPos, aSize);
+
+    CPPUNIT_ASSERT_EQUAL(Point(0, 0), aPos);
+    CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize);
+}
+
+Animation VclImplAnimViewTest::createAnimation()
+{
+    Animation aAnimation;
+
+    aAnimation.Insert(AnimationBitmap(BitmapEx(Size(3, 4), 
vcl::PixelFormat::N24_BPP), Point(0, 0),
+                                      Size(10, 10)));
+    aAnimation.Insert(AnimationBitmap(BitmapEx(Size(3, 3), 
vcl::PixelFormat::N24_BPP), Point(0, 0),
+                                      Size(10, 10)));
+
+    return aAnimation;
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VclImplAnimViewTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to