calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / animationrenderer.cxx
blob86ad06c479416ece6a02457ec5c00d0970e3de2b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/bootstrapfixture.hxx>
11 #include <cppunit/TestAssert.h>
13 #include <vcl/animate/Animation.hxx>
14 #include <vcl/outdev.hxx>
15 #include <vcl/virdev.hxx>
17 #include <animate/AnimationRenderer.hxx>
19 namespace
21 class TestRenderingContext : public OutputDevice
23 public:
24 TestRenderingContext()
25 : OutputDevice(OutDevType::OUTDEV_VIRDEV)
29 void SaveBackground(VirtualDevice&, const Point&, const Size&, const Size&) const override {}
30 bool AcquireGraphics() const override { return true; }
31 void ReleaseGraphics(bool) override {}
32 bool UsePolyPolygonForComplexGradient() override { return false; }
36 class VclAnimationRendererTest : public test::BootstrapFixture
38 public:
39 VclAnimationRendererTest()
40 : BootstrapFixture(true, false)
44 void testMatching();
45 void testDrawToPos();
46 void testGetPosSizeWindow();
48 CPPUNIT_TEST_SUITE(VclAnimationRendererTest);
49 CPPUNIT_TEST(testMatching);
50 CPPUNIT_TEST(testDrawToPos);
51 CPPUNIT_TEST(testGetPosSizeWindow);
52 CPPUNIT_TEST_SUITE_END();
54 private:
55 Animation createAnimation();
58 void VclAnimationRendererTest::testMatching()
60 Animation aTestAnim = createAnimation();
61 ScopedVclPtrInstance<TestRenderingContext> pTestRC;
63 AnimationRenderer* pAnimationRenderer
64 = new AnimationRenderer(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
65 CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 5));
66 CPPUNIT_ASSERT(!pAnimationRenderer->matches(pTestRC, 10));
68 // caller ID of 0 only matches the OutputDevice
69 CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 0));
72 void VclAnimationRendererTest::testDrawToPos()
74 Animation aTestAnim = createAnimation();
75 ScopedVclPtrInstance<VirtualDevice> pTestRC;
77 AnimationRenderer* pAnimationRenderer
78 = new AnimationRenderer(&aTestAnim, pTestRC.get(), Point(0, 0), Size(10, 10), 5);
79 pAnimationRenderer->drawToIndex(0);
80 pAnimationRenderer->drawToIndex(1);
81 pAnimationRenderer->drawToIndex(2);
82 pAnimationRenderer->drawToIndex(10);
84 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel());
87 void VclAnimationRendererTest::testGetPosSizeWindow()
89 Animation aTestAnim = createAnimation();
90 ScopedVclPtrInstance<TestRenderingContext> pTestRC;
92 AnimationRenderer* pAnimationRenderer
93 = new AnimationRenderer(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
94 AnimationFrame aAnimBmp(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), Point(0, 0),
95 Size(10, 10));
96 Point aPos;
97 Size aSize;
99 pAnimationRenderer->getPosSize(aAnimBmp, aPos, aSize);
101 CPPUNIT_ASSERT_EQUAL(Point(0, 0), aPos);
102 CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize);
105 Animation VclAnimationRendererTest::createAnimation()
107 Animation aAnimation;
109 aAnimation.Insert(
110 AnimationFrame(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10)));
111 aAnimation.Insert(
112 AnimationFrame(BitmapEx(Size(3, 3), vcl::PixelFormat::N24_BPP), Point(0, 0), Size(10, 10)));
114 return aAnimation;
117 CPPUNIT_TEST_SUITE_REGISTRATION(VclAnimationRendererTest);
119 CPPUNIT_PLUGIN_IMPLEMENT();
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */