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