Add (a very simple for now) wxBoxSizer unit test.

Only check that layout for a single sizer item works correctly for now.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-03-18 15:07:10 +00:00
parent bbf82147ab
commit 869c7a944b
11 changed files with 356 additions and 23 deletions

View File

@ -156,6 +156,7 @@ TEST_GUI_OBJECTS = \
test_gui_garbage.o \
test_gui_settings.o \
test_gui_socket.o \
test_gui_boxsizer.o \
test_gui_clientsize.o \
test_gui_setsize.o
TEST_GUI_ODEP = $(_____pch_testprec_test_gui_testprec_h_gch___depname)
@ -634,6 +635,9 @@ test_gui_settings.o: $(srcdir)/misc/settings.cpp $(TEST_GUI_ODEP)
test_gui_socket.o: $(srcdir)/net/socket.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/net/socket.cpp
test_gui_boxsizer.o: $(srcdir)/sizers/boxsizer.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/sizers/boxsizer.cpp
test_gui_clientsize.o: $(srcdir)/window/clientsize.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/window/clientsize.cpp

View File

@ -141,6 +141,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_garbage.obj \
$(OBJS)\test_gui_settings.obj \
$(OBJS)\test_gui_socket.obj \
$(OBJS)\test_gui_boxsizer.obj \
$(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
@ -688,6 +689,9 @@ $(OBJS)\test_gui_settings.obj: .\misc\settings.cpp
$(OBJS)\test_gui_socket.obj: .\net\socket.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\net\socket.cpp
$(OBJS)\test_gui_boxsizer.obj: .\sizers\boxsizer.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\sizers\boxsizer.cpp
$(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp

View File

@ -135,6 +135,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_garbage.o \
$(OBJS)\test_gui_settings.o \
$(OBJS)\test_gui_socket.o \
$(OBJS)\test_gui_boxsizer.o \
$(OBJS)\test_gui_clientsize.o \
$(OBJS)\test_gui_setsize.o
@ -670,6 +671,9 @@ $(OBJS)\test_gui_settings.o: ./misc/settings.cpp
$(OBJS)\test_gui_socket.o: ./net/socket.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_boxsizer.o: ./sizers/boxsizer.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_clientsize.o: ./window/clientsize.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<

View File

@ -136,6 +136,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_garbage.obj \
$(OBJS)\test_gui_settings.obj \
$(OBJS)\test_gui_socket.obj \
$(OBJS)\test_gui_boxsizer.obj \
$(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_setsize.obj
TEST_GUI_RESOURCES = \
@ -814,6 +815,9 @@ $(OBJS)\test_gui_settings.obj: .\misc\settings.cpp
$(OBJS)\test_gui_socket.obj: .\net\socket.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\net\socket.cpp
$(OBJS)\test_gui_boxsizer.obj: .\sizers\boxsizer.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\sizers\boxsizer.cpp
$(OBJS)\test_gui_clientsize.obj: .\window\clientsize.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\window\clientsize.cpp

View File

@ -379,6 +379,7 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_garbage.obj &
$(OBJS)\test_gui_settings.obj &
$(OBJS)\test_gui_socket.obj &
$(OBJS)\test_gui_boxsizer.obj &
$(OBJS)\test_gui_clientsize.obj &
$(OBJS)\test_gui_setsize.obj
@ -725,6 +726,9 @@ $(OBJS)\test_gui_settings.obj : .AUTODEPEND .\misc\settings.cpp
$(OBJS)\test_gui_socket.obj : .AUTODEPEND .\net\socket.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_boxsizer.obj : .AUTODEPEND .\sizers\boxsizer.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_clientsize.obj : .AUTODEPEND .\window\clientsize.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<

107
tests/sizers/boxsizer.cpp Normal file
View File

@ -0,0 +1,107 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/sizers/boxsizer.cpp
// Purpose: Unit tests for wxBoxSizer
// Author: Vadim Zeitlin
// Created: 2010-03-06
// RCS-ID: $Id$
// Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/sizer.h"
#endif // WX_PRECOMP
inline std::ostream& operator<<(std::ostream& o, const wxSize& s)
{
return o << s.x << 'x' << s.y;
}
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class BoxSizerTestCase : public CppUnit::TestCase
{
public:
BoxSizerTestCase() { }
virtual void setUp();
virtual void tearDown();
private:
CPPUNIT_TEST_SUITE( BoxSizerTestCase );
CPPUNIT_TEST( Size1 );
CPPUNIT_TEST_SUITE_END();
void Size1();
wxWindow *m_win;
wxSizer *m_sizer;
DECLARE_NO_COPY_CLASS(BoxSizerTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( BoxSizerTestCase );
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BoxSizerTestCase, "BoxSizerTestCase" );
// ----------------------------------------------------------------------------
// test initialization
// ----------------------------------------------------------------------------
void BoxSizerTestCase::setUp()
{
m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
m_win->SetClientSize(127, 35);
m_sizer = new wxBoxSizer(wxHORIZONTAL);
m_win->SetSizer(m_sizer);
}
void BoxSizerTestCase::tearDown()
{
delete m_win;
m_win = NULL;
m_sizer = NULL;
}
// ----------------------------------------------------------------------------
// tests themselves
// ----------------------------------------------------------------------------
void BoxSizerTestCase::Size1()
{
const wxSize sizeTotal = m_win->GetClientSize();
const wxSize sizeChild = sizeTotal / 2;
wxWindow * const
child = new wxWindow(m_win, wxID_ANY, wxDefaultPosition, sizeChild);
m_sizer->Add(child);
m_win->Layout();
CPPUNIT_ASSERT_EQUAL( sizeChild, child->GetSize() );
;
m_sizer->Clear();
m_sizer->Add(child, wxSizerFlags(1));
m_win->Layout();
CPPUNIT_ASSERT_EQUAL( wxSize(sizeTotal.x, sizeChild.y), child->GetSize() );
m_sizer->Clear();
m_sizer->Add(child, wxSizerFlags(1).Expand());
m_win->Layout();
CPPUNIT_ASSERT_EQUAL( sizeTotal, child->GetSize() );
}

View File

@ -142,6 +142,7 @@
applications.
-->
net/socket.cpp
sizers/boxsizer.cpp
window/clientsize.cpp
window/setsize.cpp
</sources>

View File

@ -235,6 +235,10 @@ LINK32=link.exe
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\sizers\boxsizer.cpp
# End Source File
# Begin Source File
SOURCE=.\window\clientsize.cpp
# End Source File
# Begin Source File

View File

@ -566,6 +566,9 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\sizers\boxsizer.cpp">
</File>
<File
RelativePath=".\window\clientsize.cpp">
</File>
<File

View File

@ -828,6 +828,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\sizers\boxsizer.cpp"
>
</File>
<File
RelativePath=".\window\clientsize.cpp"
>
</File>

View File

@ -1,16 +1,10 @@
<?xml version="1.0" encoding="Windows-1252"?>
<!--
This project was generated by
Bakefile 0.2.8 (http://www.bakefile.org)
Do not modify, all changes will be overwritten!
-->
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="test_gui"
ProjectGUID="{9BB295D9-A6AA-510D-AA0D-9375B5D91025}"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
@ -18,7 +12,6 @@
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
@ -104,8 +97,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswud\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswud\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -185,9 +178,9 @@
GenerateDebugInformation="true"
ProgramDatabaseFile="vc_mswu\test_gui.pdb"
SubSystem="1"
TargetMachine="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -200,8 +193,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswu\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswu\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -296,8 +289,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswunivud\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswunivud\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -377,9 +370,9 @@
GenerateDebugInformation="true"
ProgramDatabaseFile="vc_mswunivu\test_gui.pdb"
SubSystem="1"
TargetMachine="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -392,8 +385,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswunivu\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswunivu\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -488,8 +481,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswuddll\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswuddll\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -569,9 +562,9 @@
GenerateDebugInformation="true"
ProgramDatabaseFile="vc_mswudll\test_gui.pdb"
SubSystem="1"
TargetMachine="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -584,8 +577,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswudll\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswudll\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -680,8 +673,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswunivuddll\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswunivuddll\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -761,9 +754,9 @@
GenerateDebugInformation="true"
ProgramDatabaseFile="vc_mswunivudll\test_gui.pdb"
SubSystem="1"
TargetMachine="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -776,8 +769,8 @@
/>
<Tool
Name="VCBscMakeTool"
OutputFile="vc_mswunivudll\test_vc9_test_gui.bsc"
SuppressStartupBanner="true"
OutputFile="vc_mswunivudll\test_vc9_test_gui.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -791,7 +784,6 @@
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
@ -800,24 +792,68 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\sizers\boxsizer.cpp"
>
</File>
<File
RelativePath=".\window\clientsize.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\events\clone.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\graphics\colour.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\controls\comboboxtest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\config\config.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\dummy.cpp"
@ -894,70 +930,206 @@
<File
RelativePath=".\font\fonttest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\misc\garbage.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\misc\guifuncs.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\controls\headerctrltest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\html\htmlwindow.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\image\image.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\controls\listctrltest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\graphics\measuring.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\geometry\point.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\events\propagation.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\image\rawbmp.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\geometry\rect.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\misc\selstoretest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\window\setsize.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\misc\settings.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\geometry\size.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\net\socket.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\test.cpp"
@ -966,14 +1138,38 @@
<File
RelativePath=".\controls\textctrltest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\controls\textentrytest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\controls\treectrltest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
@ -988,7 +1184,5 @@
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>