]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/textentrytest.cpp
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / tests / controls / textentrytest.cpp
index e28fc4809f11904ff4ea602a16952599bd6f4a73..2bf31ed555aead06bc5990a4966fb5311d17bedb 100644 (file)
@@ -41,40 +41,45 @@ void TextEntryTestCase::SetValue()
 
 void TextEntryTestCase::TextChangeEvents()
 {
 
 void TextEntryTestCase::TextChangeEvents()
 {
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
-    EventCounter count(GetTestWindow(), wxEVT_COMMAND_TEXT_UPDATED);
+    EventCounter updated(GetTestWindow(), wxEVT_COMMAND_TEXT_UPDATED);
 
     wxTextEntry * const entry = GetTestEntry();
 
     // notice that SetValue() generates an event even if the text didn't change
     entry->SetValue("");
 
     wxTextEntry * const entry = GetTestEntry();
 
     // notice that SetValue() generates an event even if the text didn't change
     entry->SetValue("");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->SetValue("foo");
 
     entry->SetValue("foo");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->SetValue("foo");
 
     entry->SetValue("foo");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->ChangeValue("bar");
 
     entry->ChangeValue("bar");
-    CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
 
     entry->AppendText("bar");
 
     entry->AppendText("bar");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->Replace(3, 6, "baz");
 
     entry->Replace(3, 6, "baz");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->Remove(0, 3);
 
     entry->Remove(0, 3);
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->WriteText("foo");
 
     entry->WriteText("foo");
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 
     entry->Clear();
 
     entry->Clear();
-    CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
+    CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
+    updated.Clear();
 }
 
 void TextEntryTestCase::CheckStringSelection(const char *sel)
 }
 
 void TextEntryTestCase::CheckStringSelection(const char *sel)
@@ -144,6 +149,9 @@ void TextEntryTestCase::InsertionPoint()
     entry->WriteText("-"); // should move it after the written text
     CPPUNIT_ASSERT_EQUAL( 4, entry->GetLastPosition() );
     CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
     entry->WriteText("-"); // should move it after the written text
     CPPUNIT_ASSERT_EQUAL( 4, entry->GetLastPosition() );
     CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
+
+    entry->SetValue("something different"); // should still reset the caret
+    CPPUNIT_ASSERT_EQUAL( 0, entry->GetInsertionPoint() );
 }
 
 void TextEntryTestCase::Replace()
 }
 
 void TextEntryTestCase::Replace()
@@ -173,13 +181,10 @@ void TextEntryTestCase::Replace()
 void TextEntryTestCase::Editable()
 {
 #if wxUSE_UIACTIONSIMULATOR
 void TextEntryTestCase::Editable()
 {
 #if wxUSE_UIACTIONSIMULATOR
-    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
-                                          wxTestableFrame);
-
     wxTextEntry * const entry = GetTestEntry();
     wxWindow * const window = GetTestWindow();
 
     wxTextEntry * const entry = GetTestEntry();
     wxWindow * const window = GetTestWindow();
 
-    EventCounter count(window, wxEVT_COMMAND_TEXT_UPDATED);
+    EventCounter updated(window, wxEVT_COMMAND_TEXT_UPDATED);
 
     window->SetFocus();
     wxYield();
 
     window->SetFocus();
     wxYield();
@@ -189,14 +194,16 @@ void TextEntryTestCase::Editable()
     wxYield();
 
     CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
     wxYield();
 
     CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
-    CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
+    CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
+
+    updated.Clear();
 
     entry->SetEditable(false);
     sim.Text("gh");
     wxYield();
 
     CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
 
     entry->SetEditable(false);
     sim.Text("gh");
     wxYield();
 
     CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
-    CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
+    CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
 #endif
 }
 
 #endif
 }