Debian Codegraph @

test/FTPolygonFont-Test.cpp

raw
1 #include <cppunit/extensions/HelperMacros.h>
2 #include <cppunit/TestCaller.h>
3 #include <cppunit/TestCase.h>
4 #include <cppunit/TestSuite.h>
5 #include <assert.h>
6
7 #include "Fontdefs.h"
8
9 #include "FTGL/ftgl.h"
10 #include "FTInternals.h"
11
12 extern void buildGLContext();
13
14 class FTPolygonFontTest : public CppUnit::TestCase
15 {
16 CPPUNIT_TEST_SUITE(FTPolygonFontTest);
17 CPPUNIT_TEST(testConstructor);
18 // CPPUNIT_TEST(testRender);
19 CPPUNIT_TEST(testBadDisplayList);
20 CPPUNIT_TEST(testGoodDisplayList);
21 CPPUNIT_TEST_SUITE_END();
22
23 public:
24 FTPolygonFontTest() : CppUnit::TestCase("FTPolygonFont Test")
25 {
26 }
27
28 FTPolygonFontTest(const std::string& name) : CppUnit::TestCase(name) {}
29
30 ~FTPolygonFontTest()
31 {
32 }
33
34 void testConstructor()
35 {
36 buildGLContext();
37
38 FTPolygonFont* polygonFont = new FTPolygonFont(FONT_FILE);
39 CPPUNIT_ASSERT_EQUAL(polygonFont->Error(), 0);
40
41 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
42 delete polygonFont;
43 }
44
45 void testRender()
46 {
47 buildGLContext();
48
49 FTPolygonFont* polygonFont = new FTPolygonFont(FONT_FILE);
50
51 polygonFont->Render(GOOD_ASCII_TEST_STRING);
52
53 CPPUNIT_ASSERT_EQUAL(polygonFont->Error(), 0x97); // Invalid pixels per em
54 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
55
56 polygonFont->FaceSize(18);
57 polygonFont->Render(GOOD_ASCII_TEST_STRING);
58
59 CPPUNIT_ASSERT_EQUAL(polygonFont->Error(), 0);
60 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
61 delete polygonFont;
62 }
63
64 void testBadDisplayList()
65 {
66 buildGLContext();
67
68 FTPolygonFont* polygonFont = new FTPolygonFont(FONT_FILE);
69 polygonFont->FaceSize(18);
70
71 int glList = glGenLists(1);
72 glNewList(glList, GL_COMPILE);
73
74 polygonFont->Render(GOOD_ASCII_TEST_STRING);
75
76 glEndList();
77
78 CPPUNIT_ASSERT_EQUAL((int)glGetError(), GL_INVALID_OPERATION);
79 delete polygonFont;
80 }
81
82 void testGoodDisplayList()
83 {
84 buildGLContext();
85
86 FTPolygonFont* polygonFont = new FTPolygonFont(FONT_FILE);
87 polygonFont->FaceSize(18);
88
89 polygonFont->UseDisplayList(false);
90 int glList = glGenLists(1);
91 glNewList(glList, GL_COMPILE);
92
93 polygonFont->Render(GOOD_ASCII_TEST_STRING);
94
95 glEndList();
96
97 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
98 delete polygonFont;
99 }
100
101 void setUp()
102 {}
103
104 void tearDown()
105 {}
106
107 private:
108 };
109
110 CPPUNIT_TEST_SUITE_REGISTRATION(FTPolygonFontTest);
111