X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3778b4d9c7eebc39f496a9dd055638e06fb9140..3942aa77f5f737e668137a09ee197c7099c45a9e:/tests/font/fonttest.cpp?ds=sidebyside diff --git a/tests/font/fonttest.cpp b/tests/font/fonttest.cpp index 24a28a7904..bf19403207 100644 --- a/tests/font/fonttest.cpp +++ b/tests/font/fonttest.cpp @@ -26,6 +26,8 @@ #include "wx/font.h" +#include "asserthelper.h" + // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- @@ -37,11 +39,13 @@ public: private: CPPUNIT_TEST_SUITE( FontTestCase ); + CPPUNIT_TEST( Construct ); CPPUNIT_TEST( GetSet ); CPPUNIT_TEST( NativeFontInfo ); CPPUNIT_TEST( NativeFontInfoUserDesc ); CPPUNIT_TEST_SUITE_END(); + void Construct(); void GetSet(); void NativeFontInfo(); void NativeFontInfoUserDesc(); @@ -93,6 +97,23 @@ wxString DumpFont(const wxFont *font) return s; } +void FontTestCase::Construct() +{ + // The main purpose of this test is to verify that the font ctors below + // compile because it's easy to introduce ambiguities due to the number of + // overloaded wxFont ctors. + + CPPUNIT_ASSERT( wxFont(10, wxFONTFAMILY_DEFAULT, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL).IsOk() ); + +#if FUTURE_WXWIN_COMPATIBILITY_3_0 + // Tests relying on the soon-to-be-deprecated ctor taking ints and not + // wxFontXXX enum elements. + CPPUNIT_ASSERT( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() ); +#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 +} + void FontTestCase::GetSet() { unsigned numFonts; @@ -182,6 +203,12 @@ void FontTestCase::GetSet() CPPUNIT_ASSERT( test.IsOk() ); CPPUNIT_ASSERT_EQUAL( true, test.GetUnderlined() ); + // test Get/SetStrikethrough() + + test.SetStrikethrough(true); + CPPUNIT_ASSERT( test.IsOk() ); + CPPUNIT_ASSERT_EQUAL( true, test.GetStrikethrough() ); + // test Get/SetWeight() @@ -223,6 +250,26 @@ void FontTestCase::NativeFontInfo() #if !defined(__WXGTK__) && !defined(__WXX11__) CPPUNIT_ASSERT( !font.SetNativeFontInfo("bloordyblop") ); #endif + + // Pango font description doesn't have 'underlined' and 'strikethrough' + // attributes, so wxNativeFontInfo implements these itself. Test if these + // are properly preserved by wxNativeFontInfo or its string description. + font.SetUnderlined(true); + font.SetStrikethrough(true); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font)); + CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo())); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc())); + font.SetUnderlined(false); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font)); + CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo())); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc())); + font.SetUnderlined(true); + font.SetStrikethrough(false); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font)); + CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo())); + CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc())); + // note: the GetNativeFontInfoUserDesc() doesn't preserve all attributes + // according to docs, so it is not tested. } void FontTestCase::NativeFontInfoUserDesc()