Debian Codegraph @

test/FTPixmapFont-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 FTPixmapFontTest : public CppUnit::TestCase
15 {
16 CPPUNIT_TEST_SUITE(FTPixmapFontTest);
17 CPPUNIT_TEST(testConstructor);
18 // CPPUNIT_TEST(testRender);
19 CPPUNIT_TEST(testDisplayList);
20 CPPUNIT_TEST_SUITE_END();
21
22 public:
23 FTPixmapFontTest() : CppUnit::TestCase("FTPixmapFont Test")
24 {
25 }
26
27 FTPixmapFontTest(const std::string& name) : CppUnit::TestCase(name) {}
28
29 ~FTPixmapFontTest()
30 {
31 }
32
33 void testConstructor()
34 {
35 buildGLContext();
36
37 FTPixmapFont* pixmapFont = new FTPixmapFont(FONT_FILE);
38 CPPUNIT_ASSERT_EQUAL(pixmapFont->Error(), 0);
39
40 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
41 delete pixmapFont;
42 }
43
44 void testRender()
45 {
46 buildGLContext();
47
48 FTPixmapFont* pixmapFont = new FTPixmapFont(FONT_FILE);
49
50 pixmapFont->Render(GOOD_ASCII_TEST_STRING);
51 CPPUNIT_ASSERT_EQUAL(pixmapFont->Error(), 0x97); // Invalid pixels per em
52 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
53
54 pixmapFont->FaceSize(18);
55 pixmapFont->Render(GOOD_ASCII_TEST_STRING);
56
57 CPPUNIT_ASSERT_EQUAL(pixmapFont->Error(), 0);
58 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
59 delete pixmapFont;
60 }
61
62 void testDisplayList()
63 {
64 buildGLContext();
65
66 FTPixmapFont* pixmapFont = new FTPixmapFont(FONT_FILE);
67 pixmapFont->FaceSize(18);
68
69 int glList = glGenLists(1);
70 glNewList(glList, GL_COMPILE);
71
72 pixmapFont->Render(GOOD_ASCII_TEST_STRING);
73
74 glEndList();
75
76 CPPUNIT_ASSERT_EQUAL(GL_NO_ERROR, (int)glGetError());
77 delete pixmapFont;
78 }
79
80 void setUp()
81 {}
82
83 void tearDown()
84 {}
85
86 private:
87 };
88
89 CPPUNIT_TEST_SUITE_REGISTRATION(FTPixmapFontTest);
90