summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-06-05 22:26:44 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-06-05 22:26:44 +0200
commit0fcce50af009f97efa2a5c5f2c74415c92830962 (patch)
treef8abf0e4f445fed9480b426b2f856b50911f1210 /tests/auto/widgets
parent74d46a669badc5bf32187686102ca4e644a3c0af (diff)
parentc54f7720d09e7d00f3309736bbeaaa6a81967ec1 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: mkspecs/features/qt.prf src/plugins/platforms/xcb/qxcbwindow.h src/tools/qdoc/qdocindexfiles.cpp src/widgets/kernel/qwidget_qpa.cpp Change-Id: I214f57b03bc2ff86cf3b7dfe2966168af93a5a67
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp34
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp26
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp14
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp8
6 files changed, 61 insertions, 28 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
index db36eea11d..5239614fc7 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
+++ b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
@@ -19,3 +19,5 @@ wince* {
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+
+macx:CONFIG += insignificant_test # QTBUG-39183
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 0425db3098..f9abd50a15 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -593,6 +593,11 @@ void tst_QMessageBox::detailsText()
QString text("This is the details text.");
box.setDetailedText(text);
QCOMPARE(box.detailedText(), text);
+ box.show();
+ QTest::qWaitForWindowExposed(&box);
+ // QTBUG-39334, the box should now have the default "Ok" button as well as
+ // the "Show Details.." button.
+ QCOMPARE(box.findChildren<QAbstractButton *>().size(), 2);
}
void tst_QMessageBox::detailsButtonText()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index f686b5854c..c89b05616d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -49,6 +49,7 @@
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
#include <QCursor>
+#include <QScreen>
#include <QLabel>
#include <QDial>
#include <QGraphicsItem>
@@ -141,6 +142,17 @@ static void sendKeyClick(QGraphicsScene *scene, Qt::Key key)
sendKeyRelease(scene, key);
}
+static inline void centerOnScreen(QWidget *w, const QSize &size)
+{
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
+static inline void centerOnScreen(QWidget *w)
+{
+ centerOnScreen(w, w->geometry().size());
+}
+
class EventSpy : public QGraphicsWidget
{
Q_OBJECT
@@ -4213,14 +4225,18 @@ void tst_QGraphicsItem::cursor()
item2->setCursor(Qt::PointingHandCursor);
QWidget topLevel;
+ topLevel.resize(250, 150);
+ centerOnScreen(&topLevel);
QGraphicsView view(&scene,&topLevel);
view.setFixedSize(200, 100);
topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
QTest::mouseMove(&view, view.rect().center());
QTest::qWait(25);
- QCursor cursor = view.viewport()->cursor();
+ const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
{
QTest::mouseMove(view.viewport(), QPoint(100, 50));
@@ -4228,9 +4244,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
{
QTest::mouseMove(view.viewport(), view.mapFromScene(item1->sceneBoundingRect().center()));
@@ -4238,7 +4252,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
{
QTest::mouseMove(view.viewport(), view.mapFromScene(item2->sceneBoundingRect().center()));
@@ -4246,9 +4260,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
{
QTest::mouseMove(view.viewport(), view.rect().center());
@@ -4256,9 +4268,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
}
#endif
/*
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 2a70431223..34936fa5b8 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -288,6 +288,7 @@ private slots:
#ifndef Q_OS_MAC
void scroll();
+ void scrollNativeChildren();
#endif
// tests QWidget::setGeometry()
@@ -4336,7 +4337,30 @@ void tst_QWidget::scroll()
QTRY_COMPARE(updateWidget.paintedRegion, dirty);
}
}
-#endif
+
+// QTBUG-38999, scrolling a widget with native child widgets should move the children.
+void tst_QWidget::scrollNativeChildren()
+{
+ QWidget parent;
+ parent.setWindowTitle(QLatin1String(__FUNCTION__));
+ parent.resize(400, 400);
+ centerOnScreen(&parent);
+ QLabel *nativeLabel = new QLabel(QStringLiteral("nativeLabel"), &parent);
+ const QPoint oldLabelPos(100, 100);
+ nativeLabel->move(oldLabelPos);
+ QVERIFY(nativeLabel->winId());
+ parent.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ const QPoint delta(50, 50);
+ parent.scroll(delta.x(), delta.y());
+ const QPoint newLabelPos = oldLabelPos + delta;
+ QWindow *labelWindow = nativeLabel->windowHandle();
+ QVERIFY(labelWindow);
+ QTRY_COMPARE(labelWindow->geometry().topLeft(), newLabelPos);
+ QTRY_COMPARE(nativeLabel->geometry().topLeft(), newLabelPos);
+}
+
+#endif // Mac OS
class DestroyedSlotChecker : public QObject
{
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index d02b86bd8a..7e0b0dac0c 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -1726,9 +1726,8 @@ void tst_QMainWindow::addToolbarAfterShow()
QToolBar toolBar;
mainWindow.addToolBar(&toolBar);
- QTest::qWait(100);
- QVERIFY(!toolBar.isHidden());
+ QTRY_VERIFY(!toolBar.isHidden());
}
void tst_QMainWindow::centralWidgetSize()
@@ -1743,8 +1742,7 @@ void tst_QMainWindow::centralWidgetSize()
mainWindow.setCentralWidget(&widget);
mainWindow.show();
- QTest::qWait(100);
- QCOMPARE(widget.size(), widget.sizeHint());
+ QTRY_COMPARE(widget.size(), widget.sizeHint());
}
void tst_QMainWindow::dockWidgetSize()
@@ -1789,19 +1787,15 @@ void tst_QMainWindow::QTBUG2774_stylechange()
{
- QTest::qWait(1000);
mw.setStyleSheet("QMainWindow::separator { width: 50px; height:50px; }");
- QTest::qWait(5000);
- QApplication::processEvents();
- QVERIFY(central->width() < centralOriginalWidth);
+ QTRY_VERIFY(central->width() < centralOriginalWidth);
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 49)));
}
{
mw.setStyleSheet("QMainWindow::separator { width: 0px; height: 0px; }");
- QApplication::processEvents();
- QVERIFY(central->width() > centralOriginalWidth);
+ QTRY_VERIFY(central->width() > centralOriginalWidth);
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 1)));
}
diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
index a301d51c4c..8dd191e621 100644
--- a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
+++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
@@ -127,9 +127,7 @@ void tst_QStatusBar::tempMessage()
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
- QTest::qWait(1000);
-
- QVERIFY(testWidget->currentMessage().isNull());
+ QTRY_VERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
testWidget->showMessage("Ready again", 500);
@@ -294,10 +292,10 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
- QTest::qWait(3000);
+ QTest::qWait(1500);
// Message disappears after 2 seconds
- QVERIFY(testWidget->currentMessage().isNull());
+ QTRY_VERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
// Set display message for 2 seconds first