Commit 8cb3031d authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Changing sendEvent() to notifyEvent().

QTest code uses notifyEvent() to post events. That being the case, it may be
more appropriate for our testing code to use notifyEvent() as well. This may
improve test playback reliability across platforms.
parent 5a1d83d0
...@@ -70,7 +70,7 @@ bool pq3DViewEventPlayer::playEvent(QObject* Object, ...@@ -70,7 +70,7 @@ bool pq3DViewEventPlayer::playEvent(QObject* Object,
QEvent::Type type = (Command == "mousePress")? QEvent::MouseButtonPress : QEvent::Type type = (Command == "mousePress")? QEvent::MouseButtonPress :
((Command=="mouseMove")? QEvent::MouseMove : QEvent::MouseButtonRelease); ((Command=="mouseMove")? QEvent::MouseMove : QEvent::MouseButtonRelease);
QMouseEvent e(type, QPoint(x,y), button, buttons, keym); QMouseEvent e(type, QPoint(x,y), button, buttons, keym);
QCoreApplication::sendEvent(Object, &e); qApp->notify(Object, &e);
} }
return true; return true;
} }
......
...@@ -101,7 +101,7 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object, ...@@ -101,7 +101,7 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
{ {
menu_bar->setActiveAction(next->menuAction()); menu_bar->setActiveAction(next->menuAction());
int max_wait = 0; int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 10) while(!next->isVisible() && (++max_wait) <= 2)
{ {
pqEventDispatcher::processEventsAndWait(100); pqEventDispatcher::processEventsAndWait(100);
} }
...@@ -111,7 +111,7 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object, ...@@ -111,7 +111,7 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
menu->setActiveAction(next->menuAction()); menu->setActiveAction(next->menuAction());
int max_wait = 0; int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 10) while(!next->isVisible() && (++max_wait) <= 2)
{ {
pqEventDispatcher::processEventsAndWait(100); pqEventDispatcher::processEventsAndWait(100);
} }
...@@ -126,8 +126,8 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object, ...@@ -126,8 +126,8 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
QKeyEvent keyDown(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QKeyEvent keyDown(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QKeyEvent keyUp(QEvent::KeyRelease, Qt::Key_Enter, Qt::NoModifier); QKeyEvent keyUp(QEvent::KeyRelease, Qt::Key_Enter, Qt::NoModifier);
QApplication::sendEvent(object, &keyDown); qApp->notify(object, &keyDown);
QApplication::sendEvent(object, &keyUp); qApp->notify(object, &keyUp);
//QApplication::processEvents(); //QApplication::processEvents();
return true; return true;
......
...@@ -143,7 +143,7 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co ...@@ -143,7 +143,7 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
data[3], data[3],
!!data[4].toInt(), !!data[4].toInt(),
data[5].toInt()); data[5].toInt());
QCoreApplication::sendEvent(object, &ke); qApp->notify(object, &ke);
return true; return true;
} }
} }
...@@ -178,12 +178,13 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co ...@@ -178,12 +178,13 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
QRect r = object->visualRect(idx); QRect r = object->visualRect(idx);
pt = r.topLeft() + QPoint(x,y); pt = r.topLeft() + QPoint(x,y);
} }
QEvent::Type type = QEvent::MouseButtonPress; QEvent::Type type = QEvent::MouseButtonPress;
type = Command == "mouseMove" ? QEvent::MouseMove : type; type = Command == "mouseMove" ? QEvent::MouseMove : type;
type = Command == "mouseRelease" ? QEvent::MouseButtonRelease : type; type = Command == "mouseRelease" ? QEvent::MouseButtonRelease : type;
type = Command == "mouseDblClick" ? QEvent::MouseButtonDblClick : type; type = Command == "mouseDblClick" ? QEvent::MouseButtonDblClick : type;
QMouseEvent e(type, pt, button, buttons, keym); QMouseEvent e(type, pt, button, buttons, keym);
QCoreApplication::sendEvent(object->viewport(), &e); qApp->notify(object->viewport(), &e);
return true; return true;
} }
} }
......
...@@ -55,15 +55,15 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object, ...@@ -55,15 +55,15 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
QPoint pt(widget->x(), widget->y()); QPoint pt(widget->x(), widget->y());
QPoint globalPt = widget->mapToGlobal(pt); QPoint globalPt = widget->mapToGlobal(pt);
QContextMenuEvent e(QContextMenuEvent::Other, pt, globalPt); QContextMenuEvent e(QContextMenuEvent::Other, pt, globalPt);
QCoreApplication::sendEvent(widget, &e); qApp->notify(widget, &e);
return true; return true;
} }
else if(Command == "key") else if(Command == "key")
{ {
QKeyEvent kd(QEvent::KeyPress, Arguments.toInt(), Qt::NoModifier); QKeyEvent kd(QEvent::KeyPress, Arguments.toInt(), Qt::NoModifier);
QKeyEvent ku(QEvent::KeyRelease, Arguments.toInt(), Qt::NoModifier); QKeyEvent ku(QEvent::KeyRelease, Arguments.toInt(), Qt::NoModifier);
QCoreApplication::sendEvent(widget, &kd); qApp->notify(widget, &kd);
QCoreApplication::sendEvent(widget, &ku); qApp->notify(widget, &ku);
return true; return true;
} }
else if(Command == "keyEvent") else if(Command == "keyEvent")
...@@ -75,7 +75,7 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object, ...@@ -75,7 +75,7 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
data[3], data[3],
!!data[4].toInt(), !!data[4].toInt(),
data[5].toInt()); data[5].toInt());
QCoreApplication::sendEvent(widget, &ke); qApp->notify(widget, &ke);
return true; return true;
} }
else if(Command.startsWith("mouse")) else if(Command.startsWith("mouse"))
...@@ -100,7 +100,7 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object, ...@@ -100,7 +100,7 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
button = Qt::NoButton; button = Qt::NoButton;
} }
QMouseEvent e(type, pt, button, buttons, keym); QMouseEvent e(type, pt, button, buttons, keym);
QCoreApplication::sendEvent(widget, &e); qApp->notify(widget, &e);
return true; return true;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment