From 841a25bbc345369cc1794e80ff4b7c082909cb97 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Sep 2008 16:03:45 +0000 Subject: [PATCH] added a simple test for wxGetDisplayXXX() functions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/Makefile.in | 4 ++ tests/makefile.bcc | 4 ++ tests/makefile.gcc | 4 ++ tests/makefile.vc | 4 ++ tests/makefile.wat | 4 ++ tests/misc/guifuncs.cpp | 69 ++++++++++++++++++++++++++++++++++ tests/test.bkl | 1 + tests/test_test_gui.dsp | 4 ++ tests/test_vc7_test_gui.vcproj | 2 + tests/test_vc8_test_gui.vcproj | 3 ++ 10 files changed, 99 insertions(+) create mode 100644 tests/misc/guifuncs.cpp diff --git a/tests/Makefile.in b/tests/Makefile.in index bbff08c43a..b391b3a8cb 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -124,6 +124,7 @@ TEST_GUI_OBJECTS = \ test_gui_textctrltest.o \ test_gui_textentrytest.o \ test_gui_rawbmp.o \ + test_gui_guifuncs.o \ test_gui_selstoretest.o \ test_gui_clientsize.o \ test_gui_setsize.o @@ -531,6 +532,9 @@ test_gui_textentrytest.o: $(srcdir)/controls/textentrytest.cpp $(TEST_GUI_ODEP) test_gui_rawbmp.o: $(srcdir)/image/rawbmp.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/image/rawbmp.cpp +test_gui_guifuncs.o: $(srcdir)/misc/guifuncs.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/misc/guifuncs.cpp + test_gui_selstoretest.o: $(srcdir)/misc/selstoretest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/misc/selstoretest.cpp diff --git a/tests/makefile.bcc b/tests/makefile.bcc index aff1930ca8..88144e0b32 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -112,6 +112,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ $(OBJS)\test_gui_rawbmp.obj \ + $(OBJS)\test_gui_guifuncs.obj \ $(OBJS)\test_gui_selstoretest.obj \ $(OBJS)\test_gui_clientsize.obj \ $(OBJS)\test_gui_setsize.obj @@ -572,6 +573,9 @@ $(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp $(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp +$(OBJS)\test_gui_guifuncs.obj: .\misc\guifuncs.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\misc\guifuncs.cpp + $(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\misc\selstoretest.cpp diff --git a/tests/makefile.gcc b/tests/makefile.gcc index b201e85bec..2dcf5a66d2 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -105,6 +105,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_textctrltest.o \ $(OBJS)\test_gui_textentrytest.o \ $(OBJS)\test_gui_rawbmp.o \ + $(OBJS)\test_gui_guifuncs.o \ $(OBJS)\test_gui_selstoretest.o \ $(OBJS)\test_gui_clientsize.o \ $(OBJS)\test_gui_setsize.o @@ -550,6 +551,9 @@ $(OBJS)\test_gui_textentrytest.o: ./controls/textentrytest.cpp $(OBJS)\test_gui_rawbmp.o: ./image/rawbmp.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_guifuncs.o: ./misc/guifuncs.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_selstoretest.o: ./misc/selstoretest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index dc2ec67e06..331705a2fd 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -108,6 +108,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ $(OBJS)\test_gui_rawbmp.obj \ + $(OBJS)\test_gui_guifuncs.obj \ $(OBJS)\test_gui_selstoretest.obj \ $(OBJS)\test_gui_clientsize.obj \ $(OBJS)\test_gui_setsize.obj @@ -657,6 +658,9 @@ $(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp $(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp +$(OBJS)\test_gui_guifuncs.obj: .\misc\guifuncs.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\misc\guifuncs.cpp + $(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\misc\selstoretest.cpp diff --git a/tests/makefile.wat b/tests/makefile.wat index 15b4793f55..cc01f9613f 100644 --- a/tests/makefile.wat +++ b/tests/makefile.wat @@ -317,6 +317,7 @@ TEST_GUI_OBJECTS = & $(OBJS)\test_gui_textctrltest.obj & $(OBJS)\test_gui_textentrytest.obj & $(OBJS)\test_gui_rawbmp.obj & + $(OBJS)\test_gui_guifuncs.obj & $(OBJS)\test_gui_selstoretest.obj & $(OBJS)\test_gui_clientsize.obj & $(OBJS)\test_gui_setsize.obj @@ -603,6 +604,9 @@ $(OBJS)\test_gui_textentrytest.obj : .AUTODEPEND .\controls\textentrytest.cpp $(OBJS)\test_gui_rawbmp.obj : .AUTODEPEND .\image\rawbmp.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_guifuncs.obj : .AUTODEPEND .\misc\guifuncs.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_selstoretest.obj : .AUTODEPEND .\misc\selstoretest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< diff --git a/tests/misc/guifuncs.cpp b/tests/misc/guifuncs.cpp new file mode 100644 index 0000000000..886769aa51 --- /dev/null +++ b/tests/misc/guifuncs.cpp @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/misc/misctests.cpp +// Purpose: test miscellaneous GUI functions +// Author: Vadim Zeitlin +// Created: 2008-09-22 +// RCS-ID: $Id$ +// Copyright: (c) 2008 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/defs.h" + +// ---------------------------------------------------------------------------- +// test class +// ---------------------------------------------------------------------------- + +class MiscGUIFuncsTestCase : public CppUnit::TestCase +{ +public: + MiscGUIFuncsTestCase() { } + +private: + CPPUNIT_TEST_SUITE( MiscGUIFuncsTestCase ); + CPPUNIT_TEST( DisplaySize ); + CPPUNIT_TEST_SUITE_END(); + + void DisplaySize(); + + DECLARE_NO_COPY_CLASS(MiscGUIFuncsTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( MiscGUIFuncsTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MiscGUIFuncsTestCase, "MiscGUIFuncsTestCase" ); + +void MiscGUIFuncsTestCase::DisplaySize() +{ + // test that different (almost) overloads return the same results + int w, h; + wxDisplaySize(&w, &h); + wxSize sz = wxGetDisplaySize(); + + CPPUNIT_ASSERT_EQUAL( w, sz.x ); + CPPUNIT_ASSERT_EQUAL( h, sz.y ); + + // test that passing NULL works as expected, e.g. doesn't crash + wxDisplaySize(NULL, NULL); + wxDisplaySize(&w, NULL); + wxDisplaySize(NULL, &h); + + CPPUNIT_ASSERT_EQUAL( w, sz.x ); + CPPUNIT_ASSERT_EQUAL( h, sz.y ); + + // test that display PPI is something reasonable + sz = wxGetDisplayPPI(); + CPPUNIT_ASSERT( sz.x < 1000 && sz.y < 1000 ); +} + diff --git a/tests/test.bkl b/tests/test.bkl index 80ec00b75f..f6d3ec51ae 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -109,6 +109,7 @@ controls/textctrltest.cpp controls/textentrytest.cpp image/rawbmp.cpp + misc/guifuncs.cpp misc/selstoretest.cpp window/clientsize.cpp window/setsize.cpp diff --git a/tests/test_test_gui.dsp b/tests/test_test_gui.dsp index b3b644d5b2..396016da2d 100644 --- a/tests/test_test_gui.dsp +++ b/tests/test_test_gui.dsp @@ -253,6 +253,10 @@ SOURCE=.\dummy.cpp # End Source File # Begin Source File +SOURCE=.\misc\guifuncs.cpp +# End Source File +# Begin Source File + SOURCE=.\geometry\point.cpp # End Source File # Begin Source File diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index 9f942f2aca..bfc46ef2ab 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -706,6 +706,8 @@ UsePrecompiledHeader="1"/> + + -- 2.45.2