From 7337bf1da124e58b99252cfc50e6b291a48fd5b2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 27 Sep 2021 19:15:02 +0200 Subject: [PATCH] Add a simple wxBitmapBundle unit test Check for the minimal functionality when using vector-based implementation. --- tests/Makefile.in | 4 +++ tests/graphics/bmpbundle.cpp | 48 ++++++++++++++++++++++++++++++++++ tests/makefile.gcc | 4 +++ tests/makefile.vc | 4 +++ tests/test.bkl | 1 + tests/test_gui.vcxproj | 1 + tests/test_gui.vcxproj.filters | 5 +++- tests/test_vc8_test_gui.vcproj | 4 +++ tests/test_vc9_test_gui.vcproj | 4 +++ 9 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests/graphics/bmpbundle.cpp diff --git a/tests/Makefile.in b/tests/Makefile.in index 41e448c2b8..afefe8f5f7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -183,6 +183,7 @@ TEST_GUI_OBJECTS = \ test_gui_point.o \ test_gui_region.o \ test_gui_bitmap.o \ + test_gui_bmpbundle.o \ test_gui_colour.o \ test_gui_ellipsization.o \ test_gui_measuring.o \ @@ -904,6 +905,9 @@ test_gui_region.o: $(srcdir)/geometry/region.cpp $(TEST_GUI_ODEP) test_gui_bitmap.o: $(srcdir)/graphics/bitmap.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/bitmap.cpp +test_gui_bmpbundle.o: $(srcdir)/graphics/bmpbundle.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/bmpbundle.cpp + test_gui_colour.o: $(srcdir)/graphics/colour.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/colour.cpp diff --git a/tests/graphics/bmpbundle.cpp b/tests/graphics/bmpbundle.cpp new file mode 100644 index 0000000000..aa79c4a560 --- /dev/null +++ b/tests/graphics/bmpbundle.cpp @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/graphics/bmpbundle.cpp +// Purpose: wxBitmapBundle unit test +// Author: Vadim Zeitlin +// Created: 2021-09-27 +// Copyright: (c) 2021 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#include "wx/bmpbndl.h" + +#include "asserthelper.h" + +// ---------------------------------------------------------------------------- +// tests +// ---------------------------------------------------------------------------- + +TEST_CASE("BitmapBundle::Create", "[bmpbundle]") +{ + wxBitmapBundle b; + CHECK( !b.IsOk() ); + CHECK( b.GetDefaultSize() == wxDefaultSize ); + + b = wxBitmap(16, 16); + CHECK( b.IsOk() ); + CHECK( b.GetDefaultSize() == wxSize(16, 16) ); +} + +TEST_CASE("BitmapBundle::FromBitmaps", "[bmpbundle]") +{ + wxVector bitmaps; + bitmaps.push_back(wxBitmap(16, 16)); + bitmaps.push_back(wxBitmap(24, 24)); + + wxBitmapBundle b = wxBitmapBundle::FromBitmaps(bitmaps); + REQUIRE( b.IsOk() ); + CHECK( b.GetDefaultSize() == wxSize(16, 16) ); + + CHECK( b.GetBitmap(wxDefaultSize ).GetSize() == wxSize(16, 16) ); + CHECK( b.GetBitmap(wxSize(16, 16)).GetSize() == wxSize(16, 16) ); + CHECK( b.GetBitmap(wxSize(20, 20)).GetSize() == wxSize(20, 20) ); + CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) ); +} diff --git a/tests/makefile.gcc b/tests/makefile.gcc index 99f099a87b..8b0ebd8054 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -157,6 +157,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_point.o \ $(OBJS)\test_gui_region.o \ $(OBJS)\test_gui_bitmap.o \ + $(OBJS)\test_gui_bmpbundle.o \ $(OBJS)\test_gui_colour.o \ $(OBJS)\test_gui_ellipsization.o \ $(OBJS)\test_gui_measuring.o \ @@ -879,6 +880,9 @@ $(OBJS)\test_gui_region.o: ./geometry/region.cpp $(OBJS)\test_gui_bitmap.o: ./graphics/bitmap.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_bmpbundle.o: ./graphics/bmpbundle.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_colour.o: ./graphics/colour.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index 83e5888831..8e656f802a 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -173,6 +173,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_point.obj \ $(OBJS)\test_gui_region.obj \ $(OBJS)\test_gui_bitmap.obj \ + $(OBJS)\test_gui_bmpbundle.obj \ $(OBJS)\test_gui_colour.obj \ $(OBJS)\test_gui_ellipsization.obj \ $(OBJS)\test_gui_measuring.obj \ @@ -1313,6 +1314,9 @@ $(OBJS)\test_gui_region.obj: .\geometry\region.cpp $(OBJS)\test_gui_bitmap.obj: .\graphics\bitmap.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\graphics\bitmap.cpp +$(OBJS)\test_gui_bmpbundle.obj: .\graphics\bmpbundle.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\graphics\bmpbundle.cpp + $(OBJS)\test_gui_colour.obj: .\graphics\colour.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\graphics\colour.cpp diff --git a/tests/test.bkl b/tests/test.bkl index d4b7e2d829..49fbc02f34 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -177,6 +177,7 @@ geometry/point.cpp geometry/region.cpp graphics/bitmap.cpp + graphics/bmpbundle.cpp graphics/colour.cpp graphics/ellipsization.cpp graphics/measuring.cpp diff --git a/tests/test_gui.vcxproj b/tests/test_gui.vcxproj index 7fdbe59b5b..c98fd7fce8 100644 --- a/tests/test_gui.vcxproj +++ b/tests/test_gui.vcxproj @@ -545,6 +545,7 @@ + diff --git a/tests/test_gui.vcxproj.filters b/tests/test_gui.vcxproj.filters index 4528b32f47..25a943ac30 100644 --- a/tests/test_gui.vcxproj.filters +++ b/tests/test_gui.vcxproj.filters @@ -23,6 +23,9 @@ Source Files + + Source Files + Source Files @@ -320,4 +323,4 @@ Resource Files - \ No newline at end of file + diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj index db9e9d3d4c..150f9f8879 100644 --- a/tests/test_vc8_test_gui.vcproj +++ b/tests/test_vc8_test_gui.vcproj @@ -858,6 +858,10 @@ RelativePath=".\controls\bitmaptogglebuttontest.cpp" > + + diff --git a/tests/test_vc9_test_gui.vcproj b/tests/test_vc9_test_gui.vcproj index 867da681f6..64c7eced6f 100644 --- a/tests/test_vc9_test_gui.vcproj +++ b/tests/test_vc9_test_gui.vcproj @@ -830,6 +830,10 @@ RelativePath=".\controls\bitmaptogglebuttontest.cpp" > + +