summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-29 12:58:32 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-29 12:58:41 +0200
commite66d181e659a08d19ab7d144c3ba0619d537de83 (patch)
tree7367e93797cb9a2a331f0741baed5a1cad2c96b6 /tests/auto
parent4758555f3e44af3425f0b691dc38fb40f3c9413d (diff)
parent75aea3ff5eec4a5c8f4184e14a90f4a5e3a577b0 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp76
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp63
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp26
-rw-r--r--tests/auto/tools/moc/namespace.h72
-rw-r--r--tests/auto/tools/moc/namespace_no_merge.h74
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp13
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp25
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp4
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp8
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp10
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp8
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp76
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp7
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp6
15 files changed, 390 insertions, 82 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index a8760843b3..fea185c48f 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -6546,6 +6546,29 @@ signals:
CountedStruct mySignal(const CountedStruct &s1, CountedStruct s2);
};
+class CountedExceptionThrower : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit CountedExceptionThrower(bool throwException, QObject *parent = Q_NULLPTR)
+ : QObject(parent)
+ {
+ if (throwException)
+ throw ObjectException();
+ ++counter;
+ }
+
+ ~CountedExceptionThrower()
+ {
+ --counter;
+ }
+
+ static int counter;
+};
+
+int CountedExceptionThrower::counter = 0;
+
void tst_QObject::exceptions()
{
#ifndef QT_NO_EXCEPTIONS
@@ -6607,6 +6630,59 @@ void tst_QObject::exceptions()
}
QCOMPARE(countedStructObjectsCount, 0);
+ // Child object reaping in case of exceptions thrown by constructors
+ {
+ QCOMPARE(CountedExceptionThrower::counter, 0);
+
+ try {
+ class ParentObject : public QObject {
+ public:
+ explicit ParentObject(QObject *parent = Q_NULLPTR)
+ : QObject(parent)
+ {
+ new CountedExceptionThrower(false, this);
+ new CountedExceptionThrower(false, this);
+ new CountedExceptionThrower(true, this); // throws
+ }
+ };
+
+ ParentObject p;
+ QFAIL("Exception not thrown");
+ } catch (const ObjectException &) {
+ } catch (...) {
+ QFAIL("Wrong exception thrown");
+ }
+
+ QCOMPARE(CountedExceptionThrower::counter, 0);
+
+ try {
+ QObject o;
+ new CountedExceptionThrower(false, &o);
+ new CountedExceptionThrower(false, &o);
+ new CountedExceptionThrower(true, &o); // throws
+
+ QFAIL("Exception not thrown");
+ } catch (const ObjectException &) {
+ } catch (...) {
+ QFAIL("Wrong exception thrown");
+ }
+
+ QCOMPARE(CountedExceptionThrower::counter, 0);
+
+ try {
+ QObject o;
+ CountedExceptionThrower c1(false, &o);
+ CountedExceptionThrower c2(false, &o);
+ CountedExceptionThrower c3(true, &o); // throws
+
+ QFAIL("Exception not thrown");
+ } catch (const ObjectException &) {
+ } catch (...) {
+ QFAIL("Wrong exception thrown");
+ }
+
+ QCOMPARE(CountedExceptionThrower::counter, 0);
+ }
#else
QSKIP("Needs exceptions");
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 03ddd4d6f8..4eb26d17fe 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -227,6 +227,7 @@ private slots:
void ecdhServer();
void verifyClientCertificate_data();
void verifyClientCertificate();
+ void readBufferMaxSize();
#ifndef QT_NO_OPENSSL
void simplePskConnect_data();
@@ -3136,6 +3137,68 @@ void tst_QSslSocket::verifyClientCertificate()
QCOMPARE(client.isEncrypted(), works);
}
+void tst_QSslSocket::readBufferMaxSize()
+{
+#ifdef QT_SECURETRANSPORT
+ // QTBUG-55170:
+ // SecureTransport back-end was ignoring read-buffer
+ // size limit, resulting (potentially) in a constantly
+ // growing internal buffer.
+ // The test's logic is: we set a small read buffer size on a client
+ // socket (to some ridiculously small value), server sends us
+ // a bunch of bytes , we ignore readReady signal so
+ // that socket's internal buffer size stays
+ // >= readBufferMaxSize, we wait for a quite long time
+ // (which previously would be enough to read completely)
+ // and we check socket's bytesAvaiable to be less than sent.
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ SslServer server;
+ QVERIFY(server.listen());
+
+ QEventLoop loop;
+
+ QSslSocketPtr client(new QSslSocket);
+ socket = client.data();
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
+ connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
+ connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
+
+ client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(),
+ server.serverPort());
+
+ // Wait for 'encrypted' first:
+ QTimer::singleShot(5000, &loop, SLOT(quit()));
+ loop.exec();
+
+ QCOMPARE(client->state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(client->mode(), QSslSocket::SslClientMode);
+
+ client->setReadBufferSize(10);
+ const QByteArray message(int(0xffff), 'a');
+ server.socket->write(message);
+
+ QTimer::singleShot(5000, &loop, SLOT(quit()));
+ loop.exec();
+
+ int readSoFar = client->bytesAvailable();
+ QVERIFY(readSoFar > 0 && readSoFar < message.size());
+ // Now, let's check that we still can read the rest of it:
+ QCOMPARE(client->readAll().size(), readSoFar);
+
+ client->setReadBufferSize(0);
+
+ QTimer::singleShot(1500, &loop, SLOT(quit()));
+ loop.exec();
+
+ QCOMPARE(client->bytesAvailable() + readSoFar, message.size());
+#else
+ // Not needed, QSslSocket works correctly with other back-ends.
+#endif
+}
+
void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects
{
// used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index eb575a88ea..8fc0521102 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -75,6 +75,10 @@ private slots:
void testRasterA2RGB30PM();
void testRasterBGR30_data();
void testRasterBGR30();
+ void testRasterARGB8565PM_data();
+ void testRasterARGB8565PM();
+ void testRasterGrayscale8_data();
+ void testRasterGrayscale8();
#ifndef QT_NO_OPENGL
void testOpenGL_data();
@@ -178,6 +182,28 @@ void tst_Lancelot::testRasterBGR30()
}
+void tst_Lancelot::testRasterARGB8565PM_data()
+{
+ setupTestSuite();
+}
+
+void tst_Lancelot::testRasterARGB8565PM()
+{
+ runTestSuite(Raster, QImage::Format_ARGB8565_Premultiplied);
+}
+
+
+void tst_Lancelot::testRasterGrayscale8_data()
+{
+ setupTestSuite();
+}
+
+void tst_Lancelot::testRasterGrayscale8()
+{
+ runTestSuite(Raster, QImage::Format_Grayscale8);
+}
+
+
#ifndef QT_NO_OPENGL
bool tst_Lancelot::checkSystemGLSupport()
{
diff --git a/tests/auto/tools/moc/namespace.h b/tests/auto/tools/moc/namespace.h
index 2bb1d8e958..6e04831589 100644
--- a/tests/auto/tools/moc/namespace.h
+++ b/tests/auto/tools/moc/namespace.h
@@ -1,7 +1,77 @@
-#pragma once
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NAMESPACE_H
+#define NAMESPACE_H
#include <QObject>
+#include "namespace_no_merge.h"
+// moc should not merge namespace_no_merge.h content with this one !
+
namespace FooNamespace {
Q_NAMESPACE
+ enum class Enum1 {
+ Key1,
+ Key2
+ };
+ Q_ENUM_NS(Enum1)
+
+ namespace FooNestedNamespace {
+ Q_NAMESPACE
+ enum class Enum2 {
+ Key3,
+ Key4
+ };
+ Q_ENUM_NS(Enum2)
+ }
+
+ using namespace FooNamespace;
+ namespace Bar = FooNamespace;
+
+ // Moc should merge this namespace with the previous one
+ namespace FooNestedNamespace {
+ Q_NAMESPACE
+ enum class Enum3 {
+ Key5,
+ Key6
+ };
+ Q_ENUM_NS(Enum3)
+
+ namespace FooMoreNestedNamespace {
+ Q_NAMESPACE
+ enum class Enum4 {
+ Key7,
+ Key8
+ };
+ Q_ENUM_NS(Enum4)
+ }
+ }
}
+
+#endif // NAMESPACE_H
diff --git a/tests/auto/tools/moc/namespace_no_merge.h b/tests/auto/tools/moc/namespace_no_merge.h
new file mode 100644
index 0000000000..8d1639ad4c
--- /dev/null
+++ b/tests/auto/tools/moc/namespace_no_merge.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NAMESPACE_NO_MERGE_H
+#define NAMESPACE_NO_MERGE_H
+
+#include <QObject>
+
+namespace FooNamespace {
+ Q_NAMESPACE
+ enum class MEnum1 {
+ Key1,
+ Key2
+ };
+ Q_ENUM_NS(MEnum1)
+
+ namespace FooNestedNamespace {
+ Q_NAMESPACE
+ enum class MEnum2 {
+ Key3,
+ Key4
+ };
+ Q_ENUM_NS(MEnum2)
+ }
+
+ using namespace FooNamespace;
+ namespace Bar = FooNamespace;
+
+ // Moc should merge this namespace with the previous one
+ namespace FooNestedNamespace {
+ Q_NAMESPACE
+ enum class MEnum3 {
+ Key5,
+ Key6
+ };
+ Q_ENUM_NS(MEnum3)
+
+ namespace FooMoreNestedNamespace {
+ Q_NAMESPACE
+ enum class MEnum4 {
+ Key7,
+ Key8
+ };
+ Q_ENUM_NS(MEnum4)
+ }
+ }
+}
+
+#endif // NAMESPACE_NO_MERGE_H
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 601b1bb36b..ecf6c7e992 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -3777,6 +3777,10 @@ void tst_Moc::testQNamespace()
QCOMPARE(meta.name(), "TestEnum1");
QCOMPARE(meta.enclosingMetaObject(), &TestQNamespace::staticMetaObject);
QCOMPARE(meta.keyCount(), 2);
+
+ QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1);
+ QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2);
+ QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1);
}
QTEST_MAIN(tst_Moc)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 46d0b18990..76e3b43ce2 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -5050,9 +5050,10 @@ void tst_QGraphicsItem::sceneEventFilter()
delete ti;
}
-class GeometryChanger : public QGraphicsItem
+class GeometryChanger : public QGraphicsRectItem
{
public:
+ explicit GeometryChanger(QRectF r) : QGraphicsRectItem(r) {}
void changeGeometry()
{ prepareGeometryChange(); }
};
@@ -5061,10 +5062,12 @@ void tst_QGraphicsItem::prepareGeometryChange()
{
{
QGraphicsScene scene;
- QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100));
- QVERIFY(scene.items(QRectF(0, 0, 100, 100)).contains(item));
- ((GeometryChanger *)item)->changeGeometry();
- QVERIFY(scene.items(QRectF(0, 0, 100, 100)).contains(item));
+ const QRectF rect(0, 0, 100, 100);
+ GeometryChanger item(rect);
+ scene.addItem(&item);
+ QVERIFY(scene.items(rect).contains(&item));
+ item.changeGeometry();
+ QVERIFY(scene.items(rect).contains(&item));
}
}
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index eda51e31a9..411b925adb 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -1715,25 +1715,6 @@ void tst_QApplication::focusOut()
QTest::qWait(2000);
}
-class SpontaneousEvent
-{
- Q_GADGET
- QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
- Q_ENUMS(Type)
-public:
- enum Type {
- Void
- };
-
- virtual ~SpontaneousEvent() {}
-
- QEventPrivate *d;
- ushort t;
-
- ushort posted : 1;
- ushort spont : 1;
-};
-
void tst_QApplication::focusMouseClick()
{
int argc = 1;
@@ -1751,14 +1732,14 @@ void tst_QApplication::focusMouseClick()
// now send a mouse button press event and check what happens with the focus
// it should be given to the parent widget
QMouseEvent ev(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
- reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QSpontaneKeyEvent::setSpontaneous(&ev);
QVERIFY(ev.spontaneous());
qApp->notify(&w2, &ev);
QCOMPARE(QApplication::focusWidget(), &w);
// then we give the inner widget strong focus -> it should get focus
w2.setFocusPolicy(Qt::StrongFocus);
- reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QSpontaneKeyEvent::setSpontaneous(&ev);
QVERIFY(ev.spontaneous());
qApp->notify(&w2, &ev);
QTRY_COMPARE(QApplication::focusWidget(), &w2);
@@ -1766,7 +1747,7 @@ void tst_QApplication::focusMouseClick()
// now back to tab focus and click again (it already had focus) -> focus should stay
// (focus was revoked as of QTBUG-34042)
w2.setFocusPolicy(Qt::TabFocus);
- reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QSpontaneKeyEvent::setSpontaneous(&ev);
QVERIFY(ev.spontaneous());
qApp->notify(&w2, &ev);
QCOMPARE(QApplication::focusWidget(), &w2);
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index e87598617a..0b35db1b5f 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -183,7 +183,7 @@ void tst_QBoxLayout::sizeConstraints()
window.show();
QTest::qWaitForWindowExposed(&window);
QSize sh = window.sizeHint();
- lay->takeAt(1);
+ delete lay->takeAt(1);
QVERIFY(sh.width() >= window.sizeHint().width() &&
sh.height() >= window.sizeHint().height());
@@ -512,7 +512,7 @@ void tst_QBoxLayout::replaceWidget()
QCOMPARE(boxLayout->indexOf(replaceFrom), 1);
QCOMPARE(boxLayout->indexOf(replaceTo), -1);
- boxLayout->replaceWidget(replaceFrom, replaceTo);
+ delete boxLayout->replaceWidget(replaceFrom, replaceTo);
QCOMPARE(boxLayout->indexOf(replaceFrom), -1);
QCOMPARE(boxLayout->indexOf(replaceTo), 1);
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 3c4c1a1d41..c1ab5f51be 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -341,6 +341,8 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.removeItem(spacer);
+ delete spacer;
+ spacer = Q_NULLPTR;
rightChild.hide();
QApplication::sendPostedEvents(0, 0);
@@ -1577,10 +1579,10 @@ void tst_QGridLayout::contentsRect()
void tst_QGridLayout::distributeMultiCell()
{
QWidget w;
- Qt42Style *style = new Qt42Style();
- style->spacing = 9;
+ Qt42Style style;
+ style.spacing = 9;
- w.setStyle(style);
+ w.setStyle(&style);
QGridLayout grid;
w.setLayout(&grid);
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index eaa4c8a636..5f3fed1f66 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -4997,7 +4997,8 @@ void tst_QWidget::moveChild()
ColorWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint);
// prevent custom styles
- parent.setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
+ parent.setStyle(style.data());
ColorWidget child(&parent, Qt::Widget, Qt::blue);
parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50),
@@ -5042,7 +5043,8 @@ void tst_QWidget::showAndMoveChild()
QSKIP("Wayland: This fails. Figure out why.");
QWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint);
// prevent custom styles
- parent.setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
+ parent.setStyle(style.data());
QDesktopWidget desktop;
QRect desktopDimensions = desktop.availableGeometry(&parent);
@@ -6542,7 +6544,9 @@ void tst_QWidget::renderWithPainter()
{
QWidget widget(0, Qt::Tool);
// prevent custom styles
- widget.setStyle(QStyleFactory::create(QLatin1String("Windows")));
+
+ const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows")));
+ widget.setStyle(style.data());
widget.show();
widget.resize(70, 50);
widget.setAutoFillBackground(true);
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 28c2e92f78..09ab20f7ca 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -221,6 +221,7 @@ private slots:
void timeSpec_data();
void timeSpec();
void timeSpecBug();
+ void timeSpecInit();
void monthEdgeCase();
void setLocale();
@@ -3176,6 +3177,13 @@ void tst_QDateTimeEdit::timeSpecBug()
QCOMPARE(oldText, testWidget->text());
}
+void tst_QDateTimeEdit::timeSpecInit()
+{
+ QDateTime utc(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC);
+ QDateTimeEdit widget(utc);
+ QCOMPARE(widget.dateTime(), utc);
+}
+
void tst_QDateTimeEdit::cachedDayTest()
{
testWidget->setDisplayFormat("MM/dd");
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 086c1049ab..76c3ac4143 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -357,25 +357,25 @@ void tst_QMdiSubWindow::mainWindowSupport()
mainWindow.show();
mainWindow.menuBar()->setVisible(true);
qApp->setActiveWindow(&mainWindow);
-
- // QMainWindow's window title is empty
-#if !defined(Q_OS_DARWIN)
- {
- QCOMPARE(mainWindow.windowTitle(), QString());
- QMdiSubWindow *window = workspace->addSubWindow(new QPushButton(QLatin1String("Test")));
- QString expectedTitle = QLatin1String("MainWindow's title is empty");
- window->setWindowTitle(expectedTitle);
- QCOMPARE(window->windowTitle(), expectedTitle);
- window->showMaximized();
- QVERIFY(window->isMaximized());
- QCOMPARE(window->windowTitle(), expectedTitle);
- QCOMPARE(mainWindow.windowTitle(), expectedTitle);
- window->showNormal();
- QCOMPARE(window->windowTitle(), expectedTitle);
- QCOMPARE(mainWindow.windowTitle(), QString());
- window->close();
+ bool nativeMenuBar = mainWindow.menuBar()->isNativeMenuBar();
+
+ // QMainWindow's window title is empty, so on a platform which does NOT have a native menubar,
+ // the maximized subwindow's title is imposed onto the main window's titlebar.
+ if (!nativeMenuBar) {
+ QCOMPARE(mainWindow.windowTitle(), QString());
+ QMdiSubWindow *window = workspace->addSubWindow(new QPushButton(QLatin1String("Test")));
+ QString expectedTitle = QLatin1String("MainWindow's title is empty");
+ window->setWindowTitle(expectedTitle);
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ window->showMaximized();
+ QVERIFY(window->isMaximized());
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ QCOMPARE(mainWindow.windowTitle(), expectedTitle);
+ window->showNormal();
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ QCOMPARE(mainWindow.windowTitle(), QString());
+ window->close();
}
-#endif
QString originalWindowTitle = QString::fromLatin1("MainWindow");
mainWindow.setWindowTitle(originalWindowTitle);
@@ -411,16 +411,16 @@ void tst_QMdiSubWindow::mainWindowSupport()
window->showMaximized();
qApp->processEvents();
QVERIFY(window->isMaximized());
-#if !defined(Q_OS_DARWIN)
- QVERIFY(window->maximizedButtonsWidget());
- QCOMPARE(window->maximizedButtonsWidget(), mainWindow.menuBar()->cornerWidget(Qt::TopRightCorner));
- QVERIFY(window->maximizedSystemMenuIconWidget());
- QCOMPARE(window->maximizedSystemMenuIconWidget(), qobject_cast<QWidget *>(mainWindow.menuBar()
- ->cornerWidget(Qt::TopLeftCorner)));
- const QString expectedTitle = originalWindowTitle + QLatin1String(" - [")
- + window->widget()->windowTitle() + QLatin1Char(']');
- QCOMPARE(mainWindow.windowTitle(), expectedTitle);
-#endif
+ if (!nativeMenuBar) {
+ QVERIFY(window->maximizedButtonsWidget());
+ QCOMPARE(window->maximizedButtonsWidget(), mainWindow.menuBar()->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(window->maximizedSystemMenuIconWidget());
+ QCOMPARE(window->maximizedSystemMenuIconWidget(),
+ qobject_cast<QWidget *>(mainWindow.menuBar()->cornerWidget(Qt::TopLeftCorner)));
+ const QString expectedTitle = originalWindowTitle + QLatin1String(" - [")
+ + window->widget()->windowTitle() + QLatin1Char(']');
+ QCOMPARE(mainWindow.windowTitle(), expectedTitle);
+ }
// Check that nested child windows don't set window title
nestedWorkspace->show();
@@ -434,15 +434,14 @@ void tst_QMdiSubWindow::mainWindowSupport()
QVERIFY(!nestedWindow->maximizedButtonsWidget());
QVERIFY(!nestedWindow->maximizedSystemMenuIconWidget());
-#if !defined(Q_OS_DARWIN) && !defined(Q_OS_QNX)
- QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
- .arg(originalWindowTitle, window->widget()->windowTitle()));
-#endif
+ if (!nativeMenuBar) {
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+ }
}
-#if defined(Q_OS_DARWIN)
- return;
-#endif
+ if (nativeMenuBar)
+ return;
workspace->activateNextSubWindow();
qApp->processEvents();
@@ -1905,14 +1904,14 @@ void tst_QMdiSubWindow::mdiArea()
void tst_QMdiSubWindow::task_182852()
{
-#if !defined(Q_OS_DARWIN)
-
QMdiArea *workspace = new QMdiArea;
QMainWindow mainWindow;
mainWindow.setCentralWidget(workspace);
mainWindow.show();
mainWindow.menuBar()->setVisible(true);
qApp->setActiveWindow(&mainWindow);
+ if (mainWindow.menuBar()->isNativeMenuBar())
+ return; // The main window's title is not overwritten if we have a native menubar (macOS, Unity etc.)
QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]");
mainWindow.setWindowTitle(originalWindowTitle);
@@ -1948,9 +1947,6 @@ void tst_QMdiSubWindow::task_182852()
QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
.arg(originalWindowTitle, window->widget()->windowTitle()));
-
-
-#endif
}
void tst_QMdiSubWindow::task_233197()
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 58725346d0..ca58dc1247 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -93,7 +93,6 @@ private slots:
#if !defined(Q_OS_DARWIN)
void accel();
void activatedCount();
- void allowActiveAndDisabled();
void check_accelKeys();
void check_cursorKeys1();
@@ -102,6 +101,9 @@ private slots:
void check_escKey();
#endif
+#ifndef Q_OS_WINCE
+ void allowActiveAndDisabled();
+#endif
void check_endKey();
void check_homeKey();
@@ -918,10 +920,10 @@ void tst_QMenuBar::check_escKey()
// QCOMPARE(m_complexActionTriggerCount['h'], (uint)itemH_count);
// }
-#if !defined(Q_OS_DARWIN)
void tst_QMenuBar::allowActiveAndDisabled()
{
QMenuBar menuBar;
+ menuBar.setNativeMenuBar(false);
// Task 241043 : check that second menu is activated if only
// disabled menu items are added
@@ -957,7 +959,6 @@ void tst_QMenuBar::allowActiveAndDisabled()
else
QCOMPARE(menuBar.activeAction()->text(), fileMenu.title());
}
-#endif
void tst_QMenuBar::check_altPress()
{
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index f46d58513e..b09a3447e3 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -1718,14 +1718,14 @@ void tst_QDom::germanUmlautToFile() const
QDomDocument d("test");
d.appendChild(d.createElement(name));
- QFile file("germanUmlautToFile.xml");
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QTemporaryFile file;
+ QVERIFY(file.open());
QTextStream ts(&file);
ts.setCodec("UTF-8");
ts << d.toString();
file.close();
- QFile inFile("germanUmlautToFile.xml");
+ QFile inFile(file.fileName());
QVERIFY(inFile.open(QIODevice::ReadOnly));
QString baseline(QLatin1String("<!DOCTYPE test>\n<german"));