From 64481bcc671892cd140ce5415eaec7fef3e2a35d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 9 Dec 2015 16:57:54 -0800 Subject: QWidgetWindow: The alien widget should be from the window's hierarchy This partially reverts commit 025d6a778ceb377e688f1. Change-Id: I7b964b0d598abe46137c22177fe2b5dcca5bb812 Task-number: QTBUG-49831 Reviewed-by: Gabriel de Dietrich Reviewed-by: Andy Shaw --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 21446de069..00636e50a8 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -165,6 +165,7 @@ private slots: void setCustomModelAndView(); void updateDelegateOnEditableChange(); void task_QTBUG_39088_inputMethodHints(); + void task_QTBUG_49831_scrollerNotActivated(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -3184,5 +3185,36 @@ void tst_QComboBox::task_QTBUG_39088_inputMethodHints() QCOMPARE(box.lineEdit()->inputMethodHints(), Qt::ImhNoPredictiveText); } +void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() +{ + QStringList modelData; + for (int i = 0; i < 1000; i++) + modelData << QStringLiteral("Item %1").arg(i); + QStringListModel model(modelData); + + QComboBox box; + box.setModel(&model); + box.setCurrentIndex(500); + box.show(); + QTest::qWaitForWindowShown(&box); + QTest::mouseMove(&box, QPoint(5, 5), 100); + box.showPopup(); + QFrame *container = box.findChild(); + QVERIFY(container); + QTest::qWaitForWindowShown(container); + + QList scrollers = container->findChildren(); + // Not all styles support scrollers. We rely only on those platforms that do to catch any regression. + if (!scrollers.isEmpty()) { + Q_FOREACH (QComboBoxPrivateScroller *scroller, scrollers) { + if (scroller->isVisible()) { + QSignalSpy doScrollSpy(scroller, SIGNAL(doScroll(int))); + QTest::mouseMove(scroller, QPoint(5, 5), 500); + QTRY_VERIFY(doScrollSpy.count() > 0); + } + } + } +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v1.2.3 From 38c8af7231823429ca6cb9ea6418e2dcef3691a0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 22 Dec 2015 17:15:57 +0100 Subject: Revert "Fix global coordinate mapping for child widgets in QGraphicsView." This reverts commit 56aad2ad6074237537fecf10d0cda0f3872e7f71. QWidget::mapFromGlobal() does not work correctly when the widget is a child widget of another widget embedded into a QGraphicsView with a transformation (scaling/rotation). It starts applying offsets going up the widget tree (just as mapToGlobal) until it hits the embedded widget not taking into account the transformation. It would need to go in from to top to bottom or better be reimplemented such that a QTransform for mapping coordinates from/to global is determined which is then applied in reverse. Task-number: QTBUG-50030 Task-number: QTBUG-50136 Change-Id: Iadeb891d793be1938c64942bfbf38d541a281c33 Reviewed-by: Marc Mutz --- .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index cd40c5541c..f3a683fe8b 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3684,6 +3684,7 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 const QSize size = availableGeometry.size() / 5; QGraphicsScene scene; QGraphicsView view(&scene); + view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform. view.setWindowTitle(QTest::currentTestFunction()); view.resize(size); view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); @@ -3706,10 +3707,15 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, msgPointMismatch(embeddedCenterGlobal, viewCenter).constData()); - // Same test with child centered on embeddedWidget + // Same test with child centered on embeddedWidget. The correct + // mapping is not implemented yet, but at least make sure + // the roundtrip maptoGlobal()/mapFromGlobal() returns the same + // point since that is important for mouse event handling (QTBUG-50030, + // QTBUG-50136). const QPoint childCenter = childWidget->rect().center(); const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter); QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter); + QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue); QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4, msgPointMismatch(childCenterGlobal, viewCenter).constData()); } -- cgit v1.2.3 From 9c7be0a7ec92a28d5d489fb78c500dad3f01d9ec Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 Jan 2016 23:10:12 +0100 Subject: Fix UB in tst_QDialog::showExtension() Don't cast a QDialog to a subclass it is not. Fix by creating it as the required subclass in the first place. Found by UBSan: tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp:203:20: runtime error: downcast of address 0x2b5f5000ad40 which does not point to an object of type 'DummyDialog' tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp:203:46: runtime error: member call on address 0x2b5f5000ad40 which does not point to an object of type 'DummyDialog' Change-Id: I63ae7e782bda6a78d11af5c2bc2f7d88aacd0ac0 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index e62ce3ceb5..a23938959b 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -49,6 +49,14 @@ QT_FORWARD_DECLARE_CLASS(QDialog) +// work around function being protected +class DummyDialog : public QDialog +{ +public: + DummyDialog(): QDialog(0, Qt::X11BypassWindowManagerHint) {} + using QDialog::showExtension; +}; + class tst_QDialog : public QObject { Q_OBJECT @@ -82,7 +90,7 @@ private slots: void transientParent(); private: - QDialog *testWidget; + DummyDialog *testWidget; }; // Testing get/set functions @@ -108,13 +116,6 @@ void tst_QDialog::getSetCheck() QCOMPARE(INT_MAX, obj1.result()); } -// work around function being protected -class DummyDialog : public QDialog { -public: - DummyDialog(): QDialog(0) {} - void showExtension( bool b ) { QDialog::showExtension( b ); } -}; - class ToolDialog : public QDialog { public: @@ -148,7 +149,7 @@ tst_QDialog::tst_QDialog() void tst_QDialog::initTestCase() { // Create the test class - testWidget = new QDialog(0, Qt::X11BypassWindowManagerHint); + testWidget = new DummyDialog; testWidget->resize(200,200); testWidget->show(); qApp->setActiveWindow(testWidget); @@ -193,7 +194,7 @@ void tst_QDialog::showExtension() QPoint oldPosition = testWidget->pos(); // show - ((DummyDialog*)testWidget)->showExtension( true ); + testWidget->showExtension( true ); // while ( testWidget->size() == dlgSize ) // qApp->processEvents(); @@ -202,7 +203,7 @@ void tst_QDialog::showExtension() QCOMPARE(testWidget->pos(), oldPosition); // hide extension. back to old size ? - ((DummyDialog*)testWidget)->showExtension( false ); + testWidget->showExtension( false ); QCOMPARE( testWidget->size(), dlgSize ); testWidget->setExtension( 0 ); -- cgit v1.2.3