diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-02-20 11:50:04 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-02-20 22:08:29 +0100 |
commit | dcb710dd87ab15c3af803133ff2449902dbec036 (patch) | |
tree | 1f3ed87165f05e45260ff45fb15d5df96d684abb /tests | |
parent | 4606ea53958df33fffba680dd75c8b1733ca9f40 (diff) | |
parent | e47c2744e6cefa42fc70320e07d534742934f737 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
mkspecs/features/unix/separate_debug_info.prf
src/gui/kernel/qwindow_p.h
src/plugins/platforms/cocoa/qcocoacursor.mm
tests/auto/tools/moc/tst_moc.cpp
Change-Id: Ieb57834c00f961a747ffe51e6eb9fc9612cebccf
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp | 12 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp | 98 |
2 files changed, 93 insertions, 17 deletions
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 6198aa8668..2163426cac 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -600,9 +600,6 @@ void tst_QMdiSubWindow::showShaded() else #endif mouseReceiver = window; -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-25297", Abort); -#endif QVERIFY(mouseReceiver); sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton); sendMousePress(mouseReceiver, mousePosition); @@ -711,9 +708,6 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove() mouseReceiver = qFindChild<QSizeGrip *>(window); else mouseReceiver = window; -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-25297", Abort); -#endif QVERIFY(mouseReceiver); // ----------------------------- resize ----------------------------- @@ -1451,9 +1445,6 @@ void tst_QMdiSubWindow::defaultSizeGrip() // QSizeGrip on windows with decoration. QMdiSubWindow *windowWithDecoration = mdiArea.addSubWindow(new QWidget); windowWithDecoration->show(); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-25297", Abort); -#endif QVERIFY(qFindChild<QSizeGrip *>(windowWithDecoration)); // ...but not on windows without decoration (Qt::FramelessWindowHint). @@ -1713,9 +1704,6 @@ void tst_QMdiSubWindow::fixedMinMaxSize() // to minimize the window. subWindow->showMinimized(); QVERIFY(subWindow->isMinimized()); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-25297", Abort); -#endif QCOMPARE(subWindow->size(), minimizedSize); QCOMPARE(subWindow->minimumSize(), minimizedSize); diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp index 3b5c73ca57..c17db4c7f3 100644 --- a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp +++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp @@ -47,6 +47,7 @@ #include <qstackedwidget.h> #include <qpushbutton.h> #include <QHBoxLayout> +#include <qlineedit.h> class tst_QStackedWidget : public QObject { @@ -58,7 +59,8 @@ public: private slots: void getSetCheck(); - void testMinimumSize(); + void testMinimumSize(); + void dynamicPages(); }; tst_QStackedWidget::tst_QStackedWidget() @@ -72,15 +74,15 @@ tst_QStackedWidget::~tst_QStackedWidget() // Testing that stackedwidget respect the minimum size of it's contents (task 95319) void tst_QStackedWidget::testMinimumSize() { - QWidget w; + QWidget w; QStackedWidget sw(&w); QPushButton button("Text", &sw); - sw.addWidget(&button); + sw.addWidget(&button); QHBoxLayout hboxLayout; hboxLayout.addWidget(&sw); w.setLayout(&hboxLayout); w.show(); - QVERIFY(w.minimumSize() != QSize(0, 0)); + QVERIFY(w.minimumSize() != QSize(0, 0)); } // Testing get/set functions @@ -111,11 +113,97 @@ void tst_QStackedWidget::getSetCheck() // has no problem handling out-of-bounds indices. // ("convenience function" => "just another way of achieving the // same goal") - obj1.setCurrentWidget((QWidget *)0); + obj1.setCurrentWidget((QWidget *)0); QCOMPARE(obj1.currentWidget(), var2); #endif delete var2; } +// QTBUG-18242, a widget that deletes its children in hideEvent(). +// This caused a crash in QStackedLayout::setCurrentIndex() since +// the focus widget was destroyed while hiding the previous page. +class TestPage : public QWidget +{ +public: + TestPage (bool staticWidgets = false) : QWidget(0), m_staticWidgets(staticWidgets) + { + new QVBoxLayout (this); + } + + ~TestPage() { + destroyWidgets(); + } + + void setN(int n) + { + m_n = n; + if (m_staticWidgets) + createWidgets(); + } + + virtual void showEvent (QShowEvent *) + { + if (!m_staticWidgets) + createWidgets(); + } + + virtual void hideEvent (QHideEvent *) + { + if (!m_staticWidgets) + destroyWidgets(); + } + +private: + void createWidgets() { + for (int i = 0; i < m_n; ++i) { + QLineEdit *le = new QLineEdit(this); + le->setObjectName(QString::fromLatin1("lineEdit%1").arg(i)); + layout ()->addWidget(le); + m_les << le; + } + } + + void destroyWidgets() + { + qDeleteAll(m_les); + m_les.clear (); + } + + int m_n; + const bool m_staticWidgets; + QList<QLineEdit*> m_les; +}; + +void tst_QStackedWidget::dynamicPages() +{ + QStackedWidget *sw = new QStackedWidget; + + TestPage *w1 = new TestPage(true); + w1->setN(3); + + TestPage *w2 = new TestPage; + w2->setN(3); + + sw->addWidget(w1); + sw->addWidget(w2); + + QLineEdit *le11 = w1->findChild<QLineEdit*>(QLatin1String("lineEdit1")); + le11->setFocus(); // set focus to second widget in the page + sw->resize(200, 200); + sw->show(); + qApp->setActiveWindow(sw); + QTest::qWaitForWindowActive(sw); + QTRY_COMPARE(QApplication::focusWidget(), le11); + + sw->setCurrentIndex(1); + QLineEdit *le22 = w2->findChild<QLineEdit*>(QLatin1String("lineEdit2")); + le22->setFocus(); + QTRY_COMPARE(QApplication::focusWidget(), le22); + // Going back should move focus back to le11 + sw->setCurrentIndex(0); + QTRY_COMPARE(QApplication::focusWidget(), le11); + +} + QTEST_MAIN(tst_QStackedWidget) #include "tst_qstackedwidget.moc" |