]>
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
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
11 #if wxUSE_BITMAPCOMBOBOX
21 #include "wx/bmpcbox.h"
22 #include "wx/artprov.h"
23 #include "textentrytest.h"
24 #include "itemcontainertest.h"
25 #include "asserthelper.h"
27 //Test only if we are based off of wxComboBox
28 #ifndef wxGENERIC_BITMAPCOMBOBOX
30 class BitmapComboBoxTestCase
: public TextEntryTestCase
,
31 public ItemContainerTestCase
,
32 public CppUnit::TestCase
35 BitmapComboBoxTestCase() { }
38 virtual void tearDown();
41 virtual wxTextEntry
*GetTestEntry() const { return m_combo
; }
42 virtual wxWindow
*GetTestWindow() const { return m_combo
; }
44 virtual wxItemContainer
*GetContainer() const { return m_combo
; }
45 virtual wxWindow
*GetContainerWindow() const { return m_combo
; }
47 virtual void CheckStringSelection(const char * WXUNUSED(sel
))
49 // do nothing here, as explained in TextEntryTestCase comment, our
50 // GetStringSelection() is the wxChoice, not wxTextEntry, one and there
51 // is no way to return the selection contents directly
54 CPPUNIT_TEST_SUITE( BitmapComboBoxTestCase
);
56 wxITEM_CONTAINER_TESTS();
57 CPPUNIT_TEST( Bitmap
);
58 CPPUNIT_TEST_SUITE_END();
62 wxBitmapComboBox
*m_combo
;
64 DECLARE_NO_COPY_CLASS(BitmapComboBoxTestCase
)
67 // register in the unnamed registry so that these tests are run by default
68 CPPUNIT_TEST_SUITE_REGISTRATION( BitmapComboBoxTestCase
);
70 // also include in its own registry so that these tests can be run alone
71 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapComboBoxTestCase
,
72 "BitmapComboBoxTestCase" );
74 void BitmapComboBoxTestCase::setUp()
76 m_combo
= new wxBitmapComboBox(wxTheApp
->GetTopWindow(), wxID_ANY
);
79 void BitmapComboBoxTestCase::tearDown()
84 void BitmapComboBoxTestCase::Bitmap()
87 items
.push_back("item 0");
88 items
.push_back("item 1");
90 //We need this otherwise MSVC complains as it cannot find a suitable append
91 static_cast<wxComboBox
*>(m_combo
)->Append(items
);
93 CPPUNIT_ASSERT(!m_combo
->GetItemBitmap(0).IsOk());
95 wxBitmap bitmap
= wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_OTHER
,
98 m_combo
->Append("item with bitmap", bitmap
);
100 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(2).IsOk());
102 m_combo
->Insert("item with bitmap", bitmap
, 1);
104 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(1).IsOk());
106 m_combo
->SetItemBitmap(0, bitmap
);
108 CPPUNIT_ASSERT(m_combo
->GetItemBitmap(0).IsOk());
110 CPPUNIT_ASSERT_EQUAL(wxSize(16, 16), m_combo
->GetBitmapSize());
113 #endif //wxGENERIC_BITMAPCOMBOBOX
115 #endif //wxUSE_BITMAPCOMBOBOX