Debian Codegraph @

test/FTExtrudeFont-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 FTExtrudeFontTest : public CppUnit::TestCase
15 {
16 CPPUNIT_TEST_SUITE(FTExtrudeFontTest);
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 FTExtrudeFontTest() : CppUnit::TestCase("FTExtrudeFont Test")
25 {
26 }
27
28 FTExtrudeFontTest(const std::string& name) : CppUnit::TestCase(name) {}
29
30 ~FTExtrudeFontTest()
31 {
32 }
33
34 void testConstructor()
35 {
36 buildGLContext();
37
38 FTExtrudeFont* extrudedFont = new FTExtrudeFont(FONT_FILE);
39 CPPUNIT_ASSERT_EQUAL(extrudedFont->Error(), 0);
40
41 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
42 delete extrudedFont;
43 }
44
45 void testRender()
46 {
47 buildGLContext();
48
49 FTExtrudeFont* extrudedFont = new FTExtrudeFont(FONT_FILE);
50 extrudedFont->Render(GOOD_ASCII_TEST_STRING);
51
52 CPPUNIT_ASSERT_EQUAL(extrudedFont->Error(), 0x97); // Invalid pixels per em
53 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
54
55 extrudedFont->FaceSize(18);
56 extrudedFont->Render(GOOD_ASCII_TEST_STRING);
57
58 CPPUNIT_ASSERT_EQUAL(extrudedFont->Error(), 0);
59 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
60 delete extrudedFont;
61 }
62
63 void testBadDisplayList()
64 {
65 buildGLContext();
66
67 FTExtrudeFont* extrudedFont = new FTExtrudeFont(FONT_FILE);
68 extrudedFont->FaceSize(18);
69
70 int glList = glGenLists(1);
71 glNewList(glList, GL_COMPILE);
72
73 extrudedFont->Render(GOOD_ASCII_TEST_STRING);
74
75 glEndList();
76
77 CPPUNIT_ASSERT_EQUAL((int)glGetError(), GL_INVALID_OPERATION);
78 delete extrudedFont;
79 }
80
81 void testGoodDisplayList()
82 {
83 buildGLContext();
84
85 FTExtrudeFont* extrudedFont = new FTExtrudeFont(FONT_FILE);
86 extrudedFont->FaceSize(18);
87
88 extrudedFont->UseDisplayList(false);
89 int glList = glGenLists(1);
90 glNewList(glList, GL_COMPILE);
91
92 extrudedFont->Render(GOOD_ASCII_TEST_STRING);
93
94 glEndList();
95
96 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
97 delete extrudedFont;
98 }
99
100 void setUp()
101 {}
102
103 void tearDown()
104 {}
105
106 private:
107 };
108
109 CPPUNIT_TEST_SUITE_REGISTRATION(FTExtrudeFontTest);
110