Fix initial value returned from wxRichTextCtrl::IsModified()
A just created control shouldn't be considered modified, so reset its modified state in Create(). And add a unit test checking that IsModified() really behaves as expected. Closes https://github.com/wxWidgets/wxWidgets/pull/1652
This commit is contained in:
committed by
Vadim Zeitlin
parent
33da780ecf
commit
68de1b2acf
@@ -343,7 +343,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
|
|||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
SetDropTarget(new wxRichTextDropTarget(this));
|
SetDropTarget(new wxRichTextDropTarget(this));
|
||||||
#endif
|
#endif
|
||||||
|
SetModified( false );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CPPUNIT_TEST_SUITE( RichTextCtrlTestCase );
|
CPPUNIT_TEST_SUITE( RichTextCtrlTestCase );
|
||||||
|
CPPUNIT_TEST( IsModified );
|
||||||
WXUISIM_TEST( CharacterEvent );
|
WXUISIM_TEST( CharacterEvent );
|
||||||
WXUISIM_TEST( DeleteEvent );
|
WXUISIM_TEST( DeleteEvent );
|
||||||
WXUISIM_TEST( ReturnEvent );
|
WXUISIM_TEST( ReturnEvent );
|
||||||
@@ -64,6 +65,7 @@ private:
|
|||||||
CPPUNIT_TEST( Table );
|
CPPUNIT_TEST( Table );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
void IsModified();
|
||||||
void CharacterEvent();
|
void CharacterEvent();
|
||||||
void DeleteEvent();
|
void DeleteEvent();
|
||||||
void ReturnEvent();
|
void ReturnEvent();
|
||||||
@@ -115,6 +117,13 @@ void RichTextCtrlTestCase::tearDown()
|
|||||||
wxDELETE(m_rich);
|
wxDELETE(m_rich);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RichTextCtrlTestCase::IsModified()
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL( false, m_rich->IsModified() );
|
||||||
|
m_rich->WriteText("abcdef");
|
||||||
|
CPPUNIT_ASSERT_EQUAL( true, m_rich->IsModified() );
|
||||||
|
}
|
||||||
|
|
||||||
void RichTextCtrlTestCase::CharacterEvent()
|
void RichTextCtrlTestCase::CharacterEvent()
|
||||||
{
|
{
|
||||||
#if wxUSE_UIACTIONSIMULATOR
|
#if wxUSE_UIACTIONSIMULATOR
|
||||||
|
Reference in New Issue
Block a user