Replace direct QPA access in tst_qguiappliction with testlib wrapper

Change-Id: I698aa9d7633992d257296759f5e04307ff0d8331
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2015-09-04 17:56:24 +02:00
parent 0a1206a8b2
commit 0e342fce4c
2 changed files with 10 additions and 4 deletions

View File

@ -61,7 +61,7 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
namespace QTest
{
enum KeyAction { Press, Release, Click };
enum KeyAction { Press, Release, Click, Shortcut };
static void simulateEvent(QWindow *window, bool press, int code,
Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
@ -95,6 +95,12 @@ namespace QTest
bool repeat = false;
if (action == Shortcut) {
int timestamp = 0;
qt_sendShortcutOverrideEvent(window, timestamp, code, modifier, text, repeat);
return;
}
if (action == Press) {
if (modifier & Qt::ShiftModifier)
simulateEvent(window, true, Qt::Key_Shift, Qt::KeyboardModifiers(), QString(), false, delay);

View File

@ -400,11 +400,11 @@ void tst_QGuiApplication::keyboardModifiers()
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// shortcut events
QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_5, Qt::MetaModifier);
QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_5, Qt::MetaModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::MetaModifier);
QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_Period, Qt::NoModifier);
QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_Period, Qt::NoModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_0, Qt::ControlModifier);
QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_0, Qt::ControlModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// key events