summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2016-01-14 07:48:48 +1100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-01-13 20:52:40 +0000
commitf8ffe2ff7a654052e0e2d6cb168841025bcc2f25 (patch)
tree8fa9ecea82cdc680558a42a41c89b25f9d2bf400 /vcl/qa
parent398491236015721e067273657ad3016634b5a166 (diff)
vcl: Create accessor and mutator for ascent and descent in FontMetric
Accessor and mutator created for ascent and descent spacing in FontMetric. See commit description in 8bfccd3a71d911b6d ("vcl: Create accessor and mutator for font scaling in FontMetric") for reasoning behind patch. Unit tests - check to ensure that can set font ascent and descent spacing - check equality operator on FontMetric after setting both ascent and descent font spacing Change-Id: I714363b14bdc61ddfa37a619fe4b03f4e4e96f7a Reviewed-on: https://gerrit.libreoffice.org/21458 Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com> Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/fontmetric.cxx43
1 files changed, 38 insertions, 5 deletions
diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx
index 316e03d3a8a4..07fc0e6d170f 100644
--- a/vcl/qa/cppunit/fontmetric.cxx
+++ b/vcl/qa/cppunit/fontmetric.cxx
@@ -8,6 +8,8 @@
*/
#include <test/bootstrapfixture.hxx>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
#include <osl/file.hxx>
#include <osl/process.h>
@@ -24,6 +26,7 @@ public:
void testScalableFlag();
void testFullstopCenteredFlag();
void testBuiltInFontFlag();
+ void testSpacings();
void testEqualityOperator();
CPPUNIT_TEST_SUITE(VclFontMetricTest);
@@ -31,6 +34,7 @@ public:
CPPUNIT_TEST(testFullstopCenteredFlag);
CPPUNIT_TEST(testBuiltInFontFlag);
CPPUNIT_TEST(testEqualityOperator);
+ CPPUNIT_TEST(testSpacings);
CPPUNIT_TEST_SUITE_END();
};
@@ -70,6 +74,30 @@ void VclFontMetricTest::testBuiltInFontFlag()
CPPUNIT_ASSERT_MESSAGE( "Built-in font flag should be true", aFontMetric.IsBuiltInFont() );
}
+void VclFontMetricTest::testSpacings()
+{
+ // default constructor should set scalable flag to false
+ FontMetric aFontMetric;
+
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 0L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 0L );
+
+ aFontMetric.SetAscent( 100 );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 100L );
+
+ aFontMetric.SetDescent( 100 );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 100L );
+
+ aFontMetric.SetExternalLeading( 100L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 100L );
+
+ aFontMetric.SetInternalLeading( 100L );
+ CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 100L );
+}
+
+
void VclFontMetricTest::testEqualityOperator()
{
// default constructor should set scalable flag to false
@@ -77,33 +105,38 @@ void VclFontMetricTest::testEqualityOperator()
aLhs.SetScalableFlag(true);
aRhs.SetScalableFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Scalable flag set same, aLhs == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Scalable flag set same, aLhs != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetFullstopCenteredFlag(true);
aRhs.SetFullstopCenteredFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetBuiltInFontFlag(true);
aRhs.SetBuiltInFontFlag(true);
-
CPPUNIT_ASSERT_MESSAGE( "Builtin font flag set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Builtin font flag set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetExternalLeading(10);
aRhs.SetExternalLeading(10);
-
CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
aLhs.SetInternalLeading(10);
aRhs.SetInternalLeading(10);
-
CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS == aRhs failed", aLhs == aRhs );
CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+
+ aLhs.SetAscent( 100 );
+ aRhs.SetAscent( 100 );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS == aRhs failed", aLhs == aRhs );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+
+ aLhs.SetDescent( 100 );
+ aRhs.SetDescent( 100 );
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS == aRhs failed", aLhs == aRhs );
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
}