]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/font/fonttest.cpp
Add wxTextCtrl::PositionToCoords() functions for wxMSW and wxGTK.
[wxWidgets.git] / tests / font / fonttest.cpp
index 2e9c3ebf9e4cb02502f4646727d3b9b003dba44b..24a28a790400db9f8b98b27b9f63b29bdb71f6f9 100644 (file)
@@ -68,7 +68,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FontTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( FontTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontTestCase, "FontTestCase" );
 
 wxString DumpFont(const wxFont *font)
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontTestCase, "FontTestCase" );
 
 wxString DumpFont(const wxFont *font)
@@ -97,7 +97,7 @@ void FontTestCase::GetSet()
 {
     unsigned numFonts;
     const wxFont *pf = GetTestFonts(numFonts);
 {
     unsigned numFonts;
     const wxFont *pf = GetTestFonts(numFonts);
-    for ( size_t n = 0; n < numFonts; n++ )
+    for ( unsigned n = 0; n < numFonts; n++ )
     {
         wxFont test(*pf++);
 
     {
         wxFont test(*pf++);
 
@@ -109,7 +109,21 @@ void FontTestCase::GetSet()
         CPPUNIT_ASSERT( !test.SetFaceName("a dummy face name") );
         CPPUNIT_ASSERT( !test.IsOk() );
 
         CPPUNIT_ASSERT( !test.SetFaceName("a dummy face name") );
         CPPUNIT_ASSERT( !test.IsOk() );
 
-        CPPUNIT_ASSERT( test.SetFaceName("Arial") );
+        // if the call to SetFaceName() below fails on your system/port,
+        // consider adding another branch to this #if
+#if defined(__WXMSW__) || defined(__WXOSX__)
+        static const char *knownGoodFaceName = "Arial";
+#else
+        static const char *knownGoodFaceName = "Monospace";
+#endif
+
+        WX_ASSERT_MESSAGE
+        (
+            ("failed to set face name \"%s\" for test font #%u\n"
+             "(this failure is harmless if this face name is not "
+             "available on this system)", knownGoodFaceName, n),
+            test.SetFaceName(knownGoodFaceName)
+        );
         CPPUNIT_ASSERT( test.IsOk() );
 
 
         CPPUNIT_ASSERT( test.IsOk() );
 
 
@@ -117,10 +131,13 @@ void FontTestCase::GetSet()
 
         test.SetFamily( wxFONTFAMILY_ROMAN );
         CPPUNIT_ASSERT( test.IsOk() );
 
         test.SetFamily( wxFONTFAMILY_ROMAN );
         CPPUNIT_ASSERT( test.IsOk() );
-        CPPUNIT_ASSERT( wxFONTFAMILY_ROMAN == test.GetFamily() ||
-                        wxFONTFAMILY_UNKNOWN == test.GetFamily() );
-            // note that there is always the possibility that GetFamily() returns
-            // wxFONTFAMILY_UNKNOWN so that we consider it as a valid return value
+
+        // note that there is always the possibility that GetFamily() returns
+        // wxFONTFAMILY_DEFAULT (meaning "unknown" in this case) so that we
+        // consider it as a valid return value
+        const wxFontFamily family = test.GetFamily();
+        if ( family != wxFONTFAMILY_DEFAULT )
+            CPPUNIT_ASSERT_EQUAL( wxFONTFAMILY_ROMAN, family );
 
 
         // test Get/SetEncoding()
 
 
         // test Get/SetEncoding()
@@ -198,7 +215,14 @@ void FontTestCase::NativeFontInfo()
     // test that clearly invalid font info strings do not work
     wxFont font;
     CPPUNIT_ASSERT( !font.SetNativeFontInfo("") );
     // test that clearly invalid font info strings do not work
     wxFont font;
     CPPUNIT_ASSERT( !font.SetNativeFontInfo("") );
+
+    // pango_font_description_from_string() used by wxFont in wxGTK and wxX11
+    // never returns an error at all so this assertion fails there -- and as it
+    // doesn't seem to be possible to do anything about it maybe we should
+    // change wxMSW and other ports to also accept any strings?
+#if !defined(__WXGTK__) && !defined(__WXX11__)
     CPPUNIT_ASSERT( !font.SetNativeFontInfo("bloordyblop") );
     CPPUNIT_ASSERT( !font.SetNativeFontInfo("bloordyblop") );
+#endif
 }
 
 void FontTestCase::NativeFontInfoUserDesc()
 }
 
 void FontTestCase::NativeFontInfoUserDesc()