diff --git a/tests/Makefile.in b/tests/Makefile.in
index 7c2829446b..02f665d2f1 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -178,6 +178,7 @@ TEST_GUI_OBJECTS = \
test_gui_listctrltest.o \
test_gui_listviewtest.o \
test_gui_notebooktest.o \
+ test_gui_ownerdrawncomboboxtest.o \
test_gui_pickerbasetest.o \
test_gui_pickertest.o \
test_gui_radioboxtest.o \
@@ -758,6 +759,9 @@ test_gui_listviewtest.o: $(srcdir)/controls/listviewtest.cpp $(TEST_GUI_ODEP)
test_gui_notebooktest.o: $(srcdir)/controls/notebooktest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/notebooktest.cpp
+test_gui_ownerdrawncomboboxtest.o: $(srcdir)/controls/ownerdrawncomboboxtest.cpp $(TEST_GUI_ODEP)
+ $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/ownerdrawncomboboxtest.cpp
+
test_gui_pickerbasetest.o: $(srcdir)/controls/pickerbasetest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/pickerbasetest.cpp
diff --git a/tests/controls/ownerdrawncomboboxtest.cpp b/tests/controls/ownerdrawncomboboxtest.cpp
new file mode 100644
index 0000000000..54c228676e
--- /dev/null
+++ b/tests/controls/ownerdrawncomboboxtest.cpp
@@ -0,0 +1,197 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/controls/ownerdrawncomboboxtest.cpp
+// Purpose: OwnerDrawnComboBox unit test
+// Author: Jaakko Salli
+// Created: 2010-12-17
+// RCS-ID: $Id$
+// Copyright: (c) 2010 Jaakko Salli
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#if wxUSE_ODCOMBOBOX
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+#endif // WX_PRECOMP
+
+#include "wx/odcombo.h"
+
+#include "textentrytest.h"
+#include "itemcontainertest.h"
+#include "testableframe.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class OwnerDrawnComboBoxTestCase : public TextEntryTestCase,
+ public ItemContainerTestCase,
+ public CppUnit::TestCase
+{
+public:
+ OwnerDrawnComboBoxTestCase() { }
+
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ virtual wxTextEntry *GetTestEntry() const { return m_combo; }
+ virtual wxWindow *GetTestWindow() const { return m_combo; }
+
+ virtual wxItemContainer *GetContainer() const { return m_combo; }
+ virtual wxWindow *GetContainerWindow() 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( OwnerDrawnComboBoxTestCase );
+ wxTEXT_ENTRY_TESTS();
+ wxITEM_CONTAINER_TESTS();
+ CPPUNIT_TEST( Size );
+ CPPUNIT_TEST( PopDismiss );
+ CPPUNIT_TEST( Sort );
+ CPPUNIT_TEST( ReadOnly );
+ CPPUNIT_TEST_SUITE_END();
+
+ void Size();
+ void PopDismiss();
+ void Sort();
+ void ReadOnly();
+
+ wxOwnerDrawnComboBox *m_combo;
+
+ DECLARE_NO_COPY_CLASS(OwnerDrawnComboBoxTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( OwnerDrawnComboBoxTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( OwnerDrawnComboBoxTestCase,
+ "OwnerDrawnComboBoxTestCase" );
+
+// ----------------------------------------------------------------------------
+// test initialization
+// ----------------------------------------------------------------------------
+
+void OwnerDrawnComboBoxTestCase::setUp()
+{
+ m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
+}
+
+void OwnerDrawnComboBoxTestCase::tearDown()
+{
+ delete m_combo;
+ m_combo = NULL;
+}
+
+// ----------------------------------------------------------------------------
+// tests themselves
+// ----------------------------------------------------------------------------
+
+void OwnerDrawnComboBoxTestCase::Size()
+{
+ // under MSW changing combobox size is a non-trivial operation because of
+ // confusion between the size of the control with and without dropdown, so
+ // check that it does work as expected
+
+ const int heightOrig = m_combo->GetSize().y;
+
+ // check that the height doesn't change if we don't touch it
+ m_combo->SetSize(100, -1);
+ CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
+
+ // check that setting both big and small (but not too small, there is a
+ // limit on how small the control can become under MSW) heights works
+ m_combo->SetSize(-1, 50);
+ CPPUNIT_ASSERT_EQUAL( 50, m_combo->GetSize().y );
+
+ m_combo->SetSize(-1, 10);
+ CPPUNIT_ASSERT_EQUAL( 10, m_combo->GetSize().y );
+
+ // and also that restoring it works (this used to be broken before 2.9.1)
+ m_combo->SetSize(-1, heightOrig);
+ CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
+}
+
+void OwnerDrawnComboBoxTestCase::PopDismiss()
+{
+ wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
+ wxTestableFrame);
+
+ EventCounter count(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN);
+ EventCounter count1(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP);
+
+ m_combo->Popup();
+ m_combo->Dismiss();
+
+ CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_DROPDOWN));
+ CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_CLOSEUP));
+}
+
+void OwnerDrawnComboBoxTestCase::Sort()
+{
+ m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(),
+ wxID_ANY, "",
+ wxDefaultPosition, wxDefaultSize,
+ 0, NULL,
+ wxCB_SORT);
+
+ m_combo->Append("aaa");
+ m_combo->Append("Aaa");
+ m_combo->Append("aba");
+ m_combo->Append("aaab");
+ m_combo->Append("aab");
+ m_combo->Append("AAA");
+
+ CPPUNIT_ASSERT_EQUAL("AAA", m_combo->GetString(0));
+ CPPUNIT_ASSERT_EQUAL("Aaa", m_combo->GetString(1));
+ CPPUNIT_ASSERT_EQUAL("aaa", m_combo->GetString(2));
+ CPPUNIT_ASSERT_EQUAL("aaab", m_combo->GetString(3));
+ CPPUNIT_ASSERT_EQUAL("aab", m_combo->GetString(4));
+ CPPUNIT_ASSERT_EQUAL("aba", m_combo->GetString(5));
+
+ m_combo->Append("a");
+
+ CPPUNIT_ASSERT_EQUAL("a", m_combo->GetString(0));
+}
+
+void OwnerDrawnComboBoxTestCase::ReadOnly()
+{
+ wxArrayString testitems;
+ testitems.Add("item 1");
+ testitems.Add("item 2");
+
+ m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
+ wxDefaultPosition, wxDefaultSize,
+ testitems,
+ wxCB_READONLY);
+
+ m_combo->SetValue("item 1");
+
+ CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
+
+ m_combo->SetValue("not an item");
+
+ CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
+
+ // Since this uses FindString it is case insensitive
+ m_combo->SetValue("ITEM 2");
+
+ CPPUNIT_ASSERT_EQUAL("item 2", m_combo->GetValue());
+}
+
+#endif // wxUSE_ODCOMBOBOX
diff --git a/tests/makefile.bcc b/tests/makefile.bcc
index 5c88c9c865..2a366f22d8 100644
--- a/tests/makefile.bcc
+++ b/tests/makefile.bcc
@@ -163,6 +163,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_listctrltest.obj \
$(OBJS)\test_gui_listviewtest.obj \
$(OBJS)\test_gui_notebooktest.obj \
+ $(OBJS)\test_gui_ownerdrawncomboboxtest.obj \
$(OBJS)\test_gui_pickerbasetest.obj \
$(OBJS)\test_gui_pickertest.obj \
$(OBJS)\test_gui_radioboxtest.obj \
@@ -804,6 +805,9 @@ $(OBJS)\test_gui_listviewtest.obj: .\controls\listviewtest.cpp
$(OBJS)\test_gui_notebooktest.obj: .\controls\notebooktest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\notebooktest.cpp
+$(OBJS)\test_gui_ownerdrawncomboboxtest.obj: .\controls\ownerdrawncomboboxtest.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\ownerdrawncomboboxtest.cpp
+
$(OBJS)\test_gui_pickerbasetest.obj: .\controls\pickerbasetest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\pickerbasetest.cpp
diff --git a/tests/makefile.gcc b/tests/makefile.gcc
index d5c95565ea..ee9e554aa6 100644
--- a/tests/makefile.gcc
+++ b/tests/makefile.gcc
@@ -156,6 +156,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_listctrltest.o \
$(OBJS)\test_gui_listviewtest.o \
$(OBJS)\test_gui_notebooktest.o \
+ $(OBJS)\test_gui_ownerdrawncomboboxtest.o \
$(OBJS)\test_gui_pickerbasetest.o \
$(OBJS)\test_gui_pickertest.o \
$(OBJS)\test_gui_radioboxtest.o \
@@ -785,6 +786,9 @@ $(OBJS)\test_gui_listviewtest.o: ./controls/listviewtest.cpp
$(OBJS)\test_gui_notebooktest.o: ./controls/notebooktest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_gui_ownerdrawncomboboxtest.o: ./controls/ownerdrawncomboboxtest.cpp
+ $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_gui_pickerbasetest.o: ./controls/pickerbasetest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
diff --git a/tests/makefile.vc b/tests/makefile.vc
index e4d20a04e8..85db68d10c 100644
--- a/tests/makefile.vc
+++ b/tests/makefile.vc
@@ -158,6 +158,7 @@ TEST_GUI_OBJECTS = \
$(OBJS)\test_gui_listctrltest.obj \
$(OBJS)\test_gui_listviewtest.obj \
$(OBJS)\test_gui_notebooktest.obj \
+ $(OBJS)\test_gui_ownerdrawncomboboxtest.obj \
$(OBJS)\test_gui_pickerbasetest.obj \
$(OBJS)\test_gui_pickertest.obj \
$(OBJS)\test_gui_radioboxtest.obj \
@@ -930,6 +931,9 @@ $(OBJS)\test_gui_listviewtest.obj: .\controls\listviewtest.cpp
$(OBJS)\test_gui_notebooktest.obj: .\controls\notebooktest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\notebooktest.cpp
+$(OBJS)\test_gui_ownerdrawncomboboxtest.obj: .\controls\ownerdrawncomboboxtest.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\ownerdrawncomboboxtest.cpp
+
$(OBJS)\test_gui_pickerbasetest.obj: .\controls\pickerbasetest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\pickerbasetest.cpp
diff --git a/tests/makefile.wat b/tests/makefile.wat
index 8e5019fa2e..a9f8122117 100644
--- a/tests/makefile.wat
+++ b/tests/makefile.wat
@@ -398,6 +398,7 @@ TEST_GUI_OBJECTS = &
$(OBJS)\test_gui_listctrltest.obj &
$(OBJS)\test_gui_listviewtest.obj &
$(OBJS)\test_gui_notebooktest.obj &
+ $(OBJS)\test_gui_ownerdrawncomboboxtest.obj &
$(OBJS)\test_gui_pickerbasetest.obj &
$(OBJS)\test_gui_pickertest.obj &
$(OBJS)\test_gui_radioboxtest.obj &
@@ -843,6 +844,9 @@ $(OBJS)\test_gui_listviewtest.obj : .AUTODEPEND .\controls\listviewtest.cpp
$(OBJS)\test_gui_notebooktest.obj : .AUTODEPEND .\controls\notebooktest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+$(OBJS)\test_gui_ownerdrawncomboboxtest.obj : .AUTODEPEND .\controls\ownerdrawncomboboxtest.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+
$(OBJS)\test_gui_pickerbasetest.obj : .AUTODEPEND .\controls\pickerbasetest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
diff --git a/tests/test.bkl b/tests/test.bkl
index 352d05bf49..42aaee6d14 100644
--- a/tests/test.bkl
+++ b/tests/test.bkl
@@ -159,6 +159,7 @@
controls/listctrltest.cpp
controls/listviewtest.cpp
controls/notebooktest.cpp
+ controls/ownerdrawncomboboxtest.cpp
controls/pickerbasetest.cpp
controls/pickertest.cpp
controls/radioboxtest.cpp
diff --git a/tests/test_test_gui.dsp b/tests/test_test_gui.dsp
index 13438b70e5..d130cb8647 100644
--- a/tests/test_test_gui.dsp
+++ b/tests/test_test_gui.dsp
@@ -401,6 +401,10 @@ SOURCE=.\controls\notebooktest.cpp
# End Source File
# Begin Source File
+SOURCE=.\controls\ownerdrawncomboboxtest.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\controls\pickerbasetest.cpp
# End Source File
# Begin Source File
diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj
index 6e392ad097..0172d3a962 100644
--- a/tests/test_vc7_test_gui.vcproj
+++ b/tests/test_vc7_test_gui.vcproj
@@ -736,6 +736,9 @@
+
+
diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj
index c01308af33..f300941b72 100644
--- a/tests/test_vc8_test_gui.vcproj
+++ b/tests/test_vc8_test_gui.vcproj
@@ -1055,6 +1055,10 @@
RelativePath=".\controls\notebooktest.cpp"
>
+
+
diff --git a/tests/test_vc9_test_gui.vcproj b/tests/test_vc9_test_gui.vcproj
index 7d27a76723..5063d1dca8 100644
--- a/tests/test_vc9_test_gui.vcproj
+++ b/tests/test_vc9_test_gui.vcproj
@@ -1027,6 +1027,10 @@
RelativePath=".\controls\notebooktest.cpp"
>
+
+