Merge in from trunk r67662 to r64801

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2011-07-25 16:54:53 +00:00
727 changed files with 42813 additions and 46104 deletions

View File

@@ -166,6 +166,7 @@ TEST_GUI_OBJECTS = \
test_gui_choicebooktest.o \
test_gui_choicetest.o \
test_gui_comboboxtest.o \
test_gui_datepickerctrltest.o \
test_gui_frametest.o \
test_gui_gaugetest.o \
test_gui_gridtest.o \
@@ -731,6 +732,9 @@ test_gui_choicetest.o: $(srcdir)/controls/choicetest.cpp $(TEST_GUI_ODEP)
test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp
test_gui_datepickerctrltest.o: $(srcdir)/controls/datepickerctrltest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/datepickerctrltest.cpp
test_gui_frametest.o: $(srcdir)/controls/frametest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/frametest.cpp

View File

@@ -680,7 +680,7 @@ void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out,
// then load the archive file
{
wxFFileInputStream in(tmparc);
if (in.Ok())
if (in.IsOk())
out.Write(in);
}
@@ -690,7 +690,7 @@ void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out,
// for the non-seekable test, have the archiver output to "-"
// and read the archive via a pipe
PFileInputStream in(wxString::Format(archiver, wxT("-")));
if (in.Ok())
if (in.IsOk())
out.Write(in);
}
}
@@ -893,7 +893,7 @@ void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in,
// write the archive to a temporary file
{
wxFFileOutputStream out(tmparc);
if (out.Ok())
if (out.IsOk())
out.Write(in);
}
@@ -905,7 +905,7 @@ void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in,
// for the non-seekable test, have the archiver extract "-" and
// feed it the archive via a pipe
PFileOutputStream out(wxString::Format(unarchiver, wxT("-")));
if (out.Ok())
if (out.IsOk())
out.Write(in);
}
@@ -958,7 +958,7 @@ void ArchiveTestCase<ClassFactoryT>::VerifyDir(wxString& path,
if (!isDir) {
wxFFileInputStream in(path);
CPPUNIT_ASSERT_MESSAGE(
"entry not found in archive" + error_entry, in.Ok());
"entry not found in archive" + error_entry, in.IsOk());
size_t size = (size_t)in.GetLength();
wxCharBuffer buf(size);

View File

@@ -180,7 +180,7 @@ void ZipPipeTestCase::runTest()
{
PFileInputStream in(cmd);
if (in.Ok())
if (in.IsOk())
out.Write(in);
}

View File

@@ -43,6 +43,7 @@ BENCH_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
$(CXXFLAGS)
BENCH_OBJECTS = \
bench_bench.o \
bench_datetime.o \
bench_htmlpars.o \
bench_htmltag.o \
bench_ipcclient.o \
@@ -131,6 +132,9 @@ data:
bench_bench.o: $(srcdir)/bench.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/bench.cpp
bench_datetime.o: $(srcdir)/datetime.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/datetime.cpp
bench_htmlpars.o: $(srcdir)/htmlparser/htmlpars.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmlpars.cpp

View File

@@ -11,6 +11,7 @@
template_append="wx_append_base">
<sources>
bench.cpp
datetime.cpp
htmlparser/htmlpars.cpp
htmlparser/htmltag.cpp
ipcclient.cpp

View File

@@ -239,6 +239,10 @@ SOURCE=.\bench.cpp
# End Source File
# Begin Source File
SOURCE=.\datetime.cpp
# End Source File
# Begin Source File
SOURCE=.\htmlparser\htmlpars.cpp
# End Source File
# Begin Source File

View File

@@ -544,6 +544,9 @@
<File
RelativePath=".\bench.cpp">
</File>
<File
RelativePath=".\datetime.cpp">
</File>
<File
RelativePath=".\htmlparser\htmlpars.cpp">
</File>

View File

@@ -807,6 +807,10 @@
RelativePath=".\bench.cpp"
>
</File>
<File
RelativePath=".\datetime.cpp"
>
</File>
<File
RelativePath=".\htmlparser\htmlpars.cpp"
>

View File

@@ -779,6 +779,10 @@
RelativePath=".\bench.cpp"
>
</File>
<File
RelativePath=".\datetime.cpp"
>
</File>
<File
RelativePath=".\htmlparser\htmlpars.cpp"
>

View File

@@ -0,0 +1,20 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tests/benchmarks/datetime.cpp
// Purpose: wxDateTime benchmarks
// Author: Vadim Zeitlin
// Created: 2011-05-23
// RCS-ID: $Id$
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/datetime.h"
#include "bench.h"
BENCHMARK_FUNC(ParseDate)
{
wxDateTime dt;
return dt.ParseDate("May 23, 2011") && dt.GetMonth() == wxDateTime::May;
}

View File

@@ -37,6 +37,7 @@ BENCH_CXXFLAGS = $(__RUNTIME_LIBS_7) -I$(BCCDIR)\include $(__DEBUGINFO) \
$(CPPFLAGS) $(CXXFLAGS)
BENCH_OBJECTS = \
$(OBJS)\bench_bench.obj \
$(OBJS)\bench_datetime.obj \
$(OBJS)\bench_htmlpars.obj \
$(OBJS)\bench_htmltag.obj \
$(OBJS)\bench_ipcclient.obj \
@@ -212,6 +213,9 @@ data:
$(OBJS)\bench_bench.obj: .\bench.cpp
$(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\bench.cpp
$(OBJS)\bench_datetime.obj: .\datetime.cpp
$(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\datetime.cpp
$(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp
$(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp

View File

@@ -30,6 +30,7 @@ BENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG) \
$(CXXFLAGS)
BENCH_OBJECTS = \
$(OBJS)\bench_bench.o \
$(OBJS)\bench_datetime.o \
$(OBJS)\bench_htmlpars.o \
$(OBJS)\bench_htmltag.o \
$(OBJS)\bench_ipcclient.o \
@@ -198,6 +199,9 @@ data:
$(OBJS)\bench_bench.o: ./bench.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_datetime.o: ./datetime.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\bench_htmlpars.o: ./htmlparser/htmlpars.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<

View File

@@ -31,6 +31,7 @@ BENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_10)$(__DEBUGRUNTIME_4) /DWIN32 \
$(CXXFLAGS)
BENCH_OBJECTS = \
$(OBJS)\bench_bench.obj \
$(OBJS)\bench_datetime.obj \
$(OBJS)\bench_htmlpars.obj \
$(OBJS)\bench_htmltag.obj \
$(OBJS)\bench_ipcclient.obj \
@@ -299,6 +300,9 @@ data:
$(OBJS)\bench_bench.obj: .\bench.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\bench.cpp
$(OBJS)\bench_datetime.obj: .\datetime.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\datetime.cpp
$(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp

View File

@@ -226,6 +226,7 @@ BENCH_CXXFLAGS = $(__DEBUGINFO_0) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG_5) &
$(__EXCEPTIONSFLAG_8) $(CPPFLAGS) $(CXXFLAGS)
BENCH_OBJECTS = &
$(OBJS)\bench_bench.obj &
$(OBJS)\bench_datetime.obj &
$(OBJS)\bench_htmlpars.obj &
$(OBJS)\bench_htmltag.obj &
$(OBJS)\bench_ipcclient.obj &
@@ -270,6 +271,9 @@ data : .SYMBOLIC
$(OBJS)\bench_bench.obj : .AUTODEPEND .\bench.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<
$(OBJS)\bench_datetime.obj : .AUTODEPEND .\datetime.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<
$(OBJS)\bench_htmlpars.obj : .AUTODEPEND .\htmlparser\htmlpars.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<

View File

@@ -139,6 +139,8 @@ void CmdLineTestCase::ParseSwitches()
p.AddSwitch("b");
p.AddSwitch("c");
p.AddSwitch("d");
p.AddSwitch("n", "neg", "Switch that can be negated",
wxCMD_LINE_SWITCH_NEGATABLE);
p.SetCmdLine("");
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
@@ -182,6 +184,23 @@ void CmdLineTestCase::ParseSwitches()
CPPUNIT_ASSERT( !p.Found("b") );
CPPUNIT_ASSERT( !p.Found("c") );
CPPUNIT_ASSERT( p.Found("d") );
p.SetCmdLine("-n");
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_NOT_FOUND, p.FoundSwitch("a") );
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("n") );
p.SetCmdLine("-n-");
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("neg") );
p.SetCmdLine("--neg");
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("neg") );
p.SetCmdLine("--neg-");
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("n") );
}
void CmdLineTestCase::Usage()

View File

@@ -0,0 +1,112 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/controls/datepickerctrltest.cpp
// Purpose: wxDatePickerCtrl unit test
// Author: Vadim Zeitlin
// Created: 2011-06-18
// RCS-ID: $Id$
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
///////////////////////////////////////////////////////////////////////////////
#include "testprec.h"
#if wxUSE_DATEPICKCTRL
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#endif // WX_PRECOMP
#include "wx/datectrl.h"
#include "testableframe.h"
#include "testdate.h"
class DatePickerCtrlTestCase : public CppUnit::TestCase
{
public:
DatePickerCtrlTestCase() { }
void setUp();
void tearDown();
private:
CPPUNIT_TEST_SUITE( DatePickerCtrlTestCase );
CPPUNIT_TEST( Value );
CPPUNIT_TEST( Range );
CPPUNIT_TEST_SUITE_END();
void Value();
void Range();
wxDatePickerCtrl* m_datepicker;
DECLARE_NO_COPY_CLASS(DatePickerCtrlTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( DatePickerCtrlTestCase );
// also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DatePickerCtrlTestCase, "DatePickerCtrlTestCase" );
void DatePickerCtrlTestCase::setUp()
{
m_datepicker = new wxDatePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
}
void DatePickerCtrlTestCase::tearDown()
{
delete m_datepicker;
}
void DatePickerCtrlTestCase::Value()
{
const wxDateTime dt(18, wxDateTime::Jul, 2011);
m_datepicker->SetValue(dt);
CPPUNIT_ASSERT_EQUAL( dt, m_datepicker->GetValue() );
// We don't use wxDP_ALLOWNONE currently, hence a value is required.
WX_ASSERT_FAILS_WITH_ASSERT( m_datepicker->SetValue(wxDateTime()) );
}
void DatePickerCtrlTestCase::Range()
{
// Initially we have no valid range but MSW version still has (built in)
// minimum as it doesn't support dates before 1601-01-01, hence don't rely
// on GetRange() returning false.
wxDateTime dtRangeStart, dtRangeEnd;
m_datepicker->GetRange(&dtRangeStart, &dtRangeEnd);
CPPUNIT_ASSERT( !dtRangeEnd.IsValid() );
// After we set it we should be able to get it back.
const wxDateTime
dtStart(15, wxDateTime::Feb, 1923),
dtEnd(18, wxDateTime::Jun, 2011);
m_datepicker->SetRange(dtStart, dtEnd);
CPPUNIT_ASSERT( m_datepicker->GetRange(&dtRangeStart, &dtRangeEnd) );
CPPUNIT_ASSERT_EQUAL( dtStart, dtRangeStart );
CPPUNIT_ASSERT_EQUAL( dtEnd, dtRangeEnd );
// Setting dates inside the range should work, including the range end
// points.
m_datepicker->SetValue(dtStart);
CPPUNIT_ASSERT_EQUAL( dtStart, m_datepicker->GetValue() );
m_datepicker->SetValue(dtEnd);
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
// Setting dates outside the range should not work.
m_datepicker->SetValue(dtEnd + wxTimeSpan::Day());
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
m_datepicker->SetValue(dtStart - wxTimeSpan::Day());
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
}
#endif // wxUSE_DATEPICKCTRL

View File

@@ -22,18 +22,9 @@
#if wxUSE_DATETIME
#include "wx/datetime.h"
#include "wx/wxcrt.h" // for wxStrstr()
// need this to be able to use CPPUNIT_ASSERT_EQUAL with wxDateTime objects
static std::ostream& operator<<(std::ostream& ostr, const wxDateTime& dt)
{
ostr << dt.FormatISOCombined(' ');
return ostr;
}
WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxDateTime::wxDateTime_t)
#include "testdate.h"
// to test Today() meaningfully we must be able to change the system date which
// is not usually the case, but if we're under Win32 we can try it -- define

View File

@@ -17,6 +17,10 @@
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/timer.h"
#endif
#include "wx/evtloop.h"
#include "wx/filename.h"
#include "wx/filefn.h"
@@ -248,7 +252,7 @@ public:
break;
case 2:
// actual test
CPPUNIT_ASSERT(CheckResult());
CheckResult();
Exit();
break;
@@ -325,7 +329,7 @@ public:
tested = true;
}
virtual bool CheckResult()
virtual void CheckResult()
{
CPPUNIT_ASSERT_MESSAGE( "No events received", !m_events.empty() );
@@ -356,8 +360,6 @@ public:
CPPUNIT_ASSERT_EQUAL(expected.GetPath(), e->GetPath());
CPPUNIT_ASSERT_EQUAL(expected.GetNewPath(), e->GetNewPath());
return true;
}
virtual void GenerateEvent() = 0;
@@ -414,6 +416,8 @@ private:
CPPUNIT_TEST( TestEventAccess );
#endif // __WXMSW__
#endif // !wxHAS_KQUEUE
CPPUNIT_TEST( TestNoEventsAfterRemove );
CPPUNIT_TEST_SUITE_END();
void TestEventCreate();
@@ -422,6 +426,8 @@ private:
void TestEventModify();
void TestEventAccess();
void TestNoEventsAfterRemove();
DECLARE_NO_COPY_CLASS(FileSystemWatcherTestCase)
};
@@ -607,3 +613,60 @@ void FileSystemWatcherTestCase::TestEventAccess()
EventTester tester;
tester.Run();
}
namespace
{
// We can't define this class locally inside TestNoEventsAfterRemove() for some
// reason with g++ 4.0 under OS X 10.5, it results in the following mysterious
// error:
//
// /var/tmp//ccTkNCkc.s:unknown:Non-global symbol:
// __ZThn80_ZN25FileSystemWatcherTestCase23TestNoEventsAfterRemoveEvEN11EventTester6NotifyEv.eh
// can't be a weak_definition
//
// So define this class outside the function instead.
class NoEventsAfterRemoveEventTester : public EventHandler,
public wxTimer
{
public:
NoEventsAfterRemoveEventTester()
{
// We need to use an inactivity timer as we never get any file
// system events in this test, so we consider that the test is
// finished when this 1s timeout expires instead of, as usual,
// stopping after getting the file system events.
Start(1000, true);
}
virtual void GenerateEvent()
{
m_watcher->Remove(EventGenerator::GetWatchDir());
CPPUNIT_ASSERT(eg.CreateFile());
}
virtual void CheckResult()
{
CPPUNIT_ASSERT( m_events.empty() );
}
virtual wxFileSystemWatcherEvent ExpectedEvent()
{
CPPUNIT_FAIL( "Shouldn't be called" );
return wxFileSystemWatcherEvent(wxFSW_EVENT_ERROR);
}
virtual void Notify()
{
SendIdle();
}
};
} // anonymous namespace
void FileSystemWatcherTestCase::TestNoEventsAfterRemove()
{
NoEventsAfterRemoveEventTester tester;
tester.Run();
}

View File

@@ -151,6 +151,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.obj \
$(OBJS)\test_gui_choicetest.obj \
$(OBJS)\test_gui_comboboxtest.obj \
$(OBJS)\test_gui_datepickerctrltest.obj \
$(OBJS)\test_gui_frametest.obj \
$(OBJS)\test_gui_gaugetest.obj \
$(OBJS)\test_gui_gridtest.obj \
@@ -779,6 +780,9 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp

View File

@@ -144,6 +144,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.o \
$(OBJS)\test_gui_choicetest.o \
$(OBJS)\test_gui_comboboxtest.o \
$(OBJS)\test_gui_datepickerctrltest.o \
$(OBJS)\test_gui_frametest.o \
$(OBJS)\test_gui_gaugetest.o \
$(OBJS)\test_gui_gridtest.o \
@@ -760,6 +761,9 @@ $(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp
$(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_frametest.o: ./controls/frametest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<

View File

@@ -146,6 +146,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_choicebooktest.obj \
$(OBJS)\test_gui_choicetest.obj \
$(OBJS)\test_gui_comboboxtest.obj \
$(OBJS)\test_gui_datepickerctrltest.obj \
$(OBJS)\test_gui_frametest.obj \
$(OBJS)\test_gui_gaugetest.obj \
$(OBJS)\test_gui_gridtest.obj \
@@ -905,6 +906,9 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp

View File

@@ -390,6 +390,7 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_choicebooktest.obj &
$(OBJS)\test_gui_choicetest.obj &
$(OBJS)\test_gui_comboboxtest.obj &
$(OBJS)\test_gui_datepickerctrltest.obj &
$(OBJS)\test_gui_frametest.obj &
$(OBJS)\test_gui_gaugetest.obj &
$(OBJS)\test_gui_gridtest.obj &
@@ -819,6 +820,9 @@ $(OBJS)\test_gui_choicetest.obj : .AUTODEPEND .\controls\choicetest.cpp
$(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
$(OBJS)\test_gui_frametest.obj : .AUTODEPEND .\controls\frametest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<

View File

@@ -84,6 +84,7 @@ private:
CPPUNIT_TEST( FindInMenu );
CPPUNIT_TEST( Count );
CPPUNIT_TEST( Labels );
CPPUNIT_TEST( RadioItems );
CPPUNIT_TEST_SUITE_END();
void CreateFrame();
@@ -92,6 +93,7 @@ private:
void FindInMenu();
void Count();
void Labels();
void RadioItems();
wxFrame* m_frame;
@@ -304,3 +306,56 @@ void MenuTestCase::Labels()
CPPUNIT_ASSERT_EQUAL( "Foo", itemFoo->GetItemLabelText() );
CPPUNIT_ASSERT_EQUAL( "Foo", wxMenuItem::GetLabelText("&Foo\tCtrl-F") );
}
void MenuTestCase::RadioItems()
{
wxMenuBar * const bar = m_frame->GetMenuBar();
wxMenu * const menu = new wxMenu;
bar->Append(menu, "&Radio");
// Adding consecutive radio items creates a radio group.
menu->AppendRadioItem(MenuTestCase_First, "Radio 0");
menu->AppendRadioItem(MenuTestCase_First + 1, "Radio 1");
// First item of a radio group is checked by default.
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) );
// Checking the second one make the first one unchecked however.
menu->Check(MenuTestCase_First + 1, true);
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First) );
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
// Adding more radio items after a separator creates another radio group...
menu->AppendSeparator();
menu->AppendRadioItem(MenuTestCase_First + 2, "Radio 2");
menu->AppendRadioItem(MenuTestCase_First + 3, "Radio 3");
menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4");
// ... which is independent from the first one.
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) );
menu->Check(MenuTestCase_First + 3, true);
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) );
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) );
// Insert an item in the middle of an existing radio group.
menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5");
CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) );
menu->Check( MenuTestCase_First + 5, true );
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) );
// Prepend a couple of items before the first group.
menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6");
menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7");
menu->Check(MenuTestCase_First + 7, true);
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) );
// Check that the last radio group still works as expected.
menu->Check(MenuTestCase_First + 4, true);
CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) );
}

View File

@@ -153,7 +153,8 @@ public:
ProcessData(&*Values.begin(), Values.size(), pfnWriter, pfnReader);
}
bool Ok(void) const {
bool IsOk() const
{
return m_ok;
}
};
@@ -214,8 +215,8 @@ void DataStreamTestCase::LongLongRW()
CPPUNIT_ASSERT( TestRW(wxLongLong(0x12345678l)) == wxLongLong(0x12345678l) );
CPPUNIT_ASSERT( TestRW(wxLongLong(0x12345678l, 0xabcdef01l)) == wxLongLong(0x12345678l, 0xabcdef01l) );
CPPUNIT_ASSERT( TestMultiRW<wxLongLong>(ValuesLL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).Ok() );
CPPUNIT_ASSERT( TestMultiRW<wxULongLong>(ValuesULL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).Ok() );
CPPUNIT_ASSERT( TestMultiRW<wxLongLong>(ValuesLL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).IsOk() );
CPPUNIT_ASSERT( TestMultiRW<wxULongLong>(ValuesULL, &wxDataOutputStream::WriteLL, &wxDataInputStream::ReadLL).IsOk() );
}
#endif
@@ -238,8 +239,8 @@ void DataStreamTestCase::Int64RW()
CPPUNIT_ASSERT( TestRW(wxUint64(0x12345678l)) == wxUint64(0x12345678l) );
CPPUNIT_ASSERT( TestRW((wxUint64(0x12345678l) << 32) + wxUint64(0xabcdef01l)) == (wxUint64(0x12345678l) << 32) + wxUint64(0xabcdef01l) );
CPPUNIT_ASSERT( TestMultiRW<wxInt64>(ValuesI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).Ok() );
CPPUNIT_ASSERT( TestMultiRW<wxUint64>(ValuesUI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).Ok() );
CPPUNIT_ASSERT( TestMultiRW<wxInt64>(ValuesI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).IsOk() );
CPPUNIT_ASSERT( TestMultiRW<wxUint64>(ValuesUI64, &wxDataOutputStream::Write64, &wxDataInputStream::Read64).IsOk() );
}
#endif

View File

@@ -220,7 +220,7 @@ protected:
wxInputStream *LargeFileTest_wxFile::MakeInStream(const wxString& name) const
{
auto_ptr<wxFileInputStream> in(new wxFileInputStream(name));
CPPUNIT_ASSERT(in->Ok());
CPPUNIT_ASSERT(in->IsOk());
return in.release();
}
@@ -252,7 +252,7 @@ protected:
wxInputStream *LargeFileTest_wxFFile::MakeInStream(const wxString& name) const
{
auto_ptr<wxFFileInputStream> in(new wxFFileInputStream(name));
CPPUNIT_ASSERT(in->Ok());
CPPUNIT_ASSERT(in->IsOk());
return in.release();
}

View File

@@ -129,7 +129,7 @@ void TextStreamTestCase::MiscTests()
{
wxString filename = wxT("testdata.fc");
wxFileInputStream fsIn(filename);
if ( !fsIn.Ok() )
if ( !fsIn.IsOk() )
{
return;
}

View File

@@ -39,6 +39,9 @@ private:
CPPUNIT_TEST( CharPrintf );
#if wxUSE_STD_STRING
CPPUNIT_TEST( StdString );
#endif
#if wxUSE_LONGLONG
CPPUNIT_TEST( LongLongPrintf );
#endif
CPPUNIT_TEST( Sscanf );
CPPUNIT_TEST( RepeatedPrintf );
@@ -49,6 +52,9 @@ private:
void CharPrintf();
#if wxUSE_STD_STRING
void StdString();
#endif
#if wxUSE_LONGLONG
void LongLongPrintf();
#endif
void Sscanf();
void RepeatedPrintf();
@@ -152,6 +158,18 @@ void VarArgTestCase::StdString()
}
#endif // wxUSE_STD_STRING
#if wxUSE_LONGLONG
void VarArgTestCase::LongLongPrintf()
{
const char * const llfmt = "%" wxLongLongFmtSpec "d";
CPPUNIT_ASSERT_EQUAL( "17", wxString::Format(llfmt, wxLL(17)) );
wxLongLong ll = 1234567890;
CPPUNIT_ASSERT_EQUAL( "1234567890", wxString::Format(llfmt, ll) );
}
#endif // wxUSE_LONGLONG
void VarArgTestCase::Sscanf()
{
int i = 0;

View File

@@ -147,6 +147,7 @@
controls/choicebooktest.cpp
controls/choicetest.cpp
controls/comboboxtest.cpp
controls/datepickerctrltest.cpp
controls/frametest.cpp
controls/gaugetest.cpp
controls/gridtest.cpp

View File

@@ -307,6 +307,10 @@ SOURCE=.\config\config.cpp
# End Source File
# Begin Source File
SOURCE=.\controls\datepickerctrltest.cpp
# End Source File
# Begin Source File
SOURCE=.\dummy.cpp
# ADD BASE CPP /Yc"testprec.h"
# ADD CPP /Yc"testprec.h"

View File

@@ -619,6 +619,9 @@
<File
RelativePath=".\config\config.cpp">
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp">
</File>
<File
RelativePath=".\dummy.cpp">
<FileConfiguration

View File

@@ -899,6 +899,10 @@
RelativePath=".\config\config.cpp"
>
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp"
>
</File>
<File
RelativePath=".\dummy.cpp"
>

View File

@@ -871,6 +871,10 @@
RelativePath=".\config\config.cpp"
>
</File>
<File
RelativePath=".\controls\datepickerctrltest.cpp"
>
</File>
<File
RelativePath=".\dummy.cpp"
>

25
tests/testdate.h Normal file
View File

@@ -0,0 +1,25 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/testdate.h
// Purpose: Unit test helpers for dealing with wxDateTime.
// Author: Vadim Zeitlin
// RCS-ID: $Id$
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TESTS_TESTDATE_H_
#define _WX_TESTS_TESTDATE_H_
#include "wx/datetime.h"
// need this to be able to use CPPUNIT_ASSERT_EQUAL with wxDateTime objects
inline std::ostream& operator<<(std::ostream& ostr, const wxDateTime& dt)
{
ostr << dt.FormatISOCombined(' ');
return ostr;
}
WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxDateTime::wxDateTime_t)
#endif // _WX_TESTS_TESTDATE_H_

View File

@@ -37,10 +37,12 @@ public:
private:
CPPUNIT_TEST_SUITE( ClientSizeTestCase );
CPPUNIT_TEST( ClientToWindow );
CPPUNIT_TEST( ClientSizeNotNegative );
CPPUNIT_TEST( WindowToClient );
CPPUNIT_TEST_SUITE_END();
void ClientToWindow();
void ClientSizeNotNegative();
void WindowToClient();
wxWindow *m_win;
@@ -78,6 +80,18 @@ void ClientSizeTestCase::ClientToWindow()
m_win->ClientToWindowSize(m_win->GetClientSize()));
}
void ClientSizeTestCase::ClientSizeNotNegative()
{
wxWindow* w = new wxWindow(wxTheApp->GetTopWindow(), -1,
wxDefaultPosition, wxDefaultSize,
wxBORDER_THEME);
w->SetSize(wxSize(1,1));
const wxSize szw = w->GetClientSize();
CPPUNIT_ASSERT(szw.GetWidth() >= 0);
CPPUNIT_ASSERT(szw.GetHeight() >= 0);
w->Destroy();
}
void ClientSizeTestCase::WindowToClient()
{
CPPUNIT_ASSERT(m_win->GetClientSize() ==