summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-15 10:14:11 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-15 10:14:11 +0100
commitbb0fec8057dd11c359bfcb4aefb66d9b210f52a6 (patch)
tree903e3220087ff7a3210390933ba3d8b8f7eb5ea3 /tests/auto
parent8920bf32eebe03cfc8a1a5e97f5b34c09c79a11b (diff)
parent4ba535616b8d3dfda7fbe162c6513f3008c1077a (diff)
Merge remote-tracking branch 'origin/5.10' into 5.11
Conflicts: src/corelib/corelib.pro src/corelib/global/qrandom.cpp src/network/access/qhttpnetworkrequest_p.h src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/cocoa/qcocoansmenu.mm src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/offscreen/qoffscreenintegration.h src/widgets/kernel/qaction.cpp src/widgets/widgets.pro Done-with: Andy Shaw <andy.shaw@qt.io> Change-Id: Ib01547cf4184023f19858ccf0ce7fb824fed2a8d
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp64
-rw-r--r--tests/auto/gui/image/qmovie/tst_qmovie.cpp10
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp76
3 files changed, 146 insertions, 4 deletions
diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
index 15a39b62c0..76efa008f7 100644
--- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
+++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
@@ -29,8 +29,11 @@
#include <QtTest/QtTest>
#include <qwineventnotifier.h>
#include <qtimer.h>
+#include <qvarlengtharray.h>
+#include <qvector.h>
#include <qt_windows.h>
+#include <algorithm>
#include <memory>
class tst_QWinEventNotifier : public QObject
@@ -44,6 +47,8 @@ private slots:
void simple_data();
void simple();
void manyNotifiers();
+ void disableNotifiersInActivatedSlot_data();
+ void disableNotifiersInActivatedSlot();
private:
HANDLE simpleHEvent;
@@ -109,9 +114,6 @@ public:
this, &EventWithNotifier::onNotifierActivated);
notifier.setHandle(CreateEvent(0, TRUE, FALSE, 0));
notifier.setEnabled(true);
-
- static int nextIndex = 0;
- idx = nextIndex++;
}
~EventWithNotifier()
@@ -122,6 +124,7 @@ public:
HANDLE eventHandle() const { return notifier.handle(); }
int numberOfTimesActivated() const { return activatedCount; }
+ void setEnabled(bool b) { notifier.setEnabled(b); }
signals:
void activated();
@@ -137,7 +140,6 @@ public slots:
private:
QWinEventNotifier notifier;
int activatedCount = 0;
- int idx = 0;
};
void tst_QWinEventNotifier::manyNotifiers()
@@ -184,6 +186,60 @@ void tst_QWinEventNotifier::manyNotifiers()
}));
}
+using Indices = QVector<int>;
+
+void tst_QWinEventNotifier::disableNotifiersInActivatedSlot_data()
+{
+ QTest::addColumn<int>("count");
+ QTest::addColumn<Indices>("notifiersToSignal");
+ QTest::addColumn<Indices>("notifiersToDisable");
+ QTest::addColumn<bool>("deleteNotifiers");
+ QTest::newRow("disable_signaled") << 3 << Indices{1} << Indices{1} << false;
+ QTest::newRow("disable_signaled2") << 3 << Indices{1, 2} << Indices{1} << false;
+ QTest::newRow("disable_before_signaled") << 3 << Indices{1} << Indices{0, 1} << false;
+ QTest::newRow("disable_after_signaled") << 3 << Indices{1} << Indices{1, 2} << false;
+ QTest::newRow("delete_signaled") << 3 << Indices{1} << Indices{1} << true;
+ QTest::newRow("delete_before_signaled1") << 3 << Indices{1} << Indices{0} << true;
+ QTest::newRow("delete_before_signaled2") << 3 << Indices{1} << Indices{0, 1} << true;
+ QTest::newRow("delete_before_signaled3") << 4 << Indices{3, 1} << Indices{0, 1} << true;
+ QTest::newRow("delete_after_signaled1") << 3 << Indices{1} << Indices{1, 2} << true;
+ QTest::newRow("delete_after_signaled2") << 4 << Indices{1, 3} << Indices{1, 2} << true;
+ QTest::newRow("delete_after_signaled3") << 5 << Indices{1} << Indices{1, 4} << true;
+}
+
+void tst_QWinEventNotifier::disableNotifiersInActivatedSlot()
+{
+ QFETCH(int, count);
+ QFETCH(Indices, notifiersToSignal);
+ QFETCH(Indices, notifiersToDisable);
+ QFETCH(bool, deleteNotifiers);
+
+ QVarLengthArray<std::unique_ptr<EventWithNotifier>, 10> events(count);
+ for (int i = 0; i < count; ++i)
+ events[i].reset(new EventWithNotifier);
+
+ auto isActivatedOrNull = [&events](int i) {
+ return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0;
+ };
+
+ for (auto &e : events) {
+ connect(e.get(), &EventWithNotifier::activated, [&]() {
+ for (int i : notifiersToDisable) {
+ if (deleteNotifiers)
+ events[i].reset();
+ else
+ events.at(i)->setEnabled(false);
+ }
+ if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), isActivatedOrNull))
+ QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop()));
+ });
+ }
+ for (int i : notifiersToSignal)
+ SetEvent(events.at(i)->eventHandle());
+ QTestEventLoop::instance().enterLoop(30);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+}
+
QTEST_MAIN(tst_QWinEventNotifier)
#include "tst_qwineventnotifier.moc"
diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
index bcaa759faa..4e9e9b8115 100644
--- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp
+++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
@@ -170,6 +170,16 @@ void tst_QMovie::playMovie()
QCOMPARE(movie.state(), QMovie::NotRunning);
QCOMPARE(movie.frameCount(), frameCount);
#endif
+
+ movie.stop();
+ QSignalSpy finishedSpy(&movie, &QMovie::finished);
+ movie.setSpeed(0);
+ movie.start();
+ QCOMPARE(movie.state(), QMovie::Running);
+ QTestEventLoop::instance().enterLoop(2);
+ QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(movie.state(), QMovie::Running);
+ QCOMPARE(movie.currentFrameNumber(), 0);
}
void tst_QMovie::jumpToFrame_data()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 3b340d06ab..fe8571abf1 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -254,6 +254,7 @@ private slots:
void zeroScale();
void focusItemChangedSignal();
void minimumRenderSize();
+ void checkTouchPointsEllipseDiameters();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4764,6 +4765,81 @@ void tst_QGraphicsScene::minimumRenderSize()
QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
}
+class TouchItem : public QGraphicsRectItem
+{
+public:
+ TouchItem() : QGraphicsRectItem(QRectF(-10, -10, 20, 20)),
+ seenTouch(false)
+ {
+ setAcceptTouchEvents(true);
+ setFlag(QGraphicsItem::ItemIgnoresTransformations);
+ }
+ bool seenTouch;
+ QList<QTouchEvent::TouchPoint> touchPoints;
+protected:
+ bool sceneEvent(QEvent *event) override
+ {
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ seenTouch = true;
+ touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
+ event->accept();
+ return true;
+ default:
+ break;
+ }
+ return QGraphicsRectItem::sceneEvent(event);
+ }
+};
+
+void tst_QGraphicsScene::checkTouchPointsEllipseDiameters()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ scene.setSceneRect(1, 1, 198, 198);
+ view.scale(1.5, 1.5);
+ view.setFocus();
+ TouchItem *rect = new TouchItem;
+ scene.addItem(rect);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+
+ const QSizeF ellipseDiameters(10.0, 10.0);
+ QTouchEvent::TouchPoint touchPoint(0);
+ touchPoint.setState(Qt::TouchPointPressed);
+ touchPoint.setPos(view.mapFromScene(rect->mapToScene(rect->boundingRect().center())));
+ touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint()));
+ touchPoint.setEllipseDiameters(ellipseDiameters);
+
+ QList<QTouchEvent::TouchPoint> touchPoints = { touchPoint };
+
+ QTouchDevice *testDevice = QTest::createTouchDevice(QTouchDevice::TouchPad);
+ QTouchEvent touchEvent(QEvent::TouchBegin,
+ testDevice,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ touchPoints);
+ QApplication::sendEvent(view.viewport(), &touchEvent);
+ QVERIFY(rect->seenTouch);
+ QVERIFY(rect->touchPoints.size() == 1);
+ QCOMPARE(ellipseDiameters, rect->touchPoints.first().ellipseDiameters());
+
+ rect->seenTouch = false;
+ rect->touchPoints.clear();
+ QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
+ testDevice,
+ Qt::NoModifier,
+ Qt::TouchPointMoved,
+ touchPoints);
+ QApplication::sendEvent(view.viewport(), &touchEvent);
+ QVERIFY(rect->seenTouch);
+ QVERIFY(rect->touchPoints.size() == 1);
+ QCOMPARE(ellipseDiameters, rect->touchPoints.first().ellipseDiameters());
+}
+
void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
{
QGraphicsScene scene;