| 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 FTExtrudeGlyphTest : public CppUnit::TestCase |
| 15 |
{ |
| 16 |
CPPUNIT_TEST_SUITE(FTExtrudeGlyphTest); |
| 17 |
CPPUNIT_TEST(testConstructor); |
| 18 |
CPPUNIT_TEST(testRender); |
| 19 |
CPPUNIT_TEST_SUITE_END(); |
| 20 |
|
| 21 |
public: |
| 22 |
FTExtrudeGlyphTest() : CppUnit::TestCase("FTExtrudeGlyph Test") |
| 23 |
{ |
| 24 |
} |
| 25 |
|
| 26 |
FTExtrudeGlyphTest(const std::string& name) : CppUnit::TestCase(name) {} |
| 27 |
|
| 28 |
~FTExtrudeGlyphTest() |
| 29 |
{ |
| 30 |
} |
| 31 |
|
| 32 |
void testConstructor() |
| 33 |
{ |
| 34 |
setUpFreetype(); |
| 35 |
|
| 36 |
buildGLContext(); |
| 37 |
|
| 38 |
FTExtrudeGlyph* extrudedGlyph = new FTExtrudeGlyph(face->glyph, |
| 39 |
0.0f, 0.0f, 0.0f, true); |
| 40 |
CPPUNIT_ASSERT(extrudedGlyph->Error() == 0); |
| 41 |
|
| 42 |
CPPUNIT_ASSERT(glGetError() == GL_NO_ERROR); |
| 43 |
|
| 44 |
tearDownFreetype(); |
| 45 |
} |
| 46 |
|
| 47 |
void testRender() |
| 48 |
{ |
| 49 |
setUpFreetype(); |
| 50 |
|
| 51 |
buildGLContext(); |
| 52 |
|
| 53 |
FTExtrudeGlyph* extrudedGlyph = new FTExtrudeGlyph(face->glyph, |
| 54 |
0.0f, 0.0f, 0.0f, true); |
| 55 |
CPPUNIT_ASSERT(extrudedGlyph->Error() == 0); |
| 56 |
extrudedGlyph->Render(FTPoint(0, 0, 0), FTGL::RENDER_FRONT | |
| 57 |
FTGL::RENDER_BACK | |
| 58 |
FTGL::RENDER_SIDE); |
| 59 |
|
| 60 |
CPPUNIT_ASSERT(glGetError() == GL_NO_ERROR); |
| 61 |
|
| 62 |
tearDownFreetype(); |
| 63 |
} |
| 64 |
|
| 65 |
void setUp() |
| 66 |
{} |
| 67 |
|
| 68 |
void tearDown() |
| 69 |
{} |
| 70 |
|
| 71 |
private: |
| 72 |
FT_Library library; |
| 73 |
FT_Face face; |
| 74 |
|
| 75 |
void setUpFreetype() |
| 76 |
{ |
| 77 |
FT_Error error = FT_Init_FreeType(&library); |
| 78 |
assert(!error); |
| 79 |
error = FT_New_Face(library, FONT_FILE, 0, &face); |
| 80 |
assert(!error); |
| 81 |
|
| 82 |
FT_Set_Char_Size(face, 0L, FONT_POINT_SIZE * 64, RESOLUTION, RESOLUTION); |
| 83 |
|
| 84 |
error = FT_Load_Char(face, CHARACTER_CODE_A, FT_LOAD_DEFAULT); |
| 85 |
assert(!error); |
| 86 |
} |
| 87 |
|
| 88 |
void tearDownFreetype() |
| 89 |
{ |
| 90 |
FT_Done_Face(face); |
| 91 |
FT_Done_FreeType(library); |
| 92 |
} |
| 93 |
|
| 94 |
}; |
| 95 |
|
| 96 |
CPPUNIT_TEST_SUITE_REGISTRATION(FTExtrudeGlyphTest); |
| 97 |
|