~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to extern/bFTGL/test/FTFace-Test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "cppunit/extensions/HelperMacros.h"
 
2
#include "cppunit/TestCaller.h"
 
3
#include "cppunit/TestCase.h"
 
4
#include "cppunit/TestSuite.h"
 
5
 
 
6
#include "Fontdefs.h"
 
7
#include "FTFace.h"
 
8
 
 
9
 
 
10
class FTFaceTest : public CppUnit::TestCase
 
11
{
 
12
    CPPUNIT_TEST_SUITE( FTFaceTest);
 
13
        CPPUNIT_TEST( testOpenFace);
 
14
        CPPUNIT_TEST( testOpenFaceFromMemory);
 
15
        CPPUNIT_TEST( testAttachFile);
 
16
        CPPUNIT_TEST( testAttachMemoryData);
 
17
        CPPUNIT_TEST( testGlyphCount);
 
18
        CPPUNIT_TEST( testSetFontSize);
 
19
        CPPUNIT_TEST( testGetCharmapList);
 
20
        CPPUNIT_TEST( testUnitPerEMSquare);
 
21
        CPPUNIT_TEST( testKerning);
 
22
    CPPUNIT_TEST_SUITE_END();
 
23
 
 
24
    public:
 
25
        FTFaceTest() : CppUnit::TestCase( "FTFace test") {};
 
26
        FTFaceTest( const std::string& name) : CppUnit::TestCase(name) {};
 
27
        
 
28
        
 
29
        void testOpenFace()
 
30
        {
 
31
            FTFace face1( BAD_FONT_FILE);
 
32
            CPPUNIT_ASSERT( face1.Error() == 0x06);
 
33
        
 
34
            FTFace face2( GOOD_FONT_FILE);
 
35
            CPPUNIT_ASSERT( face2.Error() == 0);        
 
36
        }
 
37
        
 
38
        
 
39
        void testOpenFaceFromMemory()
 
40
        {
 
41
            FTFace face1( (unsigned char*)100, 0);
 
42
            CPPUNIT_ASSERT( face1.Error() == 0x02);
 
43
        
 
44
            FTFace face2( HPGCalc_pfb.dataBytes, HPGCalc_pfb.numBytes);
 
45
            CPPUNIT_ASSERT( face2.Error() == 0);        
 
46
        }
 
47
        
 
48
        
 
49
        void testAttachFile()
 
50
        {
 
51
            CPPUNIT_ASSERT( !testFace->Attach( TYPE1_AFM_FILE));
 
52
            CPPUNIT_ASSERT( testFace->Error() == 0x07);
 
53
        
 
54
            FTFace test( TYPE1_FONT_FILE);
 
55
            CPPUNIT_ASSERT( test.Error() == 0);
 
56
        
 
57
            CPPUNIT_ASSERT( test.Attach( TYPE1_AFM_FILE));
 
58
            CPPUNIT_ASSERT( test.Error() == 0);
 
59
        }
 
60
        
 
61
        
 
62
        void testAttachMemoryData()
 
63
        {
 
64
            CPPUNIT_ASSERT( !testFace->Attach((unsigned char*)100, 0));
 
65
            CPPUNIT_ASSERT( testFace->Error() == 0x07);        
 
66
        
 
67
            FTFace test( TYPE1_FONT_FILE);
 
68
            CPPUNIT_ASSERT( test.Error() == 0);
 
69
        
 
70
            CPPUNIT_ASSERT( test.Attach( HPGCalc_afm.dataBytes, HPGCalc_afm.numBytes));
 
71
            CPPUNIT_ASSERT( test.Error() == 0);
 
72
        }
 
73
        
 
74
        
 
75
        void testGlyphCount()
 
76
        {
 
77
            CPPUNIT_ASSERT( testFace->GlyphCount() == 14099);        
 
78
        }
 
79
        
 
80
        
 
81
        void testSetFontSize()
 
82
        {
 
83
            FTSize size = testFace->Size( FONT_POINT_SIZE, RESOLUTION);
 
84
            CPPUNIT_ASSERT( testFace->Error() == 0);
 
85
        }
 
86
        
 
87
 
 
88
        void testGetCharmapList()
 
89
        {
 
90
            CPPUNIT_ASSERT( testFace->CharMapCount() == 2);
 
91
            
 
92
            FT_Encoding* charmapList = testFace->CharMapList();
 
93
            
 
94
            CPPUNIT_ASSERT( charmapList[0] == ft_encoding_unicode);
 
95
            CPPUNIT_ASSERT( charmapList[1] == ft_encoding_adobe_standard);
 
96
        }
 
97
        
 
98
        
 
99
        void testUnitPerEMSquare()
 
100
        {
 
101
            CPPUNIT_ASSERT_DOUBLES_EQUAL( 1000, testFace->UnitsPerEM(), 0);
 
102
        }
 
103
 
 
104
        
 
105
        void testKerning()
 
106
        {
 
107
            FTPoint kerningVector = testFace->KernAdvance( 'A', 'W');
 
108
            CPPUNIT_ASSERT( kerningVector.x == 0);
 
109
            CPPUNIT_ASSERT( kerningVector.y == 0);
 
110
            CPPUNIT_ASSERT( kerningVector.z == 0);
 
111
        
 
112
            kerningVector = testFace->KernAdvance( 0x6FB3, 0x9580);
 
113
            CPPUNIT_ASSERT( kerningVector.x == 0);
 
114
            CPPUNIT_ASSERT( kerningVector.y == 0);
 
115
            CPPUNIT_ASSERT( kerningVector.z == 0);
 
116
        }
 
117
        
 
118
        
 
119
        void setUp() 
 
120
        {
 
121
            testFace = new FTFace( GOOD_FONT_FILE);
 
122
        }
 
123
        
 
124
        
 
125
        void tearDown() 
 
126
        {
 
127
            delete testFace;
 
128
        }
 
129
        
 
130
    private:
 
131
        FTFace* testFace;
 
132
 
 
133
};
 
134
 
 
135
CPPUNIT_TEST_SUITE_REGISTRATION( FTFaceTest);
 
136