Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/vcl/qa/cppunit/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 3 kB image not shown  

Quelle  animationrenderer.cxx

  Sprache: C
 

/* -*- 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 <animate/AnimationRenderer.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; }
    bool CanAnimate() const override { return false; }
};

Animation createAnimation()
{
    Animation aAnimation;

    aAnimation.Insert(
        AnimationFrame(BitmapEx(Size(34), vcl::PixelFormat::N24_BPP), Point(00), Size(1010)));
    aAnimation.Insert(
        AnimationFrame(BitmapEx(Size(33), vcl::PixelFormat::N24_BPP), Point(00), Size(1010)));

    return aAnimation;
}
}

class VclAnimationRendererTest : public test::BootstrapFixture
{
public:
    VclAnimationRendererTest()
        : BootstrapFixture(truefalse)
    {
    }
};

CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testMatching)
{
    Animation aTestAnim = createAnimation();
    ScopedVclPtrInstance<TestRenderingContext> pTestRC;

    AnimationRenderer* pAnimationRenderer
        = new AnimationRenderer(&aTestAnim, pTestRC, Point(00), Size(1010), 5);
    CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 5));
    CPPUNIT_ASSERT(!pAnimationRenderer->matches(pTestRC, 10));

    // caller ID of 0 only matches the OutputDevice
    CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 0));
}

CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testDrawToPos)
{
    Animation aTestAnim = createAnimation();
    ScopedVclPtrInstance<VirtualDevice> pTestRC;

    AnimationRenderer* pAnimationRenderer
        = new AnimationRenderer(&aTestAnim, pTestRC.get(), Point(00), Size(1010), 5);
    pAnimationRenderer->drawToIndex(0);
    pAnimationRenderer->drawToIndex(1);
    pAnimationRenderer->drawToIndex(2);
    pAnimationRenderer->drawToIndex(10);

    CPPUNIT_ASSERT_EQUAL(Size(11), pTestRC->GetOutputSizePixel());
}

CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testGetPosSizeWindow)
{
    Animation aTestAnim = createAnimation();
    ScopedVclPtrInstance<TestRenderingContext> pTestRC;

    AnimationRenderer* pAnimationRenderer
        = new AnimationRenderer(&aTestAnim, pTestRC, Point(00), Size(1010), 5);
    AnimationFrame aAnimBmp(BitmapEx(Size(34), vcl::PixelFormat::N24_BPP), Point(00),
                            Size(1010));
    Point aPos;
    Size aSize;

    pAnimationRenderer->getPosSize(aAnimBmp, aPos, aSize);

    CPPUNIT_ASSERT_EQUAL(Point(00), aPos);
    CPPUNIT_ASSERT_EQUAL(Size(1010), aSize);
}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5 in Prozent
C=89 H=97 G=93

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.