summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp34
-rw-r--r--tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp62
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST121
-rw-r--r--tests/auto/widgets/kernel/qwidget/qwidget.pro2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp57
5 files changed, 230 insertions, 46 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index c9a1a64135..c33fd5a951 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -178,6 +178,12 @@ private slots:
void settableStyleHints_data();
void settableStyleHints(); // Needs to run last as it changes style hints.
+
+protected slots:
+ void quitApplication();
+
+private:
+ bool quitApplicationTriggered;
};
class EventSpy : public QObject
@@ -235,6 +241,7 @@ public:
static char *argv0;
tst_QApplication::tst_QApplication()
+ : quitApplicationTriggered(false)
{
#ifdef Q_OS_WINCE
// Clean up environment previously to launching test
@@ -719,11 +726,8 @@ void tst_QApplication::quitOnLastWindowClosed()
{
int argc = 0;
QApplication app(argc, 0);
- QTimer timer;
- timer.setInterval(100);
QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
- QSignalSpy spy2(&timer, SIGNAL(timeout()));
CloseEventTestWindow mainWindow;
@@ -733,14 +737,14 @@ void tst_QApplication::quitOnLastWindowClosed()
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
- timer.start();
- QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should quit the application
- QTimer::singleShot(2000, &app, SLOT(quit())); // This makes sure we quit even if it didn't
+ QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should NOT quit the application (see CloseEventTestWindow)
+ quitApplicationTriggered = false;
+ QTimer::singleShot(2000, this, SLOT(quitApplication())); // This actually quits the application.
app.exec();
QCOMPARE(spy.count(), 1);
- QVERIFY(spy2.count() > 15); // Should be around 20 if closing did not caused the quit
+ QVERIFY(quitApplicationTriggered);
}
{
int argc = 0;
@@ -768,24 +772,20 @@ void tst_QApplication::quitOnLastWindowClosed()
QApplication app(argc, 0);
QVERIFY(app.quitOnLastWindowClosed());
- QTimer timer;
- timer.setInterval(100);
- QSignalSpy timerSpy(&timer, SIGNAL(timeout()));
-
QWindow w;
w.show();
QWidget wid;
wid.show();
- timer.start();
QTimer::singleShot(1000, &wid, SLOT(close())); // This should NOT quit the application because the
// QWindow is still there.
- QTimer::singleShot(2000, &app, SLOT(quit())); // This causes the quit.
+ quitApplicationTriggered = false;
+ QTimer::singleShot(2000, this, SLOT(quitApplication())); // This causes the quit.
app.exec();
- QVERIFY(timerSpy.count() > 15); // Should be around 20 if closing did not caused the quit
+ QVERIFY(quitApplicationTriggered); // Should be around 20 if closing did not caused the quit
}
{ // QTBUG-31569: If the last widget with Qt::WA_QuitOnClose set is closed, other
// widgets that don't have the attribute set should be closed automatically.
@@ -2406,6 +2406,12 @@ void tst_QApplication::globalStaticObjectDestruction()
#endif
}
+void tst_QApplication::quitApplication()
+{
+ quitApplicationTriggered = true;
+ qApp->quit();
+}
+
//QTEST_APPLESS_MAIN(tst_QApplication)
int main(int argc, char *argv[])
{
diff --git a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
index ebd99be786..0de9e188a0 100644
--- a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
+++ b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
@@ -34,30 +34,32 @@
#include <QtTest/QtTest>
#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qscreen.h>
class tst_QToolTip : public QObject
{
Q_OBJECT
-public:
- tst_QToolTip() {}
- virtual ~tst_QToolTip() {}
-
-public slots:
- void initTestCase() {}
- void cleanupTestCase() {}
- void init() {}
- void cleanup() {}
-
private slots:
-
- // task-specific tests below me
+ void init();
+ void cleanup();
void task183679_data();
void task183679();
void whatsThis();
void setPalette();
};
+void tst_QToolTip::init()
+{
+ QVERIFY(!QToolTip::isVisible());
+}
+
+void tst_QToolTip::cleanup()
+{
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
class Widget_task183679 : public QWidget
{
Q_OBJECT
@@ -100,12 +102,14 @@ void tst_QToolTip::task183679()
#endif
Widget_task183679 widget;
+ widget.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(50, 50));
+ widget.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
widget.show();
QApplication::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));
widget.showDelayedToolTip(100);
- QTest::qWait(300);
QTRY_VERIFY(QToolTip::isVisible());
QTest::keyPress(&widget, key);
@@ -116,26 +120,31 @@ void tst_QToolTip::task183679()
QTest::qWait(1500);
QCOMPARE(QToolTip::isVisible(), visible);
+ if (visible)
+ QToolTip::hideText();
}
-#include <QWhatsThis>
+static QWidget *findWhatsThat()
+{
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (widget->inherits("QWhatsThat"))
+ return widget;
+ }
+ return Q_NULLPTR;
+}
void tst_QToolTip::whatsThis()
{
qApp->setStyleSheet( "QWidget { font-size: 72px; }" );
- QWhatsThis::showText(QPoint(0,0), "THis is text");
- QTest::qWait(400);
- QWidget *whatsthis = 0;
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
- if (widget->inherits("QWhatsThat")) {
- whatsthis = widget;
- break;
- }
- }
- QVERIFY(whatsthis);
+ QWhatsThis::showText(QPoint(0, 0), "This is text");
+
+ QWidget *whatsthis = Q_NULLPTR;
+ QTRY_VERIFY( (whatsthis = findWhatsThat()) );
QVERIFY(whatsthis->isVisible());
- QVERIFY(whatsthis->height() > 100); // Test QTBUG-2416
- qApp->setStyleSheet("");
+ const int whatsThisHeight = whatsthis->height();
+ qApp->setStyleSheet(QString());
+ QWhatsThis::hideText();
+ QVERIFY2(whatsThisHeight > 100, QByteArray::number(whatsThisHeight)); // Test QTBUG-2416
}
@@ -167,6 +176,7 @@ void tst_QToolTip::setPalette()
newPalette.setColor(QPalette::ToolTipText, Qt::blue);
QToolTip::setPalette(newPalette);
QCOMPARE(toolTip->palette(), newPalette);
+ QToolTip::hideText();
}
QTEST_MAIN(tst_QToolTip)
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index ed40f98051..591aa9e40f 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -1,11 +1,16 @@
+# OSX QTBUG-25300 QTBUG-45502
[normalGeometry]
ubuntu-14.04
+osx
[saveRestoreGeometry]
ubuntu-14.04
+osx
[restoreVersion1Geometry]
ubuntu-14.04
+osx
[updateWhileMinimized]
ubuntu-14.04
+osx
[focusProxyAndInputMethods]
ubuntu-14.04
[touchEventSynthesizedMouseEvent]
@@ -14,3 +19,119 @@ ubuntu-14.04
ubuntu-14.04
[largerThanScreen_QTBUG30142]
ubuntu-14.04
+[windowState]
+osx
+[showMaximized]
+osx
+[setGeometry]
+osx
+[stackUnder]
+osx
+[raise]
+osx-10.9
+[widgetAt]
+osx
+[sheetOpacity]
+osx
+[resizeEvent]
+osx
+[setWindowGeometry:100,123 200x200, flags 0]
+osx-10.10
+[windowMoveResize:100,123 200x200, flags 0]
+osx-10.10
+[setWindowGeometry:100,122 200x200, flags 0]
+osx-10.9
+[windowMoveResize:100,122 200x200, flags 0]
+osx-10.9
+[setWindowGeometry:100,100 824x564, flags 0]
+osx-10.10
+[windowMoveResize:100,100 824x564, flags 0]
+osx-10.10
+[setWindowGeometry:100,100 824x516, flags 0]
+osx-10.10
+[windowMoveResize:100,100 824x516, flags 0]
+osx-10.10
+[setWindowGeometry:100,73 200x0, flags 0]
+osx-10.10
+[windowMoveResize:100,73 200x0, flags 0]
+osx-10.10
+[setWindowGeometry:100,100 824x519, flags 0]
+osx-10.10
+[windowMoveResize:100,100 824x519, flags 0]
+osx-10.10
+[setWindowGeometry:100,100 824x518, flags 0]
+osx-10.10
+[windowMoveResize:100,100 824x518, flags 0]
+osx-10.10
+[setWindowGeometry:100,72 200x0, flags 0]
+osx-10.9
+[windowMoveResize:100,72 200x0, flags 0]
+osx-10.9
+[setWindowGeometry:100,122 952x574, flags 0]
+osx-10.9
+[windowMoveResize:100,122 952x574, flags 0]
+osx-10.9
+[setWindowGeometry:100,122 952x578, flags 0]
+osx-10.9
+[windowMoveResize:100,122 952x578, flags 0]
+osx-10.9
+[setWindowGeometry:100,122 952x576, flags 0]
+osx-10.9
+[windowMoveResize:100,122 952x576, flags 0]
+osx-10.9
+[setWindowGeometry:100,100 824x521, flags 0]
+osx-10.10
+[windowMoveResize:100,100 824x521, flags 0]
+osx-10.10
+[setWindowGeometry:100,122 952x577, flags 0]
+osx-10.9
+[windowMoveResize:100,122 952x577, flags 0]
+osx-10.9
+[setWindowGeometry:100,122 952x580, flags 0]
+osx-10.9
+[windowMoveResize:100,122 952x580, flags 0]
+osx-10.9
+[windowMoveResize:130,72 0x0, flags 0]
+osx-10.9
+[windowMoveResize:130,122 0x200, flags 0]
+osx-10.9
+[childEvents]
+osx
+[renderInvisible]
+osx
+[optimizedResizeMove]
+osx
+[optimizedResize_topLevel]
+osx
+[render_systemClip]
+osx
+[update]
+osx
+[doubleRepaint]
+osx
+[childAt_unifiedToolBar]
+osx
+[showMinimizedKeepsFocus]
+osx-10.10
+[moveWindowInShowEvent:1]
+osx-10.9
+[moveWindowInShowEvent:2]
+osx-10.9
+[taskQTBUG_4055_sendSyntheticEnterLeave]
+osx
+[syntheticEnterLeave]
+osx
+[maskedUpdate]
+osx
+[hideWhenFocusWidgetIsChild]
+osx-10.10
+[hideOpaqueChildWhileHidden]
+osx
+[resizeStaticContentsChildWidget_QTBUG35282]
+osx-10.9
+[lower]
+osx
+[setClearAndResizeMask]
+osx
+[setToolTip]
+osx-10.9
diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro
index 30e1048247..aae083d45e 100644
--- a/tests/auto/widgets/kernel/qwidget/qwidget.pro
+++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro
@@ -21,5 +21,3 @@ x11 {
}
!wince*:win32:!winrt: LIBS += -luser32 -lgdi32
-
-mac:CONFIG+=insignificant_test # QTBUG-25300, QTBUG-23695
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 10c553bd3e..68ccaef43f 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -436,6 +436,7 @@ private slots:
void grabKeyboard();
void touchEventSynthesizedMouseEvent();
+ void touchUpdateOnNewTouch();
void styleSheetPropagation();
@@ -3335,8 +3336,6 @@ void tst_QWidget::widgetAt()
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
#endif
- if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
- QEXPECT_FAIL("", "Window mask not implemented on Mac QTBUG-22326", Continue);
QTRY_VERIFY((wr = QApplication::widgetAt(testPos)));
QTRY_COMPARE(wr->objectName(), w1->objectName());
@@ -3355,8 +3354,6 @@ void tst_QWidget::widgetAt()
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
#endif
- if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
- QEXPECT_FAIL("", "Window mask not implemented on Mac QTBUG-22326", Continue);
QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data());
QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
@@ -9757,6 +9754,9 @@ class TouchMouseWidget : public QWidget {
public:
explicit TouchMouseWidget(QWidget *parent = 0)
: QWidget(parent),
+ m_touchBeginCount(0),
+ m_touchUpdateCount(0),
+ m_touchEndCount(0),
m_touchEventCount(0),
m_acceptTouch(false),
m_mouseEventCount(0),
@@ -9783,6 +9783,12 @@ protected:
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
+ if (e->type() == QEvent::TouchBegin)
+ ++m_touchBeginCount;
+ else if (e->type() == QEvent::TouchUpdate)
+ ++m_touchUpdateCount;
+ else if (e->type() == QEvent::TouchEnd)
+ ++m_touchEndCount;
++m_touchEventCount;
if (m_acceptTouch)
e->accept();
@@ -9807,6 +9813,9 @@ protected:
}
public:
+ int m_touchBeginCount;
+ int m_touchUpdateCount;
+ int m_touchEndCount;
int m_touchEventCount;
bool m_acceptTouch;
int m_mouseEventCount;
@@ -9923,6 +9932,46 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
}
}
+void tst_QWidget::touchUpdateOnNewTouch()
+{
+ QTouchDevice *device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+
+ TouchMouseWidget widget;
+ widget.setAcceptTouch(true);
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(new QWidget);
+ widget.setLayout(layout);
+ widget.show();
+
+ QWindow* window = widget.windowHandle();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QCOMPARE(widget.m_touchBeginCount, 0);
+ QCOMPARE(widget.m_touchUpdateCount, 0);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).press(0, QPoint(20, 20), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 0);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).move(0, QPoint(25, 25), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 1);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).stationary(0).press(1, QPoint(40, 40), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 2);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).stationary(1).release(0, QPoint(25, 25), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 3);
+ QCOMPARE(widget.m_touchEndCount, 0);
+ QTest::touchEvent(window, device).release(1, QPoint(40, 40), window);
+ QCOMPARE(widget.m_touchBeginCount, 1);
+ QCOMPARE(widget.m_touchUpdateCount, 3);
+ QCOMPARE(widget.m_touchEndCount, 1);
+}
+
void tst_QWidget::styleSheetPropagation()
{
QTableView tw;