summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp')
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp65
1 files changed, 43 insertions, 22 deletions
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index db252347ac..fe5c3a14a0 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** 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:LGPL21$
+** $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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** 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$
**
@@ -202,6 +197,7 @@ private slots:
void task_226929();
void styleChange();
void testFullScreenState();
+ void testRemoveBaseWidget();
};
void tst_QMdiSubWindow::initTestCase()
@@ -396,7 +392,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
QMdiArea *nestedWorkspace = new QMdiArea; // :-)
window->setWidget(nestedWorkspace);
- window->widget()->setWindowTitle(QString::fromLatin1("Window %1").arg(i));
+ window->widget()->setWindowTitle(QLatin1String("Window ") + QString::number(i));
workspace->addSubWindow(window);
QVERIFY(!window->maximizedButtonsWidget());
@@ -423,8 +419,9 @@ void tst_QMdiSubWindow::mainWindowSupport()
QVERIFY(window->maximizedSystemMenuIconWidget());
QCOMPARE(window->maximizedSystemMenuIconWidget(), qobject_cast<QWidget *>(mainWindow.menuBar()
->cornerWidget(Qt::TopLeftCorner)));
- QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
- .arg(originalWindowTitle, window->widget()->windowTitle()));
+ const QString expectedTitle = originalWindowTitle + QLatin1String(" - [")
+ + window->widget()->windowTitle() + QLatin1Char(']');
+ QCOMPARE(mainWindow.windowTitle(), expectedTitle);
#endif
// Check that nested child windows don't set window title
@@ -432,7 +429,7 @@ void tst_QMdiSubWindow::mainWindowSupport()
QMdiSubWindow *nestedWindow = new QMdiSubWindow;
nestedWindow->setWidget(new QWidget);
nestedWorkspace->addSubWindow(nestedWindow);
- nestedWindow->widget()->setWindowTitle(QString::fromLatin1("NestedWindow %1").arg(i));
+ nestedWindow->widget()->setWindowTitle(QLatin1String("NestedWindow ") + QString::number(i));
nestedWindow->showMaximized();
qApp->processEvents();
QVERIFY(nestedWindow->isMaximized());
@@ -970,7 +967,7 @@ void tst_QMdiSubWindow::setSystemMenu()
QMdiArea *mdiArea = new QMdiArea;
mdiArea->addSubWindow(subWindow);
mainWindow.setCentralWidget(mdiArea);
- mainWindow.menuBar();
+ mainWindow.menuBar()->setNativeMenuBar(false);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
QTest::qWait(60);
@@ -1470,6 +1467,7 @@ void tst_QMdiSubWindow::hideAndShow()
QMainWindow mainWindow;
mainWindow.setGeometry(0, 0, 640, 480);
QMenuBar *menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
mainWindow.setCentralWidget(tabWidget);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
@@ -1738,6 +1736,7 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
mainWindow.setCentralWidget(mdiArea);
QMenuBar *menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
@@ -1754,6 +1753,7 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
// Replace.
mainWindow.setMenuBar(new QMenuBar);
menuBar = mainWindow.menuBar();
+ menuBar->setNativeMenuBar(false);
qApp->processEvents();
QVERIFY(subWindow->maximizedButtonsWidget());
@@ -2080,6 +2080,27 @@ void tst_QMdiSubWindow::testFullScreenState()
QCOMPARE(subWindow->size(), QSize(300, 300));
}
+void tst_QMdiSubWindow::testRemoveBaseWidget()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+
+ QWidget *widget1 = new QWidget;
+ mdiArea.addSubWindow(widget1);
+
+ QWidget *widget2 = new QWidget;
+ mdiArea.addSubWindow(widget2);
+
+ mdiArea.removeSubWindow(widget1);
+ QVERIFY(!widget1->parent());
+
+ widget2->setParent(widget1);
+ mdiArea.removeSubWindow(widget2);
+ QCOMPARE(widget2->parent(), widget1);
+
+ delete widget1;
+}
+
QTEST_MAIN(tst_QMdiSubWindow)
#include "tst_qmdisubwindow.moc"