- class TextTestEventHandler : public wxEvtHandler
- {
- public:
- TextTestEventHandler() { m_events = 0; }
-
- // calling this automatically resets the events counter
- int GetEvents()
- {
- const int events = m_events;
- m_events = 0;
- return events;
- }
-
- void OnText(wxCommandEvent& WXUNUSED(event)) { m_events++; }
-
- private:
- int m_events;
- } handler;
-
- m_text->Connect(wxEVT_COMMAND_TEXT_UPDATED,
- wxCommandEventHandler(TextTestEventHandler::OnText),
- NULL,
- &handler);
-
- // notice that SetValue() generates an event even if the text didn't change
- m_text->SetValue("");
- CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
-
- m_text->SetValue("foo");
- CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
-
- m_text->SetValue("foo");
- CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
-
- m_text->ChangeValue("bar");
- CPPUNIT_ASSERT_EQUAL( 0, handler.GetEvents() );
-
- m_text->AppendText("bar");
- CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
+ // we need a multiline control for this test so recreate it
+ delete m_text;
+ m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE);