]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/bitmapcomboboxtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/bitmapcomboboxtest.cpp
3 // Purpose: wxBitmapComboBox unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
12 #if wxUSE_BITMAPCOMBOBOX
22 #include "wx/bmpcbox.h"
23 #include "wx/artprov.h"
24 #include "textentrytest.h"
25 #include "itemcontainertest.h"
26 #include "asserthelper.h"
28 //Test only if we are based off of wxComboBox
29 #ifndef wxGENERIC_BITMAPCOMBOBOX
31 class BitmapComboBoxTestCase
: public TextEntryTestCase
,
32 public ItemContainerTestCase
,
33 public CppUnit::TestCase
36 BitmapComboBoxTestCase() { }
39 virtual void tearDown();
42 virtual wxTextEntry
*GetTestEntry() const { return m_combo
; }
43 virtual wxWindow
*GetTestWindow() const { return m_combo
; }
45 virtual wxItemContainer
*GetContainer() const { return m_combo
; }
46 virtual wxWindow
*GetContainerWindow() const { return m_combo
; }
48 virtual void CheckStringSelection(const char * WXUNUSED(sel
))
50 // do nothing here, as explained in TextEntryTestCase comment, our
51 // GetStringSelection() is the wxChoice, not wxTextEntry, one and there
52 // is no way to return the selection contents directly
55 CPPUNIT_TEST_SUITE( BitmapComboBoxTestCase
);
57 wxITEM_CONTAINER_TESTS();
58 CPPUNIT_TEST( Bitmap
);
59 CPPUNIT_TEST_SUITE_END();
63 wxBitmapComboBox
*m_combo
;
65 DECLARE_NO_COPY_CLASS(BitmapComboBoxTestCase
)
68 // register in the unnamed registry so that these tests are run by default
69 CPPUNIT_TEST_SUITE_REGISTRATION( BitmapComboBoxTestCase
);
71 // also include in it's own registry so that these tests can be run alone
72 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapComboBoxTestCase
,
73 "BitmapComboBoxTestCase" );
75 void BitmapComboBoxTestCase::setUp()
77 m_combo
= new wxBitmapComboBox(wxTheApp
->GetTopWindow(), wxID_ANY
);
80 void BitmapComboBoxTestCase::tearDown()
85 void BitmapComboBoxTestCase::Bitmap()
88 items
.push_back("item 0");
89 items
.push_back("item 1");
91 //We need this otherwise MSVC complains as it cannot find a suitable append
92 static_cast<wxComboBox
*>(m_combo
)->Append(items
);
94 CPPUNIT_ASSERT(!m_combo
->GetItemBitmap(0).IsOk());
96 wxBitmap bitmap
= wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
,
99 m_combo
->Append("item with bitmap", bitmap
);
101 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(2).IsOk());
103 m_combo
->Insert("item with bitmap", bitmap
, 1);
105 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(1).IsOk());
107 m_combo
->SetItemBitmap(0, bitmap
);
109 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(0).IsOk());
111 CPPUNIT_ASSERT_EQUAL(wxSize(16, 16), m_combo
->GetBitmapSize());
114 #endif //wxGENERIC_BITMAPCOMBOBOX
116 #endif //wxUSE_BITMAPCOMBOBOX