Replace a template function with template class to fix VC6 build.
VC6 doesn't like template methods, so use a helper template class instead, hopefully this will finally allow it to compile the test suite again. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,9 +53,6 @@ private:
|
|||||||
#endif // TEST_GC
|
#endif // TEST_GC
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void DoTestGetTextExtent(const T& obj);
|
|
||||||
|
|
||||||
void DCGetTextExtent();
|
void DCGetTextExtent();
|
||||||
void WindowGetTextExtent();
|
void WindowGetTextExtent();
|
||||||
|
|
||||||
@@ -75,28 +72,36 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MeasuringTextTestCase );
|
|||||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MeasuringTextTestCase, "MeasuringTextTestCase" );
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MeasuringTextTestCase, "MeasuringTextTestCase" );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// tests themselves
|
// helper for XXXTextExtent() methods
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void MeasuringTextTestCase::DoTestGetTextExtent(const T& obj)
|
struct GetTextExtentTester
|
||||||
{
|
{
|
||||||
// Test that getting the height only doesn't crash.
|
// Constructor runs a couple of simple tests for GetTextExtent().
|
||||||
int y;
|
GetTextExtentTester(const T& obj)
|
||||||
obj.GetTextExtent("H", NULL, &y);
|
{
|
||||||
|
// Test that getting the height only doesn't crash.
|
||||||
|
int y;
|
||||||
|
obj.GetTextExtent("H", NULL, &y);
|
||||||
|
|
||||||
CPPUNIT_ASSERT( y > 1 );
|
CPPUNIT_ASSERT( y > 1 );
|
||||||
|
|
||||||
wxSize size = obj.GetTextExtent("Hello");
|
wxSize size = obj.GetTextExtent("Hello");
|
||||||
CPPUNIT_ASSERT( size.x > 1 );
|
CPPUNIT_ASSERT( size.x > 1 );
|
||||||
CPPUNIT_ASSERT_EQUAL( y, size.y );
|
CPPUNIT_ASSERT_EQUAL( y, size.y );
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// tests themselves
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MeasuringTextTestCase::DCGetTextExtent()
|
void MeasuringTextTestCase::DCGetTextExtent()
|
||||||
{
|
{
|
||||||
wxClientDC dc(wxTheApp->GetTopWindow());
|
wxClientDC dc(wxTheApp->GetTopWindow());
|
||||||
|
|
||||||
DoTestGetTextExtent(dc);
|
GetTextExtentTester<wxClientDC> testDC(dc);
|
||||||
|
|
||||||
int w;
|
int w;
|
||||||
dc.GetMultiLineTextExtent("Good\nbye", &w, NULL);
|
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
|
// should set the default font in it implicitly but for now just work
|
||||||
// around it.
|
// around it.
|
||||||
psdc.SetFont(*wxNORMAL_FONT);
|
psdc.SetFont(*wxNORMAL_FONT);
|
||||||
DoTestGetTextExtent(psdc);
|
GetTextExtentTester<wxPostScriptDC> testPS(psdc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_ENH_METAFILE
|
#if wxUSE_ENH_METAFILE
|
||||||
wxEnhMetaFileDC metadc;
|
wxEnhMetaFileDC metadc;
|
||||||
DoTestGetTextExtent(metadc);
|
GetTextExtentTester<wxEnhMetaFileDC> testMF(metadc);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +131,7 @@ void MeasuringTextTestCase::WindowGetTextExtent()
|
|||||||
{
|
{
|
||||||
wxWindow* const win = wxTheApp->GetTopWindow();
|
wxWindow* const win = wxTheApp->GetTopWindow();
|
||||||
|
|
||||||
DoTestGetTextExtent(*win);
|
GetTextExtentTester<wxWindow> testWin(*win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeasuringTextTestCase::GetPartialTextExtent()
|
void MeasuringTextTestCase::GetPartialTextExtent()
|
||||||
|
Reference in New Issue
Block a user