]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/graphics/measuring.cpp
Ensure that detached menus don't keep focus grab in wxGTK.
[wxWidgets.git] / tests / graphics / measuring.cpp
index ce59b7743439b64cbef69786d6a90cad3b89fcdb..ae02d272391012d5ea67a67d513ca3f028edc502 100644 (file)
@@ -53,9 +53,6 @@ private:
 #endif // TEST_GC
     CPPUNIT_TEST_SUITE_END();
 
-    template <typename T>
-    void DoTestGetTextExtent(const T& obj);
-
     void DCGetTextExtent();
     void WindowGetTextExtent();
 
@@ -75,28 +72,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MeasuringTextTestCase );
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MeasuringTextTestCase, "MeasuringTextTestCase" );
 
 // ----------------------------------------------------------------------------
-// tests themselves
+// helper for XXXTextExtent() methods
 // ----------------------------------------------------------------------------
 
 template <typename T>
-void MeasuringTextTestCase::DoTestGetTextExtent(const T& obj)
+struct GetTextExtentTester
 {
-    // Test that getting the height only doesn't crash.
-    int y;
-    obj.GetTextExtent("H", NULL, &y);
-
-    CPPUNIT_ASSERT( y > 1 );
+    // Constructor runs a couple of simple tests for GetTextExtent().
+    GetTextExtentTester(const T& obj)
+    {
+        // Test that getting the height only doesn't crash.
+        int y;
+        obj.GetTextExtent("H", NULL, &y);
+
+        CPPUNIT_ASSERT( y > 1 );
+
+        wxSize size = obj.GetTextExtent("Hello");
+        CPPUNIT_ASSERT( size.x > 1 );
+        CPPUNIT_ASSERT_EQUAL( y, size.y );
+    }
+};
 
-    wxSize size = obj.GetTextExtent("Hello");
-    CPPUNIT_ASSERT( size.x > 1 );
-    CPPUNIT_ASSERT_EQUAL( y, size.y );
-}
+// ----------------------------------------------------------------------------
+// tests themselves
+// ----------------------------------------------------------------------------
 
 void MeasuringTextTestCase::DCGetTextExtent()
 {
     wxClientDC dc(wxTheApp->GetTopWindow());
 
-    DoTestGetTextExtent(dc);
+    GetTextExtentTester<wxClientDC> testDC(dc);
 
     int w;
     dc.GetMultiLineTextExtent("Good\nbye", &w, NULL);
@@ -113,12 +118,12 @@ void MeasuringTextTestCase::DCGetTextExtent()
     // should set the default font in it implicitly but for now just work
     // around it.
     psdc.SetFont(*wxNORMAL_FONT);
-    DoTestGetTextExtent(psdc);
+    GetTextExtentTester<wxPostScriptDC> testPS(psdc);
 #endif
 
 #if wxUSE_ENH_METAFILE
     wxEnhMetaFileDC metadc;
-    DoTestGetTextExtent(metadc);
+    GetTextExtentTester<wxEnhMetaFileDC> testMF(metadc);
 #endif
 }
 
@@ -126,7 +131,7 @@ void MeasuringTextTestCase::WindowGetTextExtent()
 {
     wxWindow* const win = wxTheApp->GetTopWindow();
 
-    DoTestGetTextExtent(*win);
+    GetTextExtentTester<wxWindow> testWin(*win);
 }
 
 void MeasuringTextTestCase::GetPartialTextExtent()