summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/graphicsview')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp91
3 files changed, 92 insertions, 10 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index c91a0803ee..fad75ec045 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -2976,11 +2976,6 @@ static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint)
return result;
}
-bool qFuzzyCompare(const QSizeF &a, const QSizeF &b)
-{
- return qFuzzyCompare(a.width(), b.width()) && qFuzzyCompare(a.height(), b.height());
-}
-
void tst_QGraphicsGridLayout::heightForWidth()
{
QGraphicsWidget *widget = new QGraphicsWidget;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 964f94c7b5..c3f77957f8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -2062,7 +2062,6 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QApplication::activeWindow(), &window);
@@ -2134,7 +2133,6 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
window.setLayout(layout);
window.show();
- QApplicationPrivate::setActiveWindow(&window);
window.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(QApplication::activeWindow(), &window);
@@ -2457,7 +2455,6 @@ void tst_QGraphicsProxyWidget::tooltip_basic()
QGraphicsView view(&scene);
view.setFixedSize(200, 200);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
{
QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(),
@@ -2993,7 +2990,6 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
view.resize(200, 200);
view.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(100, 100));
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
view.setFocus();
QTRY_VERIFY(view.hasFocus());
@@ -3075,7 +3071,6 @@ void tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
- QApplicationPrivate::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
QGraphicsProxyWidget *proxy = scene.addWidget(widgetGuard.release());
@@ -3877,6 +3872,7 @@ void tst_QGraphicsProxyWidget::touchEventPropagation()
break;
}
case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
mousePressReceiver = qobject_cast<QWidget*>(receiver);
break;
default:
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 7ed1f28b0a..ed99cd93a8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -26,6 +26,7 @@
#include <QtWidgets/QStyle>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QScroller>
+#include <QtWidgets/QStackedWidget>
#if QT_CONFIG(opengl)
#include <QtOpenGLWidgets/QOpenGLWidget>
#endif
@@ -114,6 +115,7 @@ protected:
#if defined QT_BUILD_INTERNAL
class FriendlyGraphicsScene : public QGraphicsScene
{
+ using QGraphicsScene::QGraphicsScene;
friend class tst_QGraphicsView;
Q_DECLARE_PRIVATE(QGraphicsScene);
};
@@ -254,6 +256,9 @@ private slots:
#ifndef QT_NO_CURSOR
void QTBUG_7438_cursor();
#endif
+#ifdef QT_BUILD_INTERNAL
+ void QTBUG_53974_mismatched_hide_show_events();
+#endif
void resizeContentsOnItemDrag_data();
void resizeContentsOnItemDrag();
@@ -4975,6 +4980,92 @@ void tst_QGraphicsView::QTBUG_70255_scrollTo()
QCOMPARE(point, QPoint(0, -500));
}
+#ifdef QT_BUILD_INTERNAL
+void tst_QGraphicsView::QTBUG_53974_mismatched_hide_show_events()
+{
+ QGraphicsView *view = new QGraphicsView;
+ FriendlyGraphicsScene *scene = new FriendlyGraphicsScene(view);
+ view->setScene(scene);
+
+ QStackedWidget *lowLevel = new QStackedWidget;
+ lowLevel->addWidget(new QLabel);
+ lowLevel->addWidget(view);
+
+ QStackedWidget topLevel;
+ topLevel.addWidget(new QLabel);
+ topLevel.addWidget(lowLevel);
+
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ topLevel.show();
+ topLevel.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+
+ // Starting point
+ QCOMPARE_EQ(topLevel.currentIndex(), 0);
+ QCOMPARE_EQ(lowLevel->currentIndex(), 0);
+
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // lowLevel is not visible. Changing the current index there
+ // should not affect the refcount.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(0);
+ QEXPECT_FAIL("", "The view was already hidden, so the refcount should still be 0", Continue);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+ scene->d_func()->activationRefCount = 0;
+
+ // Make lowLevel visible.
+ topLevel.setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Show and hide the QGV a couple of times.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ lowLevel->setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Make lowLevel hidden again.
+ topLevel.setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Change the current index in the hidden lowLevel
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ lowLevel->setCurrentIndex(0);
+ QEXPECT_FAIL("", "The view was already hidden, so the refcount should still be 0", Continue);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+ scene->d_func()->activationRefCount = 0;
+
+ // Make lowLevel and the QGV visible.
+ lowLevel->setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ topLevel.setCurrentIndex(1);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 1);
+
+ // Make lowLevel hidden (keeping the QGV as current index).
+ topLevel.setCurrentIndex(0);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+
+ // Hide the QGV:
+ lowLevel->setCurrentIndex(0);
+ QEXPECT_FAIL("", "The view was already hidden, so the refcount should still be 0", Continue);
+ QCOMPARE_EQ(scene->d_func()->activationRefCount, 0);
+ scene->d_func()->activationRefCount = 0;
+}
+#endif
+
void tst_QGraphicsView::resizeContentsOnItemDrag_data()
{
QTest::addColumn<Qt::Alignment>("alignment");