Add a test for WriteText and fix implementation in wxQt

This commit is contained in:
Richard Smith
2019-01-18 10:31:56 +00:00
committed by Vadim Zeitlin
parent 3618356cf1
commit 4c05b3650a
2 changed files with 25 additions and 1 deletions

View File

@@ -201,6 +201,28 @@ void TextEntryTestCase::Replace()
CPPUNIT_ASSERT_EQUAL(2, entry->GetInsertionPoint()); CPPUNIT_ASSERT_EQUAL(2, entry->GetInsertionPoint());
} }
void TextEntryTestCase::WriteText()
{
wxTextEntry * const entry = GetTestEntry();
entry->SetValue("foo");
entry->SetInsertionPoint(3);
entry->WriteText("bar");
CPPUNIT_ASSERT_EQUAL( "foobar", entry->GetValue() );
entry->SetValue("foo");
entry->SetInsertionPoint(0);
entry->WriteText("bar");
CPPUNIT_ASSERT_EQUAL( "barfoo", entry->GetValue() );
entry->SetValue("abxxxhi");
entry->SetSelection(2, 5);
entry->WriteText("cdefg");
CPPUNIT_ASSERT_EQUAL( "abcdefghi", entry->GetValue() );
CPPUNIT_ASSERT_EQUAL( 7, entry->GetInsertionPoint() );
CPPUNIT_ASSERT_EQUAL( false, entry->HasSelection() );
}
#if wxUSE_UIACTIONSIMULATOR #if wxUSE_UIACTIONSIMULATOR
class TextEventHandler class TextEventHandler

View File

@@ -44,7 +44,8 @@ protected:
WXUISIM_TEST( Editable ); \ WXUISIM_TEST( Editable ); \
CPPUNIT_TEST( Hint ); \ CPPUNIT_TEST( Hint ); \
CPPUNIT_TEST( CopyPaste ); \ CPPUNIT_TEST( CopyPaste ); \
CPPUNIT_TEST( UndoRedo ) CPPUNIT_TEST( UndoRedo ); \
CPPUNIT_TEST( WriteText )
void SetValue(); void SetValue();
void TextChangeEvents(); void TextChangeEvents();
@@ -55,6 +56,7 @@ protected:
void Hint(); void Hint();
void CopyPaste(); void CopyPaste();
void UndoRedo(); void UndoRedo();
void WriteText();
private: private:
// Selection() test helper: verify that selection is as described by the // Selection() test helper: verify that selection is as described by the