summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp92
1 files changed, 47 insertions, 45 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 169e90d9c7..e39437d8c7 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -709,7 +709,6 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
if (hasScene) {
scene.addItem(proxyGuard.release());
@@ -751,7 +750,6 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
scene.addItem(proxy);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
view.activateWindow();
view.setFocus();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -784,6 +782,9 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
{
+#ifdef ANDROID
+ QSKIP("This test leads to failures on subsequent test cases, QTBUG-119574");
+#endif
// QSpinBox has an internal QLineEdit; this QLineEdit has the spinbox
// as its focus proxy.
struct FocusedSpinBox : QSpinBox
@@ -806,6 +807,9 @@ void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856()
}
};
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
QGraphicsView view(&scene);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -927,7 +931,6 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
@@ -942,7 +945,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
proxy->setPos(50, 0);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
// outside graphics item
QTest::mouseMove(&view, QPoint(10, 10));
@@ -981,7 +984,6 @@ void tst_QGraphicsProxyWidget::keyPressEvent()
QGraphicsView view(&scene);
view.show();
view.viewport()->setFocus();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1020,7 +1022,6 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1040,9 +1041,9 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
proxy->setFocus();
QTest::keyPress(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::keyRelease(view.viewport(), Qt::Key_Space);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
// protected void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
@@ -1066,11 +1067,10 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
view.resize(100, 100);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(QApplication::activeWindow(), (QWidget*)&view);
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint pointInLineEdit = view.mapFromScene(proxy->mapToScene(15, proxy->boundingRect().center().y()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, pointInLineEdit);
@@ -1111,13 +1111,13 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
proxy->setFocus();
// wait for scene to be updated before doing any coordinate mappings on it
- QTRY_VERIFY(sceneChangedSpy.count() > 0);
+ QTRY_VERIFY(sceneChangedSpy.size() > 0);
QPoint buttonCenter = view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()));
QTest::mousePress(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {}, buttonCenter);
- QTRY_COMPARE(spy.count(), hasWidget ? 1 : 0);
+ QTRY_COMPARE(spy.size(), hasWidget ? 1 : 0);
}
void tst_QGraphicsProxyWidget::resizeEvent_data()
@@ -1152,7 +1152,6 @@ void tst_QGraphicsProxyWidget::paintEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.isActiveWindow());
@@ -1168,7 +1167,7 @@ void tst_QGraphicsProxyWidget::paintEvent()
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(&proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
proxy.paintCount = 0;
w->update();
@@ -1323,6 +1322,9 @@ static QList<QRect> rects(const QRegion &region)
void tst_QGraphicsProxyWidget::scrollUpdate()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
ScrollWidget *widget = new ScrollWidget;
QGraphicsScene scene;
@@ -1536,7 +1538,6 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1620,7 +1621,6 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1753,7 +1753,6 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -1890,7 +1889,6 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
@@ -2404,7 +2402,7 @@ void tst_QGraphicsProxyWidget::changingCursor_basic()
proxy->setWidget(widget);
QSignalSpy sceneChangedSpy(&scene, &QGraphicsScene::changed);
scene.addItem(proxy);
- QTRY_VERIFY(sceneChangedSpy.count() > 0); // make sure the scene is ready
+ QTRY_VERIFY(sceneChangedSpy.size() > 0); // make sure the scene is ready
// in
QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center())));
@@ -2470,7 +2468,8 @@ void tst_QGraphicsProxyWidget::tooltip_basic()
bool foundView = false;
bool foundTipLabel = false;
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ const auto widgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : widgets) {
if (widget == &view)
foundView = true;
if (widget->inherits("QTipLabel"))
@@ -2622,7 +2621,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints);
- QTRY_COMPARE(signalSpy.count(), 1);
+ QTRY_COMPARE(signalSpy.size(), 1);
const QList<QVariant> arguments = signalSpy.takeFirst();
const QList<QRectF> updateRects = qvariant_cast<QList<QRectF> >(arguments.at(0));
QCOMPARE(updateRects.size(), 1);
@@ -2897,10 +2896,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QTest::mousePress(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 0);
+ QTRY_COMPARE(spy.size(), 0);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, {},
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
@@ -3065,6 +3064,9 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget_data()
void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(bool, bypass);
std::unique_ptr<QWidget> widgetGuard(new QWidget);
@@ -3278,6 +3280,9 @@ public:
void tst_QGraphicsProxyWidget::inputMethod()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QGraphicsScene scene;
// check that the proxy is initialized with the correct input method sensitivity
@@ -3337,7 +3342,6 @@ void tst_QGraphicsProxyWidget::clickFocus()
view.setFrameStyle(0);
view.resize(300, 300);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!proxy->hasFocus());
@@ -3481,7 +3485,6 @@ void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget()
QGraphicsView view(&scene);
view.resize(600, 600);
- QApplicationPrivate::setActiveWindow(&view);
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -3525,7 +3528,6 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
childWidget->resize(embeddedWidget->size() / 2);
childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget
scene.addWidget(embeddedWidget);
- QApplicationPrivate::setActiveWindow(&view);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
const QPoint embeddedCenter = embeddedWidget->rect().center();
@@ -3690,27 +3692,27 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// accepted by the embedded widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// wheeling on the label, which ignores the event, should scroll the view
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// left the widget
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reached the nested widget, which accepts the wheel event, so no more scrolling
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
// remember this position for later
const int scrollBarValueOnNestedProxy = view.verticalScrollBar()->value();
wheelUp(Qt::NoScrollPhase);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
QCOMPARE(nestedWidget->wheelEventCount, 1);
// reset, try with kinetic events
@@ -3721,41 +3723,41 @@ void tst_QGraphicsProxyWidget::wheelEventPropagation()
// no matter if the widget accepts wheel events - the view has the grab
QCOMPARE(view.itemAt(wheelPosition), nullptr);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// reset
view.verticalScrollBar()->setValue(0);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
// starting a scroll on a widget that doesn't accept wheel events
// should also scroll the view, which still gets the grab
wheelUp(Qt::NoScrollPhase);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), labelProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
for (int i = 0; i < 5; ++i) {
wheelUp(Qt::ScrollUpdate);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
}
wheelUp(Qt::ScrollEnd);
- QCOMPARE(scrollSpy.count(), ++scrollCount);
+ QCOMPARE(scrollSpy.size(), ++scrollCount);
// starting a scroll on a widget that does accept wheel events
// should not scroll the view
view.verticalScrollBar()->setValue(scrollBarValueOnNestedProxy);
- scrollCount = scrollSpy.count();
+ scrollCount = scrollSpy.size();
QCOMPARE(view.itemAt(wheelPosition), nestedProxy);
wheelUp(Qt::ScrollBegin);
- QCOMPARE(scrollSpy.count(), scrollCount);
+ QCOMPARE(scrollSpy.size(), scrollCount);
}
#endif // QT_CONFIG(wheelevent)
@@ -3957,7 +3959,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(record.receiver, view.windowHandle());
QCOMPARE(record.eventType, QEvent::TouchEnd);
QCOMPARE(eventSpy.mousePressReceiver, pushButton1);
- QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedSpy.size(), 1);
eventSpy.clear();
clickedSpy.clear();
@@ -4025,7 +4027,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
QCOMPARE(eventSpy.at(0, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(1, 3).receiver, touchWidget2);
QCOMPARE(eventSpy.at(2, 3).receiver, touchWidget2);
- QCOMPARE(clickedSpy.count(), 0); // multi-touch event does not synthesize a mouse event
+ QCOMPARE(clickedSpy.size(), 0); // multi-touch event does not synthesize a mouse event
}
QTEST_MAIN(tst_QGraphicsProxyWidget)