summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-10-30 10:56:16 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-10-30 10:56:16 (GMT)
commit6fbd9589cbe77c4d3213ba43c7e88fc451c9664e (patch)
treebfec32f37cdeed130731b758d4fe9fe14e2a8392 /tests/auto
parent83fff2f970b9a7b41861336c7dca0eadbda28099 (diff)
parent8c4edbd04f350294462fd689748de2dd7cc84d47 (diff)
downloadQt-6fbd9589cbe77c4d3213ba43c7e88fc451c9664e.zip
Qt-6fbd9589cbe77c4d3213ba43c7e88fc451c9664e.tar.gz
Qt-6fbd9589cbe77c4d3213ba43c7e88fc451c9664e.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-platform-team into 4.6
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp212
-rw-r--r--tests/auto/qapplication/tst_qapplication.cpp22
-rw-r--r--tests/auto/qmouseevent/tst_qmouseevent.cpp75
3 files changed, 297 insertions, 12 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 92f979f..02c8232 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -103,6 +103,8 @@ int CustomEvent::EventType = 0;
class CustomGestureRecognizer : public QGestureRecognizer
{
public:
+ static bool ConsumeEvents;
+
CustomGestureRecognizer()
{
if (!CustomEvent::EventType)
@@ -117,7 +119,9 @@ public:
QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event)
{
if (event->type() == CustomEvent::EventType) {
- QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint;
+ QGestureRecognizer::Result result = 0;
+ if (CustomGestureRecognizer::ConsumeEvents)
+ result |= QGestureRecognizer::ConsumeEventHint;
CustomGesture *g = static_cast<CustomGesture*>(state);
CustomEvent *e = static_cast<CustomEvent*>(event);
g->serial = e->serial;
@@ -143,6 +147,7 @@ public:
QGestureRecognizer::reset(state);
}
};
+bool CustomGestureRecognizer::ConsumeEvents = false;
// same as CustomGestureRecognizer but triggers early without the maybe state
class CustomContinuousGestureRecognizer : public QGestureRecognizer
@@ -280,6 +285,7 @@ protected:
}
};
+// TODO rename to sendGestureSequence
static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0)
{
for (int i = CustomGesture::SerialMaybeThreshold;
@@ -322,6 +328,10 @@ private slots:
void multipleGesturesInTree();
void multipleGesturesInComplexTree();
void testMapToScene();
+ void ungrabGesture();
+ void consumeEventHint();
+ void unregisterRecognizer();
+ void autoCancelGestures();
};
tst_Gestures::tst_Gestures()
@@ -334,13 +344,14 @@ tst_Gestures::~tst_Gestures()
void tst_Gestures::initTestCase()
{
- CustomGesture::GestureType = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ CustomGesture::GestureType = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
QVERIFY(CustomGesture::GestureType != Qt::GestureType(0));
QVERIFY(CustomGesture::GestureType != Qt::CustomGesture);
}
void tst_Gestures::cleanupTestCase()
{
+ QApplication::unregisterGestureRecognizer(CustomGesture::GestureType);
}
void tst_Gestures::init()
@@ -372,6 +383,19 @@ void tst_Gestures::customGesture()
QCOMPARE(widget.events.canceled.size(), 0);
}
+void tst_Gestures::consumeEventHint()
+{
+ GestureWidget widget;
+ widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+
+ CustomGestureRecognizer::ConsumeEvents = true;
+ CustomEvent event;
+ sendCustomGesture(&event, &widget);
+ CustomGestureRecognizer::ConsumeEvents = false;
+
+ QCOMPARE(widget.customEventsReceived, 0);
+}
+
void tst_Gestures::autoCancelingGestures()
{
GestureWidget widget;
@@ -534,7 +558,7 @@ void tst_Gestures::conflictingGestures()
parent.reset();
child->reset();
- Qt::GestureType ContinuousGesture = qApp->registerGestureRecognizer(new CustomContinuousGestureRecognizer);
+ Qt::GestureType ContinuousGesture = QApplication::registerGestureRecognizer(new CustomContinuousGestureRecognizer);
static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
child->grabGesture(ContinuousGesture);
// child accepts override. And it also receives another custom gesture.
@@ -547,6 +571,8 @@ void tst_Gestures::conflictingGestures()
QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
+
+ QApplication::unregisterGestureRecognizer(ContinuousGesture);
}
void tst_Gestures::finishedWithoutStarted()
@@ -710,6 +736,7 @@ void tst_Gestures::graphicsItemGesture()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
GestureItem *item = new GestureItem("item");
scene.addItem(item);
@@ -772,6 +799,7 @@ void tst_Gestures::graphicsItemTreeGesture()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
GestureItem *item1 = new GestureItem("item1");
item1->setPos(100, 100);
@@ -829,6 +857,7 @@ void tst_Gestures::explicitGraphicsObjectTarget()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
GestureItem *item1 = new GestureItem("item1");
scene.addItem(item1);
@@ -882,6 +911,7 @@ void tst_Gestures::gestureOverChildGraphicsItem()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
GestureItem *item0 = new GestureItem("item0");
scene.addItem(item0);
@@ -951,7 +981,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
GestureWidget *child = new GestureWidget("child");
l->addWidget(child);
- Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture);
@@ -978,6 +1008,8 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
for(int i = 0; i < child->events.all.size(); ++i)
QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType);
+
+ QApplication::unregisterGestureRecognizer(SecondGesture);
}
void tst_Gestures::multipleGesturesInTree()
@@ -989,8 +1021,8 @@ void tst_Gestures::multipleGesturesInTree()
GestureWidget *D = new GestureWidget("D", C);
Qt::GestureType FirstGesture = CustomGesture::GestureType;
- Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3]
A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // |
@@ -1046,6 +1078,9 @@ void tst_Gestures::multipleGesturesInTree()
QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
QCOMPARE(A->events.all.count(SecondGesture), 0);
QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
+
+ QApplication::unregisterGestureRecognizer(SecondGesture);
+ QApplication::unregisterGestureRecognizer(ThirdGesture);
}
void tst_Gestures::multipleGesturesInComplexTree()
@@ -1057,12 +1092,12 @@ void tst_Gestures::multipleGesturesInComplexTree()
GestureWidget *D = new GestureWidget("D", C);
Qt::GestureType FirstGesture = CustomGesture::GestureType;
- Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType FourthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType FifthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType SixthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
- Qt::GestureType SeventhGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FourthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType FifthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SixthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
+ Qt::GestureType SeventhGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer);
A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4]
A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // |
@@ -1139,6 +1174,13 @@ void tst_Gestures::multipleGesturesInComplexTree()
QCOMPARE(A->events.all.count(FifthGesture), 0);
QCOMPARE(A->events.all.count(SixthGesture), 0);
QCOMPARE(A->events.all.count(SeventhGesture), 0);
+
+ QApplication::unregisterGestureRecognizer(SecondGesture);
+ QApplication::unregisterGestureRecognizer(ThirdGesture);
+ QApplication::unregisterGestureRecognizer(FourthGesture);
+ QApplication::unregisterGestureRecognizer(FifthGesture);
+ QApplication::unregisterGestureRecognizer(SixthGesture);
+ QApplication::unregisterGestureRecognizer(SeventhGesture);
}
void tst_Gestures::testMapToScene()
@@ -1151,6 +1193,7 @@ void tst_Gestures::testMapToScene()
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setWindowFlags(Qt::X11BypassWindowManagerHint);
GestureItem *item0 = new GestureItem;
scene.addItem(item0);
@@ -1166,5 +1209,150 @@ void tst_Gestures::testMapToScene()
QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200)));
}
+void tst_Gestures::ungrabGesture() // a method on QWidget
+{
+ class MockGestureWidget : public GestureWidget {
+ public:
+ MockGestureWidget(const char *name = 0, QWidget *parent = 0)
+ : GestureWidget(name, parent) { }
+
+
+ QSet<QGesture*> gestures;
+ protected:
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *gestureEvent = static_cast<QGestureEvent*>(event);
+ if (gestureEvent)
+ foreach (QGesture *g, gestureEvent->allGestures())
+ gestures.insert(g);
+ }
+ return GestureWidget::event(event);
+ }
+ };
+
+ MockGestureWidget parent("A");
+ MockGestureWidget *a = &parent;
+ MockGestureWidget *b = new MockGestureWidget("B", a);
+
+ a->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture);
+ b->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture);
+ b->ignoredGestures << CustomGesture::GestureType;
+
+ CustomEvent event;
+ // sending an event will cause the QGesture objects to be instantiated for the widgets
+ sendCustomGesture(&event, b);
+
+ QCOMPARE(a->gestures.count(), 1);
+ QPointer<QGesture> customGestureA;
+ customGestureA = *(a->gestures.begin());
+ QVERIFY(!customGestureA.isNull());
+ QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
+
+ QCOMPARE(b->gestures.count(), 1);
+ QPointer<QGesture> customGestureB;
+ customGestureB = *(b->gestures.begin());
+ QVERIFY(!customGestureB.isNull());
+ QVERIFY(customGestureA.data() == customGestureB.data());
+ QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType);
+
+ a->gestures.clear();
+ // sending an event will cause the QGesture objects to be instantiated for the widget
+ sendCustomGesture(&event, a);
+
+ QCOMPARE(a->gestures.count(), 1);
+ customGestureA = *(a->gestures.begin());
+ QVERIFY(!customGestureA.isNull());
+ QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
+ QVERIFY(customGestureA.data() != customGestureB.data());
+
+ a->ungrabGesture(CustomGesture::GestureType);
+ QVERIFY(customGestureA.isNull());
+ QVERIFY(!customGestureB.isNull());
+
+ a->gestures.clear();
+ a->reset();
+ // send again to 'b' and make sure a never gets it.
+ sendCustomGesture(&event, b);
+ QCOMPARE(a->gestureEventsReceived, 0);
+ QCOMPARE(a->gestureOverrideEventsReceived, 0);
+}
+
+void tst_Gestures::unregisterRecognizer() // a method on QApplication
+{
+ /*
+ The hardest usecase to get right is when we remove a recognizer while several
+ of the gestures it created are in active state and we immediately add a new recognizer
+ for the same type (thus replacing the old one).
+ The expected result is that all old gestures continue till they are finished/cancelled
+ and the new recognizer starts creating gestures immediately at registration.
+
+ This implies that deleting of the recognizer happens only when there are no more gestures
+ that it created. (since gestures might have a pointer to the recognizer)
+ */
+
+}
+
+void tst_Gestures::autoCancelGestures()
+{
+ class MockRecognizer : public QGestureRecognizer {
+ public:
+ QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event)
+ {
+ Q_UNUSED(gesture);
+ Q_UNUSED(watched);
+ if (event->type() == QEvent::MouseButtonPress)
+ return QGestureRecognizer::GestureTriggered;
+ if (event->type() == QEvent::MouseButtonRelease)
+ return QGestureRecognizer::GestureFinished;
+ return QGestureRecognizer::Ignore;
+ }
+ };
+
+ class MockWidget : public GestureWidget {
+ public:
+ MockWidget(const char *name) : GestureWidget(name) { }
+
+ bool event(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent*>(event);
+ Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here...
+ ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
+ }
+ return GestureWidget::event(event);
+ }
+ };
+
+ MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext
+ parent.resize(300, 100);
+ GestureWidget *child = new GestureWidget("child", &parent);
+ child->setGeometry(10, 10, 100, 80);
+
+ Qt::GestureType type = QApplication::registerGestureRecognizer(new MockRecognizer());
+ parent.grabGesture(type, Qt::WidgetWithChildrenGesture);
+ child->grabGesture(type, Qt::WidgetWithChildrenGesture);
+
+ /*
+ An event is send to both the child and the parent, when the child gets it a gesture is triggered
+ and send to the child.
+ When the parent gets the event a new gesture is triggered and delivered to the parent. When the
+ parent gets it he accepts it and that causes the cancel policy to activate.
+ The cause of that is the gesture for the child is cancelled and send to the child as such.
+ */
+ QMouseEvent event(QEvent::MouseButtonPress, QPoint(20,20), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ QApplication::sendEvent(child, &event);
+ QCOMPARE(child->events.started.count(), 1);
+ QCOMPARE(child->events.all.count(), 1);
+ QCOMPARE(parent.events.all.count(), 0);
+ child->reset();
+ QApplication::sendEvent(&parent, &event);
+ QCOMPARE(parent.events.all.count(), 1);
+ QCOMPARE(parent.events.started.count(), 1);
+ QCOMPARE(child->events.started.count(), 0);
+ QCOMPARE(child->events.all.count(), 1);
+ QCOMPARE(child->events.canceled.count(), 1);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp
index 675e559..5888866 100644
--- a/tests/auto/qapplication/tst_qapplication.cpp
+++ b/tests/auto/qapplication/tst_qapplication.cpp
@@ -129,6 +129,7 @@ private slots:
void style();
void allWidgets();
+ void topLevelWidgets();
void setAttribute();
@@ -1795,6 +1796,27 @@ void tst_QApplication::allWidgets()
QVERIFY(!app.allWidgets().contains(w)); // removal test
}
+void tst_QApplication::topLevelWidgets()
+{
+ int argc = 1;
+ QApplication app(argc, &argv0, QApplication::GuiServer);
+ QWidget *w = new QWidget;
+ w->show();
+#ifndef QT_NO_CLIPBOARD
+ QClipboard *clipboard = QApplication::clipboard();
+ QString originalText = clipboard->text();
+ clipboard->setText(QString("newText"));
+#endif
+ app.processEvents();
+ QVERIFY(QApplication::topLevelWidgets().contains(w));
+ QCOMPARE(QApplication::topLevelWidgets().count(), 1);
+ delete w;
+ w = 0;
+ app.processEvents();
+ QCOMPARE(QApplication::topLevelWidgets().count(), 0);
+}
+
+
void tst_QApplication::setAttribute()
{
diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp
index b961851..d700181 100644
--- a/tests/auto/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp
@@ -62,6 +62,7 @@ public:
}
bool mousePressEventRecieved;
bool mouseReleaseEventRecieved;
+ bool mouseMoveEventRecieved;
#ifdef QT3_SUPPORT
int mousePressStateBefore;
int mousePressStateAfter;
@@ -76,6 +77,13 @@ public:
int mouseReleaseButton;
int mouseReleaseButtons;
int mouseReleaseModifiers;
+#ifdef QT3_SUPPORT
+ int mouseMoveStateBefore;
+ int mouseMoveStateAfter;
+#endif
+ int mouseMoveButton;
+ int mouseMoveButtons;
+ int mouseMoveModifiers;
protected:
void mousePressEvent(QMouseEvent *e)
{
@@ -103,6 +111,19 @@ protected:
mouseReleaseEventRecieved = TRUE;
e->accept();
}
+ void mouseMoveEvent(QMouseEvent *e)
+ {
+ QWidget::mouseMoveEvent(e);
+#ifdef QT3_SUPPORT
+ mouseMoveStateBefore = e->state();
+ mouseMoveStateAfter = e->stateAfter();
+#endif
+ mouseMoveButton = e->button();
+ mouseMoveButtons = e->buttons();
+ mouseMoveModifiers = e->modifiers();
+ mouseMoveEventRecieved = TRUE;
+ e->accept();
+ }
};
class tst_QMouseEvent : public QObject
@@ -124,6 +145,8 @@ private slots:
void checkMousePressEvent();
void checkMouseReleaseEvent_data();
void checkMouseReleaseEvent();
+ void checkMouseMoveEvent_data();
+ void checkMouseMoveEvent();
void qt3supportConstructors();
@@ -157,11 +180,14 @@ void tst_QMouseEvent::init()
{
testMouseWidget->mousePressEventRecieved = FALSE;
testMouseWidget->mouseReleaseEventRecieved = FALSE;
+ testMouseWidget->mouseMoveEventRecieved = FALSE;
#ifdef QT3_SUPPORT
testMouseWidget->mousePressStateBefore = 0;
testMouseWidget->mousePressStateAfter = 0;
testMouseWidget->mouseReleaseStateBefore = 0;
testMouseWidget->mouseReleaseStateAfter = 0;
+ testMouseWidget->mouseMoveStateBefore = 0;
+ testMouseWidget->mouseMoveStateAfter = 0;
#endif
testMouseWidget->mousePressButton = 0;
testMouseWidget->mousePressButtons = 0;
@@ -169,6 +195,9 @@ void tst_QMouseEvent::init()
testMouseWidget->mouseReleaseButton = 0;
testMouseWidget->mouseReleaseButtons = 0;
testMouseWidget->mouseReleaseModifiers = 0;
+ testMouseWidget->mouseMoveButton = 0;
+ testMouseWidget->mouseMoveButtons = 0;
+ testMouseWidget->mouseMoveModifiers = 0;
}
void tst_QMouseEvent::cleanup()
@@ -265,6 +294,52 @@ void tst_QMouseEvent::checkMouseReleaseEvent()
#endif
}
+void tst_QMouseEvent::checkMouseMoveEvent_data()
+{
+ QTest::addColumn<int>("buttonMoved");
+ QTest::addColumn<int>("keyPressed");
+
+ QTest::newRow("leftButton-nokey") << int(Qt::LeftButton) << int(Qt::NoButton);
+ QTest::newRow("leftButton-shiftkey") << int(Qt::LeftButton) << int(Qt::ShiftModifier);
+ QTest::newRow("leftButton-controlkey") << int(Qt::LeftButton) << int(Qt::ControlModifier);
+ QTest::newRow("leftButton-altkey") << int(Qt::LeftButton) << int(Qt::AltModifier);
+ QTest::newRow("leftButton-metakey") << int(Qt::LeftButton) << int(Qt::MetaModifier);
+ QTest::newRow("rightButton-nokey") << int(Qt::RightButton) << int(Qt::NoButton);
+ QTest::newRow("rightButton-shiftkey") << int(Qt::RightButton) << int(Qt::ShiftModifier);
+ QTest::newRow("rightButton-controlkey") << int(Qt::RightButton) << int(Qt::ControlModifier);
+ QTest::newRow("rightButton-altkey") << int(Qt::RightButton) << int(Qt::AltModifier);
+ QTest::newRow("rightButton-metakey") << int(Qt::RightButton) << int(Qt::MetaModifier);
+ QTest::newRow("midButton-nokey") << int(Qt::MidButton) << int(Qt::NoButton);
+ QTest::newRow("midButton-shiftkey") << int(Qt::MidButton) << int(Qt::ShiftModifier);
+ QTest::newRow("midButton-controlkey") << int(Qt::MidButton) << int(Qt::ControlModifier);
+ QTest::newRow("midButton-altkey") << int(Qt::MidButton) << int(Qt::AltModifier);
+ QTest::newRow("midButton-metakey") << int(Qt::MidButton) << int(Qt::MetaModifier);
+}
+
+void tst_QMouseEvent::checkMouseMoveEvent()
+{
+ QFETCH(int,buttonMoved);
+ QFETCH(int,keyPressed);
+ int button = (int)Qt::NoButton;
+ int buttons = buttonMoved;
+ int modifiers = keyPressed;
+
+ QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed));
+ QTest::mouseMove(testMouseWidget, QPoint(10,10));
+ QVERIFY(testMouseWidget->mouseMoveEventRecieved);
+ QCOMPARE(testMouseWidget->mouseMoveButton, button);
+ QCOMPARE(testMouseWidget->mouseMoveButtons, buttons);
+ QCOMPARE(testMouseWidget->mouseMoveModifiers, modifiers);
+#ifdef QT3_SUPPORT
+ int stateAfter = buttons|modifiers;
+ int stateBefore = stateAfter|button;
+
+ QCOMPARE(testMouseWidget->mouseMoveStateBefore, stateBefore);
+ QCOMPARE(testMouseWidget->mouseMoveStateAfter, stateAfter);
+#endif
+ QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed));
+}
+
void tst_QMouseEvent::qt3supportConstructors()
{
#if !defined(QT3_SUPPORT)