Give more details in GarbageTestCase unit test.
Try to find out why this test fails in the OS X buildbot builds. Use macros to ensure that all checks provide information about the bitmap (or animation) type they fail for, without having to repeat the same code for doing it many times.
This commit is contained in:
@@ -89,52 +89,65 @@ void GarbageTestCase::LoadGarbage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute the given macro with the given first and second parameters and
|
||||||
|
// bitmap type as its third parameter for all bitmap types.
|
||||||
|
#define wxFOR_ALL_VALID_BITMAP_TYPES(m, p1, p2) \
|
||||||
|
for ( wxBitmapType type = wxBitmapType(wxBITMAP_TYPE_INVALID + 1); \
|
||||||
|
type < wxBITMAP_TYPE_MAX; \
|
||||||
|
type = (wxBitmapType)(type + 1) ) \
|
||||||
|
m(p1, p2, type)
|
||||||
|
|
||||||
|
// Similar to above but for animation types.
|
||||||
|
#define wxFOR_ALL_VALID_ANIMATION_TYPES(m, p1, p2) \
|
||||||
|
for ( wxAnimationType type = wxAnimationType(wxANIMATION_TYPE_INVALID + 1); \
|
||||||
|
type < wxANIMATION_TYPE_ANY; \
|
||||||
|
type = (wxAnimationType)(type + 1) ) \
|
||||||
|
m(p1, p2, type)
|
||||||
|
|
||||||
|
// This macro is used as an argument to wxFOR_ALL_VALID_BITMAP_TYPES() to
|
||||||
|
// include the information about the type for which the test failed.
|
||||||
|
#define ASSERT_FUNC_FAILS_FOR_TYPE(func, arg, type) \
|
||||||
|
WX_ASSERT_MESSAGE \
|
||||||
|
( \
|
||||||
|
(#func "() unexpectedly succeeded for type %d", type), \
|
||||||
|
!func(arg) \
|
||||||
|
)
|
||||||
|
|
||||||
|
// And this one exists mostly just for consistency with the one above.
|
||||||
|
#define ASSERT_FUNC_FAILS(func, arg) \
|
||||||
|
WX_ASSERT_MESSAGE \
|
||||||
|
( \
|
||||||
|
(#func "() unexpectedly succeeded for default type"), \
|
||||||
|
!func(arg) \
|
||||||
|
)
|
||||||
|
|
||||||
void GarbageTestCase::DoLoadFile(const wxString& fullname)
|
void GarbageTestCase::DoLoadFile(const wxString& fullname)
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
|
|
||||||
// test wxImage
|
// test wxImage
|
||||||
wxImage img;
|
wxImage img;
|
||||||
CPPUNIT_ASSERT( img.LoadFile(fullname) == false );
|
ASSERT_FUNC_FAILS(img.LoadFile, fullname);
|
||||||
// test with the default wxBITMAP_TYPE_ANY
|
wxFOR_ALL_VALID_BITMAP_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, img.LoadFile, fullname);
|
||||||
|
|
||||||
for (type = wxBITMAP_TYPE_BMP; type < wxBITMAP_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( img.LoadFile(fullname, (wxBitmapType)type) == false );
|
|
||||||
// test with all other possible wxBITMAP_TYPE_* flags
|
|
||||||
|
|
||||||
// test wxBitmap
|
// test wxBitmap
|
||||||
wxBitmap bmp;
|
wxBitmap bmp;
|
||||||
CPPUNIT_ASSERT( bmp.LoadFile(fullname) == false );
|
ASSERT_FUNC_FAILS(bmp.LoadFile, fullname);
|
||||||
// test with the default wxBITMAP_TYPE_ANY
|
wxFOR_ALL_VALID_BITMAP_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, bmp.LoadFile, fullname);
|
||||||
|
|
||||||
for (type = wxBITMAP_TYPE_BMP; type < wxBITMAP_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( bmp.LoadFile(fullname, (wxBitmapType)type) == false );
|
|
||||||
// test with all other possible wxBITMAP_TYPE_* flags
|
|
||||||
|
|
||||||
// test wxIcon
|
// test wxIcon
|
||||||
wxIcon icon;
|
wxIcon icon;
|
||||||
CPPUNIT_ASSERT( icon.LoadFile(fullname) == false );
|
ASSERT_FUNC_FAILS(icon.LoadFile, fullname);
|
||||||
// test with the default wxICON_DEFAULT_TYPE
|
wxFOR_ALL_VALID_BITMAP_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, icon.LoadFile, fullname);
|
||||||
|
|
||||||
for (type = wxBITMAP_TYPE_BMP; type < wxBITMAP_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( icon.LoadFile(fullname, (wxBitmapType)type) == false );
|
|
||||||
// test with all other possible wxBITMAP_TYPE_* flags
|
|
||||||
|
|
||||||
|
|
||||||
// test wxAnimation
|
// test wxAnimation
|
||||||
wxAnimation anim;
|
wxAnimation anim;
|
||||||
CPPUNIT_ASSERT( anim.LoadFile(fullname) == false );
|
ASSERT_FUNC_FAILS(anim.LoadFile, fullname);
|
||||||
// test with the default wxANIMATION_TYPE_ANY
|
wxFOR_ALL_VALID_ANIMATION_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, anim.LoadFile, fullname);
|
||||||
|
|
||||||
for (type = wxANIMATION_TYPE_INVALID+1; type < wxANIMATION_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( anim.LoadFile(fullname, (wxAnimationType)type) == false );
|
|
||||||
// test with all other possible wxANIMATION_TYPE_* flags
|
|
||||||
|
|
||||||
|
|
||||||
// test wxDynamicLibrary
|
// test wxDynamicLibrary
|
||||||
wxDynamicLibrary lib;
|
wxDynamicLibrary lib;
|
||||||
CPPUNIT_ASSERT( lib.Load(fullname) == false );
|
CPPUNIT_ASSERT( lib.Load(fullname) == false );
|
||||||
// test with the default wxANIMATION_TYPE_ANY
|
|
||||||
/*
|
/*
|
||||||
#if wxUSE_MEDIACTRL
|
#if wxUSE_MEDIACTRL
|
||||||
// test wxMediaCtrl
|
// test wxMediaCtrl
|
||||||
@@ -153,29 +166,19 @@ void GarbageTestCase::DoLoadFile(const wxString& fullname)
|
|||||||
|
|
||||||
void GarbageTestCase::DoLoadStream(wxInputStream& stream)
|
void GarbageTestCase::DoLoadStream(wxInputStream& stream)
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
|
|
||||||
// NOTE: not all classes tested by DoLoadFile() supports loading
|
// NOTE: not all classes tested by DoLoadFile() supports loading
|
||||||
// from an input stream!
|
// from an input stream!
|
||||||
|
|
||||||
// test wxImage
|
// test wxImage
|
||||||
wxImage img;
|
wxImage img;
|
||||||
CPPUNIT_ASSERT( img.LoadFile(stream) == false );
|
ASSERT_FUNC_FAILS(img.LoadFile, stream);
|
||||||
// test with the default wxBITMAP_TYPE_ANY
|
wxFOR_ALL_VALID_BITMAP_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, img.LoadFile, stream);
|
||||||
|
|
||||||
for (type = wxBITMAP_TYPE_INVALID+1; type < wxBITMAP_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( img.LoadFile(stream, (wxBitmapType)type) == false );
|
|
||||||
// test with all other possible wxBITMAP_TYPE_* flags
|
|
||||||
|
|
||||||
|
|
||||||
// test wxAnimation
|
// test wxAnimation
|
||||||
wxAnimation anim;
|
wxAnimation anim;
|
||||||
CPPUNIT_ASSERT( anim.Load(stream) == false );
|
ASSERT_FUNC_FAILS(anim.Load, stream);
|
||||||
// test with the default wxANIMATION_TYPE_ANY
|
wxFOR_ALL_VALID_BITMAP_TYPES(ASSERT_FUNC_FAILS_FOR_TYPE, anim.Load, stream);
|
||||||
|
|
||||||
for (type = wxANIMATION_TYPE_INVALID+1; type < wxANIMATION_TYPE_ANY; type++)
|
|
||||||
CPPUNIT_ASSERT( anim.Load(stream, (wxAnimationType)type) == false );
|
|
||||||
// test with all other possible wxANIMATION_TYPE_* flags
|
|
||||||
/*
|
/*
|
||||||
// test wxHtmlWindow
|
// test wxHtmlWindow
|
||||||
wxHtmlWindow *htmlwin = new wxHtmlWindow(wxTheApp->GetTopWindow());
|
wxHtmlWindow *htmlwin = new wxHtmlWindow(wxTheApp->GetTopWindow());
|
||||||
@@ -184,3 +187,7 @@ void GarbageTestCase::DoLoadStream(wxInputStream& stream)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ASSERT_FUNC_FAILS
|
||||||
|
#undef ASSERT_FUNC_FAILS_FOR_TYPE
|
||||||
|
#undef wxFOR_ALL_VALID_ANIMATION_TYPES
|
||||||
|
#undef wxFOR_ALL_VALID_BITMAP_TYPES
|
||||||
|
Reference in New Issue
Block a user