add unit test for wxTextEntry methods of wxComboBox
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -120,6 +120,7 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_size.o \
|
||||
test_gui_point.o \
|
||||
test_gui_config.o \
|
||||
test_gui_comboboxtest.o \
|
||||
test_gui_textctrltest.o \
|
||||
test_gui_textentrytest.o \
|
||||
test_gui_rawbmp.o \
|
||||
@@ -518,6 +519,9 @@ test_gui_point.o: $(srcdir)/geometry/point.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/config/config.cpp
|
||||
|
||||
test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp
|
||||
|
||||
test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp
|
||||
|
||||
|
83
tests/controls/comboboxtest.cpp
Normal file
83
tests/controls/comboboxtest.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/comboboxtest.cpp
|
||||
// Purpose: wxComboBox unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2007-09-25
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/combobox.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "textentrytest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class ComboBoxTestCase : public TextEntryTestCase
|
||||
{
|
||||
public:
|
||||
ComboBoxTestCase() { }
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
private:
|
||||
virtual wxTextEntry *GetTestEntry() const { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const { return m_combo; }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel))
|
||||
{
|
||||
// do nothing here, as explained in TextEntryTestCase comment, our
|
||||
// GetStringSelection() is the wxChoice, not wxTextEntry, one and there
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE( ComboBoxTestCase );
|
||||
wxTEXT_ENTRY_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxComboBox *m_combo;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(ComboBoxTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ComboBoxTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComboBoxTestCase, "ComboBoxTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void ComboBoxTestCase::setUp()
|
||||
{
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::tearDown()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -96,6 +96,11 @@ void TextEntryTestCase::TextChangeEvents()
|
||||
CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::CheckStringSelection(const char *sel)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( sel, GetTestEntry()->GetStringSelection() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::AssertSelection(int from, int to, const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
@@ -107,9 +112,10 @@ void TextEntryTestCase::AssertSelection(int from, int to, const char *sel)
|
||||
entry->GetSelection(&fromReal, &toReal);
|
||||
CPPUNIT_ASSERT_EQUAL( from, fromReal );
|
||||
CPPUNIT_ASSERT_EQUAL( to, toReal );
|
||||
CPPUNIT_ASSERT_EQUAL( sel, entry->GetStringSelection() );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( from, entry->GetInsertionPoint() );
|
||||
|
||||
CheckStringSelection(sel);
|
||||
}
|
||||
|
||||
void TextEntryTestCase::Selection()
|
||||
|
@@ -49,6 +49,15 @@ private:
|
||||
// function parameters
|
||||
void AssertSelection(int from, int to, const char *sel);
|
||||
|
||||
// helper of AssertSelection(): check that the text selected in the control
|
||||
// is the given one
|
||||
//
|
||||
// this is necessary to disable testing this in wxComboBox test as it
|
||||
// doesn't provide any way to access the string selection directly, its
|
||||
// GetStringSelection() method returns the currently selected string in the
|
||||
// wxChoice part of the control, not the selected text
|
||||
virtual void CheckStringSelection(const char *sel);
|
||||
|
||||
DECLARE_NO_COPY_CLASS(TextEntryTestCase)
|
||||
};
|
||||
|
||||
|
@@ -108,6 +108,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_size.obj \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_textentrytest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
@@ -559,6 +560,9 @@ $(OBJS)\test_gui_point.obj: .\geometry\point.cpp
|
||||
$(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
|
||||
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
|
@@ -101,6 +101,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_size.o \
|
||||
$(OBJS)\test_gui_point.o \
|
||||
$(OBJS)\test_gui_config.o \
|
||||
$(OBJS)\test_gui_comboboxtest.o \
|
||||
$(OBJS)\test_gui_textctrltest.o \
|
||||
$(OBJS)\test_gui_textentrytest.o \
|
||||
$(OBJS)\test_gui_rawbmp.o \
|
||||
@@ -537,6 +538,9 @@ $(OBJS)\test_gui_point.o: ./geometry/point.cpp
|
||||
$(OBJS)\test_gui_config.o: ./config/config.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -104,6 +104,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_size.obj \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_textentrytest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
@@ -644,6 +645,9 @@ $(OBJS)\test_gui_point.obj: .\geometry\point.cpp
|
||||
$(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
|
||||
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
|
@@ -313,6 +313,7 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_size.obj &
|
||||
$(OBJS)\test_gui_point.obj &
|
||||
$(OBJS)\test_gui_config.obj &
|
||||
$(OBJS)\test_gui_comboboxtest.obj &
|
||||
$(OBJS)\test_gui_textctrltest.obj &
|
||||
$(OBJS)\test_gui_textentrytest.obj &
|
||||
$(OBJS)\test_gui_rawbmp.obj &
|
||||
@@ -590,6 +591,9 @@ $(OBJS)\test_gui_point.obj : .AUTODEPEND .\geometry\point.cpp
|
||||
$(OBJS)\test_gui_config.obj : .AUTODEPEND .\config\config.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_textctrltest.obj : .AUTODEPEND .\controls\textctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
|
@@ -105,6 +105,7 @@
|
||||
geometry/size.cpp
|
||||
geometry/point.cpp
|
||||
config/config.cpp
|
||||
controls/comboboxtest.cpp
|
||||
controls/textctrltest.cpp
|
||||
controls/textentrytest.cpp
|
||||
image/rawbmp.cpp
|
||||
|
@@ -239,6 +239,10 @@ SOURCE=.\window\clientsize.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\comboboxtest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\config\config.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -651,6 +651,8 @@
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx">
|
||||
<File
|
||||
RelativePath=".\window\clientsize.cpp"/>
|
||||
<File
|
||||
RelativePath=".\controls\comboboxtest.cpp"/>
|
||||
<File
|
||||
RelativePath=".\config\config.cpp"/>
|
||||
<File
|
||||
|
@@ -810,6 +810,9 @@
|
||||
<File
|
||||
RelativePath=".\window\clientsize.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\controls\comboboxtest.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\config\config.cpp"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user