diff --git a/tests/Makefile.in b/tests/Makefile.in index d20559e8fe..bc37e442f9 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -243,6 +243,7 @@ TEST_GUI_OBJECTS = \ test_gui_rawbmp.o \ test_gui_htmlparser.o \ test_gui_htmlwindow.o \ + test_gui_htmprint.o \ test_gui_accelentry.o \ test_gui_menu.o \ test_gui_guifuncs.o \ @@ -997,6 +998,9 @@ test_gui_htmlparser.o: $(srcdir)/html/htmlparser.cpp $(TEST_GUI_ODEP) test_gui_htmlwindow.o: $(srcdir)/html/htmlwindow.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/html/htmlwindow.cpp +test_gui_htmprint.o: $(srcdir)/html/htmprint.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/html/htmprint.cpp + test_gui_accelentry.o: $(srcdir)/menu/accelentry.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/menu/accelentry.cpp diff --git a/tests/html/htmprint.cpp b/tests/html/htmprint.cpp new file mode 100644 index 0000000000..0466182845 --- /dev/null +++ b/tests/html/htmprint.cpp @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/html/htmprint.cpp +// Purpose: wxHtmlPrintout tests +// Author: Vadim Zeitlin +// Created: 2018-05-22 +// Copyright: (c) 2018 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#if wxUSE_HTML + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/dcmemory.h" +#endif // WX_PRECOMP + +#include "wx/html/htmprint.h" + +namespace +{ + +// Return the number of pages in the printout. +int CountPages(wxHtmlPrintout& pr) +{ + REQUIRE_NOTHROW( pr.OnPreparePrinting() ); + + int pageMin = -1, + pageMax = -1, + selFrom = -1, + selTo = -1; + REQUIRE_NOTHROW( pr.GetPageInfo(&pageMin, &pageMax, &selFrom, &selTo) ); + + // This should be always the case. + CHECK( pageMin == 1 ); + + // Return the really interesting value to the caller. + return pageMax; +} + +} // anonymous namespace + +TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]") +{ + wxHtmlPrintout pr; + + wxBitmap bmp(1000, 1000); + wxMemoryDC dc(bmp); + pr.SetUp(dc); + + // Empty or short HTML documents should be printed on a single page only. + CHECK( CountPages(pr) == 1 ); + + pr.SetHtmlText("

Hello world!

"); + CHECK( CountPages(pr) == 1 ); + + // This one should be too big to fit on a single page. + pr.SetHtmlText + ( + "" + "
" + "" + ); + CHECK( CountPages(pr) == 2 ); + + // Special case: normally images are not split, but if the image height is + // greater than the page height, it should be. + pr.SetHtmlText + ( + "" + ); + CHECK( CountPages(pr) == 3 ); +} + +#endif //wxUSE_HTML diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 30897885eb..69ff216d07 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -229,6 +229,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_rawbmp.obj \ $(OBJS)\test_gui_htmlparser.obj \ $(OBJS)\test_gui_htmlwindow.obj \ + $(OBJS)\test_gui_htmprint.obj \ $(OBJS)\test_gui_accelentry.obj \ $(OBJS)\test_gui_menu.obj \ $(OBJS)\test_gui_guifuncs.obj \ @@ -1050,6 +1051,9 @@ $(OBJS)\test_gui_htmlparser.obj: .\html\htmlparser.cpp $(OBJS)\test_gui_htmlwindow.obj: .\html\htmlwindow.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\html\htmlwindow.cpp +$(OBJS)\test_gui_htmprint.obj: .\html\htmprint.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\html\htmprint.cpp + $(OBJS)\test_gui_accelentry.obj: .\menu\accelentry.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\menu\accelentry.cpp diff --git a/tests/makefile.gcc b/tests/makefile.gcc index b9a05edb64..9855000899 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -224,6 +224,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_rawbmp.o \ $(OBJS)\test_gui_htmlparser.o \ $(OBJS)\test_gui_htmlwindow.o \ + $(OBJS)\test_gui_htmprint.o \ $(OBJS)\test_gui_accelentry.o \ $(OBJS)\test_gui_menu.o \ $(OBJS)\test_gui_guifuncs.o \ @@ -1027,6 +1028,9 @@ $(OBJS)\test_gui_htmlparser.o: ./html/htmlparser.cpp $(OBJS)\test_gui_htmlwindow.o: ./html/htmlwindow.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_htmprint.o: ./html/htmprint.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_accelentry.o: ./menu/accelentry.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index 8ae6c6c439..60ecf9ff0c 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -235,6 +235,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_rawbmp.obj \ $(OBJS)\test_gui_htmlparser.obj \ $(OBJS)\test_gui_htmlwindow.obj \ + $(OBJS)\test_gui_htmprint.obj \ $(OBJS)\test_gui_accelentry.obj \ $(OBJS)\test_gui_menu.obj \ $(OBJS)\test_gui_guifuncs.obj \ @@ -1229,6 +1230,9 @@ $(OBJS)\test_gui_htmlparser.obj: .\html\htmlparser.cpp $(OBJS)\test_gui_htmlwindow.obj: .\html\htmlwindow.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\html\htmlwindow.cpp +$(OBJS)\test_gui_htmprint.obj: .\html\htmprint.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\html\htmprint.cpp + $(OBJS)\test_gui_accelentry.obj: .\menu\accelentry.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\menu\accelentry.cpp diff --git a/tests/test.bkl b/tests/test.bkl index 47016bcf33..4db76b86cb 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -249,6 +249,7 @@ image/rawbmp.cpp html/htmlparser.cpp html/htmlwindow.cpp + html/htmprint.cpp menu/accelentry.cpp menu/menu.cpp misc/guifuncs.cpp diff --git a/tests/test_gui.vcxproj b/tests/test_gui.vcxproj index af4d68b517..d7710c370f 100644 --- a/tests/test_gui.vcxproj +++ b/tests/test_gui.vcxproj @@ -535,6 +535,7 @@ + @@ -564,4 +565,4 @@ - + \ No newline at end of file diff --git a/tests/test_gui.vcxproj.filters b/tests/test_gui.vcxproj.filters index 40ab41a51d..bd3fbfdc4d 100644 --- a/tests/test_gui.vcxproj.filters +++ b/tests/test_gui.vcxproj.filters @@ -293,10 +293,13 @@ Source Files + + Source Files + Resource Files - + \ No newline at end of file diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index 484c4776ac..eade1cba94 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -439,6 +439,9 @@ + + diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj index 15fda65a98..8ab1a7002d 100644 --- a/tests/test_vc8_test_gui.vcproj +++ b/tests/test_vc8_test_gui.vcproj @@ -1054,6 +1054,10 @@ RelativePath=".\html\htmlwindow.cpp" > + + diff --git a/tests/test_vc9_test_gui.vcproj b/tests/test_vc9_test_gui.vcproj index 6e99dc8de7..6852c292ab 100644 --- a/tests/test_vc9_test_gui.vcproj +++ b/tests/test_vc9_test_gui.vcproj @@ -1026,6 +1026,10 @@ RelativePath=".\html\htmlwindow.cpp" > + +