summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp46
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp43
2 files changed, 88 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index d8bb34933a..32437050f5 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -167,6 +167,7 @@ private slots:
void task_QTBUG_52027_mapCompleterIndex();
void checkMenuItemPosWhenStyleSheetIsSet();
void checkEmbeddedLineEditWhenStyleSheetIsSet();
+ void propagateStyleChanges();
private:
PlatformInputContext m_platformInputContext;
@@ -3586,5 +3587,50 @@ void tst_QComboBox::checkEmbeddedLineEditWhenStyleSheetIsSet()
qApp->setStyleSheet(oldCss);
}
+/*!
+ Tests that the style-based frame style propagates to the internal container
+ widget of QComboBox when the style changes by verifying that the respective
+ styleHint is asked for when the style changes.
+
+ See QTBUG-92488
+*/
+void tst_QComboBox::propagateStyleChanges()
+{
+ class FrameStyle : public QProxyStyle
+ {
+ public:
+ FrameStyle(int frameStyle, QStyle *style = nullptr)
+ : QProxyStyle(style), frameStyle(frameStyle)
+ {}
+
+ int styleHint(QStyle::StyleHint hint, const QStyleOption *opt,
+ const QWidget *widget, QStyleHintReturn *returnData) const
+ {
+ if (hint == QStyle::SH_ComboBox_PopupFrameStyle) {
+ inquired = true;
+ return frameStyle;
+ }
+ return QProxyStyle::styleHint(hint, opt, widget, returnData);
+ }
+
+ int frameStyle;
+ mutable bool inquired = false;
+ };
+
+ FrameStyle framelessStyle(QFrame::NoFrame);
+ FrameStyle frameStyle(QFrame::Plain | QFrame::Sunken);
+
+ QComboBox combo;
+ // container will be created and take settings from this style
+ combo.setStyle(&framelessStyle);
+ QVERIFY(framelessStyle.inquired);
+ combo.addItem(QLatin1String("Open"));
+ combo.addItem(QLatin1String("Close"));
+ // needed because of QComboBox's adjustSizeTimer not doing anything otherwise
+ combo.setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ combo.setStyle(&frameStyle);
+ QVERIFY(frameStyle.inquired);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index e3b046e448..91bc638257 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -282,6 +282,8 @@ private slots:
void nativeSubWindows();
void task_209615();
void task_236750();
+ void qtbug92240_title_data();
+ void qtbug92240_title();
private:
QMdiSubWindow *activeWindow;
@@ -2749,6 +2751,45 @@ void tst_QMdiArea::task_236750()
subWindow->showMinimized();
}
+// QTBUG-92240: When subwindows are maximized, their title is supposed to
+// appear on the main window. When DontMaximizeSubWindowOnActivation was set,
+// titles of previously created maximized windows interfered, resulting in
+// "QTBUG-92240 - [1] - [2]".
+void tst_QMdiArea::qtbug92240_title_data()
+{
+ QTest::addColumn<bool>("dontMaximize");
+ QTest::newRow("default") << false;
+ QTest::newRow("dontMaximize") << true;
+}
+
+void tst_QMdiArea::qtbug92240_title()
+{
+ QFETCH(bool, dontMaximize);
+
+#ifdef Q_OS_MACOS
+ QSKIP("Not supported on macOS");
+#endif
+
+ QMainWindow w;
+ const QString title = QStringLiteral("QTBUG-92240");
+ w.setWindowTitle(title);
+ w.menuBar()->addMenu(QStringLiteral("File"));
+ w.show();
+
+ auto *mdiArea = new QMdiArea;
+ w.setCentralWidget(mdiArea);
+ if (dontMaximize)
+ mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
+ auto *sw1 = mdiArea->addSubWindow(new QWidget);
+ sw1->setWindowTitle(QStringLiteral("1"));
+ sw1->showMaximized();
+ QTRY_COMPARE(w.windowTitle(), QLatin1String("QTBUG-92240 - [1]"));
+ auto *sw2 = mdiArea->addSubWindow(new QWidget);
+ sw2->setWindowTitle(QStringLiteral("2"));
+ sw2->showMaximized();
+ QTRY_COMPARE(w.windowTitle(), QLatin1String("QTBUG-92240 - [2]"));
+}
+
QTEST_MAIN(tst_QMdiArea)
#include "tst_qmdiarea.moc"