--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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() );
+}
+
<?xml version="1.0" encoding="Windows-1252"?>\r
-<!--\r
-\r
- This project was generated by\r
- Bakefile 0.2.8 (http://www.bakefile.org)\r
- Do not modify, all changes will be overwritten!\r
-\r
--->\r
<VisualStudioProject\r
ProjectType="Visual C++"\r
Version="9.00"\r
Name="test_gui"\r
ProjectGUID="{9BB295D9-A6AA-510D-AA0D-9375B5D91025}"\r
+ TargetFrameworkVersion="0"
>\r
<Platforms>\r
<Platform\r
/>\r
</Platforms>\r
<ToolFiles>\r
- \r
</ToolFiles>\r
<Configurations>\r
<Configuration\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswud\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswud\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswu\test_gui.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswu\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswu\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivud\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivud\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswunivu\test_gui.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivu\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivu\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswuddll\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswuddll\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswudll\test_gui.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswudll\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswudll\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivuddll\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivuddll\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
GenerateDebugInformation="true"\r
ProgramDatabaseFile="vc_mswunivudll\test_gui.pdb"\r
SubSystem="1"\r
- TargetMachine="1"\r
OptimizeReferences="2"\r
EnableCOMDATFolding="2"\r
+ TargetMachine="1"
/>\r
<Tool\r
Name="VCALinkTool"\r
/>\r
<Tool\r
Name="VCBscMakeTool"\r
- OutputFile="vc_mswunivudll\test_vc9_test_gui.bsc"\r
SuppressStartupBanner="true"\r
+ OutputFile="vc_mswunivudll\test_vc9_test_gui.bsc"
/>\r
<Tool\r
Name="VCFxCopTool"\r
</Configuration>\r
</Configurations>\r
<References>\r
- \r
</References>\r
<Files>\r
<Filter\r
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
>\r
<File\r
+ RelativePath=".\sizers\boxsizer.cpp"
+ >
+ </File>
+ <File
RelativePath=".\window\clientsize.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\events\clone.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\graphics\colour.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\controls\comboboxtest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\config\config.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\dummy.cpp"\r
<File\r
RelativePath=".\font\fonttest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\misc\garbage.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\misc\guifuncs.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\controls\headerctrltest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\html\htmlwindow.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\image\image.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\controls\listctrltest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\graphics\measuring.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\geometry\point.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\events\propagation.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\image\rawbmp.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\geometry\rect.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\misc\selstoretest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\window\setsize.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\misc\settings.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\geometry\size.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\net\socket.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\test.cpp"\r
<File\r
RelativePath=".\controls\textctrltest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\controls\textentrytest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
<File\r
RelativePath=".\controls\treectrltest.cpp"\r
>\r
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>\r
</Filter>\r
<Filter\r
</Filter>\r
</Files>\r
<Globals>\r
- \r
</Globals>\r
</VisualStudioProject>\r
-\r