calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / qa / cppunit / fontmetric.cxx
blobbf2585ac38a78bc9295c274c30367b066cdbba06
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/metric.hxx>
15 class VclFontMetricTest : public test::BootstrapFixture
17 public:
18 VclFontMetricTest() : BootstrapFixture(true, false) {}
20 void testFullstopCenteredFlag();
21 void testSpacings();
22 void testSlant();
23 void testBulletOffset();
24 void testEqualityOperator();
26 CPPUNIT_TEST_SUITE(VclFontMetricTest);
27 CPPUNIT_TEST(testFullstopCenteredFlag);
28 CPPUNIT_TEST(testSpacings);
29 CPPUNIT_TEST(testSlant);
30 CPPUNIT_TEST(testBulletOffset);
31 CPPUNIT_TEST(testEqualityOperator);
32 CPPUNIT_TEST_SUITE_END();
35 void VclFontMetricTest::testFullstopCenteredFlag()
37 // default constructor should set scalable flag to false
38 FontMetric aFontMetric;
40 CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag should be false after default constructor called", !aFontMetric.IsFullstopCentered() );
42 aFontMetric.SetFullstopCenteredFlag(true);
44 CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag should be true", aFontMetric.IsFullstopCentered() );
47 void VclFontMetricTest::testSpacings()
49 // default constructor should set scalable flag to false
50 FontMetric aFontMetric;
52 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetAscent());
53 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetDescent());
54 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetExternalLeading());
55 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetInternalLeading());
56 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetLineHeight());
59 aFontMetric.SetAscent( 100 );
60 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aFontMetric.GetAscent());
62 aFontMetric.SetDescent( 100 );
63 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aFontMetric.GetDescent());
65 aFontMetric.SetExternalLeading( 100 );
66 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aFontMetric.GetExternalLeading());
68 aFontMetric.SetInternalLeading( 100 );
69 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aFontMetric.GetInternalLeading());
71 aFontMetric.SetLineHeight( 100 );
72 CPPUNIT_ASSERT_EQUAL(sal_Int32(100), aFontMetric.GetLineHeight());
75 void VclFontMetricTest::testSlant()
77 // default constructor should set scalable flag to false
78 FontMetric aFontMetric;
80 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetSlant());
82 aFontMetric.SetSlant( 45 );
83 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), aFontMetric.GetSlant());
86 void VclFontMetricTest::testBulletOffset()
88 // default constructor should set scalable flag to false
89 FontMetric aFontMetric;
91 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aFontMetric.GetBulletOffset());
93 aFontMetric.SetBulletOffset( 45 );
94 CPPUNIT_ASSERT_EQUAL(sal_Int32(45), aFontMetric.GetBulletOffset());
97 void VclFontMetricTest::testEqualityOperator()
99 // default constructor should set scalable flag to false
100 FontMetric aLhs, aRhs;
102 aLhs.SetFullstopCenteredFlag(true);
103 aRhs.SetFullstopCenteredFlag(true);
104 CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs == aRhs failed", aLhs.operator ==(aRhs) );
105 CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs != aRhs succeeded", !aLhs.operator !=(aRhs) );
107 aLhs.SetExternalLeading(10);
108 aRhs.SetExternalLeading(10);
109 CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
110 CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
112 aLhs.SetInternalLeading(10);
113 aRhs.SetInternalLeading(10);
114 CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
115 CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
117 aLhs.SetAscent( 100 );
118 aRhs.SetAscent( 100 );
119 CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
120 CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
122 aLhs.SetDescent( 100 );
123 aRhs.SetDescent( 100 );
124 CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS == aRhs failed", aLhs.operator ==(aRhs));
125 CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
127 aLhs.SetSlant( 100 );
128 aRhs.SetSlant( 100 );
129 CPPUNIT_ASSERT_MESSAGE( "Slant set same, aLHS == aRhs failed", aLhs.operator ==(aRhs));
130 CPPUNIT_ASSERT_MESSAGE( "Slant set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
134 CPPUNIT_TEST_SUITE_REGISTRATION(VclFontMetricTest);
136 CPPUNIT_PLUGIN_IMPLEMENT();
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */