]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/graphics/measuring.cpp
Try native method first in LoadFile() and SaveFile()
[wxWidgets.git] / tests / graphics / measuring.cpp
index ae02d272391012d5ea67a67d513ca3f028edc502..36b100be0e9adb223eaadf6f72819bc06e0b47e5 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     Tests for wxGraphicsRenderer::CreateMeasuringContext
 // Author:      Kevin Ollivier, Vadim Zeitlin (non wxGC parts)
 // Created:     2008-02-12
-// RCS-ID:      $Id$
 // Copyright:   (c) 2008 Kevin Ollivier <kevino@theolliviers.com>
 //              (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
 ///////////////////////////////////////////////////////////////////////////////
@@ -46,6 +45,7 @@ public:
 private:
     CPPUNIT_TEST_SUITE( MeasuringTextTestCase );
         CPPUNIT_TEST( DCGetTextExtent );
+        CPPUNIT_TEST( LeadingAndDescent );
         CPPUNIT_TEST( WindowGetTextExtent );
         CPPUNIT_TEST( GetPartialTextExtent );
 #ifdef TEST_GC
@@ -54,6 +54,7 @@ private:
     CPPUNIT_TEST_SUITE_END();
 
     void DCGetTextExtent();
+    void LeadingAndDescent();
     void WindowGetTextExtent();
 
     void GetPartialTextExtent();
@@ -127,6 +128,30 @@ void MeasuringTextTestCase::DCGetTextExtent()
 #endif
 }
 
+void MeasuringTextTestCase::LeadingAndDescent()
+{
+    wxClientDC dc(wxTheApp->GetTopWindow());
+
+    // Retrieving just the descent should work.
+    int descent = -17;
+    dc.GetTextExtent("foo", NULL, NULL, &descent);
+    CPPUNIT_ASSERT( descent != -17 );
+
+    // Same for external leading.
+    int leading = -289;
+    dc.GetTextExtent("foo", NULL, NULL, NULL, &leading);
+    CPPUNIT_ASSERT( leading != -289 );
+
+    // And both should also work for the empty string as they retrieve the
+    // values valid for the entire font and not just this string.
+    int descent2,
+        leading2;
+    dc.GetTextExtent("", NULL, NULL, &descent2, &leading2);
+
+    CPPUNIT_ASSERT_EQUAL( descent, descent2 );
+    CPPUNIT_ASSERT_EQUAL( leading, leading2 );
+}
+
 void MeasuringTextTestCase::WindowGetTextExtent()
 {
     wxWindow* const win = wxTheApp->GetTopWindow();