#pragma hdrstop
#endif
-#if wxUSE_UIACTIONSIMULATOR
+// FIXME: As all the other tests involving wxUIActionSimulator, this one is
+// broken under OS X, the test window siply never gets any events.
+#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
#ifndef WX_PRECOMP
#include "wx/app.h"
{
public:
KeyboardTestWindow(wxWindow *parent)
- : wxWindow(parent, wxID_ANY)
+ : wxWindow(parent, wxID_ANY, wxPoint(0, 0), parent->GetClientSize())
{
Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(KeyboardTestWindow::OnKeyDown));
Connect(wxEVT_CHAR, wxKeyEventHandler(KeyboardTestWindow::OnChar));
int m_mods;
};
-// These functions are only needed because of wx bug: currently, modifiers key
-// events are inconsistent between platforms and wxMSW generates key down event
-// for e.g. WXK_CONTROL with wxMOD_CONTROL set and key up event with it unset
-// while wxGTK does exactly vice versa. So we provide these helpers to make it
-// possible to make the tests pass under all platforms for now but ideally they
-// should all be made to behave the same and this should become unnecessary.
-
+// Helper for ModKeyDown().
int GetModForKey(int keycode)
{
switch ( keycode )
return wxMOD_NONE;
}
-#ifdef __WXGTK__
-
-KeyDesc ModKeyDown(int keycode)
-{
- // Second level bug: currently wxUIActionSimulator produces different
- // modifiers than actually pressing the key. So while the above comment is
- // true for keys pressed by user, when simulating them we do get the
- // corresponding bit set for the modifier press events.
- //
- // Again, this is a bug and wxUIActionSimulator should be fixed to behave
- // as the real events do but until this happens just work around this here.
- return KeyDesc(keycode, GetModForKey(keycode));
-}
-
-KeyDesc ModKeyUp(int keycode)
-{
- return KeyDesc(keycode, GetModForKey(keycode));
-}
-
-#else // Assume MSW-like behaviour for all the other platforms.
-
+// Helper function to allow writing just ModKeyDown(WXK_CONTROL) instead of
+// more verbose KeyDesc(WXK_CONTROL, wxMOD_CONTROL).
KeyDesc ModKeyDown(int keycode)
{
return KeyDesc(keycode, GetModForKey(keycode));
}
+// Another helper provided for symmetry with ModKeyDown() only.
KeyDesc ModKeyUp(int keycode)
{
return KeyDesc(keycode);
}
-#endif // Platforms.
-
// Verify that the event object corresponds to our idea of what it should be.
void TestEvent(int line, const wxKeyEvent& ev, const KeyDesc& desc)
{
void KeyboardEventTestCase::ShiftSpecial()
{
wxUIActionSimulator sim;
- sim.Char(WXK_TAB, wxMOD_SHIFT);
+ sim.Char(WXK_F3, wxMOD_SHIFT);
wxYield();
CPPUNIT_ASSERT_EQUAL( 2, m_win->GetKeyDownCount() );
ASSERT_KEY_EVENT_IS( m_win->GetKeyDownEvent(0),
ModKeyDown(WXK_SHIFT) );
ASSERT_KEY_EVENT_IS( m_win->GetKeyDownEvent(1),
- KeyDesc(WXK_TAB, wxMOD_SHIFT) );
+ KeyDesc(WXK_F3, wxMOD_SHIFT) );
CPPUNIT_ASSERT_EQUAL( 1, m_win->GetCharCount() );
ASSERT_KEY_EVENT_IS( m_win->GetCharEvent(),
- KeyDesc(WXK_TAB, wxMOD_SHIFT) );
+ KeyDesc(WXK_F3, wxMOD_SHIFT) );
CPPUNIT_ASSERT_EQUAL( 2, m_win->GetKeyUpCount() );
ASSERT_KEY_EVENT_IS( m_win->GetKeyUpEvent(0),
- KeyDesc(WXK_TAB, wxMOD_SHIFT) );
+ KeyDesc(WXK_F3, wxMOD_SHIFT) );
ASSERT_KEY_EVENT_IS( m_win->GetKeyUpEvent(1),
ModKeyUp(WXK_SHIFT) );
}