X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3778b4d9c7eebc39f496a9dd055638e06fb9140..339c6c92a276ac6b04dcb5deffaea7ccbd2ee109:/tests/font/fonttest.cpp diff --git a/tests/font/fonttest.cpp b/tests/font/fonttest.cpp index 24a28a7904..cdcb7ea8f4 100644 --- a/tests/font/fonttest.cpp +++ b/tests/font/fonttest.cpp @@ -3,7 +3,6 @@ // Purpose: wxFont unit test // Author: Francesco Montorsi // Created: 16.3.09 -// RCS-ID: $Id$ // Copyright: (c) 2009 Francesco Montorsi // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -26,6 +25,8 @@ #include "wx/font.h" +#include "asserthelper.h" + // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- @@ -37,11 +38,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 +96,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 +202,15 @@ void FontTestCase::GetSet() CPPUNIT_ASSERT( test.IsOk() ); CPPUNIT_ASSERT_EQUAL( true, test.GetUnderlined() ); + // test Get/SetStrikethrough() + + // Strike through support not implemented in wxOSX currently. +#ifndef __WXOSX__ + test.SetStrikethrough(true); + CPPUNIT_ASSERT( test.IsOk() ); + CPPUNIT_ASSERT_EQUAL( true, test.GetStrikethrough() ); +#endif // !__WXOSX__ + // test Get/SetWeight() @@ -223,6 +252,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()