Commit 20620dc7ccc3667e2307d552b4fd42ee560a9276

sammy 2008-05-07T15:09:25

* Fixed and reactivated unit tests that were disabled during the pImpl refactoring.

diff --git a/test/FTFont-Test.cpp b/test/FTFont-Test.cpp
index 5ae8eb3..2091f8f 100644
--- a/test/FTFont-Test.cpp
+++ b/test/FTFont-Test.cpp
@@ -15,7 +15,7 @@ class TestGlyph : public FTGlyph
         :   FTGlyph(glyph)
         {}
 
-        const FTPoint& Render(const FTPoint& pen, int renderMode){ return advance; }
+        const FTPoint& Render(const FTPoint& pen, int renderMode){ return Advance(); }
 };
 
 
@@ -30,18 +30,9 @@ class TestFont : public FTFont
         :   FTFont(pBufferBytes, bufferSizeInBytes)
         {}
 
-        FTGlyph* MakeGlyph(unsigned int g)
+        FTGlyph* MakeGlyph(FT_GlyphSlot ftGlyph)
         {
-            FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_NO_HINTING);
-
-            if(ftGlyph)
-            {
-                TestGlyph* tempGlyph = new TestGlyph(ftGlyph);
-                return tempGlyph;
-            }
-
-            err = face.Error();
-            return NULL;
+            return new TestGlyph(ftGlyph);
         }
 };
 
@@ -53,18 +44,9 @@ class BadGlyphTestFont : public FTFont
         :   FTFont(fontFilePath)
         {}
 
-        FTGlyph* MakeGlyph(unsigned int g)
+        FTGlyph* MakeGlyph(FT_GlyphSlot ftGlyph)
         {
-            FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_NO_HINTING);
-
-            if(ftGlyph)
-            {
-                TestGlyph* tempGlyph = new TestGlyph(ftGlyph);
-                return tempGlyph;
-            }
-
-            err = face.Error();
-            return NULL;
+            return new TestGlyph(ftGlyph);
         }
 
     private:
@@ -193,52 +175,52 @@ class FTFontTest : public CppUnit::TestCase
             CPPUNIT_ASSERT(testFont->FaceSize(FONT_POINT_SIZE));
             CPPUNIT_ASSERT_EQUAL(testFont->Error(), 0);
 
-            float llx, lly, llz, urx, ury, urz;
+            FTBBox bbox;
 
-            testFont->BBox(GOOD_ASCII_TEST_STRING, llx, lly, llz, urx, ury, urz);
+            bbox = testFont->BBox(GOOD_ASCII_TEST_STRING);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(1.21, llx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(-15.12, lly, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, llz, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(307.43, urx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(51.54, ury, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, urz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(1.21, bbox.Lower().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(-15.12, bbox.Lower().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, bbox.Lower().Z(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(307.43, bbox.Upper().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(51.54, bbox.Upper().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, bbox.Upper().Z(), 0.01);
 
-            testFont->BBox(BAD_ASCII_TEST_STRING, llx, lly, llz, urx, ury, urz);
+            testFont->BBox(BAD_ASCII_TEST_STRING);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, lly, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llz, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, ury, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Z(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Z(), 0.01);
 
-            testFont->BBox(GOOD_UNICODE_TEST_STRING, llx, lly, llz, urx, ury, urz);
+            testFont->BBox(GOOD_UNICODE_TEST_STRING);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(2.15, llx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.12, lly, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, llz, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(134.28, urx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(61.12, ury, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, urz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(2.15, bbox.Lower().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.12, bbox.Lower().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, bbox.Lower().Z(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(134.28, bbox.Upper().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(61.12, bbox.Upper().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, bbox.Upper().Z(), 0.01);
 
-            testFont->BBox(BAD_UNICODE_TEST_STRING, llx, lly, llz, urx, ury, urz);
+            testFont->BBox(BAD_UNICODE_TEST_STRING);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, lly, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llz, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, ury, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Z(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Z(), 0.01);
 
-            testFont->BBox((char*)0, llx, lly, llz, urx, ury, urz);
+            testFont->BBox((char*)0);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, lly, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, llz, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urx, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, ury, 0.01);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, urz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Lower().Z(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().X(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Y(), 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, bbox.Upper().Z(), 0.01);
         }
 
         void testCheckGlyphFailure()
diff --git a/test/FTGlyph-Test.cpp b/test/FTGlyph-Test.cpp
index 5f7d5b4..2fb5b6a 100644
--- a/test/FTGlyph-Test.cpp
+++ b/test/FTGlyph-Test.cpp
@@ -16,7 +16,7 @@ class TestGlyph : public FTGlyph
         :   FTGlyph(glyph)
         {}
 
-        const FTPoint& Render(const FTPoint& pen, int renderMode) { return advance; };
+        const FTPoint& Render(const FTPoint& pen, int renderMode) { return Advance(); };
 };
 
 
@@ -44,7 +44,7 @@ class FTGlyphTest : public CppUnit::TestCase
             CPPUNIT_ASSERT_EQUAL(testPoint.Y(), testGlyph.Advance().Y());
             CPPUNIT_ASSERT_EQUAL(testPoint.Z(), testGlyph.Advance().Z());
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, testGlyph.BBox().upperY, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(0, testGlyph.BBox().Upper().Y(), 0.01);
 
             CPPUNIT_ASSERT_EQUAL(testGlyph.Error(), 0);
         }
@@ -62,7 +62,7 @@ class FTGlyphTest : public CppUnit::TestCase
             CPPUNIT_ASSERT_DOUBLES_EQUAL(testPoint.Y(), nextPoint.Y(), 0.0001);
             CPPUNIT_ASSERT_DOUBLES_EQUAL(testPoint.Z(), nextPoint.Z(), 0.0001);
 
-            CPPUNIT_ASSERT_DOUBLES_EQUAL(51.39, testGlyph.BBox().upperY, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL(51.39, testGlyph.BBox().Upper().Y(), 0.01);
 
             CPPUNIT_ASSERT(testGlyph.Error() == 0);
 
diff --git a/test/FTGlyphContainer-Test.cpp b/test/FTGlyphContainer-Test.cpp
index 43ee9ec..b840a3c 100644
--- a/test/FTGlyphContainer-Test.cpp
+++ b/test/FTGlyphContainer-Test.cpp
@@ -5,8 +5,10 @@
 
 
 #include "Fontdefs.h"
+
+#include "FTGL/ftgl.h"
+
 #include "FTFace.h"
-#include "FTGlyph.h"
 #include "FTGlyphContainer.h"
 
 
@@ -14,12 +16,15 @@ class TestGlyph : public FTGlyph
 {
     public:
         TestGlyph()
-        :   FTGlyph(0)
+        :   FTGlyph((FT_GlyphSlot)0)
         {
             advance = FTPoint(50.0f, 0.0f, 0.0f);
         }
 
         virtual const FTPoint& Render(const FTPoint& pen, int renderMode){ return advance; }
+
+    private:
+        FTPoint advance;
 };
 
 
diff --git a/test/FTlayout-Test.cpp b/test/FTlayout-Test.cpp
index 23917eb..91ff207 100644
--- a/test/FTlayout-Test.cpp
+++ b/test/FTlayout-Test.cpp
@@ -4,7 +4,7 @@
 #include <cppunit/TestSuite.h>
 
 #include "Fontdefs.h"
-#include "layout/FTLayoutFont.h"
+#include "FTGL/ftgl.h"
 
 static const int SCRIPT = 2; // arabic
 
@@ -21,10 +21,7 @@ class FTLayoutTest : public CppUnit::TestCase
         FTLayoutTest(const std::string& name) : CppUnit::TestCase(name) {}
 
         void testConstructor()
-        {
-            FTLayoutFont font(FONT_FILE, SCRIPT);
-            CPPUNIT_ASSERT(font.Error() == 0);
-        }
+        {}
 
         void setUp()
         {}
diff --git a/test/Makefile.am b/test/Makefile.am
index a3f6e25..d0c2ccb 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,6 +6,7 @@ endif
 endif
 
 CXXTest_SOURCES = \
+    $(DEACTIVATED) \
     CXXTest.cpp \
     Fontdefs.h \
     FTBBox-Test.cpp \
@@ -17,6 +18,10 @@ CXXTest_SOURCES = \
     FTExtrudeFont-Test.cpp \
     FTExtrudeGlyph-Test.cpp \
     FTFace-Test.cpp \
+    FTFont-Test.cpp \
+    FTGlyph-Test.cpp \
+    FTGlyphContainer-Test.cpp \
+    FTlayout-Test.cpp \
     FTLibrary-Test.cpp \
     FTList-Test.cpp \
     FTMesh-Test.cpp \
@@ -58,11 +63,5 @@ CTest_CFLAGS = $(FT2_CFLAGS) $(GL_CFLAGS)
 CTest_LDFLAGS = $(FT2_LIBS) $(GLUT_LIBS)
 CTest_LDADD = ../src/libftgl.la
 
-DEACTIVATED = \
-    FTFont-Test.cpp \
-    FTGlyphContainer-Test.cpp \
-    FTGlyph-Test.cpp \
-    FTlayout-Test.cpp \
-    $(NULL)
-
 NULL =
+