X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/232fdc630c42eb165f7659981043e794be03b3b7..cd15bcaf50ead53ccf9d50965312f0dc754affb4:/tests/controls/windowtest.cpp diff --git a/tests/controls/windowtest.cpp b/tests/controls/windowtest.cpp index 72266b2753..34223ee635 100644 --- a/tests/controls/windowtest.cpp +++ b/tests/controls/windowtest.cpp @@ -41,7 +41,9 @@ private: CPPUNIT_TEST( FocusEvent ); CPPUNIT_TEST( Mouse ); CPPUNIT_TEST( Properties ); +#if wxUSE_TOOLTIPS CPPUNIT_TEST( ToolTip ); +#endif // wxUSE_TOOLTIPS CPPUNIT_TEST( Help ); CPPUNIT_TEST( Parent ); CPPUNIT_TEST( Siblings ); @@ -58,7 +60,9 @@ private: void FocusEvent(); void Mouse(); void Properties(); +#if wxUSE_TOOLTIPS void ToolTip(); +#endif // wxUSE_TOOLTIPS void Help(); void Parent(); void Siblings(); @@ -77,7 +81,7 @@ private: // register in the unnamed registry so that these tests are run by default CPPUNIT_TEST_SUITE_REGISTRATION( WindowTestCase ); -// also include in it's own registry so that these tests can be run alone +// also include in its own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WindowTestCase, "WindowTestCase" ); void WindowTestCase::setUp() @@ -93,10 +97,7 @@ void WindowTestCase::tearDown() void WindowTestCase::ShowHideEvent() { #if defined(__WXMSW__) || defined (__WXPM__) - wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), - wxTestableFrame); - - EventCounter count(m_window, wxEVT_SHOW); + EventCounter show(m_window, wxEVT_SHOW); CPPUNIT_ASSERT(m_window->IsShown()); @@ -108,19 +109,16 @@ void WindowTestCase::ShowHideEvent() CPPUNIT_ASSERT(m_window->IsShown()); - CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(2, show.GetCount()); #endif } void WindowTestCase::KeyEvent() { #if wxUSE_UIACTIONSIMULATOR - wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), - wxTestableFrame); - - EventCounter count(m_window, wxEVT_KEY_DOWN); - EventCounter count1(m_window, wxEVT_KEY_UP); - EventCounter count2(m_window, wxEVT_CHAR); + EventCounter keydown(m_window, wxEVT_KEY_DOWN); + EventCounter keyup(m_window, wxEVT_KEY_UP); + EventCounter keychar(m_window, wxEVT_CHAR); wxUIActionSimulator sim; @@ -130,31 +128,28 @@ void WindowTestCase::KeyEvent() sim.Char(WXK_SHIFT); wxYield(); - CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_DOWN)); - CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_UP)); - CPPUNIT_ASSERT_EQUAL(4, frame->GetEventCount(wxEVT_CHAR)); + CPPUNIT_ASSERT_EQUAL(5, keydown.GetCount()); + CPPUNIT_ASSERT_EQUAL(5, keyup.GetCount()); + CPPUNIT_ASSERT_EQUAL(4, keychar.GetCount()); #endif } void WindowTestCase::FocusEvent() { #ifndef __WXOSX__ - wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), - wxTestableFrame); - - EventCounter count(m_window, wxEVT_SET_FOCUS); - EventCounter count1(m_window, wxEVT_KILL_FOCUS); + EventCounter setfocus(m_window, wxEVT_SET_FOCUS); + EventCounter killfocus(m_window, wxEVT_KILL_FOCUS); m_window->SetFocus(); - CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SET_FOCUS)); + CPPUNIT_ASSERT_EQUAL(1, setfocus.GetCount()); CPPUNIT_ASSERT(m_window->HasFocus()); wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY); button->SetFocus(); - CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_KILL_FOCUS)); + CPPUNIT_ASSERT_EQUAL(1, killfocus.GetCount()); CPPUNIT_ASSERT(!m_window->HasFocus()); #endif } @@ -185,11 +180,9 @@ void WindowTestCase::Mouse() void WindowTestCase::Properties() { -#ifndef __WXGTK__ m_window->SetLabel("label"); CPPUNIT_ASSERT_EQUAL("label", m_window->GetLabel()); -#endif m_window->SetName("name"); @@ -203,6 +196,7 @@ void WindowTestCase::Properties() CPPUNIT_ASSERT_EQUAL(wxID_HIGHEST + 10, m_window->GetId()); } +#if wxUSE_TOOLTIPS void WindowTestCase::ToolTip() { CPPUNIT_ASSERT(!m_window->GetToolTip()); @@ -224,6 +218,7 @@ void WindowTestCase::ToolTip() CPPUNIT_ASSERT_EQUAL(tip, m_window->GetToolTip()); CPPUNIT_ASSERT_EQUAL("other tip", m_window->GetToolTipText()); } +#endif // wxUSE_TOOLTIPS void WindowTestCase::Help() { @@ -370,15 +365,11 @@ void WindowTestCase::FindWindowBy() { m_window->SetId(wxID_HIGHEST + 1); m_window->SetName("name"); -#ifndef __WXGTK__ m_window->SetLabel("label"); -#endif CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowById(wxID_HIGHEST + 1)); CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByName("name")); -#ifndef __WXGTK__ CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByLabel("label")); -#endif CPPUNIT_ASSERT_EQUAL(static_cast(NULL), wxWindow::FindWindowById(wxID_HIGHEST + 3));